fix(permissions): use standard macOS Local Network request flow (STA-3505) (#12833)
* fix(permissions): surface macOS silent Local Network denial with diagnostic and workaround (STA-3505) On macOS 27 beta, NECP silently denies Orca's whole process tree Local Network access: no prompt fires, the app never appears in System Settings, and terminal child processes fail with EHOSTUNREACH. The Settings trigger swallowed the probe's socket error and reported 'unknown' + a 'Permission request sent' toast, indistinguishable from success. Classify the mDNS probe outcome (EHOSTUNREACH/EHOSTDOWN -> denied, clean send -> granted, else unknown), remember the verdict for the status chip, and render an inline diagnostic with the documented NECP re-evaluation workaround when denial is detected. * fix(permissions): avoid false Local Network grants * fix(permissions): use standard Local Network request flow * feat(permissions): add local network connection test * fix(permissions): nest local network connection test * fix(permissions): collapse connection test by default * fix(permissions): emphasize connection test action * fix(permissions): restore outlined connection action
This commit is contained in:
@@ -14,7 +14,8 @@ const {
|
||||
} = vi.hoisted(() => {
|
||||
const handleMock = vi.fn()
|
||||
const socketState = {
|
||||
sendCallback: null as (() => void) | null
|
||||
sendCallback: null as ((error?: Error | null) => void) | null,
|
||||
errorListener: null as ((error: Error) => void) | null
|
||||
}
|
||||
const socketMock = {
|
||||
on: vi.fn(),
|
||||
@@ -65,6 +66,7 @@ vi.mock('../macos-full-disk-access-status', () => ({
|
||||
getMacosFullDiskAccessStatus: getMacosFullDiskAccessStatusMock
|
||||
}))
|
||||
|
||||
import type { DeveloperPermissionState } from '../../shared/developer-permissions-types'
|
||||
import { registerDeveloperPermissionHandlers } from './developer-permissions'
|
||||
|
||||
describe('registerDeveloperPermissionHandlers', () => {
|
||||
@@ -91,7 +93,13 @@ describe('registerDeveloperPermissionHandlers', () => {
|
||||
})
|
||||
createSocketMock.mockClear()
|
||||
socketState.sendCallback = null
|
||||
socketMock.on.mockClear()
|
||||
socketState.errorListener = null
|
||||
socketMock.on.mockReset()
|
||||
socketMock.on.mockImplementation((event: string, listener: (error: Error) => void) => {
|
||||
if (event === 'error') {
|
||||
socketState.errorListener = listener
|
||||
}
|
||||
})
|
||||
socketMock.removeListener.mockClear()
|
||||
socketMock.bind.mockReset()
|
||||
socketMock.bind.mockImplementation((callback: () => void) => callback())
|
||||
@@ -103,7 +111,7 @@ describe('registerDeveloperPermissionHandlers', () => {
|
||||
_length: number,
|
||||
_port: number,
|
||||
_address: string,
|
||||
callback: () => void
|
||||
callback: (error?: Error | null) => void
|
||||
) => {
|
||||
socketState.sendCallback = callback
|
||||
}
|
||||
@@ -127,6 +135,26 @@ describe('registerDeveloperPermissionHandlers', () => {
|
||||
return call[1] as (_event: unknown, args: { id: string }) => Promise<unknown>
|
||||
}
|
||||
|
||||
function getStatusHandler(): () => Promise<DeveloperPermissionState[]> {
|
||||
const call = handleMock.mock.calls.find(
|
||||
(c: unknown[]) => c[0] === 'developerPermissions:getStatus'
|
||||
)
|
||||
if (!call) {
|
||||
throw new Error('developerPermissions:getStatus handler not registered')
|
||||
}
|
||||
return call[1] as () => Promise<DeveloperPermissionState[]>
|
||||
}
|
||||
|
||||
function getOpenSettingsHandler(): (_event: unknown, args: { id: string }) => Promise<void> {
|
||||
const call = handleMock.mock.calls.find(
|
||||
(c: unknown[]) => c[0] === 'developerPermissions:openSettings'
|
||||
)
|
||||
if (!call) {
|
||||
throw new Error('developerPermissions:openSettings handler not registered')
|
||||
}
|
||||
return call[1] as (_event: unknown, args: { id: string }) => Promise<void>
|
||||
}
|
||||
|
||||
it('returns the Full Disk Access read-probe status', async () => {
|
||||
getMacosFullDiskAccessStatusMock.mockResolvedValue('granted')
|
||||
registerDeveloperPermissionHandlers()
|
||||
@@ -142,7 +170,7 @@ describe('registerDeveloperPermissionHandlers', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('clears the local-network prompt fallback timer when UDP send settles first', async () => {
|
||||
it('keeps the local-network status unknown when UDP send settles without an error', async () => {
|
||||
registerDeveloperPermissionHandlers()
|
||||
|
||||
const result = getRequestHandler()({}, { id: 'local-network' })
|
||||
@@ -161,6 +189,37 @@ describe('registerDeveloperPermissionHandlers', () => {
|
||||
expect(socketMock.close).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('keeps local-network status unknown when the prompt trigger receives a socket error', async () => {
|
||||
registerDeveloperPermissionHandlers()
|
||||
|
||||
const result = getRequestHandler()({}, { id: 'local-network' })
|
||||
socketState.errorListener?.(
|
||||
Object.assign(new Error('send EHOSTUNREACH 224.0.0.251:5353'), {
|
||||
code: 'EHOSTUNREACH'
|
||||
})
|
||||
)
|
||||
|
||||
await expect(result).resolves.toEqual({
|
||||
id: 'local-network',
|
||||
status: 'unknown',
|
||||
openedSystemSettings: false
|
||||
})
|
||||
await expect(getStatusHandler()()).resolves.toContainEqual({
|
||||
id: 'local-network',
|
||||
status: 'unknown'
|
||||
})
|
||||
})
|
||||
|
||||
it('opens the standard macOS Local Network settings pane', async () => {
|
||||
registerDeveloperPermissionHandlers()
|
||||
|
||||
await getOpenSettingsHandler()({}, { id: 'local-network' })
|
||||
|
||||
expect(shellOpenExternalMock).toHaveBeenCalledWith(
|
||||
'x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension?Privacy_LocalNetwork'
|
||||
)
|
||||
})
|
||||
|
||||
it('settles the automation prompt when osascript hangs', async () => {
|
||||
const killMock = vi.fn()
|
||||
execFileMock.mockImplementation(() => ({ kill: killMock }))
|
||||
|
||||
@@ -2,6 +2,7 @@ import { execFile } from 'node:child_process'
|
||||
import dgram from 'node:dgram'
|
||||
import { ipcMain, shell, systemPreferences } from 'electron'
|
||||
import { getMacosFullDiskAccessStatus } from '../macos-full-disk-access-status'
|
||||
import { testLocalNetworkConnection } from './local-network-connection-test'
|
||||
import type {
|
||||
DeveloperPermissionId,
|
||||
DeveloperPermissionRequestResult,
|
||||
@@ -16,6 +17,8 @@ const PRIVACY_PANE_URLS: Partial<Record<DeveloperPermissionId, string>> = {
|
||||
accessibility: 'x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility',
|
||||
'full-disk-access': 'x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles',
|
||||
automation: 'x-apple.systempreferences:com.apple.preference.security?Privacy_Automation',
|
||||
'local-network':
|
||||
'x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension?Privacy_LocalNetwork',
|
||||
bluetooth: 'x-apple.systempreferences:com.apple.preference.security?Privacy_Bluetooth'
|
||||
}
|
||||
|
||||
@@ -235,4 +238,10 @@ export function registerDeveloperPermissionHandlers(): void {
|
||||
await openPrivacyPane(args.id)
|
||||
}
|
||||
)
|
||||
|
||||
ipcMain.handle('developerPermissions:testLocalNetworkConnection', async (_event, args: unknown) =>
|
||||
testLocalNetworkConnection(
|
||||
args && typeof args === 'object' ? (args as { host?: unknown; port?: unknown }) : {}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import { createServer } from 'node:net'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { testLocalNetworkConnection } from './local-network-connection-test'
|
||||
|
||||
describe('testLocalNetworkConnection', () => {
|
||||
it('runs a bounded Electron child probe and reports a verified connection', async () => {
|
||||
const runChild = vi.fn((_file, _args, _options, callback) => callback(null, '', ''))
|
||||
|
||||
await expect(
|
||||
testLocalNetworkConnection(
|
||||
{ host: '192.168.1.20', port: 3000 },
|
||||
{ platform: 'darwin', now: () => 1234, runChild }
|
||||
)
|
||||
).resolves.toEqual({
|
||||
ok: true,
|
||||
host: '192.168.1.20',
|
||||
port: 3000,
|
||||
testedAt: 1234
|
||||
})
|
||||
expect(runChild).toHaveBeenCalledWith(
|
||||
process.execPath,
|
||||
expect.arrayContaining(['192.168.1.20', '3000']),
|
||||
expect.objectContaining({
|
||||
timeout: 5000,
|
||||
env: expect.objectContaining({ ELECTRON_RUN_AS_NODE: '1' })
|
||||
}),
|
||||
expect.any(Function)
|
||||
)
|
||||
})
|
||||
|
||||
it('rejects a hostname that resolves to loopback in the real child probe', async () => {
|
||||
const server = createServer()
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server.once('error', reject)
|
||||
server.listen(0, '127.0.0.1', resolve)
|
||||
})
|
||||
const address = server.address()
|
||||
if (!address || typeof address === 'string') {
|
||||
throw new Error('Expected a TCP listener address')
|
||||
}
|
||||
|
||||
try {
|
||||
await expect(
|
||||
testLocalNetworkConnection(
|
||||
{ host: '2130706433', port: address.port },
|
||||
{ platform: 'darwin' }
|
||||
)
|
||||
).resolves.toMatchObject({ ok: false, failure: 'invalid-target' })
|
||||
} finally {
|
||||
await new Promise<void>((resolve) => server.close(() => resolve()))
|
||||
}
|
||||
})
|
||||
|
||||
it.each([
|
||||
['INVALID_TARGET', 'invalid-target'],
|
||||
['ETIMEDOUT', 'timeout'],
|
||||
['ECONNREFUSED', 'refused'],
|
||||
['EHOSTUNREACH', 'unreachable'],
|
||||
['ENETUNREACH', 'unreachable'],
|
||||
['ENOTFOUND', 'unresolved']
|
||||
] as const)('maps %s without claiming a permission denial', async (stderr, failure) => {
|
||||
const runChild = vi.fn((_file, _args, _options, callback) =>
|
||||
callback(Object.assign(new Error(stderr), { code: 1 }), '', stderr)
|
||||
)
|
||||
|
||||
await expect(
|
||||
testLocalNetworkConnection(
|
||||
{ host: 'devbox.local', port: 8080 },
|
||||
{ platform: 'darwin', runChild }
|
||||
)
|
||||
).resolves.toMatchObject({ ok: false, failure })
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ host: '127.0.0.1', port: 3000 },
|
||||
{ host: 'localhost', port: 3000 },
|
||||
{ host: 'service.localhost', port: 3000 },
|
||||
{ host: '8.8.8.8', port: 53 },
|
||||
{ host: 'https://devbox.local', port: 443 },
|
||||
{ host: 'devbox.local', port: 0 }
|
||||
])('rejects a target that does not test a LAN connection: $host:$port', async (target) => {
|
||||
const runChild = vi.fn()
|
||||
|
||||
await expect(
|
||||
testLocalNetworkConnection(target, { platform: 'darwin', runChild })
|
||||
).resolves.toMatchObject({ ok: false, failure: 'invalid-target' })
|
||||
expect(runChild).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,167 @@
|
||||
import { execFile, type ExecFileException, type ExecFileOptions } from 'node:child_process'
|
||||
import { isIP } from 'node:net'
|
||||
import { classifyRemotePairingHostname } from '../../shared/remote-pairing-address'
|
||||
import type {
|
||||
LocalNetworkConnectionTestFailure,
|
||||
LocalNetworkConnectionTestResult
|
||||
} from '../../shared/developer-permissions-types'
|
||||
|
||||
const CONNECT_TIMEOUT_MS = 4_000
|
||||
const CHILD_TIMEOUT_MS = CONNECT_TIMEOUT_MS + 1_000
|
||||
const CONNECT_SCRIPT = `
|
||||
const net = require('node:net')
|
||||
const host = process.argv[1]
|
||||
const port = Number(process.argv[2])
|
||||
const socket = net.createConnection({ host, port })
|
||||
let settled = false
|
||||
function finish(code) {
|
||||
if (settled) return
|
||||
settled = true
|
||||
if (code) {
|
||||
process.stderr.write(code)
|
||||
process.exitCode = 1
|
||||
}
|
||||
socket.destroy()
|
||||
}
|
||||
function isLanAddress(address) {
|
||||
const normalized = (address || '').toLowerCase().split('%', 1)[0]
|
||||
const mapped = normalized.match(/^::ffff:(\\d{1,3}(?:\\.\\d{1,3}){3})$/)?.[1]
|
||||
const ipv4 = mapped || (net.isIP(normalized) === 4 ? normalized : null)
|
||||
if (ipv4) {
|
||||
const octets = ipv4.split('.').map(Number)
|
||||
return octets[0] === 10 ||
|
||||
(octets[0] === 172 && octets[1] >= 16 && octets[1] <= 31) ||
|
||||
(octets[0] === 192 && octets[1] === 168) ||
|
||||
(octets[0] === 169 && octets[1] === 254)
|
||||
}
|
||||
if (net.isIP(normalized) === 6) {
|
||||
const first = Number.parseInt(normalized.split(':')[0], 16)
|
||||
return (first & 0xfe00) === 0xfc00 || (first & 0xffc0) === 0xfe80
|
||||
}
|
||||
return false
|
||||
}
|
||||
socket.setTimeout(${CONNECT_TIMEOUT_MS})
|
||||
socket.once('connect', () => finish(isLanAddress(socket.remoteAddress) ? undefined : 'INVALID_TARGET'))
|
||||
socket.once('timeout', () => finish('ETIMEDOUT'))
|
||||
socket.once('error', (error) => finish(error.code || 'FAILED'))
|
||||
`
|
||||
|
||||
type ConnectionChildRunner = (
|
||||
file: string,
|
||||
args: string[],
|
||||
options: ExecFileOptions,
|
||||
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void
|
||||
) => unknown
|
||||
|
||||
type LocalNetworkConnectionTestOptions = {
|
||||
platform?: NodeJS.Platform
|
||||
now?: () => number
|
||||
runChild?: ConnectionChildRunner
|
||||
}
|
||||
|
||||
function normalizeTargetHost(rawHost: unknown): string | null {
|
||||
if (typeof rawHost !== 'string') {
|
||||
return null
|
||||
}
|
||||
const host = rawHost.trim().replace(/^\[|\]$/g, '')
|
||||
if (
|
||||
!host ||
|
||||
host.startsWith('-') ||
|
||||
host.length > 253 ||
|
||||
/[\s/\\]/.test(host) ||
|
||||
host.includes('://') ||
|
||||
!/^[a-z0-9.:%_-]+$/i.test(host)
|
||||
) {
|
||||
return null
|
||||
}
|
||||
const addressWithoutZone = host.split('%', 1)[0] ?? host
|
||||
const kind = classifyRemotePairingHostname(addressWithoutZone)
|
||||
if (isIP(addressWithoutZone) === 0) {
|
||||
return kind === 'loopback' ? null : host
|
||||
}
|
||||
const isLinkLocalIpv4 = addressWithoutZone.startsWith('169.254.')
|
||||
return kind === 'lan' || isLinkLocalIpv4 ? host : null
|
||||
}
|
||||
|
||||
function normalizeTargetPort(rawPort: unknown): number | null {
|
||||
return typeof rawPort === 'number' &&
|
||||
Number.isInteger(rawPort) &&
|
||||
rawPort >= 1 &&
|
||||
rawPort <= 65_535
|
||||
? rawPort
|
||||
: null
|
||||
}
|
||||
|
||||
function failureFromChild(
|
||||
error: ExecFileException,
|
||||
stderr: string
|
||||
): LocalNetworkConnectionTestFailure {
|
||||
if (error.killed || error.signal) {
|
||||
return 'timeout'
|
||||
}
|
||||
const code = stderr.trim().split(/\s/, 1)[0]
|
||||
switch (code) {
|
||||
case 'INVALID_TARGET':
|
||||
return 'invalid-target'
|
||||
case 'ETIMEDOUT':
|
||||
return 'timeout'
|
||||
case 'ECONNREFUSED':
|
||||
return 'refused'
|
||||
case 'EHOSTUNREACH':
|
||||
case 'ENETUNREACH':
|
||||
return 'unreachable'
|
||||
case 'ENOTFOUND':
|
||||
case 'EAI_AGAIN':
|
||||
return 'unresolved'
|
||||
default:
|
||||
return 'failed'
|
||||
}
|
||||
}
|
||||
|
||||
export function testLocalNetworkConnection(
|
||||
args: { host?: unknown; port?: unknown },
|
||||
options: LocalNetworkConnectionTestOptions = {}
|
||||
): Promise<LocalNetworkConnectionTestResult> {
|
||||
const testedAt = (options.now ?? Date.now)()
|
||||
const host = normalizeTargetHost(args.host)
|
||||
const port = normalizeTargetPort(args.port)
|
||||
if (!host || !port) {
|
||||
return Promise.resolve({
|
||||
ok: false,
|
||||
host: typeof args.host === 'string' ? args.host.trim() : '',
|
||||
port: typeof args.port === 'number' ? args.port : 0,
|
||||
testedAt,
|
||||
failure: 'invalid-target'
|
||||
})
|
||||
}
|
||||
if ((options.platform ?? process.platform) !== 'darwin') {
|
||||
return Promise.resolve({ ok: false, host, port, testedAt, failure: 'unsupported' })
|
||||
}
|
||||
|
||||
const runChild = options.runChild ?? (execFile as ConnectionChildRunner)
|
||||
return new Promise((resolve) => {
|
||||
runChild(
|
||||
process.execPath,
|
||||
['-e', CONNECT_SCRIPT, host, String(port)],
|
||||
{
|
||||
env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },
|
||||
timeout: CHILD_TIMEOUT_MS,
|
||||
windowsHide: true,
|
||||
maxBuffer: 1024
|
||||
},
|
||||
(error, _stdout, stderr) => {
|
||||
if (!error) {
|
||||
resolve({ ok: true, host, port, testedAt })
|
||||
return
|
||||
}
|
||||
resolve({
|
||||
ok: false,
|
||||
host,
|
||||
port,
|
||||
testedAt,
|
||||
failure: failureFromChild(error, stderr)
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -432,7 +432,8 @@ import type {
|
||||
import type {
|
||||
DeveloperPermissionId,
|
||||
DeveloperPermissionRequestResult,
|
||||
DeveloperPermissionState
|
||||
DeveloperPermissionState,
|
||||
LocalNetworkConnectionTestResult
|
||||
} from '../shared/developer-permissions-types'
|
||||
import type {
|
||||
ComputerUsePermissionId,
|
||||
@@ -2558,6 +2559,10 @@ export type PreloadApi = {
|
||||
getStatus: () => Promise<DeveloperPermissionState[]>
|
||||
request: (args: { id: DeveloperPermissionId }) => Promise<DeveloperPermissionRequestResult>
|
||||
openSettings: (args: { id: DeveloperPermissionId }) => Promise<void>
|
||||
testLocalNetworkConnection: (args: {
|
||||
host: string
|
||||
port: number
|
||||
}) => Promise<LocalNetworkConnectionTestResult>
|
||||
}
|
||||
computerUsePermissions: {
|
||||
getStatus: () => Promise<ComputerUsePermissionStatusResult>
|
||||
|
||||
@@ -2406,7 +2406,9 @@ const api = {
|
||||
request: (args: { id: string }): Promise<unknown> =>
|
||||
ipcRenderer.invoke('developerPermissions:request', args),
|
||||
openSettings: (args: { id: string }): Promise<void> =>
|
||||
ipcRenderer.invoke('developerPermissions:openSettings', args)
|
||||
ipcRenderer.invoke('developerPermissions:openSettings', args),
|
||||
testLocalNetworkConnection: (args: { host: string; port: number }): Promise<unknown> =>
|
||||
ipcRenderer.invoke('developerPermissions:testLocalNetworkConnection', args)
|
||||
},
|
||||
|
||||
computerUsePermissions: {
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
import { ExternalLink } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import type {
|
||||
DeveloperPermissionId,
|
||||
DeveloperPermissionStatus
|
||||
} from '../../../../shared/developer-permissions-types'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { Button } from '../ui/button'
|
||||
|
||||
type DeveloperPermissionActionsProps = {
|
||||
id: DeveloperPermissionId
|
||||
actionLabel: string
|
||||
pending: boolean
|
||||
status: DeveloperPermissionStatus | undefined
|
||||
onRequest: (id: DeveloperPermissionId) => void
|
||||
}
|
||||
|
||||
export function DeveloperPermissionActions({
|
||||
id,
|
||||
actionLabel,
|
||||
pending,
|
||||
status,
|
||||
onRequest
|
||||
}: DeveloperPermissionActionsProps): React.JSX.Element {
|
||||
const openSettings = async (): Promise<void> => {
|
||||
try {
|
||||
await window.api.developerPermissions.openSettings({ id })
|
||||
} catch {
|
||||
toast.error(
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.openSettingsFailed',
|
||||
'Could not open System Settings'
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex shrink-0 gap-2">
|
||||
<Button
|
||||
variant={id === 'local-network' ? 'default' : 'outline'}
|
||||
size="sm"
|
||||
disabled={pending || status === 'unsupported'}
|
||||
onClick={() => onRequest(id)}
|
||||
className="gap-1.5"
|
||||
>
|
||||
<ExternalLink className="size-3.5" />
|
||||
{pending
|
||||
? translate('auto.components.settings.DeveloperPermissionsPane.dac08ec03e', 'Working...')
|
||||
: actionLabel}
|
||||
</Button>
|
||||
{id === 'local-network' && (
|
||||
<Button variant="outline" size="sm" onClick={() => void openSettings()}>
|
||||
{translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.localNetworkOpenSystemSettings',
|
||||
'Open System Settings'
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7,6 +7,16 @@ import type { DeveloperPermissionState } from '../../../../shared/developer-perm
|
||||
import { FULL_DISK_ACCESS_SETTINGS_TARGET_ID } from '@/lib/settings-navigation-types'
|
||||
import { DeveloperPermissionsPane } from './DeveloperPermissionsPane'
|
||||
|
||||
const toastMessageMock = vi.hoisted(() => vi.fn())
|
||||
|
||||
vi.mock('sonner', () => ({
|
||||
toast: {
|
||||
error: vi.fn(),
|
||||
message: toastMessageMock,
|
||||
success: vi.fn()
|
||||
}
|
||||
}))
|
||||
|
||||
let container: HTMLDivElement
|
||||
let root: Root
|
||||
|
||||
@@ -19,10 +29,16 @@ beforeEach(() => {
|
||||
{ id: 'full-disk-access', status: 'denied' }
|
||||
]
|
||||
),
|
||||
request: vi.fn()
|
||||
request: vi.fn(async ({ id }: { id: string }) => ({
|
||||
id,
|
||||
status: 'unknown',
|
||||
openedSystemSettings: false
|
||||
})),
|
||||
openSettings: vi.fn()
|
||||
}
|
||||
}
|
||||
})
|
||||
toastMessageMock.mockReset()
|
||||
container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
root = createRoot(container)
|
||||
@@ -34,6 +50,50 @@ afterEach(async () => {
|
||||
Reflect.deleteProperty(window, 'api')
|
||||
})
|
||||
|
||||
function setPermissionStates(states: DeveloperPermissionState[]): void {
|
||||
const api = (window as unknown as { api: { developerPermissions: { getStatus: unknown } } }).api
|
||||
api.developerPermissions.getStatus = vi.fn(async () => states)
|
||||
}
|
||||
|
||||
it('requests Local Network access without claiming a permission verdict', async () => {
|
||||
setPermissionStates([{ id: 'local-network', status: 'unknown' }])
|
||||
|
||||
await act(async () => {
|
||||
root.render(<DeveloperPermissionsPane />)
|
||||
})
|
||||
|
||||
const row = container.querySelector<HTMLElement>(
|
||||
'[data-settings-section="developer-permissions-local-network"]'
|
||||
)
|
||||
const [requestButton, settingsButton] = Array.from(
|
||||
row?.querySelectorAll<HTMLButtonElement>('button') ?? []
|
||||
)
|
||||
expect(row?.textContent).toContain('Managed by macOS')
|
||||
expect(row?.textContent).toContain("macOS does not report this permission's current status")
|
||||
expect(requestButton?.textContent).toContain('Request Access')
|
||||
expect(settingsButton?.textContent).toContain('Open System Settings')
|
||||
|
||||
await act(async () => requestButton?.click())
|
||||
|
||||
const api = window.api.developerPermissions
|
||||
expect(api.request).toHaveBeenCalledWith({ id: 'local-network' })
|
||||
expect(toastMessageMock).toHaveBeenCalledWith(
|
||||
'Check for a macOS prompt',
|
||||
expect.objectContaining({
|
||||
description:
|
||||
'If prompted, choose Allow. If no prompt appears, open System Settings and enable Orca under Privacy & Security → Local Network.',
|
||||
action: expect.objectContaining({ label: 'Open System Settings' })
|
||||
})
|
||||
)
|
||||
|
||||
const options = toastMessageMock.mock.calls[0]?.[1] as { action?: { onClick?: () => void } }
|
||||
options.action?.onClick?.()
|
||||
expect(api.openSettings).toHaveBeenCalledWith({ id: 'local-network' })
|
||||
|
||||
await act(async () => settingsButton?.click())
|
||||
expect(api.openSettings).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('highlights the Full Disk Access row for a targeted Settings navigation', async () => {
|
||||
await act(async () => {
|
||||
root.render(
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
Accessibility,
|
||||
Bluetooth,
|
||||
Camera,
|
||||
ExternalLink,
|
||||
HardDrive,
|
||||
Mic,
|
||||
MonitorUp,
|
||||
@@ -20,10 +19,13 @@ import type {
|
||||
} from '../../../../shared/developer-permissions-types'
|
||||
import { Button } from '../ui/button'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { DeveloperPermissionActions } from './DeveloperPermissionActions'
|
||||
import { LocalNetworkConnectionTest } from './LocalNetworkConnectionTest'
|
||||
import {
|
||||
developerPermissionStatusClass,
|
||||
developerPermissionStatusLabel
|
||||
} from './developer-permission-status'
|
||||
import { showDeveloperPermissionRequestNotice } from './developer-permission-request-notice'
|
||||
import { TerminalTccAttributionNotice } from './TerminalTccAttributionNotice'
|
||||
export { getDeveloperPermissionsPaneSearchEntries } from './developer-permissions-search'
|
||||
|
||||
@@ -157,18 +159,21 @@ const PERMISSIONS: PermissionDefinition[] = [
|
||||
{
|
||||
id: 'local-network',
|
||||
get label() {
|
||||
return translate('auto.components.settings.DeveloperPermissionsPane.e7bb06007c', 'LAN')
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.e7bb06007c',
|
||||
'Local Network'
|
||||
)
|
||||
},
|
||||
get description() {
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.f903bf20b5',
|
||||
'Discovery and access for development servers on your network.'
|
||||
"Allows terminals and development tools to connect to services on your local network. macOS does not report this permission's current status to Orca."
|
||||
)
|
||||
},
|
||||
get actionLabel() {
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.actionTriggerPrompt',
|
||||
'Trigger Prompt'
|
||||
'auto.components.settings.DeveloperPermissionsPane.actionRequestAccess',
|
||||
'Request Access'
|
||||
)
|
||||
},
|
||||
icon: <Network className="size-4" />
|
||||
@@ -290,28 +295,9 @@ export function DeveloperPermissionsPane({
|
||||
if (!mountedRef.current) {
|
||||
return
|
||||
}
|
||||
if (result.status === 'granted') {
|
||||
toast.success(
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.48d87edcd2',
|
||||
'Permission granted'
|
||||
)
|
||||
)
|
||||
} else if (result.openedSystemSettings) {
|
||||
toast.message(
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.fa809e8ada',
|
||||
'Opened macOS Privacy & Security'
|
||||
)
|
||||
)
|
||||
} else {
|
||||
toast.message(
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.66e94d6cf3',
|
||||
'Permission request sent'
|
||||
)
|
||||
)
|
||||
}
|
||||
showDeveloperPermissionRequestNotice(result, () => {
|
||||
void window.api.developerPermissions.openSettings({ id: 'local-network' })
|
||||
})
|
||||
} catch {
|
||||
if (mountedRef.current) {
|
||||
toast.error(
|
||||
@@ -360,43 +346,37 @@ export function DeveloperPermissionsPane({
|
||||
const settingId = `developer-permissions-${permission.id}`
|
||||
|
||||
return (
|
||||
<div
|
||||
key={permission.id}
|
||||
data-settings-section={settingId}
|
||||
data-highlighted={highlightedSettingId === settingId ? 'true' : undefined}
|
||||
className="flex items-center justify-between gap-4 px-4 py-3 transition-[background-color,box-shadow] duration-500 data-[highlighted=true]:bg-accent data-[highlighted=true]:ring-2 data-[highlighted=true]:ring-inset data-[highlighted=true]:ring-ring/50 motion-reduce:transition-none"
|
||||
>
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<div className="mt-0.5 text-muted-foreground">{permission.icon}</div>
|
||||
<div className="min-w-0 space-y-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-sm font-medium">{permission.label}</span>
|
||||
<span
|
||||
className={`rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wider ${developerPermissionStatusClass(
|
||||
status
|
||||
)}`}
|
||||
>
|
||||
{developerPermissionStatusLabel(status)}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{permission.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={pending || status === 'unsupported'}
|
||||
onClick={() => void request(permission.id)}
|
||||
className="shrink-0 gap-1.5"
|
||||
<div key={permission.id}>
|
||||
<div
|
||||
data-settings-section={settingId}
|
||||
data-highlighted={highlightedSettingId === settingId ? 'true' : undefined}
|
||||
className="flex items-center justify-between gap-4 px-4 py-3 transition-[background-color,box-shadow] duration-500 data-[highlighted=true]:bg-accent data-[highlighted=true]:ring-2 data-[highlighted=true]:ring-inset data-[highlighted=true]:ring-ring/50 motion-reduce:transition-none"
|
||||
>
|
||||
<ExternalLink className="size-3.5" />
|
||||
{pending
|
||||
? translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.dac08ec03e',
|
||||
'Working...'
|
||||
)
|
||||
: permission.actionLabel}
|
||||
</Button>
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<div className="mt-0.5 text-muted-foreground">{permission.icon}</div>
|
||||
<div className="min-w-0 space-y-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-sm font-medium">{permission.label}</span>
|
||||
<span
|
||||
className={`rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wider ${developerPermissionStatusClass(
|
||||
status
|
||||
)}`}
|
||||
>
|
||||
{developerPermissionStatusLabel(permission.id, status)}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">{permission.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
<DeveloperPermissionActions
|
||||
id={permission.id}
|
||||
actionLabel={permission.actionLabel}
|
||||
pending={pending}
|
||||
status={status}
|
||||
onRequest={(id) => void request(id)}
|
||||
/>
|
||||
</div>
|
||||
{permission.id === 'local-network' && <LocalNetworkConnectionTest />}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
// @vitest-environment happy-dom
|
||||
|
||||
import { act } from 'react'
|
||||
import { createRoot, type Root } from 'react-dom/client'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { LocalNetworkConnectionTest } from './LocalNetworkConnectionTest'
|
||||
|
||||
let container: HTMLDivElement
|
||||
let root: Root
|
||||
const testConnectionMock = vi.fn()
|
||||
|
||||
beforeEach(() => {
|
||||
localStorage.clear()
|
||||
testConnectionMock.mockReset()
|
||||
Object.assign(window, {
|
||||
api: {
|
||||
developerPermissions: {
|
||||
testLocalNetworkConnection: testConnectionMock
|
||||
}
|
||||
}
|
||||
})
|
||||
container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
root = createRoot(container)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await act(async () => root.unmount())
|
||||
container.remove()
|
||||
localStorage.clear()
|
||||
Reflect.deleteProperty(window, 'api')
|
||||
})
|
||||
|
||||
function inputValue(input: HTMLInputElement, value: string): void {
|
||||
const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set
|
||||
setter?.call(input, value)
|
||||
input.dispatchEvent(new Event('input', { bubbles: true }))
|
||||
}
|
||||
|
||||
async function expandConnectionTest(): Promise<void> {
|
||||
await act(async () =>
|
||||
container.querySelector<HTMLButtonElement>('[data-slot="collapsible-trigger"]')?.click()
|
||||
)
|
||||
}
|
||||
|
||||
it('keeps the target form collapsed by default', async () => {
|
||||
await act(async () => root.render(<LocalNetworkConnectionTest />))
|
||||
|
||||
expect(container.textContent).toContain('Test connection')
|
||||
expect(container.textContent).toContain('No successful test saved.')
|
||||
expect(container.querySelector('form')).toBeNull()
|
||||
})
|
||||
|
||||
it('saves and displays the last successful target-specific test', async () => {
|
||||
testConnectionMock.mockResolvedValue({
|
||||
ok: true,
|
||||
host: '192.168.1.20',
|
||||
port: 3000,
|
||||
testedAt: new Date('2026-08-06T07:00:00Z').getTime()
|
||||
})
|
||||
await act(async () => root.render(<LocalNetworkConnectionTest />))
|
||||
await expandConnectionTest()
|
||||
|
||||
const host = container.querySelector<HTMLInputElement>('#local-network-test-host')!
|
||||
const port = container.querySelector<HTMLInputElement>('#local-network-test-port')!
|
||||
await act(async () => {
|
||||
inputValue(host, '192.168.1.20')
|
||||
inputValue(port, '3000')
|
||||
})
|
||||
await act(async () =>
|
||||
container.querySelector<HTMLButtonElement>('button[type="submit"]')?.click()
|
||||
)
|
||||
|
||||
expect(testConnectionMock).toHaveBeenCalledWith({ host: '192.168.1.20', port: 3000 })
|
||||
expect(container.textContent).toContain('Last verified')
|
||||
expect(container.textContent).toContain('192.168.1.20:3000')
|
||||
|
||||
await act(async () => root.render(null))
|
||||
await act(async () => root.render(<LocalNetworkConnectionTest />))
|
||||
await expandConnectionTest()
|
||||
expect(container.textContent).toContain('192.168.1.20:3000')
|
||||
})
|
||||
|
||||
it('keeps the last success visible when a later test fails', async () => {
|
||||
testConnectionMock
|
||||
.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
host: 'devbox.local',
|
||||
port: 8080,
|
||||
testedAt: 1000
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
ok: false,
|
||||
host: 'devbox.local',
|
||||
port: 8080,
|
||||
testedAt: 2000,
|
||||
failure: 'refused'
|
||||
})
|
||||
await act(async () => root.render(<LocalNetworkConnectionTest />))
|
||||
await expandConnectionTest()
|
||||
|
||||
const host = container.querySelector<HTMLInputElement>('#local-network-test-host')!
|
||||
const port = container.querySelector<HTMLInputElement>('#local-network-test-port')!
|
||||
await act(async () => {
|
||||
inputValue(host, 'devbox.local')
|
||||
inputValue(port, '8080')
|
||||
})
|
||||
await act(async () =>
|
||||
container.querySelector<HTMLButtonElement>('button[type="submit"]')?.click()
|
||||
)
|
||||
await act(async () =>
|
||||
container.querySelector<HTMLButtonElement>('button[type="submit"]')?.click()
|
||||
)
|
||||
|
||||
expect(container.textContent).toContain('Last verified')
|
||||
expect(container.textContent).toContain('devbox.local:8080')
|
||||
expect(container.textContent).toContain('The host responded, but the port refused')
|
||||
expect(container.textContent).not.toContain('Permission denied')
|
||||
})
|
||||
@@ -0,0 +1,207 @@
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { CheckCircle2, ChevronDown } from 'lucide-react'
|
||||
import type {
|
||||
LocalNetworkConnectionTestFailure,
|
||||
LocalNetworkConnectionTestResult
|
||||
} from '../../../../shared/developer-permissions-types'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Button } from '../ui/button'
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../ui/collapsible'
|
||||
import { Input } from '../ui/input'
|
||||
import { Label } from '../ui/label'
|
||||
import {
|
||||
loadLocalNetworkConnectionSuccess,
|
||||
saveLocalNetworkConnectionSuccess,
|
||||
type LocalNetworkConnectionSuccess
|
||||
} from './local-network-connection-history'
|
||||
|
||||
function failureMessage(failure: LocalNetworkConnectionTestFailure | undefined): string {
|
||||
switch (failure) {
|
||||
case 'invalid-target':
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestInvalidTarget',
|
||||
'Enter a hostname or private LAN IP and a port from 1 to 65535.'
|
||||
)
|
||||
case 'timeout':
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestTimeout',
|
||||
'Connection timed out. Check the target, service, and macOS Local Network settings.'
|
||||
)
|
||||
case 'refused':
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestRefused',
|
||||
'The host responded, but the port refused the connection.'
|
||||
)
|
||||
case 'unreachable':
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestUnreachable',
|
||||
'The target could not be reached.'
|
||||
)
|
||||
case 'unresolved':
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestUnresolved',
|
||||
'The hostname could not be resolved.'
|
||||
)
|
||||
case 'unsupported':
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestUnsupported',
|
||||
'Connection testing is available in the macOS desktop app.'
|
||||
)
|
||||
case 'failed':
|
||||
case undefined:
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestFailed',
|
||||
'The connection test could not be completed.'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function formatTarget(success: LocalNetworkConnectionSuccess): string {
|
||||
return `${success.host}:${success.port}`
|
||||
}
|
||||
|
||||
export function LocalNetworkConnectionTest(): React.JSX.Element {
|
||||
const [lastSuccess, setLastSuccess] = useState(loadLocalNetworkConnectionSuccess)
|
||||
const [open, setOpen] = useState(false)
|
||||
const [host, setHost] = useState(lastSuccess?.host ?? '')
|
||||
const [port, setPort] = useState(lastSuccess ? String(lastSuccess.port) : '')
|
||||
const [running, setRunning] = useState(false)
|
||||
const [failure, setFailure] = useState<LocalNetworkConnectionTestFailure | null>(null)
|
||||
|
||||
const submit = async (event: FormEvent<HTMLFormElement>): Promise<void> => {
|
||||
event.preventDefault()
|
||||
setRunning(true)
|
||||
setFailure(null)
|
||||
try {
|
||||
const result: LocalNetworkConnectionTestResult =
|
||||
await window.api.developerPermissions.testLocalNetworkConnection({
|
||||
host,
|
||||
port: Number(port)
|
||||
})
|
||||
if (result.ok) {
|
||||
const success = {
|
||||
host: result.host,
|
||||
port: result.port,
|
||||
testedAt: result.testedAt
|
||||
}
|
||||
saveLocalNetworkConnectionSuccess(success)
|
||||
setLastSuccess(success)
|
||||
} else {
|
||||
setFailure(result.failure ?? 'failed')
|
||||
}
|
||||
} catch {
|
||||
setFailure('failed')
|
||||
} finally {
|
||||
setRunning(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Collapsible open={open} onOpenChange={setOpen} className="mr-4 mb-3 ml-11">
|
||||
<CollapsibleTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
className="h-auto w-full justify-between px-3 py-2 text-left"
|
||||
>
|
||||
<span className="min-w-0 space-y-0.5">
|
||||
<span className="block text-xs font-medium text-foreground">
|
||||
{translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestTitle',
|
||||
'Test connection'
|
||||
)}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
'flex items-center gap-1.5 text-xs font-normal',
|
||||
lastSuccess ? 'text-emerald-700 dark:text-emerald-300' : 'text-muted-foreground'
|
||||
)}
|
||||
>
|
||||
{lastSuccess && <CheckCircle2 className="size-3.5" />}
|
||||
{lastSuccess ? (
|
||||
<>
|
||||
{translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestLastVerified',
|
||||
'Last verified'
|
||||
)}{' '}
|
||||
{new Date(lastSuccess.testedAt).toLocaleString()} · {formatTarget(lastSuccess)}
|
||||
</>
|
||||
) : (
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestNotYetVerified',
|
||||
'No successful test saved.'
|
||||
)
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
<ChevronDown className={cn('size-4 transition-transform', open && 'rotate-180')} />
|
||||
</Button>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent className="collapsible-height-content">
|
||||
<div className="mt-2 rounded-lg border border-border/60 bg-muted/25 px-4 py-3 shadow-xs">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestDescription',
|
||||
'Enter a service on another device on your local network. Orca tests the same network path used by terminal tools.'
|
||||
)}
|
||||
</p>
|
||||
{failure && (
|
||||
<p className="mt-1 text-xs text-destructive" role="status">
|
||||
{failureMessage(failure)}
|
||||
</p>
|
||||
)}
|
||||
<form className="mt-3 flex items-end gap-2" onSubmit={(event) => void submit(event)}>
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="local-network-test-host" className="text-[11px]">
|
||||
{translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestHost',
|
||||
'Host'
|
||||
)}
|
||||
</Label>
|
||||
<Input
|
||||
id="local-network-test-host"
|
||||
value={host}
|
||||
onChange={(event) => setHost(event.target.value)}
|
||||
placeholder="192.168.1.20"
|
||||
autoComplete="off"
|
||||
className="w-44"
|
||||
disabled={running}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="local-network-test-port" className="text-[11px]">
|
||||
{translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestPort',
|
||||
'Port'
|
||||
)}
|
||||
</Label>
|
||||
<Input
|
||||
id="local-network-test-port"
|
||||
type="number"
|
||||
min={1}
|
||||
max={65_535}
|
||||
value={port}
|
||||
onChange={(event) => setPort(event.target.value)}
|
||||
placeholder="3000"
|
||||
className="w-24"
|
||||
disabled={running}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" variant="outline" disabled={running || !host || !port}>
|
||||
{running
|
||||
? translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestRunning',
|
||||
'Testing...'
|
||||
)
|
||||
: translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.connectionTestAction',
|
||||
'Test Connection'
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { toast } from 'sonner'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import type { DeveloperPermissionRequestResult } from '../../../../shared/developer-permissions-types'
|
||||
|
||||
/** Reports only permission outcomes supported by the corresponding macOS API. */
|
||||
export function showDeveloperPermissionRequestNotice(
|
||||
result: DeveloperPermissionRequestResult,
|
||||
openLocalNetworkSettings: () => void
|
||||
): void {
|
||||
if (result.status === 'granted') {
|
||||
toast.success(
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.48d87edcd2',
|
||||
'Permission granted'
|
||||
)
|
||||
)
|
||||
return
|
||||
}
|
||||
if (result.openedSystemSettings) {
|
||||
toast.message(
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.fa809e8ada',
|
||||
'Opened macOS Privacy & Security'
|
||||
)
|
||||
)
|
||||
return
|
||||
}
|
||||
if (result.id === 'local-network') {
|
||||
toast.message(
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.localNetworkPromptCheck',
|
||||
'Check for a macOS prompt'
|
||||
),
|
||||
{
|
||||
description: translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.localNetworkPromptGuidance',
|
||||
'If prompted, choose Allow. If no prompt appears, open System Settings and enable Orca under Privacy & Security → Local Network.'
|
||||
),
|
||||
action: {
|
||||
label: translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.localNetworkOpenSettings',
|
||||
'Open System Settings'
|
||||
),
|
||||
onClick: openLocalNetworkSettings
|
||||
}
|
||||
}
|
||||
)
|
||||
return
|
||||
}
|
||||
toast.message(
|
||||
translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.66e94d6cf3',
|
||||
'Permission request sent'
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import type { DeveloperPermissionStatus } from '../../../../shared/developer-permissions-types'
|
||||
import type {
|
||||
DeveloperPermissionId,
|
||||
DeveloperPermissionStatus
|
||||
} from '../../../../shared/developer-permissions-types'
|
||||
|
||||
/** Status copy and tone for the macOS developer permission rows. */
|
||||
export function developerPermissionStatusLabel(
|
||||
id: DeveloperPermissionId,
|
||||
status: DeveloperPermissionStatus | undefined
|
||||
): string {
|
||||
switch (status) {
|
||||
@@ -32,6 +36,12 @@ export function developerPermissionStatusLabel(
|
||||
)
|
||||
case 'unknown':
|
||||
case undefined:
|
||||
if (id === 'local-network') {
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.statusManagedByMacOS',
|
||||
'Managed by macOS'
|
||||
)
|
||||
}
|
||||
return translate(
|
||||
'auto.components.settings.DeveloperPermissionsPane.statusCheckManually',
|
||||
'Check manually'
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import type { LocalNetworkConnectionTestResult } from '../../../../shared/developer-permissions-types'
|
||||
|
||||
const STORAGE_KEY = 'orca.developer-permissions.local-network-last-success.v1'
|
||||
|
||||
export type LocalNetworkConnectionSuccess = Pick<
|
||||
LocalNetworkConnectionTestResult,
|
||||
'host' | 'port' | 'testedAt'
|
||||
>
|
||||
|
||||
function isSavedSuccess(value: unknown): value is LocalNetworkConnectionSuccess {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return false
|
||||
}
|
||||
const candidate = value as Partial<LocalNetworkConnectionSuccess>
|
||||
return (
|
||||
typeof candidate.host === 'string' &&
|
||||
candidate.host.length > 0 &&
|
||||
Number.isInteger(candidate.port) &&
|
||||
candidate.port! >= 1 &&
|
||||
candidate.port! <= 65_535 &&
|
||||
typeof candidate.testedAt === 'number' &&
|
||||
Number.isFinite(candidate.testedAt)
|
||||
)
|
||||
}
|
||||
|
||||
export function loadLocalNetworkConnectionSuccess(): LocalNetworkConnectionSuccess | null {
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY)
|
||||
if (!raw) {
|
||||
return null
|
||||
}
|
||||
const parsed: unknown = JSON.parse(raw)
|
||||
return isSavedSuccess(parsed) ? parsed : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function saveLocalNetworkConnectionSuccess(success: LocalNetworkConnectionSuccess): void {
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(success))
|
||||
} catch {
|
||||
// The live result remains useful when browser storage is unavailable.
|
||||
}
|
||||
}
|
||||
@@ -5874,8 +5874,8 @@
|
||||
"b2210b1b4f": "Bluetooth",
|
||||
"dfbc12c8c8": "Hardware debugging and device tools that talk to USB devices.",
|
||||
"bf51e4a542": "USB Devices",
|
||||
"f903bf20b5": "Discovery and access for development servers on your network.",
|
||||
"e7bb06007c": "LAN",
|
||||
"f903bf20b5": "Allows terminals and development tools to connect to services on your local network. macOS does not report this permission's current status to Orca.",
|
||||
"e7bb06007c": "Local Network",
|
||||
"4a73f5217a": "Apple Events for scripts that control other local apps.",
|
||||
"e119f0d66b": "Automation",
|
||||
"7ca17b62c8": "macOS names Orca when the agents it runs read other apps' data, because Orca is the responsible process for terminal commands. Grant this to Orca to reduce those prompts. Then quit and reopen Orca.",
|
||||
@@ -5898,7 +5898,29 @@
|
||||
"statusRestricted": "Restricted",
|
||||
"statusUnsupported": "macOS only",
|
||||
"statusEntitled": "Entitled",
|
||||
"statusCheckManually": "Check manually"
|
||||
"statusCheckManually": "Check manually",
|
||||
"actionRequestAccess": "Request Access",
|
||||
"localNetworkPromptCheck": "Check for a macOS prompt",
|
||||
"localNetworkPromptGuidance": "If prompted, choose Allow. If no prompt appears, open System Settings and enable Orca under Privacy & Security → Local Network.",
|
||||
"localNetworkOpenSettings": "Open System Settings",
|
||||
"openSettingsFailed": "Could not open System Settings",
|
||||
"localNetworkOpenSystemSettings": "Open System Settings",
|
||||
"statusManagedByMacOS": "Managed by macOS",
|
||||
"connectionTestInvalidTarget": "Enter a hostname or private LAN IP and a port from 1 to 65535.",
|
||||
"connectionTestTimeout": "Connection timed out. Check the target, service, and macOS Local Network settings.",
|
||||
"connectionTestRefused": "The host responded, but the port refused the connection.",
|
||||
"connectionTestUnreachable": "The target could not be reached.",
|
||||
"connectionTestUnresolved": "The hostname could not be resolved.",
|
||||
"connectionTestUnsupported": "Connection testing is available in the macOS desktop app.",
|
||||
"connectionTestFailed": "The connection test could not be completed.",
|
||||
"connectionTestTitle": "Test connection",
|
||||
"connectionTestDescription": "Enter a service on another device on your local network. Orca tests the same network path used by terminal tools.",
|
||||
"connectionTestLastVerified": "Last verified",
|
||||
"connectionTestNotYetVerified": "No successful test saved.",
|
||||
"connectionTestHost": "Host",
|
||||
"connectionTestPort": "Port",
|
||||
"connectionTestRunning": "Testing...",
|
||||
"connectionTestAction": "Test Connection"
|
||||
},
|
||||
"ExperimentalPane": {
|
||||
"9762364929": "Uses APFS clone-copy on macOS when possible, otherwise symlinks configured folders or files into created worktrees.",
|
||||
|
||||
@@ -2927,7 +2927,15 @@ function createDeveloperPermissionsApi(): NonNullable<Partial<PreloadApi>['devel
|
||||
getStatus: () => Promise.resolve([]),
|
||||
request: ({ id }) =>
|
||||
Promise.resolve({ id, status: 'unsupported', openedSystemSettings: false } as const),
|
||||
openSettings: () => Promise.resolve()
|
||||
openSettings: () => Promise.resolve(),
|
||||
testLocalNetworkConnection: ({ host, port }) =>
|
||||
Promise.resolve({
|
||||
ok: false,
|
||||
host,
|
||||
port,
|
||||
testedAt: Date.now(),
|
||||
failure: 'unsupported'
|
||||
} as const)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,3 +28,20 @@ export type DeveloperPermissionRequestResult = {
|
||||
status: DeveloperPermissionStatus
|
||||
openedSystemSettings: boolean
|
||||
}
|
||||
|
||||
export type LocalNetworkConnectionTestFailure =
|
||||
| 'invalid-target'
|
||||
| 'timeout'
|
||||
| 'refused'
|
||||
| 'unreachable'
|
||||
| 'unresolved'
|
||||
| 'failed'
|
||||
| 'unsupported'
|
||||
|
||||
export type LocalNetworkConnectionTestResult = {
|
||||
ok: boolean
|
||||
host: string
|
||||
port: number
|
||||
testedAt: number
|
||||
failure?: LocalNetworkConnectionTestFailure
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user