fix(macos): register dev binary with TCC for Screen Recording permission#2
Open
skalkii wants to merge 1 commit into
Open
fix(macos): register dev binary with TCC for Screen Recording permission#2skalkii wants to merge 1 commit into
skalkii wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/main/util.tswithisDev()andensureScreenPermissionRegistered(screen).onboarding:getPermissionsinsrc/main/ipc-handlers.tswith a single call to the new helper.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. viadesktopCapturer.getSources). Packaged.appbundles register on their own first capture; the unpackaged dev binary doesn't.Fix
In dev mode only (gated by
!app.isPackaged), invoke a no-opdesktopCapturer.getSources({ types: ['screen'], thumbnailSize: { width: 1, height: 1 } })from insideonboarding:getPermissionswhen screen status is notgranted. 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'ssrc/electron/util.ts, but usesapp.isPackagedbecause the project'sdevscript does not setNODE_ENV.Test plan
npx tsc --noEmit -p tsconfig.node.jsonclean for the touched filestccutil reset ScreenCapturethennpm run devfrom VS Code → onboarding → Open Settings — expect VS Code (or the spawning helper) to appear under Screen Recording, and granting permission there enables capture after relaunchnpm run package:macand confirmScreen permission warmup invoked (dev mode)does not appear in~/Library/Application Support/VideoDB Focusd/logs/Fixes #1