Repository navigation
feat(mobile): relay a paired phone's server-workspace requests through the desktop (hidden) - #26435
Conversation
…mobile devices A desktop paired to this runtime can now call pairing.delegatedMobileDevice.sync to make each of its phones an ordinary mobile-scope device it owns, so the phone mirrors that host through the desktop. Children are never pending, inherit the parent's reach, and die with the parent's grant. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…atch Dispatch binds the caller-bound delegated-device context, so the revoke path it needs now lives in a layer under it as a pure move; this drops the abstract method seam. No behaviour change. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…oked A failed child cleanup now leaves the parent in place so a retry can still find the children, and revokeRuntimeAccess lives beside the revoke it cascades to. Adds restart, rename and bounds coverage, shares credential minting, and drops the timing-dependent census. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…oked Matches the parent revoke: a child whose cleanup could not be saved is kept and the sync errors before minting anything, so the desktop retries instead of believing the server matches its list. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…h the desktop A phone mirrors its desktop, including workspaces on the desktop's configured servers. The desktop now forwards a request that names `executionHost: runtime:<env>` to that server over one socket per (phone, server), signed in as the phone's delegated device; replies pass through untouched except stream ids. Hidden until the phone client ships: the relay capability is not advertised yet. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…p-mobile-relay Takes S1a's contract file verbatim (plural capability name) and moves the unpair re-sync into its RuntimeRpcMobileDevices; the relay integration test now syncs against the real server. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
main dropped docs/reference, so the relay's contract lives beside the code. Also pins that a server whose delegated sync fails (e.g. delegated_device_revoke_failed) is unavailable until a later request syncs it again. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The production hosts adapter was only typechecked; this pins that it resolves configured servers by exact id only (never a name or a removed server), fences by pairing revision and runtime identity, and stops reporting retirements once unsubscribed. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Reuses the shared E2EE socket opener, folds relay state into fewer fields, never sends a request whose link ended while opening, passes failure codes through, relays only this desktop's own phones, and drops the unused host-state reader until S2 needs one. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Restores the 8 MiB frame cap on every remote runtime socket, re-checks an update-needed server on each new link so an in-place upgrade relays, answers a phone the server just declined without syncing again, and ends a link whose mirrored capability update cannot be queued. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The phone tags every call on a workspace screen with its execution host, so a paired-desktop method carrying `runtime:<env>` now runs locally instead of failing 'forbidden'. The Mac stays the only reader of the routing table. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Under the bun vitest project, `ws` resolves to Bun's built-in client, which ignores maxPayload, so the frame-cap test hung. The opener only ships on Node/Electron, so run its test in the Node runtime project like its siblings. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…able Adding a phone method now takes one edit (its route). A server-targeted call on a legacy non-E2EE socket is refused instead of running locally, and only execution-host methods enter the relay. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…elay # Conflicts: # src/main/ipc/runtime-environments.ts # src/main/runtime/delegated-mobile-device.integration.test.ts # src/main/runtime/device-registry.ts # src/main/runtime/rpc/core.ts # src/main/runtime/rpc/dispatcher-stream-options.ts # src/main/runtime/rpc/methods/pairing.ts # src/main/runtime/rpc/rpc-streaming-dispatcher.ts # src/main/runtime/runtime-rpc/runtime-rpc-mobile-devices.ts # src/main/runtime/runtime-rpc/runtime-rpc-pairing.ts # src/main/runtime/runtime-rpc/runtime-rpc-state.ts # src/main/runtime/runtime-rpc/runtime-rpc-websocket-dispatch.ts # src/shared/delegated-mobile-device-contract.ts # src/shared/protocol-version.ts
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Phones can now have their requests to a configured server relayed through the desktop, but the feature stays hidden until phones are told the relay exists. One follow-up remains: under heavy concurrent traffic, such as large image uploads, the relay connection can drop because its send queue is sized for subscriptions. This is safe to merge, but the queue limits should be fixed before the relay is enabled for phones. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
5f5ee851-af2d-41c7-8de2-7b15b90f21f2
📒 Files selected for processing (33)
config/scripts/vitest-node-runtime-files.mjssrc/main/ipc/runtime-environment-mobile-relay-hosts.test.tssrc/main/ipc/runtime-environment-mobile-relay-hosts.tssrc/main/ipc/runtime-environments.tssrc/main/runtime/mobile-desktop-relay/delegated-phone-grants.tssrc/main/runtime/mobile-desktop-relay/mobile-desktop-relay-hosts.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/mobile-desktop-relay/relayed-phone-frames.test.tssrc/main/runtime/mobile-desktop-relay/relayed-phone-frames.tssrc/main/runtime/mobile-desktop-relay/relayed-stream-carriers.test.tssrc/main/runtime/mobile-desktop-relay/relayed-stream-carriers.tssrc/main/runtime/rpc/core.tssrc/main/runtime/runtime-rpc-mobile-legacy-socket-relay-refusal.test.tssrc/main/runtime/runtime-rpc/runtime-rpc-lifecycle.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-agent-session-methods.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-devices.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-method-allowlist.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-method-routing.test.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-method-routing.tssrc/main/runtime/runtime-rpc/runtime-rpc-mobile-paired-desktop-methods.tssrc/main/runtime/runtime-rpc/runtime-rpc-pairing.tssrc/main/runtime/runtime-rpc/runtime-rpc-state.tssrc/main/runtime/runtime-rpc/runtime-rpc-websocket-dispatch.tssrc/main/startup/main-process-runtime-launch-activation.test.tssrc/main/startup/main-process-runtime-launch.tssrc/shared/delegated-mobile-device-contract.tssrc/shared/mobile-desktop-relay-contract.tssrc/shared/remote-runtime-passthrough-socket.tssrc/shared/remote-runtime-request-websocket.test.tssrc/shared/remote-runtime-request-websocket.tssrc/shared/terminal-stream-protocol.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| send: (plaintext) => | ||
| state === 'ready' && ws.readyState === WebSocket.OPEN | ||
| ? outbound.enqueueRequest(ws, encrypt(plaintext, sharedKey)) | ||
| : false, |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP 'SUBSCRIPTION_REQUEST_(SOFT_CAP_BYTES|MAX_QUEUED_BYTES|MAX_QUEUED_FRAMES)\s*=' -C2
rg -nP 'CHUNK_(BYTES|SIZE)|MAX_.*CHUNK' --type=ts -g '*clipboard*' -C2Repository: stablyai/orca
Length of output: 706
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- passthrough socket send path ---'
nl -ba src/shared/remote-runtime-passthrough-socket.ts | sed -n '145,180p'
printf '%s\n' '--- outbound queue implementation ---'
nl -ba src/shared/remote-runtime-subscription-outbound.ts | sed -n '1,220p'
printf '%s\n' '--- relay and request-size references ---'
rg -n -F --glob '*.ts' -- 'openRemoteRuntimePassthroughSocket' src
rg -n -F --glob '*.ts' -- 'enqueueRequest' src
rg -n -F --glob '*.ts' -- 'clipboard.appendImageUploadChunk' src || true
rg -n -F --glob '*.ts' -- 'terminal.send' src || true
rg -n -i --glob '*.ts' -- 'chunk' src/shared src/main src/mobile | head -200 || trueRepository: stablyai/orca
Length of output: 41543
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- passthrough socket setup ---'
nl -ba src/shared/remote-runtime-passthrough-socket.ts | sed -n '1,190p'
printf '%s\n' '--- queue behavior ---'
nl -ba src/shared/ws-outbound-backpressure-queue.ts | sed -n '1,280p'
printf '%s\n' '--- relay call site and lifecycle ---'
nl -ba src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.ts | sed -n '180,255p'
printf '%s\n' '--- request schemas and relay allowlist ---'
nl -ba src/shared/rpc-contract/clipboard-params.ts | sed -n '1,90p'
nl -ba src/shared/rpc-contract/terminal-params.ts | sed -n '1,180p' 2>/dev/null || true
nl -ba src/main/runtime/runtime-rpc/runtime-rpc-mobile-method-routing.ts | sed -n '1,80p'
printf '%s\n' '--- focused relay tests ---'
rg -n -F --glob '*mobile-desktop-relay*' -- 'overflow' src/main/runtime/mobile-desktop-relay src || true
rg -n -F --glob '*mobile-desktop-relay*' -- 'appendImageUploadChunk' src/main/runtime/mobile-desktop-relay src || trueRepository: stablyai/orca
Length of output: 27915
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- remaining queue enqueue logic ---'
nl -ba src/shared/ws-outbound-backpressure-queue.ts | sed -n '268,390p'
printf '%s\n' '--- relay link forwarding ---'
rg -n -F --glob '*.ts' -- 'class RelayLink' src/main/runtime/mobile-desktop-relay
rg -n -F --glob '*.ts' -- 'socket.send' src/main/runtime/mobile-desktop-relay
nl -ba src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.ts | sed -n '1,190p'
printf '%s\n' '--- clipboard upload producer ---'
nl -ba src/main/window/clipboard-runtime-image-upload.ts | sed -n '1,180p'
printf '%s\n' '--- serialization and encryption sizes ---'
nl -ba src/shared/remote-runtime-memory-limits.ts | sed -n '1,180p'
nl -ba src/shared/e2ee-crypto.ts | sed -n '1,180p'Repository: stablyai/orca
Length of output: 23067
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- relay callers and target guards ---'
rg -n -F --glob '*.ts' -- 'relay.forward' src/main src/shared
rg -n -F --glob '*.ts' -- 'forward(phone' src/main
rg -n -i --glob '*.ts' -- 'executionHost' src/main/runtime src/main | head -120 || true
printf '%s\n' '--- relay capability advertisement ---'
rg -n -F --glob '*.ts' -- 'MOBILE_DESKTOP_RELAY_RUNTIME_CAPABILITY' src
rg -n -F --glob '*.ts' -- 'RUNTIME_CAPABILITIES' src/main src/shared
printf '%s\n' '--- runtime request bounds ---'
rg -n -F --glob '*.ts' -- 'REMOTE_RUNTIME_MAX_PENDING_REQUESTS' src
rg -n -F --glob '*.ts' -- 'REMOTE_RUNTIME_MAX_PENDING_RPC_BYTES' srcRepository: stablyai/orca
Length of output: 33543
Use relay-specific outbound queue limits.
When the host socket is backpressured, RelayLink.forward queues every relayed request in the subscription request queue. A valid clipboard.appendImageUploadChunk request can contain 512 KiB of base64 data. After E2EE base64 encoding, 24 such queued frames exceed the 16 MiB limit. Queue overflow ends the relay with remote_runtime_unavailable.
Configure the passthrough socket with limits derived from the supported relayed RPC and frame budgets instead of the subscription queue limits. The relay capability is currently hidden, but this path can fail when concurrent phone requests are enabled.
ELI5
The desktop can now pass a phone's requests through to an Orca server the desktop is connected to,
signed in on that server as the phone itself. Nothing turns this on yet: phones don't send these
requests until the next change, which lets the phone show the server's workspaces.
Stacked on #26427, which lets the desktop register its phones on a server. Review only this
branch's own commits.
What Changed
Before: a phone paired with a desktop could only reach the desktop's own and SSH workspaces. The
remote Orca servers the desktop connects to as a client were out of reach.
After (hidden):
executionHost: "runtime:<env>". The desktop checksthe phone and its method allowlist as today, finds that configured server by exact id, and forwards the
request.
local/ssh:…, the request runs on the desktop exactly as before.MOBILE_RPC_METHOD_ROUTEStags every phone methodexecution-hostorpaired-desktop. A census test fails on any method that's untagged or stale.pairing.delegatedMobileDevice.sync(feat(runtime): let a paired desktop register its phones as phone devices #26427) and keeps the returned tokens in memory only.src/shared/remote-runtime-passthrough-socket.ts).opener, which now also takes binary frames.
requests get an error and are never replayed.
result.streamIdand the binary terminalheader), using the desktop's own counter so relayed streams never collide with local ones.
stream-id carrier.
8 MiB + 64 bytes for every caller. Two existing callers lacked it before.
RUNTIME_CAPABILITIES, so phones never send a target.The next change turns it on with that one line.
Why
Each phone is an ordinary phone device on the server (#26427), so the server applies its existing phone
behaviour: terminal seats, query replies, clipboard ownership, chat limits and cleanup. The desktop
stays a dumb pipe. The token swap and stream-id renumbering are generic, so new server methods and fields
need no relay work.
Rejected alternatives:
Linked Issue
N/A (maintainer)
Visual Proof
N/A. Nothing user-visible until the next change.
Testing
Integration (
mobile-desktop-relay.integration.test.ts) runs a real server and a real desktop withan encrypted phone client. It covers:
local/ssh:targets running on the desktop;Unit tests cover the frame rewrite, the stream-carrier and routing censuses, and the server lookup
adapter. Races: two phones racing the first sync run one sync; a server retired while its socket opens;
a phone leaving mid-sync. Also: a phone the server gives no token, oversized frames closing the socket,
and a failed capability forward ending the link.
Each protection was checked by breaking it on purpose, and its test fails. 48 tests pass across 9 files
on the reviewer's run; the lane's wider run over
src/main/{ipc,runtime,startup}andsrc/sharedhad29,701 pass, with one fish-shell test failing on that machine only.
Notes
capability and is reported as update-needed for relay. There's no new stream opcode.
outbound queue closes the link on overflow.