feat(desktop): emit system.wake on window foreground (#1653)#1797
feat(desktop): emit system.wake on window foreground (#1653)#1797mabry1985 wants to merge 1 commit into
Conversation
Completes the third ADR 0074 lifecycle event. On WindowEvent::Focused(true) the desktop shell POSTs `system.wake` to the sidecar's /api/events/publish, which broadcasts it on the event bus so `lifecycle_hooks` reactions fire on wake. Debounced to once per 60s (a WakeSignal holding the sidecar port + a throttle clock in Tauri managed state) so an alt-tab doesn't spam it; the boot focus is seeded inside the window so it doesn't double-fire after app.loaded. Fire-and-forget — a down/booting sidecar just logs. Foreground-focus is the v1 signal; true OS sleep/wake (NSWorkspace / power-broadcast) would be a native follow-up. Closes the desktop system_wake follow-up on #1653. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Review (pre-merge): design is clean — debounce, boot-focus suppression, fire-and-forget all correct, and I confirmed the server-side contract it targets exists ( One gap to close before it goes ready:
The existing Otherwise 👍 — keep as draft until the desktop-build manual test (blur >60s → refocus → confirm one |
What
Completes the third ADR 0074 lifecycle event. The server-side bus contract for
system.wakeshipped with #1653 (reserved in the seam/config); this wires the desktop origination: onWindowEvent::Focused(true)the Tauri shell POSTssystem.waketo the sidecar's existing/api/events/publish, which broadcasts it on the event bus solifecycle_hooksreactions (resume interrupted work, refresh state, check inbox) fire on wake.Design
WakeSignal(sidecar port + a throttleInstant, in Tauri managed state) suppresses rapid re-focus. It's seeded to "now" at setup, so the window's own boot focus is suppressed (no redundantsystem.wakeright afterapp.loaded).tauri::async_runtime::spawn; a down/booting sidecar just logs at debug. Never blocks the UI thread; the throttle lock is dropped before the await.reqwest+ port-resolution plumbing — no new endpoint.Scope
Foreground-focus is the v1 signal. True OS sleep/wake (laptop lid, display sleep) has no Tauri primitive — it'd need native
NSWorkspace.didWakeNotification/ WindowsWM_POWERBROADCASTobservers, a deliberate later lift.Verification
cargo checkpasses (compiledlib.rsclean in a worktree, after stubbing the bundled sidecar binary that isn't present there — the stub is not committed).system.wakebroadcast (e.g. alifecycle_hooksreaction fires, or watch the sidecar/api/eventsstream). No Python/CI surface changes.Closes the desktop
system_wakefollow-up on #1653.🤖 Generated with Claude Code