Skip to content

fix(projects): setup edits and removals name the host, so the twin on another host is never touched - #30664

Merged
nwparker merged 8 commits into
mainfrom
nwparker/r4-setup-update-host
Oct 19, 2026
Merged

nwparker merged 8 commits into
mainfrom
nwparker/r4-setup-update-host

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​153 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​142
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​200 $\color{#cf222e}{\Huge{\mathbf{−}}}$​77 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​123

ELI5

When a project is set up on two machines (say this computer and an SSH server), Orca keeps one "setup" record per machine. Both records use the project's id as their own id. Renaming or removing the setup only sent that id, so Orca edited whichever record it found first, which could be the wrong machine's copy. Now the request also names the machine whenever more than one record shares the id.

What Changed

  • Before: editing or removing the SSH copy of a project's setup (from the app, or with orca project setup-update / setup-delete) could rename or remove the copy on this computer instead. Removing it could unregister the local project.
  • After: only the named machine's setup changes. If the named machine has no such setup, nothing changes and the request reports not-found.

Mechanism:

  • ProjectHostSetupUpdateArgs and ProjectHostSetupDeleteArgs gain an optional hostId, in the types, the IPC schemas and the projectHostSetup.update / .delete RPC schemas. The RPC side normalizes it the way create already does, so runtime:* means the server itself.
  • One shared finder, findProjectHostSetup (src/shared/project-host-setup-target.ts), does an exact match on (id, host) when a host is named, and first-by-id when none is named. It replaces six first-match-by-id lookups:
    • the persistence update and delete;
    • the setup re-read after a repo-backed update;
    • the folder-to-git conversion;
    • the WSL-move write guard;
    • the runtime's unused-project check.
  • Update now finds the setup's repo on the setup's own host, as delete already did. A repo-backed setup with no matching repo row returns not-found instead of writing to a sibling host's row.
  • Renderer (prepareProjectHostSetupMutation):
    • For this computer's catalog, where every row carries its real host, the host goes on the wire when the caller names one or when another row shares the id.
    • A named host with no matching row is refused instead of falling back to a by-id request.
    • Merge and removal match on (id, host), so removing the SSH twin no longer drops the local row too.
  • The CLI's setup-update and setup-delete accept --host. On a server that does not advertise the new project-host-setup.host-target.v1 capability, --host is refused, because an older server would ignore it and act on the first twin.

Why

  • Wire compatibility: hostId is a new optional field. An older host's zod schema strips it and keeps today's first-match answer, so the CLI refuses --host there rather than letting the host guess. An older client omits it and gets today's behaviour.
  • Exact match only: an earlier revision tolerated host-spelling differences, but every tolerance could reinterpret one host's row as another's. Exact matching fails safe instead. A unique id still works without --host, because a request with no host keeps the by-id lookup.
  • Not in this PR: twins on a paired server. A paired server's setups all carry that server's single runtime: id on the client, and repo-derived fallback rows differ from the server's own answers. So the client can't reliably name a server's local-versus-SSH twin. Those requests stay by id, unchanged from main. The CLI's --host against an updated server does cover that case.
  • ref-oss check (after review round 3):
    • Mature remote-development tools sidestep mixed versions: they pin the server to the client's exact build, or refuse a protocol-version mismatch.
    • Orca has to run mixed versions, so the standard local answer is a negotiated capability before relying on a new field. Orca already does this elsewhere in the CLI (assertReferenceWritesSupported).
    • The approach changed accordingly: the capability gate was added, the spelling tolerances were dropped, and the paired-server twin case was scoped out.

Linked Issue

Found in review of #30616 (round 4 SSH hardening, R4-2 follow-up). No issue filed.

Visual Proof

N/A: no visual change.

Testing

  • Automated tests added/updated
  • persistence-duplicate-repo-id-host-scope.test.ts: delete and update with hostId for each twin, plus a hostId naming no twin. 3 of these fail on main.
  • project-host-setup-target.test.ts: the finder rules.
  • Renderer store:
    • a local/SSH twin removal drops only that row;
    • a named host the catalog lacks is refused;
    • the duplicate-id tests now pin "only its own row" (they used to pin "every collision").
  • CLI: --host is passed through, and refused on a server without the capability.
  • Local checks:
    • the full static job passed (0 fails);
    • pnpm tc passed;
    • the unit folders around every changed file passed.
  • Live: not verified on a real SSH host. The change is in id selection only, and it's covered at the store level.

Review

  • Codex (gpt-6.1-sol, high), 7 rounds; the final round is clean. Findings, all fixed:
    • an older paired server ignoring the new field (capability gate);
    • tolerance rules that could reinterpret a remote registration as local (dropped);
    • explicit SSH ids for removed targets (now passed through unresolved);
    • a stale catalog turning a named-host request into a by-id one (now refused);
    • ghost rows from fallback-versus-authoritative identity on paired servers (scoped out, see Why).
  • Dismissed (Codex P2): legacy setups that an older server stamped with a client's own runtime: id can't be targeted with --host. They still work without it, because independent setup ids are unique, so the result is a safe refusal and never a wrong edit.
  • Opus: no P1 or P2. Its P3 about a wrongly named host is resolved by exact matching.

Agent skill upstream boundary

  • Not applicable

Notes

Old/new combinations considered: old client with new host, new client with old host, the CLI against old and new servers, and the desktop IPC path. Folder projects use the same setup path.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A for screenshots (reason above)
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path impact considered
  • Lint, typecheck and the affected tests pass locally

…nother host is never touched

Repo-backed project host setups take the repo id, so a project on two hosts has
two setups with one id. Update and delete took the first match by id, so editing
or removing the SSH copy could rename or remove the local one. The args gain an
optional hostId (older peers strip it and keep the first match).
…rong twin; read legacy runtime stamps as local
…atalog; paired servers keep the by-id request
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fbec5735-2907-4e7a-9553-6f2f758147a7
📥 Commits

Reviewing files that changed from the base of the PR and between 07080b3 and c6e9715.

📒 Files selected for processing: 1
  • src/shared/protocol-version.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

Project setup update and delete operations now accept an optional host ID. The CLI checks runtime capability support before sending host-targeted requests. Renderer routing, IPC validation, runtime guards, and persistence use the host ID to distinguish setups that share an ID. Tests cover host-specific updates and deletes, unmatched hosts, and SSH setup cleanup.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to c6e97

A same-ID setup on another host can disappear from the renderer catalog when an existing-folder setup is registered. This is a localized setup-management regression; track the host-aware row merge as a follow-up.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description is complete for the change summary, rationale, testing, review notes, visual proof, compatibility considerations, and checklist. However, the required Linked Issue section states that … Link an existing issue in the Linked Issue section, for example by replacing the current text with Fixes #<issue-number> or another valid issue reference. If no issue exists, create one before merging.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: setup updates and removals now target the correct host.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete for the change summary, rationale, testing, review notes, visual proof, compatibility considerations, and checklist. However, the required Linked Issue section states that no issue was filed, while the template requires an actual linked issue.

Resolution

Link an existing issue in the Linked Issue section, for example by replacing the current text with Fixes #&lt;issue-number&gt; or another valid issue reference. If no issue exists, create one before merging.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Use upsertProjectHostSetup in… · project-host-setup-actions.ts:81-83

src/renderer/src/store/projects/project-host-setup-actions.ts:81-83
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use upsertProjectHostSetup in setupProjectExistingFolder as well.

This PR changes createProjectHostSetup (Line 129) and updateProjectHostSetup (Line 180) to use upsertProjectHostSetup. That helper matches rows by both id and hostId. setupProjectExistingFolder still matches rows by entry.id only.

Repo-backed setups use the repo ID as setup.id, so a setup on another host can have the same ID. Example: the catalog has a local setup, and the user then sets up the same repo ID on a runtime: host. The new runtime: row then overwrites the local row in projectHostSetups. The renderer catalog loses one setup until the next projection refresh. This is the twin collision that this PR fixes in the other paths. setupProjectClone also uses this code path.

🐛 Proposed fix
-          const nextSetups = s.projectHostSetups.some((entry) => entry.id === setup.id)
-            ? s.projectHostSetups.map((entry) => (entry.id === setup.id ? setup : entry))
-            : [...s.projectHostSetups, setup]
+          const nextSetups = upsertProjectHostSetup(s.projectHostSetups, setup)

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b48af34-0afd-49ec-9111-3dc8801023f9
📥 Commits

Reviewing files that changed from the base of the PR and between a451f47 and 07080b3.

📒 Files selected for processing: 23
  • src/cli/handlers/project.ts
  • src/cli/index-project-setup.test.ts
  • src/cli/root-help-text-secondary.ts
  • src/cli/specs/project.ts
  • src/main/folder-repo-git-conversion.ts
  • src/main/ipc/repos/project-host-setup-handlers.ts
  • src/main/ipc/repos/repo-ipc-arg-schemas.ts
  • src/main/persistence-duplicate-repo-id-host-scope.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts
  • src/main/persistence/tracking-repos/project-host-operations.ts
  • src/main/persistence/tracking-repos/project-host-setup-update.ts
  • src/main/runtime/runtime-project-host-setup-controller.ts
  • src/renderer/src/store/projects/project-host-routing.ts
  • src/renderer/src/store/projects/project-host-setup-actions.ts
  • src/renderer/src/store/slices/repos-project-host-lifecycle.spec.ts
  • src/renderer/src/store/slices/worktrees-removal-state-cleanup.test.ts
  • src/renderer/src/store/slices/worktrees/teardown/orphaned-runtime-ssh-project-purge.ts
  • src/shared/project-host-setup-target.test.ts
  • src/shared/project-host-setup-target.ts
  • src/shared/project-types.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/project-runtime-params.ts
  • src/shared/runtime-capability-constants.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@nwparker
nwparker merged commit cffcef7 into main Oct 19, 2026
50 checks passed
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