moeru-ai/airi · error · Error

requestMacOSScreenCapturePermission is only available on mac

Error message

requestMacOSScreenCapturePermission is only available on macOS (darwin)

What it means

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.

Source

Thrown at packages/electron-screen-capture/src/main/utils.ts:41

    id: source.id,
    name: source.name,
    display_id: source.display_id,
    appIcon: source.appIcon != null && !source.appIcon.isEmpty() ? new Uint8Array(source.appIcon.toPNG().buffer) : undefined,
    thumbnail: source.thumbnail != null ? new Uint8Array(source.thumbnail.toJPEG(90).buffer) : undefined,
  }
}

export function checkMacOSScreenCapturePermission(): ReturnType<typeof systemPreferences.getMediaAccessStatus> {
  if (!isMacOS) {
    throw new Error('checkMacOSScreenCapturePermission is only available on macOS (darwin)')
  }

  return systemPreferences.getMediaAccessStatus('screen')
}

export function requestMacOSScreenCapturePermission(): void {
  if (!isMacOS) {
    throw new Error('requestMacOSScreenCapturePermission is only available on macOS (darwin)')
  }

  shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture')
}

View on GitHub (pinned to 27111382b4)

Solutions

  1. Only show/invoke the macOS permission request when process.platform === 'darwin'.
  2. Wrap the invoke in try/catch on non-mac and skip the UX step.
  3. Use platform-conditional UI so non-mac users never trigger the request.

Example fix

// before
await invoke(screenCapture.requestMacOSPermission)
// after
if (process.platform === 'darwin') {
  await invoke(screenCapture.requestMacOSPermission)
}
Defensive patterns

Strategy: type-guard

Validate before calling

import { isMacOS } from 'std-env'

if (isMacOS) {
  await invoke(screenCapture.requestMacOSPermission)
}

Type guard

import { isMacOS } from 'std-env'

function onMacOS(): boolean { return isMacOS }

Try / catch

try {
  await invoke(screenCapture.requestMacOSPermission)
} catch (error) {
  if (error instanceof Error && error.message.includes('only available on macOS')) return
  throw error
}

Prevention

When it happens

Trigger: Calling requestMacOSScreenCapturePermission() directly or via the screenCapture.requestMacOSPermission invoke handler on Windows or Linux; a cross-platform renderer invoking the permission request unconditionally.

Common situations: 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.

Related errors


AI-assisted analysis of moeru-ai/airi@27111382b4 (2026-08-12). Data as JSON: /api/errors/01d8332785a7af41. Report an issue: GitHub.