Repository navigation
fix(worktrees): resolve the execution host at both worktree-create entry points - #18545
Conversation
…try points Two entry points create the same workspace and disagreed about how to read its host. `orca-runtime-create-managed-worktree.ts:63` resolved through `getRepoSshConnectionId` and then normalized the row; the `worktrees:create` IPC handler branched on raw `repo.connectionId` (`register-worktree-create-handlers.ts:66-69`). So a repo naming its owner only as `executionHostId: 'ssh:<target>'` created remotely through the runtime and ran `git worktree add` on the client against a remote path through IPC (#11163). Same repo, two entry points, different answers. Both now take one route, resolved through the existing layer (`getRepoExecutionHostId` -> #18296's `resolveGitRouteForHost`). No new resolver. The row normalization on the `ssh` variant is kept, and it is a **workaround, not the pattern**. `createRemoteWorktree` and its callees re-read `repo.connectionId!` at five depths in `ipc/worktree-remote.ts` (1627, 1847, 1848, 1865, 2029), so the resolved connection has to reach them through the field they already read. It travels only as far as that object does — anything downstream that re-reads the row from the store still sees the unnormalized one, and it cannot express the `runtime:` refusal on its own. Proper fix, deliberately not done here: give that pipeline an explicit connection parameter and delete `repo.connectionId!` from it so every reader becomes a compile error, the technique #18307/#18325 used. That is a change inside a 2800-line module plus its callers, and it wants its own PR. Three answers that used to collapse into one, now distinct at both entry points: - `executionHostId: 'ssh:*'` with no `connectionId` -> that SSH host (IPC used to create locally); - `executionHostId: 'local'` with a surviving `connectionId` -> local, since a local row cannot nest an SSH namespace. This is what `getRepoSshConnectionId` and therefore the runtime sibling already answered; IPC used to go remote; - `runtime:<env>` -> refused. Its worktree is created by that environment's own server and the SSH target on its repo row is that server's nested one, addressable only as (environmentId, targetId). The renderer already routes runtime-environment creates over `worktree.create` RPC rather than this IPC channel, so reaching either entry point with one is a routing mistake. Matches `workspace-cleanup-git-route` and `runtime-git-command-target`. Folder-workspace creation is untouched on both sides: it is a registration, not a filesystem create, so the route is resolved after that branch on the IPC side, and on the runtime side only the agent trust write consumes it — where a `runtime:` host now yields `null` instead of the nested target, so the write stops going to a same-named target in this client's table. No wire or persistence change: the normalized row is a local value passed to the create pipeline, never stored, and `CreateWorktreeResult` is untouched.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughWorktree creation now resolves execution hosts through one shared route model. IPC and runtime creation paths dispatch local and SSH worktrees from the resolved route. Runtime-host rows raise Merge Risk: ⚪ Minimal · up to Worktree creation now consistently selects the configured execution host and avoids dispatching runtime-owned repositories through local or unrelated SSH providers. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed coverage of the change, rationale, linked issue Resolution Use the repository template headings and complete the missing required sections. Add an explicit issue entry such as "Fixes
✨ 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 |
|
Note on the red Those keys come from Everything else is green: all 8 test shards, typecheck, package, package (windows). |
…try points (stablyai#18545) Two entry points create the same workspace and disagreed about how to read its host. `orca-runtime-create-managed-worktree.ts:63` resolved through `getRepoSshConnectionId` and then normalized the row; the `worktrees:create` IPC handler branched on raw `repo.connectionId` (`register-worktree-create-handlers.ts:66-69`). So a repo naming its owner only as `executionHostId: 'ssh:<target>'` created remotely through the runtime and ran `git worktree add` on the client against a remote path through IPC (stablyai#11163). Same repo, two entry points, different answers. Both now take one route, resolved through the existing layer (`getRepoExecutionHostId` -> stablyai#18296's `resolveGitRouteForHost`). No new resolver. The row normalization on the `ssh` variant is kept, and it is a **workaround, not the pattern**. `createRemoteWorktree` and its callees re-read `repo.connectionId!` at five depths in `ipc/worktree-remote.ts` (1627, 1847, 1848, 1865, 2029), so the resolved connection has to reach them through the field they already read. It travels only as far as that object does — anything downstream that re-reads the row from the store still sees the unnormalized one, and it cannot express the `runtime:` refusal on its own. Proper fix, deliberately not done here: give that pipeline an explicit connection parameter and delete `repo.connectionId!` from it so every reader becomes a compile error, the technique stablyai#18307/stablyai#18325 used. That is a change inside a 2800-line module plus its callers, and it wants its own PR. Three answers that used to collapse into one, now distinct at both entry points: - `executionHostId: 'ssh:*'` with no `connectionId` -> that SSH host (IPC used to create locally); - `executionHostId: 'local'` with a surviving `connectionId` -> local, since a local row cannot nest an SSH namespace. This is what `getRepoSshConnectionId` and therefore the runtime sibling already answered; IPC used to go remote; - `runtime:<env>` -> refused. Its worktree is created by that environment's own server and the SSH target on its repo row is that server's nested one, addressable only as (environmentId, targetId). The renderer already routes runtime-environment creates over `worktree.create` RPC rather than this IPC channel, so reaching either entry point with one is a routing mistake. Matches `workspace-cleanup-git-route` and `runtime-git-command-target`. Folder-workspace creation is untouched on both sides: it is a registration, not a filesystem create, so the route is resolved after that branch on the IPC side, and on the runtime side only the agent trust write consumes it — where a `runtime:` host now yields `null` instead of the nested target, so the write stops going to a same-named target in this client's table. No wire or persistence change: the normalized row is a local value passed to the create pipeline, never stored, and `CreateWorktreeResult` is untouched.

The mix
Two entry points create the same workspace and disagreed about how to read its host.
src/main/runtime/orca-runtime-create-managed-worktree.ts:63) resolved throughgetRepoSshConnectionId, then explicitly normalized the row at:101-104with a comment saying it does so because "the remote-create pipeline readsrepo.connectionId!at every depth."src/main/ipc/worktrees/create/register-worktree-create-handlers.ts:66-69) branchedcreateRemoteWorktreevscreateLocalWorktreeoff rawrepo.connectionId.So a repo naming its owner only as
executionHostId: 'ssh:<target>'created remotely through the runtime and rangit worktree addon the client, against a remote path through IPC (#11163). One sibling compensated for the pipeline's raw reads and the other didn't. Same repo, two entry points, different answers.Both now take one route, resolved through the existing layer (
getRepoExecutionHostId→ #18296'sresolveGitRouteForHost). No new resolver.Is the runtime path's normalization the right pattern? No — it's a workaround.
Verdict: workaround. Three reasons:
createRemoteWorktreeand its callees re-readrepo.connectionId!at five depths —ipc/worktree-remote.ts:1627, 1847, 1848, 1865, 2029. Handing them a normalized row only works because those reads exist.Repovalue that isn't in the store; anything downstream re-reading the row byrepo.idstill gets the unnormalized one. The compensation is invisible at the boundary where it stops holding.runtime:refusal.getRepoSshConnectionIddeliberately returns the nested target for aruntime:row (its own doc says callers routing a client-local Git provider wantgetSshTargetIdForExecutionHostinstead). Normalizing with it produces a row that says "dial this SSH target from this client" — the wrong-namespace bug feat(providers): dispatch git and filesystem providers by execution host #18296 names, traded for the silent-local one.This PR keeps the normalization (deleting it would break the remote-create pipeline outright) but moves it behind the shared route with the reason written down, and adds the refusal the raw form could not express.
What a proper fix takes, deliberately not done here: give
createRemoteWorktree,prefetchRemoteWorktreeCreateBaseand theregisterRequiredSshWorktreeCreateRootscall sites an explicitconnectionId(or route) parameter resolved once by the caller, then deleterepo.connectionId!fromworktree-remote.tsso every reader becomes a compile error — the #18307/#18325 technique. That is a change inside a 2800-line module plus its callers, and it wants its own PR rather than riding along here.Three answers that used to collapse into one
executionHostId: 'ssh:t', noconnectionIdgit worktree addon the client)executionHostId: 'local'+connectionId: 't'runtime:<env>(± nested target)runtime:is refused because the worktree is created by that environment's own server, and its repo row's SSH target is that server's nested one, addressable only as(environmentId, targetId). The renderer already routes runtime-environment creates overworktree.createRPC (store/slices/worktrees/create/create-worktree.ts—target.kind === 'local'picks the IPC channel, otherwisecallRuntimeRpc), so reaching either entry point with a runtime row is a routing mistake, not a fallback. Matchesworkspace-cleanup-git-routeandruntime-git-command-target.Folder workspaces are untouched
A folder workspace is a registration, not a filesystem create, so it is host-agnostic. On the IPC side the route is resolved inside the non-folder branch, so folder creation cannot start failing. On the runtime side only the agent trust write consumes the connection, and a
runtime:host now yieldsnullthere instead of the nested target — so the write stops going to a same-named target in this client's table.Wire / persistence
No change. The normalized row is a local value handed to the create pipeline and never stored;
CreateWorktreeResultand the create RPC params are untouched. Nothing new is published, so nothing here reaches an old client (docs/reference/remote-wire-compatibility.mdRule 3).Tests
7 failed-first, 7 pass after, plus 8 new unit cases on the route module (new module, so failed-first does not apply there).
src/main/ipc/worktrees-create-execution-host-routing.test.ts(5, all failed-first):executionHostId: 'ssh:target-a'-only row creates on that host, and the localaddWorktreeis never reachedssh:target-brow never touchestarget-a's providerruntime:with no nested target refuses, no local createruntime:with a nested target that is dialable here refuses, and that provider is untouchedlocal+connectionIdrow creates locally, matching the runtime siblingorca-runtime-tests/worktree-create-execution-host.spec.ts(2, failed-first): the runtime sibling refuses bothruntime:shapes.src/main/worktree-create-execution-host-route.test.ts(8): route-level coverage including two SSH hosts registered at once and bothruntime:shapes.Verification
pnpm tccleanpnpm test src/main/ipc— 3721 pass;src/main/ipc+src/main/runtime+ the route test — 10008 tests, only load-dependent flakes that also fail on the unmodified tree in the same scope and pass in isolation (pty-spawn-env-terminal-basics,automation-change-publication, different one each run)pnpm run check:code-quality:changed— 0 findingsnpx oxlint --deny-warningson all 6 changed files, exit 0