Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
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:
b14fa4e9-64c2-4c49-a5c2-0c1f41ae8d16
Files selected for processing: 17-
src/main/runtime/mobile-desktop-relay/delegated-phone-grant-cache.tssrc/main/runtime/mobile-desktop-relay/mobile-desktop-relay.integration.test.tssrc/main/runtime/mobile-desktop-relay/mobile-desktop-relay.test.tssrc/main/runtime/mobile-desktop-relay/mobile-desktop-relay.tssrc/main/runtime/rpc/dispatcher.tssrc/main/runtime/rpc/mobile-socket-wiring.tssrc/main/runtime/runtime-rpc/relayed-runtime-clients.test.tssrc/main/runtime/runtime-rpc/relayed-runtime-clients.tssrc/main/runtime/runtime-rpc/runtime-client-relay-admission.test.tssrc/main/runtime/runtime-rpc/runtime-client-relay-admission.tssrc/main/runtime/runtime-rpc/runtime-rpc-lifecycle.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-devices.tssrc/main/runtime/runtime-rpc/runtime-rpc-pairing.tssrc/main/runtime/runtime-rpc/runtime-rpc-state.tssrc/main/runtime/runtime-rpc/runtime-rpc-status-connection-stamp.tssrc/main/runtime/runtime-rpc/runtime-rpc-websocket-dispatch.tssrc/shared/mobile-desktop-relay-contract.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
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:
c113972f-da09-43af-94ac-a011c91f1b22
Files selected for processing: 2-
src/main/runtime/mobile-desktop-relay/delegated-phone-grant-cache.test.tssrc/main/runtime/mobile-desktop-relay/delegated-phone-grant-cache.ts
Files skipped from review as they are similar to previous changes: 1-
- src/main/runtime/mobile-desktop-relay/delegated-phone-grant-cache.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
|
Follow-up plan for the client side, so it's visible before I write it. Two questions at the end that decide its shape. The desktop client can't just send
Questions:
|
d45c0e6 to
f0c4313
Compare
f0c4313 to
0020300
Compare
[High impact] The PR appears safe to merge within its stated server-side scope. SummaryAdds server-side relay support for paired desktop and web clients targeting managed runtimes.
|
|
Local CI for 638b57a (on
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
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:
f242412d-9adc-4da9-9ed4-1c333122b7c1
Files selected for processing: 2-
src/main/runtime/mobile-desktop-relay/delegated-phone-grants.test.tssrc/main/runtime/mobile-desktop-relay/delegated-phone-grants.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
10123e5 to
2b41444
Compare
a118d6a to
80963ac
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.
80963ac to
5c3c157
Compare
ELI5
Your phone can already open a workspace on a server that your desktop manages, because the desktop passes the phone's requests through to that server. This PR teaches the desktop (or
orca serve) to do the same for a paired desktop or web client, but only when that client asks for it and only after the server says it supports it. No UI changes here. A later PR makes the client use it.What Changed
Topology: client (desktop/web, paired with
runtimescope) → server A → managed server B, which A reaches asruntime:<env>.New capability
runtime.client-relay.v1(src/shared/mobile-desktop-relay-contract.ts, next tomobile.desktop-relay.v1). It is not inRUNTIME_CAPABILITIES. A appends it tostatus.getonly for an encryptedruntime-scope socket on a server that has relay host wiring (setMobileDesktopRelayHosts). That is the desktop; orcad has none. It is added at the same transport boundary that already stampsdeviceScope, because the dispatcher has no connection context.Admission (
runtime-client-relay-admission.ts, called fromruntime-rpc-websocket-dispatch.ts) applies only when A advertises the capability to that connection: an encrypted socket, a request whose authenticated device scope isruntime, and relay host wiring on A. It judges only anexecutionHoststring starting withruntime:. Once a client names a server, the call never silently runs on A instead:execution-host→ relayed through the existingrelayMobileRequestpath;paired-desktop→ runs on A, the same deliberate rule phones get (settings, accounts, dictation and so on belong to the computer the client paired with);files.write,files.delete,projectHostSetup.*and methods added later →forbidden, nothing runs on A. Phones getforbiddenfor the same input, from the mobile allowlist;runtime:value that does not parse (runtime:,runtime:a|b) →invalid_argument, as for phones.A relayed call must also pass
denyRpcMethodForCallerwith the client's own scope and grants, using the method's declared permission on A. B only sees a phone child, so this keeps a future execution-host method that needsdesktop-controlfrom being relayed by a client that was never granted it. From there it behaves exactly like a phone: unknown or non-relayable env (WSL excluded by the host resolver) →remote_runtime_unavailablewith no local fallback;terminal.multiplex→forbidden; hosted browser pages are served locally; transport loss →remote_runtime_unavailable.Everything else from a
runtimeclient is unchanged. Untargeted calls andlocal/ssh:targets run on A as before. So does everything on unencrypted sockets and on servers without relay wiring, which do not advertise the capability. Old clients never sendexecutionHost, so the new refusals only reach clients that read the capability. The phone path is untouched.Replies stay opaque apart from stream-id renumbering, plus one reverse substitution: any occurrence of the caller's B token in a relayed text frame is replaced with the caller's own token on A. This guards against B echoing its caller, e.g. a
driver-changedclientId. The substitution applies to phones as well.Delegated devices on B reuse
pairing.delegatedMobileDevice.syncunchanged. A tracks relayingruntimeclients per server and adds one to a server's sync list only afterhosts.resolvefound that server, so a relay to X never mints a child on Y, and pairing alone mints nothing. In each server's list, phones come first so the 32-entry cap never drops a phone. Relaying clients follow: those with a live connection first, then bylastSeenAt, newest first. Web page loads mint ephemeral devices, so stale sessions lose the cap, not the client in use. The key is the client's device id on A and the name is<name> via <computer>. B mints an ordinary delegated child with scopemobile, which gets B's mobile allowlist (covers everyexecution-hostroute) and is refusedpairing-admin. The token swap and envelope stripping (deviceToken,executionHost) are the existingrewriteRelayedPhoneRequest, so the client never receives B's token.Revocation and pruning:
revokeRuntimeAccesson A resyncs the relay when the revoked client had relayed. So does the idle-session sweep when it prunes a relaying ephemeral web device (newonDevicesPrunedhook onMobileSocketWiring). The next sync omits the client and B revokes the child it minted (existingsyncDelegatedMobileDevices). This runs in the relay's background resync, not in one transaction with A's local revoke. That matches unpairing a phone today.Terminals are not covered yet. Desktop and web terminals use
terminal.multiplex, which the relay refuses (forbidden). The relay also does not forward client→server binary frames (terminal input, resize, viewport claims). Until a follow-up adds binary forwarding behind its own capability, a desktop client cannot open an interactive terminal on a relayed host. JSONterminal.subscribe,terminal.sendandterminal.listdo relay.Why
Issue #29396 asks for web/desktop clients to reach a paired server's managed hosts the way phones already can. Reusing the phone relay keeps one forwarding path, one token-rewrite path and one revocation path. The alternative was to have B mint a new child scope (e.g.
runtime), which needs a new field or method on B and its own capability gate. That would be a mixed-version wire change on both A and B, and the existing mobile child scope already covers every method this relays. Mixed versions:runtime.client-relay.v1;executionHost: runtime:<env>relays execution-host routes, keeps paired-desktop routes on A, refuses the restexecutionHost(later client PR gates on it)executionHost; behaviour identicalpairing.delegated-mobile-devices.v1remote_runtime_unavailable"needs an Orca update", nothing runs on AClient-side note for the follow-up PR: A advertises the capability per connection, not per server. A client has to re-read
status.getafter every reconnect and must not cache the capability across connections. A reconnect can land on an unencrypted socket, or on a server whose relay wiring has gone away.Linked Issue
Part of #29396 (also #26291 and #29593). This is the server side only; the client routing that lets a desktop or web client use it follows separately, so this does not close the issue yet.
Visual Proof
N/A: server-side RPC admission only, with no UI or interaction change. Nothing in the renderer sends
executionHostyet.Testing
Extended
src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.integration.test.ts(real A and B RPC servers over E2EE WebSockets) by letting the phone helper pair aruntime-scope client:status.getfrom a runtime client advertisesruntime.client-relay.v1; the same call from a phone does not. A targetedterminal.listis answered by B. The child on B has scopemobileand key = client device id, and is minted only after the client relays.terminal.sendwithclient.type: 'desktop'writes on B. Aterminal.subscribedata frame streams back from B. B's token never appears in any frame the client receives, streaming frames included.files.writetargeted at the configured server →forbidden, with A'swriteFileExplorerFilenever called and no server socket opened. Malformedruntime:→invalid_argument. An unknown env →remote_runtime_unavailablewith nothing spawned on A and no child minted on B.terminal.multiplex→forbidden.local/ssh:calls run on A with no server socket opened.revokeRuntimeAccesson A removes the client's child on B and leaves the phone's.desktop-controlwithout the grant) and allows it with the grant. Relaying clients are listed live-first, then by most recentlastSeenAt, and only for the server they relayed to. A B reply echoing the child token reaches the caller with its own token.Mutation checks: the
files.writecase fails if unlisted methods fall back to running locally. The no-child-on-unknown-env assertion fails if enrollment happens beforehosts.resolve. The echo unit test fails without the reverse substitution. The revocation test fails without the resync hook.Commands (Linux):
pnpm tc:node;pnpm test --maxWorkers=2onsrc/main/runtime/mobile-desktop-relay,src/main/runtime/runtime-rpc, the delegated-device, device-revocation, ephemeral-device, caller-scope, dispatcher, mobile-socket-wiring, mobile ACL and runtime-rpc transport suites (47 files, 329 tests);node config/scripts/check-changed-code-quality.mjs upstream/main;oxlintandoxfmt --checkon the changed files. The fullpnpm check:changedaffected-test run timed out locally; CI covers it.AI Disclosure
Written with Claude (Anthropic) via an agent harness; reviewed by the author.
Review
execution-hostmethods (already open to phones) on envs A has configured, as a mobile-scoped child that cannot dopairing-adminon B. Each relayed call must first pass A's own permission check for that client's scope and grants.ssh.connectishost-admin, which runtime-paired clients already hold on A, and it is in B's mobile allowlist, so there is no new privilege. A call that names a server never falls back to running on A. B's token never leaves A, and replies echoing it are rewritten to the caller's own token. Revoking on A, or pruning an idle web session, cascades to B on the next resync.remote_runtime_unavailableand never surfaces as "exited". WSL envs are still excluded by the host resolver.Agent skill upstream boundary
Notes
Open questions for maintainers:
mobilechild acceptable long term for a desktop client? It means B applies mobile payload dieting (clientKind: 'mobile') to relayed desktop calls, e.g. native-chat block sanitising and session-tab projection, and counts the client as a phone in device lists and push. A follow-up could add a capability-gatedkindon the sync params so B mints aruntimechild.projectHostSetup.*left out: the creating methods restampruntime:host ids tolocalon the server, so nested results look correct. But these routes are not in the route table, and the mobile child on B is refused them by B's mobile allowlist. A targeted call is therefore refused on A (forbidden) instead of running there. Adding them needs the child-scope change above.terminal.multiplexand client→server binary frames forwarded through A. Is a separate capability (e.g.runtime.client-relay.binary.v1) the shape you want for that follow-up?phonesChangedresync only walks servers with a cached grant entry, and there are none. B keeps the child until something else syncs that server. The cheap fix is to resync every configured env on a runtime-client revoke, at the cost of onestatus.get+ sync per configured server per revoke. Is that wanted, or is persisting the set preferred?lastSeenAt. A client that disconnects briefly can drop below the cap behind newer sessions until it reconnects and relays again. Acceptable?status.getrelayed to B reportsdeviceScope: 'mobile', session tabs come back mobile-shaped (the mobile tab projection, not the full desktop shape), andfolderWorkspace.createis forbidden because it is outside B's mobile allowlist. The client PR can work around the first two; the third needs the child-scope change in question 1. Is shipping with these gaps acceptable for the first step?Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)