{"record":{"id":"01d8332785a7af41","repo":"moeru-ai/airi","slug":"requestmacosscreencapturepermission-is-only-availa","errorCode":null,"errorMessage":"requestMacOSScreenCapturePermission is only available on macOS (darwin)","messagePattern":"requestMacOSScreenCapturePermission is only available on macOS \\(darwin\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/electron-screen-capture/src/main/utils.ts","lineNumber":41,"sourceCode":"    id: source.id,\n    name: source.name,\n    display_id: source.display_id,\n    appIcon: source.appIcon != null && !source.appIcon.isEmpty() ? new Uint8Array(source.appIcon.toPNG().buffer) : undefined,\n    thumbnail: source.thumbnail != null ? new Uint8Array(source.thumbnail.toJPEG(90).buffer) : undefined,\n  }\n}\n\nexport function checkMacOSScreenCapturePermission(): ReturnType<typeof systemPreferences.getMediaAccessStatus> {\n  if (!isMacOS) {\n    throw new Error('checkMacOSScreenCapturePermission is only available on macOS (darwin)')\n  }\n\n  return systemPreferences.getMediaAccessStatus('screen')\n}\n\nexport function requestMacOSScreenCapturePermission(): void {\n  if (!isMacOS) {\n    throw new Error('requestMacOSScreenCapturePermission is only available on macOS (darwin)')\n  }\n\n  shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture')\n}\n","sourceCodeStart":23,"sourceCodeEnd":46,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/electron-screen-capture/src/main/utils.ts#L23-L46","documentation":"requestMacOSScreenCapturePermission() in packages/electron-screen-capture/src/main/utils.ts opens the macOS System Settings pane for Screen Recording via shell.openExternal, and is guarded to macOS only. On any other platform it throws before touching shell, because the x-apple.systempreferences URL scheme and the Screen Capture privacy pane do not exist there. It is exposed to renderers through the screenCapture.requestMacOSPermission eventa handler.","triggerScenarios":"Invoking screenCapture.requestMacOSPermission (or the util directly) on Windows/Linux; wiring a 'Grant permission' button to this call without checking the host platform; running component/E2E tests on non-darwin machines that click through the permission UI.","commonSituations":"A permission-prompt UI built against macOS that ships to all platforms; automated tests on Linux CI reaching the request-permission branch; a shared 'first-run onboarding' flow that calls both check and request unconditionally.","solutions":["Only show/call the request-permission action when the app runs on macOS (gate in the renderer UI and/or in main before defining the flow).","Pair it with checkMacOSScreenCapturePermission: only offer 'open settings' when the check returns 'denied' or 'not-determined' on darwin.","On other platforms, skip the pre-flight entirely and let getSources/getDisplayMedia surface native failures instead."],"exampleFix":"// before\nawait invoke(screenCapture.requestMacOSPermission) // throws on Windows/Linux\n\n// after\nif (await rendererPlatform() === 'darwin') {\n  await invoke(screenCapture.requestMacOSPermission)\n}","handlingStrategy":"validation","validationCode":"const isDarwin = process.platform === 'darwin'\nif (isDarwin && (await invoke(screenCapture.checkMacOSPermission)) !== 'granted') {\n  await invoke(screenCapture.requestMacOSPermission)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only render the 'Open privacy settings' button on macOS.","Pair request with check: never call request when the platform cannot honor it or the check already returned granted.","Centralize platform capability detection in one module consumed by both UI and IPC layers."],"tags":["electron","macos","platform-guard","permissions","screen-capture"],"backgroundTag":"platform-not-supported","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}