Skip to content

fix(macos): register dev binary with TCC for Screen Recording permission#2

Open
skalkii wants to merge 1 commit into
video-db:mainfrom
skalkii:fix/macos-dev-screen-permission-warmup
Open

fix(macos): register dev binary with TCC for Screen Recording permission#2
skalkii wants to merge 1 commit into
video-db:mainfrom
skalkii:fix/macos-dev-screen-permission-warmup

Conversation

@skalkii
Copy link
Copy Markdown

@skalkii skalkii commented Apr 25, 2026

Summary

  • Adds a small src/main/util.ts with isDev() and ensureScreenPermissionRegistered(screen).
  • Replaces the body of onboarding:getPermissions in src/main/ipc-handlers.ts with a single call to the new helper.
  • Dev-only — packaged builds skip the warmup entirely.

Why

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 never appears in the list, so the user has nothing to toggle and capture stays blocked.

systemPreferences.getMediaAccessStatus('screen') is read-only and does not register the calling binary with TCC. macOS only adds an app to the list once it has attempted a capture (e.g. via desktopCapturer.getSources). Packaged .app bundles register on their own first capture; the unpackaged dev binary doesn't.

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.

The isDev() helper follows the spirit of the pattern in N-Ziermann-YouTube/electron-course's src/electron/util.ts, but uses app.isPackaged because the project's dev script does not set NODE_ENV.

Test plan

  • npx tsc --noEmit -p tsconfig.node.json clean for the touched files
  • tccutil reset ScreenCapture then npm run dev from VS Code → onboarding → Open Settings — expect VS Code (or the spawning helper) to appear under Screen Recording, and granting permission there enables capture after relaunch
  • npm run package:mac and confirm Screen permission warmup invoked (dev mode) does not appear in ~/Library/Application Support/VideoDB Focusd/logs/

Fixes #1

In dev mode, systemPreferences.getMediaAccessStatus('screen') is read-only
and never causes macOS to register the unpackaged dev binary (Electron /
VS Code helper / iTerm helper) under System Settings → Privacy → Screen
Recording. Users hit "Open Settings" from onboarding and find nothing to
toggle.

Add a small util.ts with isDev() and ensureScreenPermissionRegistered(),
the latter calling desktopCapturer.getSources once when unpackaged and
permission is not yet granted. This forces TCC to register the binary so
it appears in System Settings. Packaged builds register on their own
first capture and skip the warmup.

Fixes video-db#1

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant