Repository navigation
fix(desktop/macos): stop the screen-recording consent dialog from recurring - #12239
Merged
Merged
Conversation
…urring
macOS repeatedly showed the "would like to record this computer's screen and
audio" re-confirmation dialog even though the Screen Recording grant was
intact. tccd confirms the grant was never lost:
Handling access request to kTCCServiceScreenCapture,
from Sub:{com.omi.computer-macos.beta}
ReqResult(Auth Right: Allowed (System Set), promptType: 1, DB Action:None)
promptType: 1 is macOS asking to periodically re-confirm consent for app-built
content filters (SCContentFilter(desktopIndependentWindow:), i.e. capture that
bypasses the system window picker). Two causes, both ours:
1. Sampling amplifier. The app never held a persistent capture stream — every
frame was a fresh one-shot SCContentFilter + SCScreenshotManager.captureImage.
Measured 267 kTCCServiceScreenCapture authorization requests in 180s
(~1.5/s, ~5000/hour), each with a full SecStaticCodeCheckValidity(). A
re-consent macOS intends to surface rarely was sampled thousands of times an
hour and fired the instant it came due.
2. Retry loop re-armed the dialog. captureWindowCGImage collapsed every error
into .failed, including "The user declined TCCs". The capture tick opened
another session seconds later and re-armed the prompt — observed three times
in ten minutes.
Fix A (flagged): one long-lived SCStream scoped to the frontmost window
(WindowCaptureStreamEngine). Window switches ride updateContentFilter and
resizes updateConfiguration on the live stream, so authorization is paid once
per stream start rather than per frame. The filter stays desktopIndependentWindow
— a display-scoped stream with client-side cropping was rejected because it
moves the per-window privacy boundary (Rewind exclusions, filtered browser
windows) from OS-enforced to app-enforced.
Fix B (unflagged, straight bug fix): "user declined TCCs" is classified and
terminal. Monitoring stops, one banner per episode offers restart, and the
recovery/background polls exit through the same handler instead of re-arming
the dialog every 5-60s. The Exposé/Mission Control carve-out is preserved —
that mode raises the same error transiently and must not stop capture.
Also fixes a sibling of the same defect class found while sweeping: onboarding
ran checkAccessibilityPermission (up to five cross-process AX round trips),
checkAutomationPermission and checkFullDiskAccess every second for the life of
the view — three authorization subsystems, thousands of denied privileged
checks per onboarding session. Now every 5th tick; the instant grant-edge
signals (accessibility observer, app-activation refresh) are untouched.
Privacy note: the retarget protocol (beginRetarget/endRetarget) exists because
a frame captured under the old filter but delivered after a retarget would
otherwise be tagged with the new window's ID and handed to a caller that
believes it is looking at the new window. Each stream also owns its own sink,
so a departing stream cannot deliver into its replacement.
Co-Authored-By: Claude Opus 5 <[email protected]>
…g or bypassing Declaring a failure class was hard in ways that pushed authors toward the wrong action. Each of these was hit while declaring one class for the screen-recording consent fix in this PR. 1. `Failure-Class: new` was unsatisfiable. It requires an added definition, and the schema required a non-empty `evidence_prs` — but `evidence_prs` records *merged* PRs, and the PR fixing a class's first instance has no number until it is opened. The only ways through were to invent a number or push with --no-verify and backfill. `evidence_prs` may now be empty: the adding commit is the evidence and `git log -- <definition>` recovers it. Nothing enforced recurrence from this field anyway — the guard-artifact ratchet counts declarations in git history — so requiring it bought paperwork, not traceability. Scoping the allowance to "added by this change" was the obvious fix and is wrong: it passes in the authoring PR, then fails forever afterwards, because a merged definition is no longer new. There is a test for that. 2. The declaration syntax taught itself ambiguously. "Failure-Class: FC-<slug> | new | none" reads as a pipe-separated value in a repo whose other PR-body directives really are pipe-separated (Line-Count-Exception: path | a -> b | reason). Writing "FC-my-slug | new" got the same template echoed back. The three forms are now listed as alternatives everywhere they appear, and the error names the pipe mistake specifically. 3. That same mistake reported the wrong remedy. An invalid declaration fell into the instance-fix registry guard, so the error said registry edits need a separate lifecycle PR — which points at deleting the definition file, when the actual defect is the malformed line above it. The guard now runs only for a declaration that names a known class. 4. `prepare` printed all 145 definitions in full, which is unreadable, and an unreadable registry gets a new class invented instead of an existing one reused — inflating the registry the protocol wants to keep small. It now lists the classes whose advisory `scope_hints` overlap the change (145 -> 23 here, surfacing the adjacent FC-concurrent-capture-contention), with --all-candidates for the rest. This narrows what is listed, never what is chosen: it never narrows to empty, since that would read as "no class can apply" — a classification this CLI does not make. `pr_preflight`'s generated PR body labels the narrowed list accordingly. The PR template said a `new` declaration must go in a separate PR, never the instance-fix PR, which contradicted both the validator and the registry's own history (FC-workflow-script-input-contract shipped in its fix). It now separates adding one new definition alongside a fix, which is allowed, from every other registry transition, which is not. Failure-Class: none Co-Authored-By: Claude Opus 5 <[email protected]>
`test_standard_actions_no_longer_use_node_20_majors` has been failing on main: desktop_publish_preview.yml was the one workflow still pinned to actions/upload-artifact@v4 (Node 20), against 19 workflows already on v7. That test only runs in the preflight lane when pr_preflight.py or its siblings change, so the failure sat latent until the failure-class commit in this branch touched that file and pulled the lane in. Bumping the outlier to match every other workflow clears it. No behavior change: the step's inputs are unchanged and v7 accepts them. Failure-Class: none Co-Authored-By: Claude Opus 5 <[email protected]>
… behavioral Two desktop-test-quality ratchets caught the new tests, and both were catching something real rather than being in the way. Wall-clock waits (16 -> 17): `testWaiterFromPreviousTargetIsReleasedEmpty` slept 30 ms to let a waiter park before retargeting. On a loaded machine the retarget can land before the continuation registers, so the test would have passed for the wrong reason. `CaptureFrameSink` now exposes `hasParkedWaiter`, and the test yields until the waiter is actually parked. Production-source inspection (54 -> 55 files): two tests asserted against the *text* of ProactiveAssistantsPlugin.swift — that certain function bodies contain `captureActiveWindowCGImage()` and `case .permissionDeclined:`. That pins today's source layout rather than behavior, and breaks on any rename. Removed. The contracts they guarded are covered behaviorally by the classifier tests (`SCStreamError.userDeclined` and the message fallback both classify as `.permissionDeclined`) and by the policy tests (a decline outside the special system modes is terminal and notifies once). The residual gap is honest: nothing now pins the recovery and background polls to the classified probe, so a refactor could reintroduce the unclassified `captureActiveWindowAsync` `Data?` probe that erased the decline. Catching that behaviorally needs a seam through the plugin's async lifecycle that does not exist yet; a source-text assertion was not a real substitute for it. Also adds the two new engine files to screen-recording-permission.yaml's `covers:` list, which desktop-e2e-flow-coverage requires. Failure-Class: none Co-Authored-By: Claude Opus 5 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
FC-privileged-consent-resampled-on-timer was authored with `evidence_prs: []`, which is now valid precisely because the number did not exist yet. Filling it in once the PR is open is the intended flow, not a required follow-up: an empty list stays valid forever, so nothing is broken if this step never happens. Failure-Class: none Co-Authored-By: Claude Opus 5 <[email protected]>
…olchain CI pins Xcode 16.4; this machine has 26.2. The two SDKs disagree about the capture engine's concurrency, so a clean local build and a green local test run proved nothing about the jobs that gate the PR. Three errors, all real under 16.4: - `static let ciContext` is global mutable state whose legality depends on whether the SDK declares `CIContext` as `Sendable`. 16.4 says no and demands `nonisolated(unsafe)`; 26.2 says yes and rejects that attribute as unnecessary. No spelling satisfies both, so the context moves to an instance property of `CaptureFrameSink` (already `@unchecked Sendable`) and the question stops being asked. Cost is one context per stream — the lifetime this engine exists to make long. - `withStreamLock<T>` returned a generic, non-Sendable value out of a closure, which 16.4 treats as sending it from a nonisolated context. It is now Void-returning, and `configureStream` — the one holder that returns a `CaptureFrameSink` — takes the lock directly with `acquireStreamLock` and releases it in a `defer`, so no value crosses a closure boundary. Behavior is unchanged: same lock, same bound, same leak-proof release. Co-Authored-By: Claude Opus 5 <[email protected]>
The first fix cleared the interface-level errors, which let the pinned toolchain reach the function bodies for the first time and report the next layer: every `updateContentFilter` / `updateConfiguration` / `startCapture` / `stopCapture` call sends a `self`-isolated non-Sendable value to a nonisolated method. These were latent, not new — module emission had failed before any body was checked, so this file has never actually compiled under Xcode 16.4. ScreenCaptureKit carries no concurrency annotations in that SDK, so the crossings are errors there and silent on a newer one. `@preconcurrency` is the sanctioned way to mark a module as predating strict concurrency, and is already how this codebase handles AVFoundation, UserNotifications, GRDB, CoreAudio, and ApplicationServices. What actually serializes these calls is the stream lock. Co-Authored-By: Claude Opus 5 <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Aug 26, 2026
* fix(repo): reject Git identities that can never be attributed PR #12239 was authored entirely by `r <r@r>` from a stale clone-local `user.email`. This guard ran on every one of those commits — 66 over five days — and printed "OK: Git author identity is not a test fixture" each time. It was enumerating the previous incident rather than the invariant. After #11525 minted `Ratchet Test <[email protected]>`, the check learned that exact display name, that exact local-part, and three reserved TLDs. `r@r` is none of those, so it passed: `email_tld("r@r")` returns `"r"`, because the domain has no dot to split on. The rule is now the property that makes an identity wrong. An address whose domain cannot resolve can never be delivered or attributed to anyone, whatever it is called. That single predicate covers both incidents and the family they belong to, and it needs no allowlist to maintain. `failures_for` already applied its predicate to clone-local config as well as to the commit range, so one change covers every lane at once: - pre-commit (`--pending`) rejects the override before a commit is minted - the local lane of `git-author-identity` rejects it again before push - the CI lane never sees a developer's `.git/config`, so the commit range is the only unbypassable place this can be caught — and it now is Real addresses, including `users.noreply.github.com`, are untouched; a name-only identity carries an empty email and is not judged on it. The report wording said "test fixture", which is exactly what let a non-fixture bad identity read as a pass. It now says unattributable. Co-Authored-By: Claude Opus 5 <[email protected]> * feat(failure-classes): add FC-guard-encodes-incident-literals The class this PR's fix belongs to, and the reason it took a second incident to notice: a guard written after an incident encoded that incident's literal values instead of the property that made it wrong, so the next instance passed while the check reported success. evidence_prs is empty because this PR is the first instance; the adding commit is the evidence. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
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.
What
macOS repeatedly showed the "Omi Beta would like to record this computer's screen and audio" dialog even though Screen Recording was already granted — three times in ten minutes in one observed session.
The grant was never lost.
tccdlogged this while the dialog was on screen:Allowed (System Set)= granted.DB Action: None= nothing revoked.promptType: 1is macOS asking to periodically re-confirm consent for app-built content filters —SCContentFilter(desktopIndependentWindow:), capture that bypasses the system window picker.Two causes, both ours.
1. Sampling amplifier. The app never held a persistent capture stream. Every frame was a fresh one-shot
SCContentFilter+SCScreenshotManager.captureImage. Measured from tccd msgIDs: 267kTCCServiceScreenCaptureauthorization requests in 180 seconds (~1.5/s, ~5,000/hour), each running a fullSecStaticCodeCheckValidity()against a 534KB code directory. A re-confirmation macOS intends to surface rarely was sampled thousands of times an hour, so it fired the instant it came due.2. The retry loop re-armed the dialog.
captureWindowCGImagecollapsed every error into.failed, including "The user declined TCCs":Fix
A — one long-lived
SCStream(flagged).WindowCaptureStreamEngineholds a single stream scoped to the frontmost window. Window switches rideupdateContentFilter, resizes rideupdateConfiguration; neither creates a session. Authorization is paid once per stream start instead of per frame. Torn down on sleep, lock,stopMonitoring, and after 60s idle so the OS recording indicator never outlives use.The filter stays
desktopIndependentWindow. A display-scoped stream with cropping would have been simpler but was rejected: it moves the per-window privacy boundary — Rewind exclusions, filtered browser windows — from OS-enforced to app-enforced.B — declined consent is terminal (unflagged, straight bug fix).
.permissionDeclinedis classified fromSCStreamErrorand stops monitoring, with one banner per episode offering restart. The recovery (5s) and background (60s) polls exit through the same handler instead of re-arming the dialog. The Exposé/Mission Control carve-out is preserved — that mode raises the same error transiently and must not stop capture.Sibling defect, same class. Onboarding ran
checkAccessibilityPermission(up to five cross-process AX round trips),checkAutomationPermission, andcheckFullDiskAccessevery second for the life of the view — three authorization subsystems, thousands of denied privileged checks per onboarding session. Now every 5th tick; the instant grant-edge signals are untouched, so perceived grant latency is unchanged.Privacy
The retarget protocol (
beginRetarget/endRetarget) exists for a specific hazard: a frame captured under the old filter but delivered after a retarget would otherwise be tagged with the new window's ID and handed to a caller that believes it is looking at the new window — with the upstream exclusion check having been made against the new window. Each stream also owns its own sink, so a departing stream cannot deliver into its replacement.A residual hole is not closable in code: a frame already queued when
updateContentFilterreturns is indistinguishable from a new one. It is documented in the design note with a dogfood check.Making the failure-class protocol usable
Declaring one class for this fix hit four separate problems, each of which pushed toward a wrong action. Fixed here rather than worked around, because the next author hits them too.
Failure-Class: newwas unsatisfiable. It requires an added definition, whose schema required a non-emptyevidence_prs— but that field records merged PRs, and the PR fixing a class's first instance has no number until it is opened. The only ways through were to invent a number or push with--no-verifyand backfill.evidence_prsmay now be empty; the adding commit is the evidence. (Scoping the allowance to "added by this change" is the obvious fix and is wrong — it passes in the authoring PR and fails forever after. There's a test for that.)Failure-Class: FC-<slug> | new | nonereads as a pipe-separated value in a repo whose other PR-body directives really are pipe-separated (Line-Count-Exception: path | a -> b | reason). The three forms are now listed as alternatives, and the error names the pipe mistake specifically.prepareprinted all 145 definitions in full. An unreadable registry gets a new class invented instead of an existing one reused. It now lists classes whose advisoryscope_hintsoverlap the change (145 → 23 here, surfacing the adjacentFC-concurrent-capture-contention), with--all-candidatesfor the rest. This narrows what is listed, never what is chosen, and never narrows to empty — that would read as a classification the CLI does not make.The PR template also said a
newdeclaration must never go in the instance-fix PR, contradicting both the validator and the registry's own history (FC-workflow-script-input-contractshipped in its fix). It now distinguishes adding one definition alongside a fix, which is allowed, from every other registry transition, which is not.Verification
swift buildclean; full suite 5793 tests, 2 failures, both pre-existing onorigin/main— verified by running the same suite on a detachedorigin/mainin the same worktree (5781 tests, identical two failures:FloatingBarNotificationPreviewPolicyTests.testDirectorDeliveryWithDisabledCategoryToggleIsSuppressedAtTheEntryPoint,RewindCaptureExclusionGenerationTests.testOwnerSnapshotStaysCurrentWhenAuthLeadsUnresolvedRewindDatabase).scripts/test_failure_class.py24 tests,test_check_failure_class_guard_ratchet.py16,test_pr_preflight.py40 — all pass.make preflight: 31 checks passed, and the branch pushes through the pre-push gate with no--no-verify.hasParkedWaiter), and two tests asserting production source text (removed — see that commit for the residual coverage gap, stated plainly).On the weight of that local evidence. CI pins Xcode 16.4; the machine those numbers came from runs 26.2, and the two SDKs disagree about this engine's concurrency. The first push was green locally and red on all three desktop Swift jobs. Two commits here fix that, and the second layer of errors only became visible once the first was cleared — module emission had been failing before any function body was checked, so
WindowCaptureStreamEngine.swifthad never actually compiled under the pinned toolchain. Localswift build,make preflight, and the pre-push hook all use whatever Xcode is installed, so none of them can see this class of failure. CI is the only authority for it here.Not verified, and not verifiable without dogfooding: whether
updateContentFilteron a live stream re-runs TCC authorization is undocumented. If it does, sampling still drops from ~1.5/s to per-window-switch. The design note names the check: watch tccdkTCCServiceScreenCapturevolume before and after.Flag
desktop_persistent_capture_stream(PostHog, fail-closed in production). Non-production defaults ON;OMI_PERSISTENT_CAPTURE_STREAM=0disables. Flag off is byte-identical to today, except the declined-consent terminal state, which ships unflagged.Line-Count-Exception: desktop/macos/Desktop/Sources/Onboarding/OnboardingChatView.swift | 2157 -> 2181 | staggering three privileged probes off the 1 Hz tick needs a tick counter, an interval constant, and the why-comment recording which probes are cheap and which are not
Line-Count-Exception: desktop/macos/Desktop/Sources/ProactiveAssistants/ProactiveAssistantsPlugin.swift | 2001 -> 2101 | the terminal declined-consent handler plus routing the recovery, background-poll, preview and dwell paths through it; splitting the file is a larger unrelated refactor
Failure-Class: new
Product invariants affected
INV-CHAT-1 — touched only because the onboarding permission-probe cadence lives in
OnboardingChatView.swift. This change adds a tick counter and moves three privileged probes off the 1 Hz timer. It introduces no transcript or session state, no second store, no per-surface continuity ring, and does not move session identity or context assembly into Swift. The invariant is unaffected.🤖 Generated with Claude Code