Skip to content

feat(remote): list a paired server's managed hosts and their workspaces - #35242

Draft
jutaz wants to merge 6 commits into
stablyai:mainfrom
jutaz:feat/runtime-client-relay-routing
Draft

jutaz wants to merge 6 commits into
stablyai:mainfrom
jutaz:feat/runtime-client-relay-routing

Conversation

@jutaz

@jutaz jutaz commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

If your laptop is paired with a computer or server that manages other servers (for example one VM per workspace), the laptop could not see those servers at all. Now the sidebar shows them, with their workspaces, under "On 's servers". You can look but not open them yet; that comes in later PRs. Until then, use the server itself or your phone.

What Changed

Topology: laptop (desktop Orca) → paired server A (desktop or orca serve) → managed servers B1..Bn that A reaches as runtime:<id on A>.

No new IPC channel, main handler or preload method. The renderer already holds every input the gate needs (runtimeEnvironments, runtimeStatusByEnvironmentId). It reads A through the existing generic call path (callRuntimeRpc({ kind: 'environment' }) → runtimeEnvironments.call), which also applies main's manual-disconnect, WSL move fence and account checks.

  • Gate (src/renderer/src/runtime/relayed-runtime-hosts.ts, relayingRuntimeOwners): A counts as relaying only when its status snapshot is for the current pairing revision (pairingRevision ?? createdAt), is not refused or retired, and the last verified status advertises runtime.client-relay.v1. WSL environments are skipped with isWslHostRuntimeEnvironment.
  • Contact gate: A is called only while in contact, meaning its snapshot is verification === 'verified' && transport === 'ready'. A server that is down, still checking, unreachable or manually disconnected (its status owner is retired) is never called, so a poll can't wake it or restart a managed server. Its last rows stay on screen while it is out of contact, like the phone.
  • Reads: mobileRelay.hosts.list and then mobileRelay.hosts.worktrees per ready B, untargeted on A. They go through callRuntimeRpc pinned to A's pairing revision (expectedEnvironmentPairingRevision) with skipCompatibilityCheck: true, because the capability in the verified status already gates them. If A's list fails or is malformed, A shows as unavailable. If one B's rows fail, that B keeps its last rows.
  • Untrusted input: A's answer is parsed with zod and bounded. At most 50 hosts per A and 200 rows per host are kept. Labels, names, branches and repos are cut to 200 characters. Ids over 1024 characters are dropped, not cut, because a cut id would name another workspace once rows open. Hosts are deduped by hostId and rows by worktreeId, since duplicates would collide as React keys. Only runtime: hosts with relay: 'ready' are kept, and archived rows are dropped.
  • Store (relayedRuntimeHosts slice): kept separate from worktreesByRepo and the detected-worktree catalog. Actions on those rows would be refused through the relay, so these rows must not enter it. Owners are keyed by environment id plus pairing revision, and B rows by hostId inside their owner. B's id stays A's runtime:<id on A>. The rows are not an ExecutionHostId here and nothing routes to them, so no re-qualified id is built until the routing PR needs one. Each refresh takes a generation number, and only the latest refresh may land, so a slower, older read can't overwrite a newer one. After the reads it rechecks the gate, so an unpair, a re-pair or a downgrade during a read can't bring rows back. Unchanged polls keep identity through a field-by-field compare (no JSON.stringify).
  • Polling (relayed-runtime-hosts-polling.ts, installed from app-lifetime-ipc-bridge): it watches the store's runtimeEnvironments and runtimeStatusByEnvironmentId, which the existing catalog-changed and status-changed events write. While some relaying A is in contact, it polls every 30s through installWindowVisibilityInterval, so hidden windows don't poll. When the set of A in contact changes (pair, re-pair, reconnect, downgrade), it re-reads at once. It stops when none is in contact.
  • Sidebar: RelayedRuntimeHostsSection sits below the workspace list, next to the WSL moved-projects section, which it mirrors (border-top, scrollbar-sleek, 40% max height). Its selector shows only owners that are still relaying on the pairing their rows came from, so an unpair, re-pair or downgrade hides them before the next read. That is the same pattern as WslMovedProjectsSection, with no separate retain action. The section has an accessible name (aria-label). Each A's title ("On 's servers") is an h3. Each B uses the host-header Server glyph, and its workspaces show a branch or folder icon, display name and branch. Rows are plain list items: not buttons, no hover state, nothing to click. The note "Opening these from this computer is coming in a later update; use the server or your phone." shows only when some host is listed. Nothing renders when no paired server relays.
  • i18n: six sidebar.relayedHosts.* English keys. Other locales fall back until localization fills them, per the catalog checker.

