{"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/27111382b4a79a7e983289d6e983a06af185ed0f/packages/electron-screen-capture/src/main/utils.ts#L23-L46","documentation":"Thrown by requestMacOSScreenCapturePermission() when isMacOS is false. The function calls shell.openExternal with an x-apple.systempreferences: URL that only resolves on macOS, so on other platforms the call is meaningless and would confuse the user.","triggerScenarios":"Calling requestMacOSScreenCapturePermission() directly or via the screenCapture.requestMacOSPermission invoke handler on Windows or Linux; a cross-platform renderer invoking the permission request unconditionally.","commonSituations":"Shared renderer code path that requests screen-capture permission regardless of OS; a button labeled 'Grant screen capture permission' that is shown on all platforms; tests on non-mac CI that invoke the handler.","solutions":["Only show/invoke the macOS permission request when process.platform === 'darwin'.","Wrap the invoke in try/catch on non-mac and skip the UX step.","Use platform-conditional UI so non-mac users never trigger the request."],"exampleFix":"// before\nawait invoke(screenCapture.requestMacOSPermission)\n// after\nif (process.platform === 'darwin') {\n  await invoke(screenCapture.requestMacOSPermission)\n}","handlingStrategy":"type-guard","validationCode":"import { isMacOS } from 'std-env'\n\nif (isMacOS) {\n  await invoke(screenCapture.requestMacOSPermission)\n}","typeGuard":"import { isMacOS } from 'std-env'\n\nfunction onMacOS(): boolean { return isMacOS }","tryCatchPattern":"try {\n  await invoke(screenCapture.requestMacOSPermission)\n} catch (error) {\n  if (error instanceof Error && error.message.includes('only available on macOS')) return\n  throw error\n}","preventionTips":["Show the 'Grant screen capture permission' control only on macOS.","Wrap cross-platform permission flows in platform branches.","Keep a non-mac fallback path so users on other OSes are not blocked."],"tags":["electron","screen-capture","platform","macos"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}