Repository navigation
fix(projects): setup edits and removals name the host, so the twin on another host is never touched - #30664
Conversation
…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).
…st misses an independent setup
…rong twin; read legacy runtime stamps as local
…only for twins on one route
…atalog; paired servers keep the by-id request
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 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 winUse
upsertProjectHostSetupinsetupProjectExistingFolderas well.This PR changes
createProjectHostSetup(Line 129) andupdateProjectHostSetup(Line 180) to useupsertProjectHostSetup. That helper matches rows by bothidandhostId.setupProjectExistingFolderstill matches rows byentry.idonly.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 alocalsetup, and the user then sets up the same repo ID on aruntime:host. The newruntime:row then overwrites thelocalrow inprojectHostSetups. The renderer catalog loses one setup until the next projection refresh. This is the twin collision that this PR fixes in the other paths.setupProjectClonealso 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
📒 Files selected for processing: 23
src/cli/handlers/project.tssrc/cli/index-project-setup.test.tssrc/cli/root-help-text-secondary.tssrc/cli/specs/project.tssrc/main/folder-repo-git-conversion.tssrc/main/ipc/repos/project-host-setup-handlers.tssrc/main/ipc/repos/repo-ipc-arg-schemas.tssrc/main/persistence-duplicate-repo-id-host-scope.test.tssrc/main/persistence/moving-wsl-projects/wsl-move-scope-guard.tssrc/main/persistence/tracking-repos/project-host-operations.tssrc/main/persistence/tracking-repos/project-host-setup-update.tssrc/main/runtime/runtime-project-host-setup-controller.tssrc/renderer/src/store/projects/project-host-routing.tssrc/renderer/src/store/projects/project-host-setup-actions.tssrc/renderer/src/store/slices/repos-project-host-lifecycle.spec.tssrc/renderer/src/store/slices/worktrees-removal-state-cleanup.test.tssrc/renderer/src/store/slices/worktrees/teardown/orphaned-runtime-ssh-project-purge.tssrc/shared/project-host-setup-target.test.tssrc/shared/project-host-setup-target.tssrc/shared/project-types.tssrc/shared/protocol-version.tssrc/shared/rpc-contract/project-runtime-params.tssrc/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.
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
orca project setup-update/setup-delete) could rename or remove the copy on this computer instead. Removing it could unregister the local project.Mechanism:
ProjectHostSetupUpdateArgsandProjectHostSetupDeleteArgsgain an optionalhostId, in the types, the IPC schemas and theprojectHostSetup.update/.deleteRPC schemas. The RPC side normalizes it the waycreatealready does, soruntime:*means the server itself.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:prepareProjectHostSetupMutation):setup-updateandsetup-deleteaccept--host. On a server that does not advertise the newproject-host-setup.host-target.v1capability,--hostis refused, because an older server would ignore it and act on the first twin.Why
hostIdis a new optional field. An older host's zod schema strips it and keeps today's first-match answer, so the CLI refuses--hostthere rather than letting the host guess. An older client omits it and gets today's behaviour.--host, because a request with no host keeps the by-id lookup.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--hostagainst an updated server does cover that case.assertReferenceWritesSupported).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
persistence-duplicate-repo-id-host-scope.test.ts: delete and update withhostIdfor each twin, plus ahostIdnaming no twin. 3 of these fail on main.project-host-setup-target.test.ts: the finder rules.--hostis passed through, and refused on a server without the capability.pnpm tcpassed;Review
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.Agent skill upstream boundary
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