Repository navigation
perf(web): window focus probes instead of resyncing; desktop wake reconnects at once - #220
Merged
Merged
Conversation
…onnects at once Every window focus fired "application-active", so each alt-tab rebuilt the shell subscription and replayed every open thread. Focus now emits a new probe-only "application-focus" wakeup unless the window was blurred or hidden for at least 60 s. After sleep the desktop window stays visible, so the focus probe waited out its 15 s timeout on a dead socket. The desktop shell now forwards the OS resume and unlock-screen events to the renderer, which reconnects at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
This was referenced Sep 26, 2026
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.
Problem
The client-sync audit (
~/perf-audit-bkt3/30-client-sync.md, F6) found two problems.windowfocusfireapplication-activeunconditionally. That wakeup:CONNECTION_PROBE_TIMEOUT(15 s). The OS resume event only reached telemetry (DesktopTelemetryPublisher.ts:187-190).Fix
Focus probes; a real return resyncs.
application-focus, marked inclient-runtime/connection/wakeups.ts.application-active.shouldResubscribeAfterWakeup, so streams are not restarted.apps/web/src/connection/platform.ts, marked block, helperfocusWakeup.expbkt3.ts) tracks when the window was blurred or hidden. Afocusafter ≥ 60 s away emitsapplication-active(resync as before); a shorter absence emitsapplication-focus.visibilitychangeto visible still emitsapplication-active(upstream) and clears the tracker, so the focus that follows only probes rather than resyncing twice.Desktop resume/unlock reconnects at once.
apps/desktop/src/power/SystemResumeForwarder.expbkt3.tsforwardspowerMonitorresumeandunlock-screento every window ondesktop:system-resumed. A sliding queue of 1 means a resume and an unlock that fire together produce one message.onSystemResumedinpreload.ts, an optionalonSystemResumed?field incontracts/ipc.ts, and one line inmain.ts.application-active-reconnect, which replaces the lease immediately. The supervisor already interrupts an in-flight probe for that reason.Surfaces
onlinewakeups are unchanged.application-focus.Evidence
client-runtime/src/connection/supervisor.expbkt3.test.ts:application-focusprobes the live session without replacing it (1 session, 0 releases);supervisor.test.ts: 46 pass.apps/web/src/connection/focusWakeup.expbkt3.test.ts, 4 pass:vp run typecheckis clean inpackages/contracts,packages/client-runtime,apps/desktopandapps/web. Lint is clean and the fork-marker check passes.No screenshots: nothing visible changes. The effect is fewer "synchronizing" flips and faster reconnects. I have not exercised it in a real desktop client, because that needs a desktop build.
Model/harness: Claude Opus 5.5 via Claude Code in T3 Code.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.