From fb3d46710b9ae07b1b60f7d3ae35629460201743 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Wed, 29 Apr 2026 23:50:41 -0700 Subject: [PATCH] fix(mac-perms): fall through to Privacy pane when in-app prompt is a no-op (#1273) Co-authored-by: Orca --- src/main/ipc/developer-permissions.ts | 25 ++++++++++++++++--- .../settings/DeveloperPermissionsPane.tsx | 12 +++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/ipc/developer-permissions.ts b/src/main/ipc/developer-permissions.ts index 60b4ea887..060eb7a38 100644 --- a/src/main/ipc/developer-permissions.ts +++ b/src/main/ipc/developer-permissions.ts @@ -147,13 +147,32 @@ async function requestPermission( } if (id === 'microphone' || id === 'camera') { + // Why: askForMediaAccess only surfaces the TCC prompt when status is + // 'not-determined'. If the user previously denied (or macOS set the status + // to 'denied'/'restricted'), it resolves false with no prompt — leaving + // the user stuck. Fall through to the Privacy pane so they can toggle it. const granted = await systemPreferences.askForMediaAccess(id) - return { id, status: granted ? 'granted' : getMediaStatus(id), openedSystemSettings: false } + if (granted) { + return { id, status: 'granted', openedSystemSettings: false } + } + const status = getMediaStatus(id) + if (status === 'denied' || status === 'restricted' || status === 'unknown') { + await openPrivacyPane(id) + return { id, status, openedSystemSettings: true } + } + return { id, status, openedSystemSettings: false } } if (id === 'accessibility') { - systemPreferences.isTrustedAccessibilityClient(true) - return { id, status: getAccessibilityStatus(), openedSystemSettings: false } + // Why: isTrustedAccessibilityClient(true) shows the prompt only the first + // time for a given bundle. Once the user has dismissed or denied, calling + // it again is a no-op. Fall through to the Privacy pane when not granted. + const trusted = systemPreferences.isTrustedAccessibilityClient(true) + if (trusted) { + return { id, status: 'granted', openedSystemSettings: false } + } + await openPrivacyPane(id) + return { id, status: getAccessibilityStatus(), openedSystemSettings: true } } if (id === 'automation') { diff --git a/src/renderer/src/components/settings/DeveloperPermissionsPane.tsx b/src/renderer/src/components/settings/DeveloperPermissionsPane.tsx index eead3e04e..1273fda68 100644 --- a/src/renderer/src/components/settings/DeveloperPermissionsPane.tsx +++ b/src/renderer/src/components/settings/DeveloperPermissionsPane.tsx @@ -179,6 +179,18 @@ export function DeveloperPermissionsPane(): React.JSX.Element { void refresh() }, [refresh]) + // Why: after the user flips a permission in System Settings and switches + // back to Orca, the chip should reflect the new status without a manual + // Refresh click. Tied to window focus rather than a polling interval so + // we don't keep hammering `systemPreferences` while the pane is idle. + useEffect(() => { + const onFocus = (): void => { + void refresh() + } + window.addEventListener('focus', onFocus) + return () => window.removeEventListener('focus', onFocus) + }, [refresh]) + const request = async (id: DeveloperPermissionId): Promise => { setPendingId(id) try {