Why

Issue #29396: desktop clients should reach a paired server's managed hosts the way phones already can. #35195 added the server side; this is the first client-side step. It reuses the listing A already serves to phones (mobileRelay.hosts.*, permission workspace, which runtime-paired clients hold, answered untargeted on A). There is no new server method, so a laptop works against any A that advertises the capability.

Alternatives considered:

  • Feeding the rows into the workspace catalog, which would have shown them with the normal cards: every action on them (worktree.*, files.write, projectHostSetup.*) is outside the relay route table and would be refused, so the cards would break as soon as they were clicked. A separate read-only slice keeps that out until routing lands (3b/3c).
  • A dedicated main IPC that reads every A: it duplicates gating the renderer can already do, and it would skip the generic call path's manual-disconnect, WSL-fence and account checks.
  • A virtual runtime: environment per B: needs envelope plumbing through call, shared-control and subscriptions, and is the subject of 3b.

Mixed versions:

Laptop Server A Outcome
new new + relay wiring section lists A's ready servers
new old, orcad, unencrypted socket, or no relay wiring no capability in status → no calls, no section
new A reconnects to an older build status loses the capability → section drops A at once
new A goes down no calls; last rows stay until A is back or unpaired
old any unchanged
web client relaying A same code path: the web shim implements runtimeEnvironments.call and status snapshots for its one paired server, so the section works there too

Linked Issue

Part of #29396.
Stacked on #35195: this PR's diff includes its 3 commits until it merges. Review only the last commit, feat(remote): list a paired server's managed hosts and their workspaces.

Visual Proof

Component fixture (sidebar/RelayedRuntimeHostsSection, pnpm fixtures:shot), dark and light. A real Electron app paired to a real relaying server and VMs was not captured.

Before: no section; nothing renders when no paired server relays.

After, dark After, light
listed dark listed light
unreadable dark unreadable light

The "after" fixture shows: one A with two ready servers (git workspaces, with and without a display name, and a folder workspace), a server whose workspaces have not loaded yet, a second A whose read failed, and the read-only note. --unreadable shows only an A whose read failed: there is no host to open, so the note is hidden.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • mobile-relay-host-catalog.integration.test.ts (existing harness with real RPC servers over E2EE WebSockets): a runtime-scope client gets the same untargeted mobileRelay.hosts.list as the phone, and hosts.worktrees returns the server's rows. This proves the contract is usable for laptop callers.

  • runtime/relayed-runtime-hosts.test.ts: host and row caps, text clipping, dedupe by hostId and worktreeId, and dropping non-ready, non-runtime:, archived and malformed entries. A malformed list is unreadable. A WSL environment is never treated as relaying, even when its status advertises the capability.

  • store/slices/relayed-runtime-hosts.test.ts (real test store, stubbed window.api.runtimeEnvironments.call): no call when A is disconnected, unverified, unreachable, manually disconnected (retired), on an earlier pairing, or lacks the capability. Reads go through the generic call pinned to A's revision. Rows are kept without a call while A is out of contact. A downgrade drops A. A re-pair under the same id drops the old rows and never shows them for the new pairing. An unpair during a read doesn't restore rows. A newer read wins over an older one that answers later. Failed owner and row reads keep the last rows and their identity. An A never read shows as unavailable.

  • hooks/ipc-events/relayed-runtime-hosts-polling.test.ts: the visibility interval starts only once a relaying A is in contact and stops when contact is lost.

  • Mutation checks: removing the contact filter fails 5 tests, removing the generation check fails the ordering test, removing the revision check fails the earlier-pairing test, and removing the host cap and dedupe fails the parser test.

Commands (Linux): corepack pnpm tc; corepack pnpm test --maxWorkers=2 on the new suites plus src/main/ipc/runtime-environments, src/renderer/src/hooks/ipc-events, src/preload, the host-catalog integration test and the runtime-status slice tests (125 files, 808 passed); node config/scripts/check-changed-code-quality.mjs upstream/main (0 new findings in all passes); oxlint and oxfmt --check on changed files; oxlint --config config/oxlint-design-system.json on changed renderer files; pnpm run lint:react-doctor:changed; pnpm run verify:localization-catalogs and verify-localization-extraction.mjs. The full pnpm check:changed was not run locally; CI covers it.

