Repository navigation
fix(desktop): screen capture starts seconds after launch instead of 30-60s (launch-anchored warmup) - #9021
Conversation
…t to 6s Since BasedHardware#8013, proactiveAssistantsStartDelay (30s) was applied as a fixed delay from whatever event triggered scheduling (launch, key load, app active), so late triggers re-paid the full 30s and the Capture pill sat 'paused' for 30-60+ seconds after every launch. Measure the delay as a launch-anchored budget instead (max(0, delay - elapsedSinceLaunch)) and reduce it to 6s, keeping capture start strictly after the 5s settings sync and 2s deferred warmup that BasedHardware#8013's ordering tests pin.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Adjusts the macOS desktop startup warmup policy so screen capture (“proactive assistants” monitoring) starts promptly after launch by anchoring the warmup delay to a launch-time budget rather than re-applying a full delay on every trigger (launch / key-load / app-active).
Changes:
- Reduce
StartupWarmupPolicy.proactiveAssistantsStartDelayfrom 30s to 6s and addremainingProactiveAssistantsStartDelay(elapsedSinceLaunch:)to compute a launch-anchored remaining delay budget. - Use the remaining-delay helper in
DesktopHomeView.scheduleProactiveMonitoringStart(...)and log the effective scheduled delay for observability. - Add focused unit tests for the remaining-delay helper and add a desktop changelog fragment.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| desktop/macos/Desktop/Tests/StartupWarmupPolicyTests.swift | Adds unit tests covering the new launch-anchored remaining-delay helper. |
| desktop/macos/Desktop/Sources/StartupWarmupPolicy.swift | Reduces proactive-assistants startup delay and introduces remaining-delay computation anchored to launch elapsed time. |
| desktop/macos/Desktop/Sources/MainWindow/DesktopHomeView.swift | Computes/uses remaining delay when scheduling screen analysis start and logs the effective delay. |
| desktop/macos/changelog/unreleased/20260704-capture-startup-delay.json | Documents the user-visible improvement in capture startup timing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
1 issue found across 4 files
Confidence score: 5/5
- In
desktop/macos/Desktop/Tests/StartupWarmupPolicyTests.swift, the new test names referenceProactiveMonitoringwhile they actually validateStartupWarmupPolicy.remainingProactiveAssistantsStartDelay, which risks future confusion or misinterpretation of test intent rather than product behavior; this looks safe to merge, but renaming the four methods to matchProactiveAssistantswould de-risk maintenance.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…nology Post-merge review feedback on BasedHardware#9021: the four anchored-delay tests used 'ProactiveMonitoring' while the API and the rest of the suite say 'ProactiveAssistants' (StartupWarmupPolicy.remainingProactiveAssistantsStartDelay). Rename-only; no behavior change.
…nology (#9077) ## Summary Addresses the post-merge Copilot/cubic review feedback on #9021: the four anchored-delay tests were named `testProactiveMonitoringRemainingDelay…` while the API they exercise is `StartupWarmupPolicy.remainingProactiveAssistantsStartDelay` and the rest of the suite uses the ProactiveAssistants terminology. Rename-only — no behavior change. ## Testing `xcrun swift test --package-path Desktop --filter StartupWarmupPolicy` → 40 tests, 0 failures (all four renamed tests pass). ## AI Disclosure Authored and verified with Claude Code; ran the filtered suite locally after the rename. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9077?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Summary
StartupWarmupPolicy.proactiveAssistantsStartDelay(30s) is applied as a fixed delay from whatever event triggers scheduling, not from launch — so a launch with cached keys waits 30s, a launch whose API keys load late waits key-load + 30s (~40–60s), and re-activating the app (reason: "app active", e.g. right after granting Screen Recording) waits a fresh 30s even minutes after launch. For a product whose core feature is capturing your screen, the first half-minute of every session is silently lost.remainingProactiveAssistantsStartDelay(elapsedSinceLaunch:)returnsmax(0, delay − elapsed), so the delay is paid once per session, not once per trigger — and the budget is reduced from 30s to 6s. AScheduling screen analysis start in Xs (reason)log line makes the effective delay observable.initialSettingsSyncDelay(5s) so a remotescreenAnalysisEnabled=falselands before monitoring starts, and still afterdeferredWarmupDelay(2s). Both existing ordering tests pass unchanged. No other warmup delays are touched.Linked Issue / Bounty
Root Cause (bug fixes only)
proactiveAssistantsStartDelay = 30.0andscheduleProactiveMonitoringStart()passes it verbatim toscheduleSessionWarmupon every trigger (launch,key load,app active). The delay's purpose is to keep capture out of the busy launch window, but measuring it from the trigger instead of from launch makes late triggers re-pay the full 30s.How It Works
StartupWarmupPolicy.remainingProactiveAssistantsStartDelay(elapsedSinceLaunch:)computes the remaining launch-anchored budget (clamping negative elapsed to the full delay).DesktopHomeViewcaptures aproactiveMonitoringWarmupAnchor = Date()when the view is created (≈ launch) and passes the computed remainder toscheduleSessionWarmup. Behavior by scenario:Change Type
Scope
Security Impact
Testing
xcrun swift build -c debug --package-path Desktop, clean (macOS 26.5.1, arm64)StartupWarmupPolicyTests(including the two ordering invariants that pin capture after settings sync and deferred warmup)Human Verification
Verified on a dedicated named bundle (
com.omi.omi-verify-capture) built from this branch, signed in, macOS 26.5.1:Scheduling screen analysis start in 5.2s (launch)→Screen analysis started (launch, delayed)), versus +30.4s measured on production v0.12.0.5.2s/5.4sacross launches depending on view-appear latency), and the start attempt consistently fired at launch+6s.ScreenCaptureApprovals.plistLastUsed).key loadtrigger with a genuinely slow network fetch (exercised the code path via the anchored computation instead).Evidence
Production v0.12.0 (before — fixed 30s from window appear):
This branch (after):
Permission-missing launch on the same build (retry loop intact, timing unchanged):
Docs
Performance, Privacy, and Reliability
Launch performance: capture-start work now runs at +6s instead of +30s. This sits after the first-window render and the 5s settings sync; the heavier startup warmups (
crispInitialPoll15s,agentVMProvisioning20s,initialFileIndexing45s) remain untouched, so launch responsiveness — the goal of #8013 — is preserved. If capture start measurably contends at +6s, the constant is a single knob to tune; the launch-anchoring fix stands on its own regardless of the chosen value.Migration / Backward Compatibility
Risks and Mitigations
screenAnalysisEnabled=falsearriving after capture starts (settings sync slower than 6s on a slow network) would leave monitoring running this session.AI Disclosure