Repository navigation
fix(push): honor "only when desktop is away" on headless orca serve - #31956
Conversation
…connection reports at once
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
📝 Walkthrough
Priority: ⚪ Pending latest changes Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
cfecf86d-eb00-48c6-82f0-4e592a2a244b
⛔ Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing: 17
src/main/ipc/runtime-environments/runtime-environment-request-connections.tssrc/main/ipc/runtime-environments/runtime-environment-shared-control-answers.tssrc/main/notifications/desktop-presence-reporter.test.tssrc/main/notifications/desktop-presence-reporter.tssrc/main/runtime/desktop-client-presence-tracker.tssrc/main/runtime/push/push-policy-pipeline.integration.test.tssrc/main/runtime/rpc/methods/notifications.tssrc/main/runtime/runtime-desktop-surface.tssrc/main/runtime/runtime-mobile-notification-controller.tssrc/main/runtime/runtime-service-command-surface.tssrc/main/startup/main-process-observers-hang-breadcrumb.test.tssrc/main/startup/main-process-observers.tssrc/main/startup/main-process-quit.tssrc/main/startup/main-process-state.tssrc/shared/desktop-client-presence.tssrc/shared/mobile-runtime-capabilities.tssrc/shared/rpc-contract/notifications-params.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| const entry = { socket: target.socket, away, at } | ||
| sent.set(target.environmentId, entry) | ||
| // Why: a refused report waits for the keepalive; only an unsent one retries on the next tick. | ||
| void target | ||
| .request('notifications.reportDesktopPresence', { away }, REPORT_TIMEOUT_MS) | ||
| .catch(() => { | ||
| if (sent.get(target.environmentId) === entry) { | ||
| sent.delete(target.environmentId) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Serialize presence reports per environment.
target.request('notifications.reportDesktopPresence', { away }, REPORT_TIMEOUT_MS) runs without ordering against earlier requests. Overlapping reports can therefore arrive out of order, so an older present report can overwrite a newer away state on the host. An away-only push during that stale present state is rejected and not retained for later delivery.
Order reports by environment and socket generation, or use an equivalent mechanism that prevents stale requests from overwriting newer presence.
ELI5
Your phone has a setting: "only notify me when I'm away from my desktop." On a headless server (
orca serve, or the server Orca installs over SSH or in WSL), the server had no way to tell whether you were at your desktop. So the setting did nothing, and the phone buzzed for every agent turn, even while you were watching that turn live on the desktop. Now each desktop tells the servers it's connected to whether someone is using it, and the server uses that to decide.What Changed
How it works:
notifications.reportDesktopPresence { away }is advertised asnotifications.desktop-presence.v1.powerMonitorcheck the desktop host already uses. It reports to every ready shared-control socket whose host advertises the capability. A report is sent when the state changes, when the socket reconnects, and as a 30-second keepalive.suspendorlock-screenthe desktop reports away straight away, and keeps reporting away untilresumeorunlock-screen. Closing the lid doesn't leave pushes held back until the 90-second expiry. That expiry is only there for crashes.Why
The server can't watch the user's keyboard, but the desktop already can (
readDesktopAwayState), so the desktop is the right place to measure presence. This uses the transport and capability gating that already exist (shared-control socket,status.capabilities), so SSH, WSL and plainorca serveall behave the same.Alternatives considered:
undefinedas away. This would keep buzzing during active use, which is the bug itself.Scope of a presence report, and why it covers all of a host's events: the desktop renderer itself shows OS notifications for agents on every mirrored remote host, including background worktrees and hosts other than the active one. It does this through the
session.tabs.subscribeAllmirror, the hook-completion lane and the parked-terminal watcher. So when the desktop is in use, the same event already shows on the desktop. Two limits on this:Mixed versions:
Fixes #31570
Thanks to @letjsk for the precise report and bundle analysis.
Visual Proof
N/A: no UI change. The change is in when a host sends a push.
Testing
push-policy-pipeline.integration.test.tsdrives the real controller, the RPC handler and the subscription registry against the push pipeline. It covers:It fails on main, where neither the method nor the controller API exists and headless presence is undefined.
desktop-presence-reporter.test.tschecks:Ran the 50 test files that import changed modules, the full static job, and
pnpm tc.Not verified live on a real SSH/WSL host with a paired phone. A push gateway round-trip needs a real APNs/FCM device.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Codex review clean on the head commit. Independent Opus review: no P0–P2. Its P2s from the first round (the sleep gap, presence scope) and its P3s (late reports, pruning, early return, the suspend latch) are addressed.
Agent skill upstream boundary
Notes
powerMonitoris available on all three. Lock events are macOS/Windows; on Linux, the idle check'slockedstate covers it.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)