Fix Screen Recording permission cache never downgrading after revocation#29
Merged
Merged
Conversation
The persisted screenCaptureTCCGranted flag seeded the in-process granted state at launch and could never be cleared, so revoking Screen Recording in System Settings while Heard wasn't running left the app showing Granted forever. Replace the boolean with ScreenCaptureGrantCache, a pure state machine: a grant cached from a previous session is trusted only for a ~30 s reconfirmation window after launch (10 poll probes), then cleared if probes keep failing. A grant confirmed live within a session remains sticky for the process lifetime, and the authoritative SCShareableContent check after the Grant… flow now clears a stale cache immediately on a definitive false. https://claude.ai/code/session_01UMbvMVowzQq3LgFpaQA8aE
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
The persisted
screenCaptureTCCGrantedflag seeded the in-process granted state at launch and could never be cleared — so revoking Screen Recording in System Settings while Heard wasn't running left the app showing Granted forever, across restarts.This replaces the boolean with
ScreenCaptureGrantCache, a pure, unit-tested state machine that distinguishes the two cases the old code conflated:SCShareableContentcheck after the "Grant…" flow now clears a stale cache immediately on a definitive false, instead of being ignored.Changes
Sources/HeardCore/Services.swift: newScreenCaptureGrantCachevalue type;PermissionCentermigrated off the sticky boolean; UserDefaults writes centralized inapplyScreenCaptureProbeTests/HeardTests/PermissionCenterTests.swift: 9 new tests covering revocation-while-not-running, confirmation stickiness, budget exhaustion, recovery after downgrade, and authoritative-probe semanticshandoff.md: documented the grant-caching behaviorTesting
HeardTestssuite): https://github.com/execsumo/Heard/actions/runs/27388179318https://claude.ai/code/session_01UMbvMVowzQq3LgFpaQA8aE
Generated by Claude Code