Repository navigation
fix(ssh): decide remote-vs-local from the resolved execution host, not a raw field - #18294
Conversation
…t a raw field `repoIsRemote` read `repo.connectionId` directly. That is one of four spellings of host ownership, so the predicate was wrong in both directions: a row carrying only `executionHostId: 'ssh:<target>'` read as local and got the Linux-only `orca-ide` rename it cannot resolve through the relay shim, while a row that declares itself `local` with a stale `connectionId` read as remote and lost the rename it needs on a Linux desktop. The predicate now resolves the host first and asks "does an SSH target hold this row's files" via `getRepoSshConnectionId`. That keeps a `runtime:` host's nested SSH target remote (that machine reaches the files through its own relay shim) while a runtime with no nested target - a full Orca install - stays local, as do WSL and local. Its call sites did not all want that question: - The four launch-scope sites in main already hold the resolved PTY route on `TerminalWorkspaceLaunchScope.connectionId`. `scope.repo` is documented display metadata and can be a row from a different host than the worktree names, so they now read the route they will actually spawn on. A launch shape that disagrees with its own route is the bug, not a second predicate. - `launchAgentInNewTab` picked its repo row with a host-blind `store.repos.find`, so a worktree that names its own host could be shaped by another host's row. It now resolves through `getConnectionIdFromState`, the same rule the file already used for transcript readability. - `resolveAgentBackgroundLaunchHost` derived the route, the trust write and the launch shape from three reads of the raw field; one resolution now feeds all three. Also converts the raw `repo.connectionId` agent-detection probe eight lines above `buildWorktreeStartupForDraft`'s launch shape, which #17919 deferred precisely because converting it alone would have left that file internally inconsistent. Tests cover two distinct SSH hosts (a single-host fixture passes even when the answer comes off the wrong row, which is how the `ssh:m4air` -> openclaw leak survived review) and a `runtime:` host carrying a nested SSH target.
|
📝 WalkthroughWalkthroughAgent launch routing now uses resolved execution-host metadata. Runtime session and terminal flows derive remote status from the workspace connection ID. Startup detection and renderer launch-host resolution use Merge Risk: 🟡 Moderate · up to Remote-versus-local routing now follows the resolved execution host, but two launch paths still choose the shell platform from potentially stale or foreign repository metadata. Cross-platform workspaces could therefore receive commands quoted for the wrong shell, causing failed or unsafe agent launches; this should be fixed or explicitly accepted before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the defect, implementation, scope, and tests in detail, but it omits most required template sections, including ELI5, What Changed, Why, Linked Issue with a Fixes reference, Visual Proof or N/A, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the final Checklist. Resolution Reformat the description to include every required template section. Add the linked issue in the required
✨ 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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 571e7ac8-54bd-401a-8b50-5a1d3929f0db
📒 Files selected for processing (13)
src/main/runtime/orca-runtime-agent-session-operation.test.tssrc/main/runtime/orca-runtime-create-agent-session.tssrc/main/runtime/orca-runtime-get-agent-session-execution-namespace.tssrc/main/runtime/orca-runtime-resolve-mobile-session-terminal-command.tssrc/main/runtime/orca-runtime-resolve-worktree-removal-target.tssrc/main/runtime/runtime-worktree-agent-startup.test.tssrc/main/runtime/runtime-worktree-agent-startup.tssrc/renderer/src/lib/agent-background-session-launch-host.test.tssrc/renderer/src/lib/agent-background-session-launch-host.tssrc/renderer/src/lib/launch-agent-in-new-tab-host-resolution.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/shared/agent-launch-remote.test.tssrc/shared/agent-launch-remote.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| platform: getAgentLaunchPlatformForRepo( | ||
| repo, | ||
| repo.connectionId ? undefined : getLocalProjectExecutionRuntimeContext(store, worktreeId) | ||
| sshConnectionId ? undefined : getLocalProjectExecutionRuntimeContext(store, worktreeId) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Use resolved host metadata for platform selection.
getAgentLaunchPlatformForRepo reads repo.connectionId. Both call sites pass raw repository metadata after resolving the worktree host. A local worktree with a stale or rival SSH row therefore bypasses local Windows runtime resolution and can use the wrong platform.
src/renderer/src/lib/agent-background-session-launch-host.ts#L51-L53: pass{ connectionId: sshConnectionId, path: worktreePath ?? repo.path }togetAgentLaunchPlatformForRepo.src/renderer/src/lib/launch-agent-in-new-tab.ts#L106-L110: pass the resolved connection ID and selected worktree path instead of the host-blind repository row.
Add Windows coverage for a local worktree with a stale or rival SSH row and a WSL runtime preference.
📍 Affects 2 files
src/renderer/src/lib/agent-background-session-launch-host.ts#L51-L53(this comment)src/renderer/src/lib/launch-agent-in-new-tab.ts#L106-L110
Conflict in runtime-worktree-agent-startup.test.ts: main added host-resolution and draft-detection suites (stablyai#18294) while this branch rewrote the markLocalWorktreeTrusted describe onto the consolidated dispatch. Took main's file whole and re-applied only the dispatch change — the module mock now provides applyLocalAgentTrustPreset delegating to the per-preset mocks, so main's await and rejection tests keep asserting through markCodexProjectTrusted unchanged, plus the claude and no-preset cases from this branch.
…t a raw field (stablyai#18294) `repoIsRemote` read `repo.connectionId` directly. That is one of four spellings of host ownership, so the predicate was wrong in both directions: a row carrying only `executionHostId: 'ssh:<target>'` read as local and got the Linux-only `orca-ide` rename it cannot resolve through the relay shim, while a row that declares itself `local` with a stale `connectionId` read as remote and lost the rename it needs on a Linux desktop. The predicate now resolves the host first and asks "does an SSH target hold this row's files" via `getRepoSshConnectionId`. That keeps a `runtime:` host's nested SSH target remote (that machine reaches the files through its own relay shim) while a runtime with no nested target - a full Orca install - stays local, as do WSL and local. Its call sites did not all want that question: - The four launch-scope sites in main already hold the resolved PTY route on `TerminalWorkspaceLaunchScope.connectionId`. `scope.repo` is documented display metadata and can be a row from a different host than the worktree names, so they now read the route they will actually spawn on. A launch shape that disagrees with its own route is the bug, not a second predicate. - `launchAgentInNewTab` picked its repo row with a host-blind `store.repos.find`, so a worktree that names its own host could be shaped by another host's row. It now resolves through `getConnectionIdFromState`, the same rule the file already used for transcript readability. - `resolveAgentBackgroundLaunchHost` derived the route, the trust write and the launch shape from three reads of the raw field; one resolution now feeds all three. Also converts the raw `repo.connectionId` agent-detection probe eight lines above `buildWorktreeStartupForDraft`'s launch shape, which stablyai#17919 deferred precisely because converting it alone would have left that file internally inconsistent. Tests cover two distinct SSH hosts (a single-host fixture passes even when the answer comes off the wrong row, which is how the `ssh:m4air` -> openclaw leak survived review) and a `runtime:` host carrying a nested SSH target.

The defect
repoIsRemotedecided remote-vs-local from a rawrepo.connectionIdread. That field is one of four spellings of host ownership (Repo.connectionId,Repo.executionHostId,Worktree.hostId, andFolderWorkspace's pair), so the predicate was wrong in both directions:executionHostId: 'ssh:<target>'read as local and got the Linux-onlyorca-iderename, which does not exist on a PATH served by the relay shim;localwhile a staleconnectionIdsurvives read as remote and lost the rename it needs on a Linux desktop.Same host-blind class as #17909 / #17919; deliberately deferred out of #17919 because converting
runtime-worktree-agent-startup.ts's detection probe alone would have left that file internally inconsistent — agent detection resolved on the host, launch shape still saying local.Which question the predicate answers
The two questions #17909/#17919 settled are different, and
repoIsRemotewants the first one — "which SSH target holds this row's files", i.e.getRepoSshConnectionId:repoIsRemotessh:xxxruntime:env+ nested SSHnullruntime:env, no nested targetnullnulllocal+ stale fieldnullnulllocaland WSL stay false, as before.Not every call site wanted that question
Three of the nine sites did not, and the honest answer was to stop calling the predicate there rather than to make it subtly wrong:
TerminalWorkspaceLaunchScope.connectionId.scope.repois documented display metadata (resolution.repo ?? getRepo(...)) and can be a row from a different host than the worktree names. They now read the route they will actually spawn on — a launch shape that disagrees with its own route is the bug, not a second predicate.launchAgentInNewTabpicked its repo row with a host-blindstore.repos.find, so a worktree naming its own host could be shaped by another host's row. It now resolves throughgetConnectionIdFromState— the same rule the file already used for transcript readability, and the renderer half of the shared resolver.resolveAgentBackgroundLaunchHostderived the route, the trust write and the launch shape from three separate raw reads. One resolution now feeds all three.No new resolver: everything goes through
getRepoSshConnectionId/getConnectionIdFromState/ the already-resolved scope connection.Call-site table
runtime-worktree-agent-startup.tsbuildWorktreeStartupForDraftdetection probe (raw field)ssh:*-only rows now probe the host; contradictory-local rows now probe this clientruntime-worktree-agent-startup.ts:72launch shaperuntime-worktree-agent-startup.ts:139launch shapeorca-runtime-create-agent-session.tsscope.repoorca-runtime-resolve-worktree-removal-target.ts(resolveAgentTerminalCreateOptions)orca-runtime-get-agent-session-execution-namespace.tsorca-runtime-resolve-mobile-session-terminal-command.ts(both calls)runtime-target-selection.ts:152selectedRepois already host-resolved byresolveWorkspaceCreationTargetlaunch-agent-in-new-tab.ts:108Every site changes for at least one row shape; ordinary
ssh:<target>+ matchingconnectionIdrows and plain local rows are unaffected.Tests
src/shared/agent-launch-remote.test.ts— both spellings on two different SSH hosts (m4air,openclaw), contradictory-local,runtime:with and without a nested SSH target.src/main/runtime/runtime-worktree-agent-startup.test.ts— launched CLI name per host shape, plus detection routing toopenclawfor anexecutionHostId-only row and to this client for a contradictory-local row.src/renderer/src/lib/launch-agent-in-new-tab-host-resolution.test.ts— rival rows on two SSH hosts; the launch follows the worktree's host, including theruntime:+ nested-SSH pair.src/renderer/src/lib/agent-background-session-launch-host.test.ts— two SSH hosts routed distinctly, contradictory-local kept off the SSH route, runtime-nested kept remote.src/main/runtime/orca-runtime-agent-session-operation.test.ts— a locally-routed scope carrying anopenclawrepo row now emits the local CLI name.Out of scope (host-keyed dispatch, happening in parallel)
getAgentLaunchPlatformForRepostill readsrepo.connectionIdraw, so the platform half of a launch is still resolved off a row rather than a host. That is the host-keyed dispatch work, not a second copy of this fix; the predicate change does not depend on it.