Skip to content

perf(remote): a paired desktop gets only the tab that changed, not the whole workspace - #29319

Merged
nwparker merged 1 commit into
mainfrom
nwparker/remote-subscription-amplification
Oct 16, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/remote-subscription-amplification

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​591 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​591
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​268 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​262

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.

  • Each status change sent the whole 17-tab workspace: about 10.9 KB per frame.
  • It sent it on both streams the desktop keeps open (the all-workspaces stream and the selected-workspace stream), so 21.8 KB per change.
  • Over 30 seconds that came to 1.31 MB, about 43.5 KB/s, for a change that touches one tab of about 1 KB. This matches the 60–70 KB/s steady traffic in the report.
  • The cause is in session-tabs.ts (session.tabs.subscribe) and session-tabs-inventory.ts publishChange (session.tabs.subscribeAll): every update emits the full projected snapshot. Every touch also bumps snapshotVersion (mobile-session-membership.ts touchMobileSessionTabsForWorktree), 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

  • Host: a new per-stream encoder (src/shared/session-tabs-tab-delta.ts). It stamps each frame for a workspace with tabsRevision. For an updated frame it replaces tabs with tabsDelta, 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.
  • Desktop main process: subscribeRuntimeEnvironment restores 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.

  • Old desktop, new host: the capability isn't advertised, so the host sends full frames byte-for-byte as before. Tested over a real WebSocket with E2EE.
  • New desktop, old host: the capability is ignored, so full frames arrive and the decoder passes them through untouched. Unit-tested.
  • Mobile, the web client, the CLI and phone-through-desktop relays: they never advertise the capability, so they are unchanged.
  • Reconnects: each new host stream starts with a full snapshot or census, so a reconnect always resets the base.

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:

    • an old-capability desktop gets full frames,
    • the raw socket of a new desktop carries deltas at under a quarter of the bytes (44.5 KB versus 9.8 KB over 10 updates in this fixture),
    • the real main-process path hands on frames identical to the old desktop's.
  • src/main/runtime/rpc/methods/session-tabs-tab-delta-stream.test.ts: for both subscribe and subscribeAll, 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 tc and pnpm run check:code-quality:changed pass, 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no compression of secrets. The delta only references tabs the same stream already delivered.
  • Cross-platform: pure TypeScript, with no paths or processes involved.
  • SSH and orcad: desktop-to-orcad and desktop-to-server streams take the same main-process path.
  • Mobile: unchanged.
  • Performance: one JSON.stringify per tab per emit on the host, plus one cached snapshot per workspace per stream.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6be2e71d-02c0-44d0-a896-dcb247c7abc5
📥 Commits

Reviewing files that changed from the base of the PR and between c023d35 and b5f6ae8.

📒 Files selected for processing: 11
  • src/main/ipc/runtime-environment-session-tabs-delta-decoding.test.ts
  • src/main/ipc/runtime-environment-session-tabs-delta-decoding.ts
  • src/main/ipc/runtime-environment-session-tabs-delta.integration.test.ts
  • src/main/ipc/runtime-environment-transport-routing.ts
  • src/main/runtime/rpc/methods/session-tabs-inventory.ts
  • src/main/runtime/rpc/methods/session-tabs-tab-delta-stream.test.ts
  • src/main/runtime/rpc/methods/session-tabs.ts
  • src/shared/electron-remote-runtime-client-capabilities.ts
  • src/shared/runtime-capability-constants.ts
  • src/shared/session-tabs-tab-delta.test.ts
  • src/shared/session-tabs-tab-delta.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The change adds capability-gated, per-worktree tab-list deltas for session subscriptions and inventory events. Clients without the capability continue to receive full frames. The IPC subscription path decodes delta responses into full tab lists and emits an out-of-sync error when decoding fails. Tests cover compatibility, reconstruction, invalid deltas, mixed clients, and payload sizes.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to b5f6a

No identified issue blocks merging the tab-delta change after normal checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning The change satisfies the repeated-snapshot objective in [#22151]. session-tabs-tab-delta.ts encodes per-stream tab deltas, and subscribeRuntimeEnvironment decodes them before other readers receive… Implement the remaining applicable [#22151] remedies, or narrow the linked-issue claim. The complete fix must provide runtime WebSocket compression and a separate or prioritized path for interactive requests, unless the issue scope is forma…
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: sending only changed session tabs to paired desktops instead of the full workspace.
Description check Passed The description covers the required explanation, user impact, implementation, compatibility, linked issue, testing, visual proof, security, cross-platform impact, and checklist. Some local testing che…
Out of Scope Changes check Passed The changed files stay connected to the tab-delta objective. They add the negotiated capability, host encoder, desktop decoder and error path, subscription integration, and automated tests. The tests …
Full details: Linked Issues check

Explanation

The change satisfies the repeated-snapshot objective in [#22151]. session-tabs-tab-delta.ts encodes per-stream tab deltas, and subscribeRuntimeEnvironment decodes them before other readers receive events. Capability negotiation preserves full frames for unsupported clients. However, [#22151] also identifies WebSocket compression and protection of interactive requests from subscription head-of-line blocking as direct suggested coding remedies. This pull request does not enable perMessageDeflate or add request prioritization or a separate channel. The related issues [#20159] and [#20158] are not directly linked and do not add requirements here.

Resolution

Implement the remaining applicable [#22151] remedies, or narrow the linked-issue claim. The complete fix must provide runtime WebSocket compression and a separate or prioritized path for interactive requests, unless the issue scope is formally changed.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 2e510c0 into main Oct 16, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant