Repository navigation
fix(cli): worktree create sends the host --project/--host selected - #31066
Conversation
Codex review 6 #6: the CLI picked the right setup but sent only its repo id, so a repo id set up on two hosts failed as selector_ambiguous; and --project-host-setup ignored --host when setup ids repeated. worktree.create gains optional repoHostId (older hosts drop it and keep the old behaviour); the runtime narrows the repo selector to that host.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to
|
…ookup Review follow-up (Codex + Opus on #31066): a separate repoHostId was dropped by the startup-agent lookup, the CLI's GitLab link check and the create dedupe key. RuntimeRepoSelector now carries the host with the selector, so showRepo/resolveRepoSelector and startup-agent resolution keep it; the create dedupe key includes it; repo.show gains the same optional repoHostId; the CLI spreads one CliRepoTarget into every repo lookup. Handler-level tests cover worktree.create (plain, startupAgent, startupDraft), agent.launch, repo.show and the dedupe key.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2c7e2543-63e3-4f30-ae3f-679f20846bcb
⛔ Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing: 21
src/cli/handlers/worktree-gitlab-link-context.tssrc/cli/handlers/worktree.tssrc/cli/index-worktree-create-repo-host.test.tssrc/cli/index-worktree-create-target.test.tssrc/cli/worktree-project-target.tssrc/main/ipc/repos/repo-ipc-wsl-move-fence.test.tssrc/main/runtime/construction/runtime-construction-services.tssrc/main/runtime/construction/runtime-file-command-state.tssrc/main/runtime/rpc/methods/agent-launch-worktree-creation.tssrc/main/runtime/rpc/methods/agent-launch.tssrc/main/runtime/rpc/methods/repo.tssrc/main/runtime/rpc/methods/worktree-create-args.tssrc/main/runtime/rpc/methods/worktree.tssrc/main/runtime/runtime-managed-worktree-create-types.tssrc/main/runtime/runtime-repo-selector.tssrc/main/runtime/runtime-repository-settings-controller.tssrc/main/runtime/runtime-worktree-create-repo-host.test.tssrc/main/runtime/terminal/launch/terminal-create-deduplication.tssrc/main/runtime/workspaces/workspace-selectors.tssrc/shared/rpc-contract/github-repo-target-params.tssrc/shared/rpc-contract/worktree-create-params.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| export function worktreeCreateRepoSelector( | ||
| params: Pick<WorktreeCreateParams, 'repo' | 'repoHostId'> | ||
| ): RuntimeRepoSelector { | ||
| return hostQualifiedRepoSelector(params.repo, params.repoHostId) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C8 '\bresolvePairedCallerHostId\s*\(' --type=ts -g '!**/*.test.ts'
rg -nP -C5 "'projectHostSetup\.list'" --type=ts -g '!**/*.test.ts'
rg -nP -C3 'runtime:gpu' src/cli/index-worktree-create-target.test.tsRepository: stablyai/orca
Length of output: 14601
🏁 Script executed:
set -e
printf '%s\n' '--- paired-caller mapper ---'
nl -ba src/main/runtime/rpc/methods/paired-caller-host-id.ts
printf '%s\n' '--- project runtime RPC methods ---'
nl -ba src/main/runtime/rpc/methods/project-runtime-rpc-methods.ts | sed -n '1,70p'
printf '%s\n' '--- setup listing definitions/usages ---'
rg -n -F --glob '*.ts' -e 'listProjectHostSetups' -e 'listRepos()' -e 'getRepoExecutionHostId' src/main src/shared
printf '%s\n' '--- runtime setup/repo implementation blocks ---'
rg -n -C8 -F --glob '*.ts' 'listProjectHostSetups' src/main
printf '%s\n' '--- create selector and handlers ---'
nl -ba src/main/runtime/rpc/methods/worktree-create-args.ts
rg -n -C12 -F --glob '*.ts' -e "'worktree.create'" -e "'agent.launch'" -e "'repo.show'" src/main/runtime/rpc/methodsRepository: stablyai/orca
Length of output: 42626
🏁 Script executed:
set -e
printf '%s\n' '--- listProjectHostSetups declarations and callers ---'
rg -n -C12 -F --glob '*.ts' -e 'listProjectHostSetups' -e 'listSetups' src/main
printf '%s\n' '--- project host setup handler ---'
nl -ba src/main/ipc/repos/project-host-setup-handlers.ts | sed -n '1,115p'
printf '%s\n' '--- execution-host representation ---'
nl -ba src/shared/execution-host.ts | sed -n '200,310p'
printf '%s\n' '--- host-qualified selector ---'
rg -n -C12 -F --glob '*.ts' -e 'function hostQualifiedRepoSelector' -e 'const hostQualifiedRepoSelector' -e 'resolveRepoSelector' src/main src/shared
printf '%s\n' '--- runtime host-list RPC binding ---'
rg -n -C15 -F --glob '*.ts' -e "'host.listSetups'" -e 'host.listSetups' src/main src/sharedRepository: stablyai/orca
Length of output: 41996
🏁 Script executed:
set -e
printf '%s\n' '--- setup creation and storage ---'
rg -n -C10 -F --glob '*.ts' -e 'createProjectHostSetup' -e 'getProjectHostSetups' -e 'hostId: getRepoExecutionHostId' src/main src/shared
printf '%s\n' '--- selector implementation ---'
rg -n -C15 -F --glob '*.ts' -e 'function resolveRepoSelector' -e 'function hostQualifiedRepoSelector' -e 'type RuntimeRepoSelector' src/main src/shared
printf '%s\n' '--- affected RPC handlers ---'
rg -n -C20 -F --glob '*.ts' -e 'worktreeCreateRepoSelector' -e 'hostQualifiedRepoSelector(params.repo' -e 'repoHostId' src/main/runtime/rpc/methods
printf '%s\n' '--- deduplication key and create path ---'
rg -n -C15 -F --glob '*.ts' -e 'dedupeWorktreeCreate' -e 'clientMutationId' -e 'repoHostId' src/main/runtimeRepository: stablyai/orca
Length of output: 45663
🏁 Script executed:
set -e
printf '%s\n' '--- selector implementation ---'
rg -n -C10 -F --glob '*.ts' -e 'resolveRepoSelector(selector' -e 'hostQualifiedRepoSelector' src/main/runtime src/shared
printf '%s\n' '--- worktree create args and handler ---'
nl -ba src/main/runtime/rpc/methods/worktree-create-args.ts
rg -n -C18 -F --glob '*.ts' -e 'worktreeCreateRepoSelector' -e 'dedupeWorktreeCreate' src/main/runtime/rpc/methods src/main/runtime
printf '%s\n' '--- agent launch and repo show host-qualified calls ---'
rg -n -C18 -F --glob '*.ts' -e 'hostQualifiedRepoSelector(params.repo' -e 'repoHostId' src/main/runtime/rpc/methods/agent-launch.ts src/main/runtime/rpc/methods/repo.ts src/main/runtime/rpc/methods/worktree.tsRepository: stablyai/orca
Length of output: 45665
Translate paired host IDs before host filtering.
projectHostSetup.list can return local for a setup on the paired server, while the CLI sends runtime:<id>. The host-qualified selector then finds no repository because it compares the raw ID with getRepoExecutionHostId(repo), and the operation can fail with repo_not_found.
Use resolvePairedCallerHostId before building the selector in worktree.create, agent.launch create-worktree, and repo.show. Use the translated ID in the deduplication key as well.
ELI5
orca worktree create --project X --host localpicks the right copy of a project when it is set up on more than one machine. Then it sent the server only the project's id. If that id existed on two machines, the server couldn't tell which one was meant and refused withselector_ambiguous. The CLI now tells the server which machine it chose.What Changed
--project … --host …resolved the right setup, then sent onlyrepo: id:<repoId>. When the same repo id was set up on two hosts,worktree.createfailed withselector_ambiguous.--project-host-setup <id>ignored--host. When setup ids repeated across hosts, it took the first match.worktree.createandagent.launch(which reuses the same schema) accept a new optionalrepoHostId, and so doesrepo.show. The CLI builds oneCliRepoTarget({ repo, repoHostId? }) and spreads it into every call that looks the repo up: the GitLab-link check'srepo.show, and the create itself.RuntimeRepoSelector(src/main/runtime/runtime-repo-selector.ts) carries the host along with the selector.resolveRepoSelector,showRepoand the runtime create'srepoSelectorall take it. Every later lookup therefore keeps the caller's host, including the startup-agent and startup-draft resolution, and nothing can drop it by forgetting a second parameter. The create dedupe key includes the host.--project-host-setup: it now goes through the same host selection as--project. With--host, it picks that host's setup. Without it, when the id names setups on two hosts, it asks for--hostinstead of guessing. A miss names the host.Why
repoHostId, and a new host behaves exactly as before.hostId-beside-an-id pattern thatworktree.rmand the project IPC handlers use, rather than inventing a host-qualified selector string. An older host would reject a new selector string outright.Codex review 6, item #6.
Linked Issue
N/A (internal review finding: Codex review 6 #6).
Visual Proof
N/A. CLI and RPC routing only.
Testing
src/cli/index-worktree-create-repo-host.test.ts:--project --host localsendsrepoHostId.--project-host-setupid with--hostpicks that host; without--hostit asks.--repostays selector-only.repo.showcarries the host.--project-host-setupmiss names the host.src/main/runtime/runtime-worktree-create-repo-host.test.ts, at handler level through the realRpcDispatcherandOrcaRuntimeService:repo.showresolves the row on the named host, and a bare duplicate id is still refused.worktree.createkeeps the host as plain, withstartupAgent, and withstartupDraft.agent.launchcreate-worktree path keeps the host.main()and the real runtime selector.Review
gpt-6.1-sol, high), round 1: two P2s. The startup-agent lookup and the GitLab-linkrepo.showdropped the host.Agent skill upstream boundary
Notes
orca automation create --project … --host …) still persist a repo id without a host. That needs a stored-schema change, so it is out of scope here.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)