Repository navigation
Conversation
This was referenced Oct 29, 2026
jutaz
force-pushed
the
feat/runtime-client-relay-terminal
branch
2 times, most recently
from
October 29, 2026 04:57
219b7fa to
e23c9ff
Compare
Contributor
Author
|
Local CI for e23c9ff (stacked on #35195): typecheck, changed-code quality, lint and format pass. The mobile-desktop-relay, binary-message-router and terminal-multiplex suites pass: 30 files, 195 tests, 1 skipped. Before the latest rebase, the broader run including runtime-rpc and shared/remote-runtime was 90 files / 542 tests, all passing. |
jutaz
force-pushed
the
feat/runtime-client-relay-terminal
branch
from
October 31, 2026 15:13
e23c9ff to
140ea27
Compare
jutaz
force-pushed
the
feat/runtime-client-relay-terminal
branch
from
November 1, 2026 07:32
140ea27 to
fa83570
Compare
8 of 10 tasks
jutaz
force-pushed
the
feat/runtime-client-relay-terminal
branch
from
November 7, 2026 01:18
fa83570 to
5a52154
Compare
…ged hosts A server with relay host wiring advertises runtime.client-relay.v1 to runtime-scope sockets and relays their execution-host calls that name a runtime:<env> target, reusing the phone relay and its delegated devices. Every other runtime-client request keeps ignoring executionHost.
jutaz
force-pushed
the
feat/runtime-client-relay-terminal
branch
from
November 7, 2026 03:18
5a52154 to
12c8150
Compare
7 of 9 tasks
This branch has not been deployed
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.
ELI5
#35195 lets your desktop pass a paired desktop or web client's requests through to a server it manages, the way it already does for phones. Terminals were left out: desktop and web terminals talk over a stream of binary frames, and the desktop refused to pass those along. This PR teaches the desktop to pass one terminal stream per connection through to the server, unchanged in both directions. It only does so when the client asks for it and the desktop says it supports it. Nothing uses it yet.
What Changed
Topology as in #35195: client (desktop/web, paired with
runtimescope) → server A → managed server B, which A reaches asruntime:<env>. All changes are on A.New capability
runtime.client-relay.terminal-multiplex.v1(src/shared/mobile-desktop-relay-contract.ts, next toruntime.client-relay.v1). A stamps it onstatus.getthrough the same per-connection stamp, and only where it stampsruntime.client-relay.v1: an encryptedruntime-scope socket on a server with relay host wiring.Negotiated on both sides. A relays
terminal.multiplexonly when the client also declared the capability in its E2EE authclientCapabilities. A client that knows onlyruntime.client-relay.v1keeps today'sforbiddenfor a targetedterminal.multiplex, which is what feat(remote): relay paired desktop and web clients to a server's managed hosts #35195 promised it. Phones never relay it, whatever they declare.New carrier kind
client-stream-ids(relayed-stream-carriers.ts) replacesphone-binary-framesforterminal.multiplex. Multiplex stream ids are allocated by the client, so A leaves them alone in both directions.RelayedPhoneRepliesdoes not renumber aclient-stream-idsrequest'sresult.streamId. It passes B→client binary frames through byte for byte. A per-streamenddoes not close the request: only the multiplex's final reply, the client's socket closing, or the link ending does.Binary for streams the client never opened passes through. B owns multiplex stream state, and on that socket only B sends binary. The client's multiplexer already handles an unknown stream: it answers stray output with
Unsubscribe, which releases B's credit for it. Dropping on A would mean A tracking stream lifetimes from the subscribe and end traffic, which can diverge from B's, and B would never hear the client'sUnsubscribefor a stream A swallowed.Client→B binary:
handleWebSocketBinaryMessagefirst asks the relay whether a live relayed multiplex owns this connection (MobileDesktopRelay.forwardClientBinary). If one does, the frame goes out unchanged on that link's passthrough socket via a newRemoteRuntimePassthroughSocket.sendBinary. If not, it falls through to the localbinaryMessageRouter.dispatchexactly as before.sendBinarymirrors the subscription transport (frame size limit,sealBinary,outbound.enqueueBinary), so client input goes through that socket's bounded binary backpressure queue, beside the separate request queue for text. The passthrough has no process memory budget, so the binary queue runs on the per-socket defaults (64 MB / 4096 frames). The multiplex orders itself throughready; text and binary are not globally ordered. Frames that arrive while the link is still opening are swallowed: B registers no stream before its multiplex handler runs, clients send nothing beforeready, and the frames must not reach A's local router either.One lane per connection. Binary frames carry no target, so one relayed multiplex owns its connection's whole binary lane. A refuses (
forbidden) a secondterminal.multiplex, local or relayed, on a connection that already relays one. The local refusal is the existingbinary_handler_mode_conflict, now also raised for a connection with a relayed lane. It refuses a relayed one on a connection that already has local binary handlers or relayed binary streams (terminal.subscribe, orbrowser.screencast, whose frames carry no stream id), and refuses either of those beside a relayed multiplex.browser.screencastgets its own carrier kind,untagged-binary, for this; the othernonecarriers send no binary. The renderer opens multiplex on its own socket, so none of these happen in practice; they keep the frames of two streams from being mixed up.Teardown. Each of these releases the lane, so later binary goes to the local router (and is dropped there as today if nothing local claims it):
closePhoneConnection). The renderer opens multiplex on a dedicated socket and ends it by closing that socket;Transport loss answers the open request with
remote_runtime_unavailable, never an exit. A also ends the link withremote_runtime_unavailablewhen B's socket cannot queue client input, or the client's socket discards a B→client frame. A lost multiplex frame desyncs the stream, and only a reconnect resyncs it (the same ruleterminal-multiplex-frame-delivery.tsapplies on B).RelayLinkmoved torelay-link.tsand the test E2EE client torelay-test-client.test-fixture.ts, to stay under the file-size caps. Neither changed behaviour.Not covered, and why no client uses this yet. A usable relayed terminal needs more than the multiplex. The client must also route
terminal.create, subscriptions and writes throughexecutionHost. That client work waits on the maintainer questions on #35195 (child kind on B, the route table, the virtual environment id). No renderer or main-IPC code changes here, and nothing sendsexecutionHostor declares the new capability yet.Why
#35195 question 5 asked whether terminal binary forwarding should come behind its own capability. This is that follow-up. The alternatives:
terminal.subscribe: the client allocates multiplex ids and B echoes them in frames and inresult.streamId. Renumbering would have to rewrite every client→B frame as well, including the subscribe payload's JSONstreamId. Passing them through is correct as long as one connection carries one multiplex. The renderer already guarantees that, and A now enforces it.registerRawMessagefor the hook: exclusive with terminal handlers per connection (binary_handler_mode_conflict), and it would have to be registered from inside dispatch. A pre-dispatch check keeps the local router untouched for every connection without a relayed lane.runtime.client-relay.v1was promisedforbiddenforterminal.multiplex. It would suddenly get a relayed multiplex whose binary it may not expect.Mixed versions:
runtime.client-relay.terminal-multiplex.v1; a targetedterminal.multiplexrelays to B with ids unchangedruntime.client-relay.v1terminal.multiplex→forbidden, as in #35195terminal.multiplexforbidden, unchangedlocalandssh:multiplexes run on A as beforeB needs no change. It already accepts
terminal.multiplexfrom the delegated mobile child (it is inEXECUTION_HOST_METHODS). The subscribe frame'sclient.type: 'desktop'comes from the payload, not from the child's scope.Linked Issue
Part of #29396.
Stacked on #35195, so this diff includes its commits until it merges. Review only the last commit,
feat(remote): relay terminal.multiplex for paired desktop and web clients. It doesn't depend on #35242 or #35478.Visual Proof
N/A: server-side relay only. No renderer or main-IPC code changes, and no client sends a relayed
terminal.multiplexyet.Testing
mobile-desktop-relay.integration.test.ts(real A and B RPC servers over E2EE WebSockets):status.getand opens a targetedterminal.multiplexvia A. A Subscribe on stream 4242 (an id neither computer's allocator would produce) reaches B as 4242, since B answers on that id. B's snapshot andOutputreach the client on 4242. ClientInputon 4242 is written to B's terminal. A second multiplex on the same connection is refused, relayed (forbidden) or local (binary_handler_mode_conflict), and a phone is refused even when it declares the capability.forbidden), and no server socket opens.remote_runtime_unavailable. After the next sync a fresh relayed multiplex carries input again.Unit (
mobile-desktop-relay.test.ts,relayed-phone-frames.test.ts): the hook claims frames only while the multiplex is open. Frames that race the open are swallowed, not sent late, and other connections fall through. The final reply releases the lane. A relayed screencast and a relayed multiplex refuse each other on one connection. B's socket dropping answersremote_runtime_unavailableand releases it. A full input queue or a discarded output frame ends the link. The carrier keeps ids in both directions, passes frames for unannounced streams, and survives a per-streamend.Mutation checks: each guard was removed in turn and its test failed. The guards: the client-capability gate, the server advertisement, the one-per-connection guard, the local-streams guard, the reverse
binary_handler_mode_conflict, the screencast refusal both ways, swallowing pre-open frames,result.streamIdpass-through, binary pass-through, per-streamend, the pre-dispatch hook, release on close, and ending the link on input or output send failure.Commands (Linux):
pnpm tc;pnpm test --maxWorkers=2onsrc/main/runtime/mobile-desktop-relay,src/main/runtime/runtime-rpc,src/shared/remote-runtime,src/main/runtime/runtime-binary-message-router.test.tsandsrc/main/runtime/rpc/terminal-multiplex*(89 files, 538 passed, 1 skipped);node config/scripts/check-changed-code-quality.mjs upstream/main;oxlintandoxfmt --checkon the changed files.AI Disclosure
Written with Claude (Anthropic) via an agent harness; reviewed by the author.
Review
terminal.multiplexto the mobile child it minted for this client. A still requires the request to pass feat(remote): relay paired desktop and web clients to a server's managed hosts #35195's admission, includingdenyRpcMethodForCallerwith the client's own grants (workspace). Client frames are forwarded opaque. They cannot change which server or child they reach, and only a connection with an open relayed multiplex forwards anything. B's token never appears in binary frames: the multiplex carries client-chosenclient.ids, not device tokens.remote_runtime_unavailableand never surfaces as "exited".localandssh:targets are untouched.Agent skill upstream boundary
Notes
Open questions:
runtime.client-relay.terminal-multiplex.v1in its authclientCapabilities.runtime.clientCapabilities.updateis phone-only on A, so a runtime client declares it once per socket. Is that the right handshake, or should the server advertisement alone be enough?client.type: 'desktop'from the payload. Floors and drivers on B are keyed by the client'sclient.idand the child's connection, which looks right. It depends on feat(remote): relay paired desktop and web clients to a server's managed hosts #35195 question 1 (child scope) all the same.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)