Repository navigation
fix(runtime): project removal and edits stay on the selected project's host - #30584
Conversation
…d execution host - Removing a project now closes its native Claude/Codex chats on this host and retires their tabs. - A terminal spawn after removal is admitted only by a surviving row on the spawn's own host. - repo.update and repo.setBaseRef write the resolved row's host, not a same-id sibling.
…heir own floor - A failed or budget-spent terminal stop no longer skips the chat closes. - Spawn admission still refuses on any host once no row with the removed id survives.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
ELI5
The same project id can be registered twice: once on this computer and once on an SSH host. Three project actions picked the right copy but then acted on the wrong one, or skipped work entirely:
What Changed
Before: removing a project on a host left native chats (which have no terminal) running and their tabs restorable. After removing the SSH copy of a project, a terminal spawn that was queued behind the removal could still start there because a same-id local row survived.
repo.update/repo.setBaseRefresolved the right row and then calledstore.updateRepo(repo.id, …)with no host, so persistence wrote the first row with that id.After:
structured-session-worktree-teardown.ts; newlistStructuredSessionsForProject). The close runs alongside the post-removal terminal pass and still runs if that pass throws. It gets a 3 s floor past the shared 10 s budget, which keeps it insiderepo.rm's 15 s client timeout. Chats are only touched after the removal commits, so a removal the WSL-move check refuses leaves them alone.connectionId(both spawn paths already had it). A spawn into a removed id is refused unless a surviving row with that id is on the spawn's own host. If no row with that id survives at all, every spawn is refused, as before.updateandsetBaseRefnow passgetRepoExecutionHostId(repo)intostore.updateRepo, so the host-scoped row lookup that persistence already has is used.Why
Each fix reuses something that already exists rather than adding a parallel path: the worktree-teardown structured-session close and tab retirement, the PTY host fence that project removal already uses (
getRepoSshConnectionId), and the optionalhostIdargument persistence'supdateRepoalready accepts.Nothing changes on the wire. The new fields are in-process options only.
Linked Issue
Internal review findings (codex-review-4 #1, #2, #3). No issue filed. Follow-ups to #29964 and #29282.
Visual Proof
N/A. This is main-process runtime behaviour with no UI change. Covered by tests.
Testing
New failing-then-passing tests:
src/main/runtime/project-removal-structured-sessions.test.ts: chats closed and tabs retired on removal, fenced to the host; still closed when the terminal stop throws or has spent the budget.src/main/runtime/project-removal-terminal-stop.test.ts: an SSH spawn is refused after removal despite a local sibling; any-host refusal once no row survives.src/main/runtime/runtime-remove-project-host-scope.spec.ts:repo.updateandrepo.setBaseRefwrite the SSH row a path selector picked.Neighbouring suites (
src/main/ipc/pty, runtime terminal, construction, structured-session, retirement contracts): 171 files / 1818 tests pass.pnpm tc:node, changed-code quality and the static ratchets pass.Live verification: unit and integration tests only, plus the managed-SSH Docker e2e lane dispatched on this branch (see comment).
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Codex (gpt-6.1-sol, high) and an Opus review. Round 1 (both reviewers) found that a failed or budget-spent terminal pass skipped the chat close, and that admission stopped refusing a different-host spawn once no row survived. Both are fixed here. Round 2: Codex and Opus found nothing further.
Agent skill upstream boundary
Notes
liveorunverifiable, neverexited.repo.rmis still running, after the chat snapshot, is not closed. Chat creation has no removal fence the way terminal spawns do.store.updateRepo(id, …)calls without a host remain:runtime-project-host-setup-controller.ts,ipc/repos/project-host-setup-handlers.ts,ipc/folder-repo-git-upgrade.ts, the clone controllers, andruntime-repository-registration-controller.ts. They are the same class of bug and left out of scope.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)