Repository navigation
[hardening 5/N] refactor(projects): shrink twin-removal teardown to the attributed close actions - #30060
Conversation
73239d0 to
53aaf9e
Compare
b1f230f to
41344c8
Compare
436045b to
ef28e88
Compare
a95f7bb to
ac1e44f
Compare
651a0f8 to
135c6fa
Compare
ac1e44f to
8bc289d
Compare
135c6fa to
516f433
Compare
516f433 to
9cabc62
Compare
8bc289d to
4a4c4d4
Compare
9cabc62 to
acee149
Compare
4a4c4d4 to
6a952e0
Compare
acee149 to
75a8c16
Compare
6a952e0 to
1ba9512
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
Stack (unmerged, review in order): 1. #30030 (base main) → 2. #30035 → 3. #30059 (1a.4) → 4. #30047 → 5. this PR (base
nwparker/host-worktree-target-kill-sleep)ELI5
If the same project is open on two machines (say this computer and an SSH host) at the same folder path, Orca shows two copies that share one id. Removing one copy must close only that copy's tabs and leave the other copy alone. The code that did this had grown to about 575 lines with several special cases. This PR cuts it down and reuses the same "which tab belongs to which host" logic that purge, kill and sleep already use.
What Changed
KNOWN_TWIN_LEAKScell (remove project | local+runtime | local) is deleted and the cell now asserts isolation.collectHostTwinPurgeScopes, the same check the host-scoped purge uses. It replaces three removal-only helpers (getSurvivingTwinHostIds,retainSurvivingTwinHostIds,splitRemovedWorktreeIds).twinSelectionPatchmoves into the shared attribution module, its only other consumer being the purge.host-twin-terminal-evidence.ts): the attribution and teardown modules go from 540 (278 + 262) to 368. The shared attribution goes from 278 to 216; purge, kill and sleep depend on it. The removal-only teardown goes from 262 to 152.repo-removal.tsgoes from 314 to 312.Why
The follow-up from the #29954 review asked removal to close only what the attribution names, using the existing close actions, and to drop the special cases that only ever left stale entries. Since then, #30030 and #30047 have reused
collectRemovedHostTwinState,removedHostCanonicalizer,twinSelectionPatchandcollectHostTwinPurgeScopes. So the shared attribution stays as it is, mixed-tab detection included, because kill and sleep refuse on it and removal uses it to stop the removed host's pane in a mixed tab. Only the removal-specific code shrinks.Alternative considered: route twin removal entirely through the host-scoped purge (
purgeWorktreeTerminalStatewith host targets). That would save about 100 more lines. I rejected it because the bulk purge skips close-action side effects: it doesn't sendagentSession.closeto a published structured chat, doesn't revoke a document preview's file grant, and doesn't run the retirement planner's shared-PTY guard. Codex round 1 confirmed all three.Tests changed on purpose (special cases dropped):
project-removal-host-twin-state.test.ts:repo-removal-host-twin-teardown.test.ts(new): launch cancellation stays scoped to each attributed host's ids.host-twin-isolation.test.ts: removed the lastKNOWN_TWIN_LEAKSentry.Fixes from review:
Linked Issue
N/A. This is Stage 1 of the SSH hardening plan (follow-up from the #29954 review).
Visual Proof
N/A. No visual change. This is store teardown only, covered by unit tests.
Testing
pnpm tcsrc/renderer/src/store,src/renderer/src/lib,components/sidebarandhooks/ipc-eventsfolders: 1549 files, all pass53aaf9e7933fafter the review fixesCovered only by unit tests, not live: local, SSH, runtime and folder twins, all from the twin suite.
Notes
Checklist
N/Avisual with reasonpnpm typecheckand targeted tests pass locally