Skip to content

Dev mode (macOS): Screen Recording permission cannot be granted on first run — dev binary missing from System Settings #1

@skalkii

Description

@skalkii

Summary

On first-time npm run dev (macOS), the onboarding "Screen Recording permission required" card opens System Settings → Privacy & Security → Screen Recording, but the running dev binary (Electron / VS Code helper / iTerm helper) does not appear in the list. The user has nothing to toggle, and screen capture stays blocked.

Repro

  1. Fresh macOS state (or tccutil reset ScreenCapture to simulate first run).
  2. npm run dev from VS Code's integrated terminal (or iTerm).
  3. Complete onboarding until the Screen Recording permission card.
  4. Click Open Settings.
  5. Observe: the dev binary is not listed under Screen Recording — only stale entries (e.g. iTerm) or nothing at all.

Expected

The binary that triggered the permission check should appear in the Screen Recording list so the user can toggle it on.

Root cause

systemPreferences.getMediaAccessStatus('screen') (used in src/main/ipc-handlers.ts onboarding:getPermissions) is read-only — it does not register the calling binary with macOS TCC. macOS only adds an app to the Screen Recording list after it has attempted a capture (e.g. via desktopCapturer.getSources). Packaged .app bundles register on their own first capture; the dev binary doesn't until something actively calls into the capture API.

Fix

In dev mode only (gated by !app.isPackaged), invoke a no-op desktopCapturer.getSources({ types: ['screen'], thumbnailSize: { width: 1, height: 1 } }) from inside onboarding:getPermissions when screen status is not granted. This forces TCC to register the binary so it shows up in System Settings.

Production builds are unaffected — the packaged VideoDB Focusd.app registers itself on first real capture and does not need the warmup.

After the fix, running npm run dev from VS Code and clicking Open Settings shows VS Code (the helper that spawned Electron) in the Screen Recording list. Toggling it on and relaunching dev grants screen capture as expected.

Environment

  • macOS (TCC-managed permissions)
  • Electron via electron-vite (npm run dev)
  • Bundle id: com.videodb.focusd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions