Repository navigation
fix(runtime): stamp a runtime's own project setups as local, and report remote status about the remote (STA-4792) - #15376
Conversation
…rt remote status about the remote (STA-4792) Two independent frame-of-reference bugs, both from code describing one machine while labelled as another. #15366 — projectHostSetup.* persisted the caller's host id verbatim. Those `runtime:<environment-id>` ids are minted by the calling client's own pairing store, so they name a machine only relative to that client. A client sending one is addressing this runtime, and runtimes do not proxy these calls onward, so the host it names is us. Storing the client's spelling made one machine look like a different host to every other client, hid its rows from them, and defeated the (projectId, hostId) duplicate check — two laptops paired to one server each created their own setup for the same checkout. Re-spell it as `local` at the RPC boundary. Rows written earlier keep their old stamp; readers already project `local` back to `runtime:<their-id>`, so the client-visible model is unchanged and no ids are rewritten. STA-4792 defect 4 — `status --environment <name>` hardcoded app.running:false to mean "no desktop on THIS machine" while every other field in the same object described the target, including a desktopWindowStatus echoed straight from it. The result contradicted itself and read as "that run was headless" when the remote GUI was up. `app` now describes the target, keyed off the one window status that requires a live renderer, and the result names its own subject so the frame can't be misread again. The remote pid is not knowable, so it stays null. STA-4792 defect 2 gets a regression test rather than a fix: routing already made the client remote, which is what stops a Windows destination being joined to the local cwd. The test pins the exact reported invocation.
📝 WalkthroughWalkthroughCLI status responses now identify local or environment targets. Remote app status uses desktop window availability and reports unknown process IDs as 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/runtime/rpc/methods/project-runtime-rpc-methods.ts (1)
18-25: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten the rationale comments to one concise sentence at each site, keeping only the non-obvious persistence or status contract; place historical compatibility details in tests or design documentation.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9966fc78-6895-4c84-a142-9ae1346e4386
📒 Files selected for processing (9)
src/cli/format.tssrc/cli/index-project-setup.test.tssrc/cli/runtime-client.test.tssrc/cli/runtime/client.tssrc/cli/runtime/status.test.tssrc/cli/runtime/status.tssrc/main/runtime/rpc/methods/project-host-setup-self-host-stamp.test.tssrc/main/runtime/rpc/methods/project-runtime-rpc-methods.tssrc/shared/runtime-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
…rough, and name the version gap on project host setup Two review follow-ups. The SSH host passthrough answered `app.running: true` unconditionally for the Orca host a caller reached over SSH, claiming a desktop app even for a headless `serve`. That is the same defect as the paired-server path, one transport over, so the projection moved to shared and both now answer the question the same way. `--host runtime:<id>` routes project commands to a paired server, which means a client can reach a server that predates project host setup without meaning to. That answered a raw `method_not_found`, which reads as an Orca bug rather than a version gap; the CLI now names it the way the desktop already does. Reverted a third change: making the persistence duplicate check treat `local` and `runtime:*` as one machine. That assumption holds at the RPC boundary, where a `runtime:` host means the runtime being addressed, but not in the store, which also records independent provisioning metadata for machines that are not itself. An existing test covers exactly that, and it was right. The duplicate convergence therefore stays bounded to rows written after the normalization.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/shared/cli-app-status-projection.ts (1)
9-10: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the new status-projection comments. The changed comments repeat implementation history and defect context. Keep only the non-obvious compatibility rule at each call site.
src/shared/cli-app-status-projection.ts#L9-L10: reduce the legacyauthoritativeWindowIdexplanation to one brief compatibility comment.src/shared/cli-app-status-projection.ts#L16-L21: reduce the remote target and unavailable-PID explanation to one brief contract comment.src/main/ssh/ssh-remote-orca-cli.ts#L176-L179: reduce the SSH transport explanation to one brief statement about using the shared projection.As per coding guidelines:
**/*.{ts,tsx,js,jsx}comments must be concise, non-obvious, and brief; prefer one line.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 7575a400-0b96-4902-9879-e8ac476564b4
📒 Files selected for processing (14)
src/cli/handlers/project.tssrc/cli/index-project-setup.test.tssrc/cli/runtime/status.test.tssrc/cli/runtime/status.tssrc/cli/worktree-project-target.tssrc/main/__fixtures__/shell-wrapper-snapshots/README.mdsrc/main/codex/codex-trust-grant-host.test.tssrc/main/local-worktree-filesystem-wsl-banner.wsl.test.tssrc/main/local-worktree-filesystem.test.tssrc/main/providers/local-pty-provider-windows-shell-launch.test.tssrc/main/ssh/ssh-remote-orca-cli.tssrc/shared/cli-app-status-projection.tssrc/shared/wsl-exec-mode-separator.test.tssrc/shared/wsl-login-shell-command.test.ts
💤 Files with no reviewable changes (1)
- src/main/codex/codex-trust-grant-host.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
…rt remote status about the remote (STA-4792) (stablyai#15376) * fix(runtime): stamp a runtime's own project setups as local, and report remote status about the remote (STA-4792) Two independent frame-of-reference bugs, both from code describing one machine while labelled as another. stablyai#15366 — projectHostSetup.* persisted the caller's host id verbatim. Those `runtime:<environment-id>` ids are minted by the calling client's own pairing store, so they name a machine only relative to that client. A client sending one is addressing this runtime, and runtimes do not proxy these calls onward, so the host it names is us. Storing the client's spelling made one machine look like a different host to every other client, hid its rows from them, and defeated the (projectId, hostId) duplicate check — two laptops paired to one server each created their own setup for the same checkout. Re-spell it as `local` at the RPC boundary. Rows written earlier keep their old stamp; readers already project `local` back to `runtime:<their-id>`, so the client-visible model is unchanged and no ids are rewritten. STA-4792 defect 4 — `status --environment <name>` hardcoded app.running:false to mean "no desktop on THIS machine" while every other field in the same object described the target, including a desktopWindowStatus echoed straight from it. The result contradicted itself and read as "that run was headless" when the remote GUI was up. `app` now describes the target, keyed off the one window status that requires a live renderer, and the result names its own subject so the frame can't be misread again. The remote pid is not knowable, so it stays null. STA-4792 defect 2 gets a regression test rather than a fix: routing already made the client remote, which is what stops a Windows destination being joined to the local cwd. The test pins the exact reported invocation. * fix(status): share the remote app projection with the SSH host passthrough, and name the version gap on project host setup Two review follow-ups. The SSH host passthrough answered `app.running: true` unconditionally for the Orca host a caller reached over SSH, claiming a desktop app even for a headless `serve`. That is the same defect as the paired-server path, one transport over, so the projection moved to shared and both now answer the question the same way. `--host runtime:<id>` routes project commands to a paired server, which means a client can reach a server that predates project host setup without meaning to. That answered a raw `method_not_found`, which reads as an Orca bug rather than a version gap; the CLI now names it the way the desktop already does. Reverted a third change: making the persistence duplicate check treat `local` and `runtime:*` as one machine. That assumption holds at the RPC boundary, where a `runtime:` host means the runtime being addressed, but not in the store, which also records independent provisioning metadata for machines that are not itself. An existing test covers exactly that, and it was right. The duplicate convergence therefore stays bounded to rows written after the normalization.
…rt remote status about the remote (STA-4792) (stablyai#15376) * fix(runtime): stamp a runtime's own project setups as local, and report remote status about the remote (STA-4792) Two independent frame-of-reference bugs, both from code describing one machine while labelled as another. stablyai#15366 — projectHostSetup.* persisted the caller's host id verbatim. Those `runtime:<environment-id>` ids are minted by the calling client's own pairing store, so they name a machine only relative to that client. A client sending one is addressing this runtime, and runtimes do not proxy these calls onward, so the host it names is us. Storing the client's spelling made one machine look like a different host to every other client, hid its rows from them, and defeated the (projectId, hostId) duplicate check — two laptops paired to one server each created their own setup for the same checkout. Re-spell it as `local` at the RPC boundary. Rows written earlier keep their old stamp; readers already project `local` back to `runtime:<their-id>`, so the client-visible model is unchanged and no ids are rewritten. STA-4792 defect 4 — `status --environment <name>` hardcoded app.running:false to mean "no desktop on THIS machine" while every other field in the same object described the target, including a desktopWindowStatus echoed straight from it. The result contradicted itself and read as "that run was headless" when the remote GUI was up. `app` now describes the target, keyed off the one window status that requires a live renderer, and the result names its own subject so the frame can't be misread again. The remote pid is not knowable, so it stays null. STA-4792 defect 2 gets a regression test rather than a fix: routing already made the client remote, which is what stops a Windows destination being joined to the local cwd. The test pins the exact reported invocation. * fix(status): share the remote app projection with the SSH host passthrough, and name the version gap on project host setup Two review follow-ups. The SSH host passthrough answered `app.running: true` unconditionally for the Orca host a caller reached over SSH, claiming a desktop app even for a headless `serve`. That is the same defect as the paired-server path, one transport over, so the projection moved to shared and both now answer the question the same way. `--host runtime:<id>` routes project commands to a paired server, which means a client can reach a server that predates project host setup without meaning to. That answered a raw `method_not_found`, which reads as an Orca bug rather than a version gap; the CLI now names it the way the desktop already does. Reverted a third change: making the persistence duplicate check treat `local` and `runtime:*` as one machine. That assumption holds at the RPC boundary, where a `runtime:` host means the runtime being addressed, but not in the store, which also records independent provisioning metadata for machines that are not itself. An existing test covers exactly that, and it was right. The duplicate convergence therefore stays bounded to rows written after the normalization.
…rt remote status about the remote (STA-4792) (stablyai#15376) * fix(runtime): stamp a runtime's own project setups as local, and report remote status about the remote (STA-4792) Two independent frame-of-reference bugs, both from code describing one machine while labelled as another. stablyai#15366 — projectHostSetup.* persisted the caller's host id verbatim. Those `runtime:<environment-id>` ids are minted by the calling client's own pairing store, so they name a machine only relative to that client. A client sending one is addressing this runtime, and runtimes do not proxy these calls onward, so the host it names is us. Storing the client's spelling made one machine look like a different host to every other client, hid its rows from them, and defeated the (projectId, hostId) duplicate check — two laptops paired to one server each created their own setup for the same checkout. Re-spell it as `local` at the RPC boundary. Rows written earlier keep their old stamp; readers already project `local` back to `runtime:<their-id>`, so the client-visible model is unchanged and no ids are rewritten. STA-4792 defect 4 — `status --environment <name>` hardcoded app.running:false to mean "no desktop on THIS machine" while every other field in the same object described the target, including a desktopWindowStatus echoed straight from it. The result contradicted itself and read as "that run was headless" when the remote GUI was up. `app` now describes the target, keyed off the one window status that requires a live renderer, and the result names its own subject so the frame can't be misread again. The remote pid is not knowable, so it stays null. STA-4792 defect 2 gets a regression test rather than a fix: routing already made the client remote, which is what stops a Windows destination being joined to the local cwd. The test pins the exact reported invocation. * fix(status): share the remote app projection with the SSH host passthrough, and name the version gap on project host setup Two review follow-ups. The SSH host passthrough answered `app.running: true` unconditionally for the Orca host a caller reached over SSH, claiming a desktop app even for a headless `serve`. That is the same defect as the paired-server path, one transport over, so the projection moved to shared and both now answer the question the same way. `--host runtime:<id>` routes project commands to a paired server, which means a client can reach a server that predates project host setup without meaning to. That answered a raw `method_not_found`, which reads as an Orca bug rather than a version gap; the CLI now names it the way the desktop already does. Reverted a third change: making the persistence duplicate check treat `local` and `runtime:*` as one machine. That assumption holds at the RPC boundary, where a `runtime:` host means the runtime being addressed, but not in the store, which also records independent provisioning metadata for machines that are not itself. An existing test covers exactly that, and it was right. The duplicate convergence therefore stays bounded to rows written after the normalization.
…s local A client's runtime:<id> is its own name for the server it calls. #15376 re-spells it as local at the projectHostSetup RPC boundary; the test that pinned this was removed in #39604. Send the reported setup-existing-folder request through the real dispatcher and setup controllers and assert the server stores its folder as local.
…s local A client's runtime:<id> is its own name for the server it calls. #15376 re-spells it as local at the projectHostSetup RPC boundary; the test that pinned this was removed in #39604. Send the reported setup-existing-folder request through the real dispatcher and setup controllers and assert the server stores its folder as local.
…s local A client's runtime:<id> is its own name for the server it calls. #15376 re-spells it as local at the projectHostSetup RPC boundary; the test that pinned this was removed in #39604. Send the reported setup-existing-folder request through the real dispatcher and setup controllers and assert the server stores its folder as local.
…s local A client's runtime:<id> is its own name for the server it calls. #15376 re-spells it as local at the projectHostSetup RPC boundary; the test that pinned this was removed in #39604. Send the reported setup-existing-folder request through the real dispatcher and setup controllers and assert the server stores its folder as local.
ELI5
Two bugs, and here is exactly when you hit each one.
Bug 1 — the server stores your laptop's private nickname for itself
When you pair with a remote Orca server, your machine invents a random id for it (
randomUUID(),runtime-environment-store.ts:70). That id only means anything on your machine. When you then set a project up on that server, the server wrote your random id into its own records as the name of the machine the project lives on.You hit this when:
orca environment rm awinand add it back — after a reinstall, a rotated pairing code, or moving machines — mints a fresh random id. The server's existing rows still carry the old one. Ask it what's set up and your own projects look absent, so you set them up again and end up with two entries pointing at the same folder on disk.The symptom is
Project is not set up on the selected hostfor a project that is plainly checked out there — or two setups for one directory.Fix: the server now records its own machine as
local. Clients already translate that back to their own name for it on read, so nothing looks different — they just finally agree.Bug 2 — asking about a remote server answered about your laptop
You hit this when you run something on a paired machine and then check whether its GUI was up:
running: falsedescribed your laptop having no local Orca. Every other field describedawin. So the same object says "no app" and "a desktop window is available" at once. On this ticket that reading cost real work: a UI test run was written off as headless and nearly discarded, while the window was up the whole time.Fix:
appnow describes whichever machine you asked about, and the result says which machine that is.What Changed
1. A runtime stamps its own project setups
local(#15366)projectHostSetup.setupExistingFolder/clone/createpersisted the caller'shostIdverbatim. Thoseruntime:<environment-id>values are minted by the calling client's own pairing store (addEnvironmentFromPairingCode→randomUUID()), so they name a machine only relative to that client.The request reached this runtime and runtimes do not proxy these calls onward, so the host it names is us. Re-spelled as
localat the RPC boundary (RequestedHostId).ssh:hosts are untouched — those genuinely are a different machine from the runtime handling the call. Onlyruntime:means "you".2.
status --environment <name>reports on the environment (STA-4792 defect 4)The remote branch of
getCliStatushardcodedapp.running: false, pid: null, meaning "this client machine has no local desktop process" — whileruntime.*,graph.*anddesktopWindowStatusin the same object all described the target.appnow describes the target, via a namedprojectRemoteAppStatus.availableis the only desktop-window status that requires a live renderer owning the graph, so it's the signal separating a real desktop from a headlessserve. Remote pid isn't knowable fromstatus.get, so it staysnull.CliStatusResultalso gained an optionaltarget, so the output names its own subject and human output printstarget: environment <name>.3. Regression test for STA-4792 defect 2
Not a fix — #15364's routing already resolved it, because a routed client is remote and
resolveRepoPathArgumentthen passesC:\...through instead ofresolve(cwd, ...)-ing it into a literal local directory. The test pins the exact reported invocation.Why
Both are the same bug shape: a value that only means something relative to the observer, stored or reported as if it were absolute.
For the stamp, the alternative was to keep widening the reader (the CLI already carries a compensating
local⇔runtime:<id>match from #15364). That doesn't converge — a blanket "anyruntime:*means me" is wrong for a server that is itself paired onward, and it can't fix the duplicate-row problem, which is a write-side check. Fixing the write is the narrower and more correct move.Two premises I verified before choosing it, both load-bearing:
runtime:hosts outright ("Runtime hosts must be set up through the runtime projectHostSetup.setupExistingFolder RPC",src/main/ipc/repos.ts). So aruntime:*row can only arrive from a paired client addressing this runtime — it never denotes a third machine.${projectId}::${hostId}). Backfilling old rows would rewrite their ids and every reference to them, which is why this deliberately does not migrate.Linked Issue
Fixes #15366. Addresses defects 2 and 4 of STA-4792 (defect 1 shipped in #15364; defect 3,
terminal read, is separate and not in this PR).Visual Proof
N/A — CLI/runtime behavior, no UI surface.
Reported before, on
--environment awin status --json:self-contradictory, and it led to discarding a valid GUI test run as headless. After:
running: truewithtarget: {kind: "environment", environment: "awin"}.Testing
pnpm exec vitest run src/cli src/main/runtime/rpc— 257 files / 2339 tests pass.pnpm run typecheck(node + cli + web) andoxlintbase/native/type-aware — clean.New
project-host-setup-self-host-stamp.test.ts: all three creating methods map a callerruntime:id tolocal, leavelocalalone, preservessh:, still reject unparseable ids, and two different client ids now converge on one host id.New
projectRemoteAppStatustests:available→ running, each ofopenable/initializing/blocked→ not running, absent status (headless serve) → not running,authoritativeWindowIdfallback honored for old runtimes, pid always null.Platform: macOS. No platform-specific paths; the defect-2 test uses Windows-shaped paths explicitly.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Worth a look:
runtime:<A>row plus a freshlocalwrite from B still produces two rows for one checkout. Backfilling would fix that but means rewriting setup ids, since ids embed the host id. If you'd rather clean the data, that's a separate change.availableas the proxy for "desktop app running". On macOS an app with all windows closed reportsopenable, so this will sayrunning: falsefor it. I judged that better than the previous unconditionalfalse, and it directly answers the question that cost time here ("did this run exercise the renderer?"). Open to a stricter signal if one exists.src/main/ssh/ssh-remote-orca-cli.ts) hardcodes the opposite,app.running: true, regardless of whether a window exists. Same defect class, different transport, and the resolver lives insrc/cliso sharing it means moving it. Happy to do it here or separately.Agent skill upstream boundary
N/A — no skill content changed.
Review follow-ups (readiness pass)
Fixed here:
ssh-remote-orca-cli.tsansweredapp.running: trueunconditionally for the Orca host reached over SSH, claiming a desktop app even for a headlessserve— the same defect as defect 4, one transport over. The projection moved tosrc/shared/cli-app-status-projection.tsand both transports now share it.method_not_foundon project host setup. Since--host runtime:<id>routes these commands to a paired server, a client can reach a server that predates project host setup without meaning to. That surfaced the dispatcher'sUnknown method: projectHostSetup.list, which reads as an Orca bug; the CLI now names the version gap the way the desktop already does. This closes the capability-gate gap noted in review without an extra preflight round trip.Attempted and reverted, deliberately: making the persistence duplicate check treat
localandruntime:*as one machine, so a legacy client-minted row would block a duplicate. The self-host assumption is sound at the RPC boundary — aruntime:host there names the runtime being addressed — but false in the store, which also records independent provisioning metadata for machines that are not itself. An existing test (creates independent project host setup records for provisioning flows) covers exactly that case and failed, correctly. Duplicate convergence therefore stays bounded to rows written after the normalization, as described above.