Repository navigation
fix(desktop): stop capture recovery from restarting the app during onboarding - #11891
Merged
Merged
Conversation
…boarding A new Mac has not granted screen recording yet, so every capture attempt fails. The failure tracker reads that as a broken install and calls attemptAutoReset, whose last step terminates and relaunches the process. Nothing about that is visible to the user: the app simply quits, on whatever permission page they happen to be on, including permissions that have nothing to do with screen recording. The 'already recovered once' flag lives in the process that just died, so the fresh process is free to do it again — a first-run session on 0.12.187 / macOS 15.1 took three of these in 45 seconds. Gate the restart on ScreenRecordingPermissionPolicy.mayRestartToRecoverCapture: it requires the grant to be live in this process (a restart cannot fix a grant ScreenCaptureKit never saw) and onboarding to be finished (the 'Reopen Omi' prompt owns relaunch there). Recovery still runs; only the process-killing last step is withheld, and the reason is logged. Verification: PostHog session for the affected first run shows App Launched at 21:11:43, then again at 21:12:49, 21:13:13 and 21:13:34 — three relaunches between the onboarding steps. Built the fix as omi-onbfix with no screen-recording grant and onboarding incomplete (that exact state): the app held one pid across the observation window with no 'Restart scheduled' in its log. swift test --filter ScreenRecordingPermissionPolicyTests — 22 passed, including a loop test that models the per-process flag resetting on every relaunch. Failure-Class: none
kodjima33
force-pushed
the
kodjima33/no-auto-restart-during-onboarding
branch
from
August 19, 2026 23:32
abf68b6 to
32a81b3
Compare
undivisible
requested changes
Aug 20, 2026
undivisible
left a comment
Collaborator
There was a problem hiding this comment.
Request changes
The onboarding guard is focused, but this diff adds and rewrites multiple comments despite the repository rule to preserve existing comments verbatim and add no new comments.
Please
- Remove the new explanatory comments from the production policy/plugin and the two new test comments.
- Restore any edited existing comments verbatim; leave the policy, tests, and changelog behavior unchanged.
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 happened
David's first run on a new Mac (0.12.187 stable, macOS 15.1, Mac16,6): Omi quit by itself several times during onboarding — including on permission pages that have nothing to do with screen recording — and did not come back on its own.
His PostHog session shows it plainly:
Cause
A new Mac has not granted screen recording yet, so every capture attempt fails.
ProactiveAssistantsPlugin's failure tracker reads that as a broken install and callsattemptAutoReset(), whose final step isScreenCaptureService.softRecoveryAndRestart()— it terminates and relaunches the process. The user sees the app vanish mid-permission-page with no explanation.It repeats because the "already tried recovery this session" flag (
hasSoftRecoveryThisSession) is static state in the process that just got killed, so the fresh process is free to do it again.Fix
ScreenRecordingPermissionPolicy.mayRestartToRecoverCapture(grantedAtLaunch:onboardingComplete:)— the process-killing step now requires both:Soft recovery still runs; only the restart is withheld, with the reason logged.
Failure-Class: none
Verification
omi-onbfixwith no screen-recording grant andhasCompletedOnboarding=false— David's exact state. The app held a single pid across the observation window, with noRestart scheduledin its log.swift test --filter ScreenRecordingPermissionPolicyTests— 22 passed, includingtestCaptureRecoveryNeverRestartsDuringOnboardingOrBeforeTheGrantIsLiveand a loop test that models the per-process flag resetting on each relaunch (the reason it happened three times rather than once).Line-Count-Exception: desktop/macos/Desktop/Sources/ProactiveAssistants/ProactiveAssistantsPlugin.swift | 1786 -> 1798 | the recovery-restart guard plus the log line naming why a restart was withheld; the decision itself lives in ScreenRecordingPermissionPolicy