fix(mac-perms): fall through to Privacy pane when in-app prompt is a no-op (#1273)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-04-29 23:50:41 -07:00
committed by GitHub
co-authored by Orca
parent 066c245d14
commit fb3d46710b
2 changed files with 34 additions and 3 deletions
+22 -3
View File
@@ -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') {
@@ -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<void> => {
setPendingId(id)
try {