Repository navigation
perf(remote): a paired desktop gets only the tab that changed, not the whole workspace - #29319
Conversation
…ession tab streams Fixes #22151
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
ELI5
When a desktop is paired to a remote Orca server, the server keeps the desktop's list of tabs up to date. Before this change, every small change, such as one agent moving on to its next tool, made the server re-send every tab in that workspace, and it did so twice. On a slow upstream link that steady traffic filled the connection, so every click waited behind it. Now the server sends only the tab that changed. The desktop rebuilds the full list itself, so nothing else in the app changes.
What Changed
Measured before. I used a real host runtime and the real RPC stream code: 17 Claude Code terminals in one workspace, 3 of them working, with about 2 agent status changes per second. That is roughly what #22151 describes.
session-tabs.ts(session.tabs.subscribe) andsession-tabs-inventory.tspublishChange(session.tabs.subscribeAll): every update emits the full projected snapshot. Every touch also bumpssnapshotVersion(mobile-session-membership.tstouchMobileSessionTabsForWorktree), which is the whole-snapshot dedupe's key, so an unchanged tab list never matched it.After. Same scenario, same frame count, same content once decoded: about 1.7 KB per frame, so 3.4 KB per change and 0.21 MB in 30 seconds (about 6.9 KB/s). That is about 6.4x fewer bytes.
Mechanism
src/shared/session-tabs-tab-delta.ts). It stamps each frame for a workspace withtabsRevision. For anupdatedframe it replacestabswithtabsDelta, where each entry is either the index of an identical tab in the previous frame on the same stream, or the changed tab itself. Every other field in the frame is sent unchanged. It follows the pattern of the existing retirement-proof delta.subscribeRuntimeEnvironmentrestores every frame to exactly what a legacy host sends, before the window, the layout snapshot recorder, or any other reader sees it. Nothing in the renderer changes. If a delta does not match the last frame the stream delivered, the desktop does not guess. It turns the frame into an error response, which the window already handles by resubscribing and getting a full snapshot.Why
Compatibility. Clients and hosts update independently, so this is negotiated with a new client capability,
session-tabs.tab-delta.v1. Only the Electron desktop advertises it, because only its main process decodes.Why not WebSocket compression (
permessage-deflate)? Desktop frames are encrypted and then base64-encoded before they reach the socket. Compressing ciphertext only recovers part of the base64 overhead. Compressing the plaintext before encrypting it would put attacker-influenced text (prompts, titles) and secrets in the same compressed message, which creates a length side channel. Removing the redundant bytes is both larger and safe.Why not #22203? It solves the same problem with a custom structural codec: it compresses the snapshot "shape" and sends the strings beside it. That adds about 1,500 lines and a decompression surface, and it still re-sends every tab's text on every change. A tab-level delta sends less and is a much smaller change.
Related work. #29241 (already merged) keeps the three most recent workspace streams warm instead of resubscribing on every switch. Each of those warm streams now receives these small deltas instead of full snapshots.
Linked Issue
Fixes #22151
Visual Proof
N/A: there is no visible change. The window receives the same frames as before. Only the bytes on the wire change.
Testing
I manually tested these changes locally
Automated tests added/updated
src/main/ipc/runtime-environment-session-tabs-delta.integration.test.ts: a real host server with E2EE WebSocket clients. It checks that:src/main/runtime/rpc/methods/session-tabs-tab-delta-stream.test.ts: for bothsubscribeandsubscribeAll, it pins the frame count and the bytes per one-tab change on a 17-tab workspace, and checks that the decoded output equals the legacy stream.src/shared/session-tabs-tab-delta.test.ts: legacy passthrough in both directions, reorder, open and close, census bases, removed workspaces, a base mismatch, and an index out of range.src/main/ipc/runtime-environment-session-tabs-delta-decoding.test.ts: the decoder in main, and the error response that triggers a resubscribe.pnpm tcandpnpm run check:code-quality:changedpass, along with the existing session-tabs and remote-client suites.I did not reproduce the reporter's WAN link. The numbers above come from in-process runs of the real host stream code.
Review
Agent skill upstream boundary
Notes
JSON.stringifyper tab per emit on the host, plus one cached snapshot per workspace per stream.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)