Skip to content

perf(ssh): desktop and CLI read compressed frames from remote hosts - #39659

Merged
nwparker merged 4 commits into
mainfrom
nwparker/ssh-perf-desktop-compressed-frames
Nov 8, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/ssh-perf-desktop-compressed-frames

Conversation

@nwparker

@nwparker nwparker commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

orcad already gzips (level 1) text frames and compressible binary frames (terminal output, snapshots) before sealing them on v2 E2EE framing — but only for clients advertising transport.compressed-frames.v1, and only mobile did. The desktop↔orcad link over SSH was therefore uncompressed (and compression can't happen below the E2EE layer).

  • Refactor first: inflate logic moved from mobile into shared paired-e2ee-compressed-frame.ts with a small per-platform gzip/UTF-8 codec (mobile keeps its native/fflate path).
  • New remote-runtime-sealed-frame.ts: single place Node client sockets open frames (one-shot requests, request connection, shared control, subscriptions); inflates on v2 only, synchronously to preserve frame order; size-capped and checked against the claimed length.
  • Desktop/CLI advertise the capability. ORCA_DISABLE_MOBILE_COMPRESSED_FRAMES=1 also stops desktop/CLI from asking.
  • Failures are now classified: unexpected binary frame / undecryptable / corrupt compressed frame.
  • Compressed binary claim cap raised 4MB → 8MB to match what hosts can send (affects phones too).

Impact (gzip level 1, real coloured output)

Output 4KB frames 16KB frames
Synthetic TUI redraw 20% of original 12%
ls -R 21% 18%
Diff/log 34% 28%
JSON replies 34% 29%

~3–8× less bandwidth for TUI output, chat frames, snapshots and reconnect catch-up. Frames <~1KB (keystroke echo) stay uncompressed. Gunzip of a 4–16KB frame ≈ 5–25µs, roughly offset by decrypting less ciphertext.

Risk: low

Per-socket capability gate both ways (old desktop never asks; old orcad ignores the ask); v2 only; env kill switch on both sides; relayed phones and browser client unchanged.

Verification

  • pnpm tc (node/web/cli) + mobile typecheck, oxlint, oxfmt: pass
  • remote-runtime-client-framing.integration.test.ts 8/8 (new cases fail if inflate or the error classification is reverted)
  • Targeted remote-runtime / runtime-environments / CLI transport / mobile channel suites pass; pre-existing wsl-host-deployment-store and mobile-desktop-relay flakes also fail on main
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​76 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​280 $\color{#cf222e}{\Huge{\mathbf{−}}}$​141 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​139

…t platforms

Move the length checks and decode of paired E2EE compressed frames into
the shared module behind a small gzip/UTF-8 codec, so the desktop can
read them with node zlib while mobile keeps its native/fflate path.
…ktop and CLI

Desktop and CLI sockets to orcad/orca serve now advertise
transport.compressed-frames.v1, so a v2 host gzips large text replies and
terminal output before sealing them, as it already does for phones.

- Every Node client transport (one-shot requests, request connection,
  shared control, subscriptions) opens frames through one sealed-frame
  reader that inflates compressed frames on v2 channels, synchronously so
  frame order and v2 counters stay in arrival order.
- A compressed binary frame may claim up to the 8 MB binary outbound cap
  (terminal frames can exceed the 4 MB JSON cap), for phones too.
- ORCA_DISABLE_MOBILE_COMPRESSED_FRAMES=1 now also stops a desktop or CLI
  from asking for compressed frames.
- Relayed phones and the browser client are unchanged.
Text-only sockets report an authentic binary payload as an unexpected
binary frame again, and tell a decrypt failure apart from a corrupt
compressed frame, instead of calling every failure undecryptable.
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 1743da7d-52f6-4f0a-9c1f-cc14e2c5b8ae
Commits

Reviewing files that changed from the base of the PR and between 56d0fc1 and 89ae6f6.

Files selected for processing: 23

  • mobile/src/transport/compressed-frame-inflate.ts
  • mobile/src/transport/mobile-e2ee-v2-physical-channel.ts
  • src/main/runtime/remote-runtime-client-framing.integration.test.ts
  • src/main/runtime/rpc/mobile-e2ee-v2-compressed-frame.ts
  • src/shared/remote-runtime/control/remote-runtime-shared-control-connection-frame.ts
  • src/shared/remote-runtime/control/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime/control/remote-runtime-shared-control-frame-handler.ts
  • src/shared/remote-runtime/control/remote-runtime-shared-control-open.ts
  • src/shared/remote-runtime/control/remote-runtime-shared-control-protocol.ts
  • src/shared/remote-runtime/control/remote-runtime-shared-control-types.ts
  • src/shared/remote-runtime/e2ee/node/paired-e2ee-node-compressed-frame.ts
  • src/shared/remote-runtime/e2ee/paired-e2ee-compressed-frame.ts
  • src/shared/remote-runtime/remote-runtime-client-capabilities.ts
  • src/shared/remote-runtime/remote-runtime-connect-bound.test.ts
  • src/shared/remote-runtime/remote-runtime-passthrough-socket.ts
  • src/shared/remote-runtime/remote-runtime-sealed-frame.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-connection-stale.test.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-connection.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-response-router.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-socket.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-websocket.test.ts
  • src/shared/remote-runtime/requests/remote-runtime-request-websocket.ts
  • src/shared/remote-runtime/requests/remote-runtime-subscription-frame-router.ts
  • 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

@nwparker
nwparker merged commit 4e1d42e into main Nov 8, 2026
57 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

Development

Successfully merging this pull request may close these issues.

1 participant