Repository navigation
feat(mobile): let the desktop list its servers and their workspaces for the phone - #26442
Conversation
Rows on an SSH host the desktop cannot reach looked healthy on the phone. The badge now
adds the desktop sidebar's own word ("devbox · Disconnected"), derived by the same shared
function from the connection status ssh.listTargetSummaries already sends; old desktops keep today's badge.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The desktop card shows SSH status on any host count, so the phone now reads target summaries whenever a repo is on SSH and badges an unhealthy host alone too. Labels and health share one target-to-host keying, and a hook-level test pins the reply-to-row wiring. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…e dot
A catalog that no longer spans hosts or holds an SSH repo now clears the health and label maps,
so a host that left cannot keep badging rows. The badge gets a screen-reader label ("devbox,
Disconnected") instead of reading the middle dot.
Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…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
… tsc passes Fixtures hoisted into consts widened their health maps to string, which the now-required hostHealthById rejects under the tests-typecheck ratchet; passing them inline keeps the union. 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
The settled metadata state now carries hostHealthById, and an SSH-only catalog now reads the target summaries so a lone unhealthy host can be badged. Scoped re-record via rpc-recording.mts. 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
…rkspace rows for the phone The phone needs the same host list the desktop shows, including servers that are offline or too old to relay to. mobileRelay.hosts.list/worktrees answer from the desktop's own status and its own worktree.ps fetches, cached per server and fenced by pairing, never from relayed replies. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… side effect on listing The phone now always lists a server's rows through mobileRelay.hosts.worktrees, so the desktop's own fetch is both the live source and the cache, and stamping stays in main. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… forget removed servers The desktop now asks for the phone's full-catalog limit, answers within 5s with the last rows when a server hangs, drops a server's rows when it is removed or re-paired, and checks the server's identity after the fetch so a reply from before a re-pair is never served. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…de rows mid-delete A server Orca manages on an SSH host now lists once under that host's name, or not at all while the host is reached over the SSH relay, using the sidebar's own folding. Rows the server is deleting are left out at reply time, as a phone asking the server itself would see. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… re-paired server's fetch Retirement also fires on a manual disconnect or managed-server update, which wrongly emptied the phone's list; rows are now pruned only once a server is no longer configured. Fetches are shared per server identity, so a poll after a re-pair asks the new server right away. 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
…s1b-mobile-relay into feat/mobile-relay-hosts # Conflicts: # src/main/runtime/runtime-rpc/runtime-rpc-mobile-method-allowlist.ts
…space lists The phone reads only the rows, so stale, fetchedAt, totalCount and truncated were dead wire weight. The desktop still serves a server's last rows while the server is unreachable. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
# Conflicts: # src/main/ipc/runtime-environment-mobile-relay-hosts.test.ts # src/main/ipc/runtime-environment-mobile-relay-hosts.ts # src/main/ipc/runtime-environments.ts # src/main/runtime/delegated-mobile-device.integration.test.ts # src/main/runtime/device-registry.ts # src/main/runtime/mobile-desktop-relay/mobile-desktop-relay-hosts.ts # src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.integration.test.ts # src/main/runtime/mobile-desktop-relay/mobile-desktop-relay.test.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-paired-desktop-methods.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/protocol-version.ts
main now requires every runtime RPC namespace in the host-operation ownership table; the relay-hosts methods are served by the desktop the phone is paired to.
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to Workspace listings remain bounded, but a blocked fetch can leave a host showing cached or missing rows until the queued call settles. Address the refresh retry and runtime-identity guard before merging, or accept these bounded risks. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a44309a3-7896-4149-a969-669fce2c9446
⛔ Files ignored due to path filters (1)
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (20)
src/main/ipc/runtime-environment-mobile-relay-hosts.test.tssrc/main/ipc/runtime-environment-mobile-relay-hosts.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-relay-host-catalog.integration.test.tssrc/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.test.tssrc/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.tssrc/main/runtime/rpc/core.tssrc/main/runtime/rpc/dispatcher-stream-options.tssrc/main/runtime/rpc/methods/index.tssrc/main/runtime/rpc/methods/mobile-relay-hosts.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/renderer/src/store/slices/runtime-status-snapshot.tssrc/shared/host-operation-ownership.tssrc/shared/mobile-relay-hosts-contract.tssrc/shared/runtime-host-status.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| call: (host, method, params, options) => | ||
| callRuntimeEnvironment( | ||
| userDataPath, | ||
| host.environmentId, | ||
| method, | ||
| params, | ||
| options?.timeoutMs, | ||
| options?.expected?.pairingRevision, | ||
| undefined, | ||
| options?.expected?.runtimeId | ||
| ? { expectedEnvironmentRuntimeId: options.expected.runtimeId } | ||
| : undefined | ||
| ), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -A20 'function runtimeEnvironmentRevisionFailure' src/mainRepository: stablyai/orca
Length of output: 2065
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- reviewed file ---'
nl -ba src/main/ipc/runtime-environment-mobile-relay-hosts.ts | sed -n '1,180p'
printf '%s\n' '--- runtime call and option definitions ---'
rg -n -F --glob '*.ts' -- 'expectedEnvironmentRuntimeId' src/main
rg -n -F --glob '*.ts' -- 'runtimeId:' src/main/ipc src/main | head -80
printf '%s\n' '--- relevant catalog and relay symbols ---'
rg -n -F --glob '*.ts' -- 'hosts.worktrees' src/main src
rg -n -F --glob '*.ts' -- 'createRuntimeEnvironmentMobileRelayHosts' src/main src
printf '%s\n' '--- changed diff ---'
git diff --unified=35 ff5c284cc18a8cbebc3abd0b3a8854358fc1dd80 6732ec54616ad1fc63c64f44598ddf1a198a264e -- src/main/ipc/runtime-environment-mobile-relay-hosts.ts src/main/ipc/runtime-environment-revision-guard.tsRepository: stablyai/orca
Length of output: 26190
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- relay host contract ---'
nl -ba src/main/runtime/mobile-desktop-relay/mobile-desktop-relay-hosts.ts | sed -n '1,220p'
printf '%s\n' '--- worktree catalog implementation ---'
rg -n -F --glob '*.ts' -- 'MOBILE_RELAY_HOST_WORKTREES_METHOD' src/main src/shared
rg -n -F --glob '*.ts' -- 'worktrees' src/main/runtime/mobile-desktop-relay src/main/runtime/runtime-rpc
printf '%s\n' '--- environment type ---'
rg -n -F --glob '*.ts' -- 'interface KnownRuntimeEnvironment' src/shared src/main
rg -n -F --glob '*.ts' -- 'type KnownRuntimeEnvironment' src/shared src/main
printf '%s\n' '--- transport implementation and guard call ---'
nl -ba src/main/ipc/runtime-environment-transport-routing.ts | sed -n '1,130p'
nl -ba src/main/ipc/runtime-environment-revision-guard.ts | sed -n '1,80p'Repository: stablyai/orca
Length of output: 20870
🏁 Script executed:
set -o pipefail
nl -ba src/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.ts | sed -n '55,180p'
printf '%s\n' '--- relay method binding ---'
nl -ba src/main/runtime/rpc/methods/mobile-relay-hosts.ts | sed -n '1,120p'
printf '%s\n' '--- host catalog fence references ---'
rg -n -F --glob '*.ts' -- 'expected:' src/main/runtime/mobile-desktop-relay src/main/runtime/rpcRepository: stablyai/orca
Length of output: 8099
Preserve a null runtime ID in the mobile relay fence.
fetchAsDesktop() passes host.identity, whose runtimeId can be null. The truthiness check drops that value, so the transport does not reject a call when the runtime changes from null to a new runtime. The later catalog fence prevents stale rows from being returned, but the request still runs against the wrong runtime.
Use an undefined check and allow null through the transport and guard types.
🐛 Suggested fix
diff --git a/src/main/ipc/runtime-environment-mobile-relay-hosts.ts b/src/main/ipc/runtime-environment-mobile-relay-hosts.ts
--- a/src/main/ipc/runtime-environment-mobile-relay-hosts.ts
+++ b/src/main/ipc/runtime-environment-mobile-relay-hosts.ts
@@
- options?.expected?.runtimeId
+ options?.expected?.runtimeId !== undefined
? { expectedEnvironmentRuntimeId: options.expected.runtimeId }
: undefineddiff --git a/src/main/ipc/runtime-environment-transport-routing.ts b/src/main/ipc/runtime-environment-transport-routing.ts
--- a/src/main/ipc/runtime-environment-transport-routing.ts
+++ b/src/main/ipc/runtime-environment-transport-routing.ts
@@
- options?: { signal?: AbortSignal; expectedEnvironmentRuntimeId?: string }
+ options?: { signal?: AbortSignal; expectedEnvironmentRuntimeId?: string | null }diff --git a/src/main/ipc/runtime-environment-revision-guard.ts b/src/main/ipc/runtime-environment-revision-guard.ts
--- a/src/main/ipc/runtime-environment-revision-guard.ts
+++ b/src/main/ipc/runtime-environment-revision-guard.ts
@@
- expectedRuntimeId?: string
+ expectedRuntimeId?: string | null| private refresh(host: DescribedHost): Promise<void> { | ||
| const key = `${host.environmentId}\0${fenceOf(host.identity)}` | ||
| const inFlight = this.refreshing.get(key) | ||
| if (inFlight) { | ||
| return inFlight | ||
| } | ||
| const refresh = this.fetchAsDesktop(host).finally(() => this.refreshing.delete(key)) | ||
| this.refreshing.set(key, refresh) | ||
| return refresh | ||
| } | ||
|
|
||
| private async fetchAsDesktop(host: DescribedHost): Promise<void> { | ||
| try { | ||
| const response = await this.options.hosts.call( | ||
| host, | ||
| 'worktree.ps', | ||
| { limit: SERVER_WORKTREE_LIMIT, supportsWorktreeVisibilitySourceDefaults: true }, | ||
| // Why the transport bound too: it ends the hung call, so the next poll fetches afresh instead of joining it. | ||
| { timeoutMs: SERVER_FETCH_TIMEOUT_MS, expected: host.identity } | ||
| ) | ||
| const reply = response.ok ? WorktreePsReplySchema.safeParse(response.result) : null | ||
| if (!reply?.success) { | ||
| return | ||
| } | ||
| this.cached.set(host.environmentId, { | ||
| // Why the identity taken before the fetch: the call's own check cannot see a re-pair after dispatch. | ||
| fence: fenceOf(host.identity), | ||
| worktrees: stampServerWorktreeRows(host.environmentId, reply.data.worktrees) | ||
| }) | ||
| } catch { | ||
| // An unreachable server keeps its last rows. | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function fenceOf(identity: DescribedHost['identity']): string { | ||
| return `${identity.pairingRevision}\0${identity.runtimeId}` | ||
| } | ||
|
|
||
| /** Settles once the bound passes; the call's own timeout starts only after the desktop's per-server queue. */ | ||
| async function withinFetchBound(refresh: Promise<void>): Promise<void> { | ||
| let timer: ReturnType<typeof setTimeout> | undefined | ||
| const bound = new Promise<void>((resolve) => { | ||
| timer = setTimeout(resolve, SERVER_FETCH_TIMEOUT_MS) | ||
| }) | ||
| try { | ||
| return await Promise.race([refresh, bound]) | ||
| } finally { | ||
| clearTimeout(timer) | ||
| } | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '65,95p;130,190p' src/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.ts
sed -n '355,400p' src/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.test.ts
rg -n 'function callRuntimeEnvironment|const callRuntimeEnvironment|timeoutMs|inFlight' src/main/ipc/runtime-environment-transport-routing.ts src/main/ipc/runtime-environment-mobile-relay-hosts.ts src/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.tsRepository: stablyai/orca
Length of output: 6698
🏁 Script executed:
sed -n '1,250p' src/main/ipc/runtime-environment-mobile-relay-hosts.ts
sed -n '1,250p' src/main/ipc/runtime-environment-transport-routing.ts
rg -n -F --glob '*.ts' -- 'MobileDesktopRelayHosts' src/main
rg -n -F --glob '*.ts' -- 'options.hosts.call' src/main
rg -n -F --glob '*.ts' -- 'callRuntimeEnvironment(' src/mainRepository: stablyai/orca
Length of output: 20306
🏁 Script executed:
sed -n '1,260p' src/main/ipc/runtime-environment-call-queue.ts
rg -n -F --glob '*.ts' -- 'enqueueRuntimeCall' src/main/ipc src/main/runtime
rg -n -i --glob '*.test.ts' -- 'call.queue|queued|queue|enqueueRuntimeCall' src/main/ipc/runtime-environment-call-queue.test.ts src/main/ipcRepository: stablyai/orca
Length of output: 41078
🏁 Script executed:
sed -n '1,320p' src/shared/runtime-rpc-call-queue.ts
rg -n -F --glob '*.ts' -- 'RuntimeRpcCallQueuePool' src/shared src/main
rg -n -i --glob '*.test.ts' -- 'RuntimeRpcCallQueuePool|runtime rpc call queue|runtime_rpc_queue' src/shared src/mainRepository: stablyai/orca
Length of output: 13651
🏁 Script executed:
rg -n -F --glob '*.ts' -- 'function sendRemoteRuntimeRequestAbortable' src/main src/shared
rg -n -F --glob '*.ts' -- 'function sendRemoteRuntimeConnectionRequestAbortable' src/main src/shared
rg -n -F --glob '*.ts' -- 'function resolveManagedRuntimeEnvironment' src/main src/shared
sed -n '1,280p' src/main/ipc/runtime-environment-abortable-requests.ts
sed -n '1,220p' src/main/ipc/runtime-environment-managed-tunnel.tsRepository: stablyai/orca
Length of output: 7667
Bound the promise stored in refreshing.
worktrees() only bounds its wait. refresh() stores the unbounded fetchAsDesktop() promise. The host adapter queues that call before applying timeoutMs, and the queue has no admission timeout or cancellation signal on this path. If the call remains queued, refreshing is not cleared when the five-second fallback returns. Later requests for the same identity reuse that promise and can keep returning cached or null rows until the queued call settles.
Suggested fix
- await withinFetchBound(this.refresh(host))
+ await this.refresh(host)
...
- const refresh = this.fetchAsDesktop(host).finally(() => this.refreshing.delete(key))
+ const refresh = withinFetchBound(this.fetchAsDesktop(host)).finally(() =>
+ this.refreshing.delete(key)
+ )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private refresh(host: DescribedHost): Promise<void> { | |
| const key = `${host.environmentId}\0${fenceOf(host.identity)}` | |
| const inFlight = this.refreshing.get(key) | |
| if (inFlight) { | |
| return inFlight | |
| } | |
| const refresh = this.fetchAsDesktop(host).finally(() => this.refreshing.delete(key)) | |
| this.refreshing.set(key, refresh) | |
| return refresh | |
| } | |
| private async fetchAsDesktop(host: DescribedHost): Promise<void> { | |
| try { | |
| const response = await this.options.hosts.call( | |
| host, | |
| 'worktree.ps', | |
| { limit: SERVER_WORKTREE_LIMIT, supportsWorktreeVisibilitySourceDefaults: true }, | |
| // Why the transport bound too: it ends the hung call, so the next poll fetches afresh instead of joining it. | |
| { timeoutMs: SERVER_FETCH_TIMEOUT_MS, expected: host.identity } | |
| ) | |
| const reply = response.ok ? WorktreePsReplySchema.safeParse(response.result) : null | |
| if (!reply?.success) { | |
| return | |
| } | |
| this.cached.set(host.environmentId, { | |
| // Why the identity taken before the fetch: the call's own check cannot see a re-pair after dispatch. | |
| fence: fenceOf(host.identity), | |
| worktrees: stampServerWorktreeRows(host.environmentId, reply.data.worktrees) | |
| }) | |
| } catch { | |
| // An unreachable server keeps its last rows. | |
| } | |
| } | |
| } | |
| function fenceOf(identity: DescribedHost['identity']): string { | |
| return `${identity.pairingRevision}\0${identity.runtimeId}` | |
| } | |
| /** Settles once the bound passes; the call's own timeout starts only after the desktop's per-server queue. */ | |
| async function withinFetchBound(refresh: Promise<void>): Promise<void> { | |
| let timer: ReturnType<typeof setTimeout> | undefined | |
| const bound = new Promise<void>((resolve) => { | |
| timer = setTimeout(resolve, SERVER_FETCH_TIMEOUT_MS) | |
| }) | |
| try { | |
| return await Promise.race([refresh, bound]) | |
| } finally { | |
| clearTimeout(timer) | |
| } | |
| } | |
| private refresh(host: DescribedHost): Promise<void> { | |
| const key = `${host.environmentId}\0${fenceOf(host.identity)}` | |
| const inFlight = this.refreshing.get(key) | |
| if (inFlight) { | |
| return inFlight | |
| } | |
| const refresh = withinFetchBound(this.fetchAsDesktop(host)).finally(() => | |
| this.refreshing.delete(key) | |
| ) | |
| this.refreshing.set(key, refresh) | |
| return refresh | |
| } | |
| private async fetchAsDesktop(host: DescribedHost): Promise<void> { | |
| try { | |
| const response = await this.options.hosts.call( | |
| host, | |
| 'worktree.ps', | |
| { limit: SERVER_WORKTREE_LIMIT, supportsWorktreeVisibilitySourceDefaults: true }, | |
| // Why the transport bound too: it ends the hung call, so the next poll fetches afresh instead of joining it. | |
| { timeoutMs: SERVER_FETCH_TIMEOUT_MS, expected: host.identity } | |
| ) | |
| const reply = response.ok ? WorktreePsReplySchema.safeParse(response.result) : null | |
| if (!reply?.success) { | |
| return | |
| } | |
| this.cached.set(host.environmentId, { | |
| // Why the identity taken before the fetch: the call's own check cannot see a re-pair after dispatch. | |
| fence: fenceOf(host.identity), | |
| worktrees: stampServerWorktreeRows(host.environmentId, reply.data.worktrees) | |
| }) | |
| } catch { | |
| // An unreachable server keeps its last rows. | |
| } | |
| } | |
| } | |
| function fenceOf(identity: DescribedHost['identity']): string { | |
| return `${identity.pairingRevision}\0${identity.runtimeId}` | |
| } | |
| /** Settles once the bound passes; the call's own timeout starts only after the desktop's per-server queue. */ | |
| async function withinFetchBound(refresh: Promise<void>): Promise<void> { | |
| let timer: ReturnType<typeof setTimeout> | undefined | |
| const bound = new Promise<void>((resolve) => { | |
| timer = setTimeout(resolve, SERVER_FETCH_TIMEOUT_MS) | |
| }) | |
| try { | |
| return await Promise.race([refresh, bound]) | |
| } finally { | |
| clearTimeout(timer) | |
| } | |
| } |
ELI5
The desktop can now tell its paired phone which Orca servers it's connected to, how each one is doing,
and which workspaces each one has. It keeps the last list it saw, so the phone can still show a server's
workspaces while that server is down. Nothing calls this yet; the next change makes the phone use it.
Stacked on #26435 (the desktop relay). It also merges #26415 (the shared host-health labels), so
until that lands this diff includes it. Review only this branch's own commits.
What Changed
Before: the phone had no way to learn which remote Orca servers its desktop uses, or what's on them.
After (unused until the phone change): two new phone methods, both answered by the desktop itself.
mobileRelay.hosts.list(no params) returns{hosts:[{hostId, label, health, relay}]}.hostIdisruntime:<env>;labelis the desktop's own label, including renames.healthuses the shared host-health words and the desktop sidebar's own mapping(
buildExecutionHostRegistry) over status the desktop already tracks. No new polling.relayisupdate-neededwhen the server lacks the delegated-phone capability,readywhen it hasit and is reachable, otherwise
unavailable.host's name. When the desktop reaches that machine through SSH, it isn't listed at all, because the
phone already gets those workspaces as SSH rows.
mobileRelay.hosts.worktrees {hostId}returns that server's workspace rows, fetched by the desktopas itself (
worktree.ps, full list), withhostIdset toruntime:<env>.stale: truewithfetchedAt. It never makes upidle or stopped states.
{worktrees: null}for a server never fetched, or last fetched before a re-pair.Why
The phone should list every workspace the desktop shows, including when a server is offline or too old
to relay to. The desktop already knows each server's status and can fetch its rows as itself, so the
phone gets one listing path. The relay is used only for what happens after the list: opening a
workspace, terminals and actions. The desktop still never reads relayed replies.
Rejected alternatives:
servers: two listing paths, and nothing to show for old servers;
Linked Issue
N/A (maintainer)
Visual Proof
N/A. Nothing calls these methods until the phone change.
Testing
Automated tests added/updated, or explained why not below
Integration (
mobile-relay-host-catalog.integration.test.ts): a real phone, desktop and two realservers. The phone lists both servers and gets live rows from the update-needed one. After the ready
one stops, it gets that server's last rows unchanged with
stale: true.Unit tests cover:
Each of these was checked by breaking the code on purpose and seeing the test fail.
48 tests pass across the relay and runtime RPC folders. The node typecheck, oxlint, oxfmt and the
changed-code quality gate are clean.
Notes
relay capability, so an old desktop is never asked.
hostId.removed.