AI Disclosure

Written with Claude (Anthropic) via an agent harness; reviewed by the author.

Review

  • Security: read-only. The laptop calls two workspace-permission methods on A, which it could already call, through the same main call handler as every other renderer request. That handler applies the manual-disconnect, WSL move-fence and account checks. No routing to B happens, so no delegated device is minted on B (feat(remote): relay paired desktop and web clients to a server's managed hosts #35195 mints only on a relayed call). A's answer is treated as untrusted and bounded (see caps above). The rows carry no tokens; only names, branches and repo labels reach the renderer.
  • Remote/SSH: calls are pinned to A's pairing revision, so a re-pair mid-read fails instead of mixing identities. Rows are keyed by pairing revision and dropped when it changes. WSL distros are never called. Servers that are out of contact or manually disconnected are not called. The gate uses the per-connection capability from A's verified status for this pairing, as feat(remote): relay paired desktop and web clients to a server's managed hosts #35195 requires (no caching across connections).
  • Mobile: unchanged. It uses the same A methods the phone already uses, with the same keep-last-rows behavior.
  • Web client: the web shim implements runtimeEnvironments.call and status snapshots for its single paired server, so the same code works there without a separate path.
  • Performance: nothing runs unless a paired server in contact advertises the capability. Then it is one list call per A plus one rows call per ready B (at most 50) every 30s, paused while the window is hidden. A bounds each rows read to its own 5s fetch window. The section re-renders only when the listing changes, because unchanged polls keep identity through a field-by-field compare.
  • Cross-platform: no platform-specific code.
  • UI: follows the WSL moved-projects sibling and STYLEGUIDE: text-2xs and category-label styling, sidebar* tokens, lucide-react icons, no new colors. Checked in light and dark.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • A B paired both directly and through A appears twice; the "On A's servers" header is the "via A" label. Folding the two together needs B's real identity (runtime id), which A's listing does not expose. That belongs in a later PR if wanted.
  • Health is not shown per B: only relay: 'ready' servers are listed, and those are by definition reachable through A.
  • Opening, actions and routing come in 3b/3c, after the maintainer decisions listed on feat(remote): relay paired desktop and web clients to a server's managed hosts #35195.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

jutaz added a commit to jutaz/orca that referenced this pull request Oct 28, 2026
jutaz added a commit to jutaz/orca that referenced this pull request Oct 28, 2026
jutaz added a commit to jutaz/orca that referenced this pull request Oct 28, 2026
jutaz added a commit to jutaz/orca that referenced this pull request Oct 28, 2026
@jutaz
jutaz force-pushed the feat/runtime-client-relay-routing branch 2 times, most recently from c9891a7 to 0690375 Compare October 29, 2026 00:53
@jutaz
jutaz force-pushed the feat/runtime-client-relay-routing branch from 0690375 to 7471914 Compare October 29, 2026 01:03
@jutaz
jutaz force-pushed the feat/runtime-client-relay-routing branch 2 times, most recently from 1d48004 to 0f356b1 Compare October 29, 2026 04:57
@jutaz

jutaz commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Local CI for 0f356b1 (stacked on #35195, on main ceb9ca0). Actions waits on approval here, so these are my local runs:

  • Typecheck, changed-code quality, and both localization checks (extraction and catalogs) pass. Lint and format pass on the changed files.
  • The relay, runtime-rpc, runtime-environments, remote-runtime and renderer relayed-host suites pass, run at the top of the stack (feat(remote): read a relayed host through the paired server #35478): 116 files, 711 tests, 1 skipped.

jutaz added 6 commits November 7, 2026 03:21
…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.
A desktop paired to a server that relays (runtime.client-relay.v1) now
shows, read-only below the workspace list, the managed servers that
server can relay to and their workspaces. The renderer reads them with
mobileRelay.hosts.list/worktrees through the existing runtime call
path, only while that server is in contact and advertises the
capability for the current pairing. Polling pauses in hidden windows.
The rows stay out of the workspace catalog, whose actions the relay
would refuse.

This branch has not been deployed

No deployments
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