Repository navigation
fix(worktree): don't path-sweep sibling sessions when deleting a folder workspace (#10252) - #10268
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 00dc00fc47808ad3828439b7cc585f20cd7f875e and b3c4fd5. 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughUpdates worktree teardown so folder-workspace instances no longer use shared filesystem paths to identify untagged sessions. Exact 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
9797309 to
00dc00f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 605c512e-64fb-4ed4-95f2-749e0e2b4884
📥 Commits
Reviewing files that changed from the base of the PR and between 979730974bdc0358d150573d28934bb87b33abcb and 00dc00fc47808ad3828439b7cc585f20cd7f875e.
📒 Files selected for processing (5)
docs/delete-workspace-cwd-owned-sibling-kill.mdsrc/main/runtime/worktree-teardown.test.tssrc/main/runtime/worktree-teardown.tssrc/shared/worktree-id.test.tssrc/shared/worktree-id.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/shared/worktree-id.test.ts
- src/shared/worktree-id.ts
- src/main/runtime/worktree-teardown.test.ts
…er workspace (#10252) Deleting one folder-workspace instance could kill terminal/agent sessions in OTHER workspaces sharing the same checkout path — sibling instances, and even worktrees of a different repo rooted under that directory. Both pi and Claude Code agent sessions died at once with no recovery. The `cwdOwned` path fallback in killAllProcessesForWorktree() derives its match path via splitWorktreeIdForFilesystem(), which strips the `::workspace:<uuid>` suffix and collapses a folder instance's path to the shared checkout dir. Every untagged session under that dir then path-matched and got swept (worst case: a home directory registered as a folder repo). Disable the path fallback for folder-workspace instances — their filesystem path can't identify a single instance. The exact `${worktreeId}@@` prefix and authoritative `session.worktreeId` matches (both carrying the instance uuid) still tear down the deleted instance's own sessions; normal git worktrees (unique paths) keep the fallback. The runtime and registry sweeps already matched by exact worktreeId. Adds isFolderWorkspaceInstanceId() and regression tests. See docs/delete-workspace-cwd-owned-sibling-kill.md.
00dc00f to
b3c4fd5
Compare
…er workspace (stablyai#10252) (stablyai#10268) * fix(worktree): don't path-sweep sibling sessions when deleting a folder workspace (stablyai#10252) Deleting one folder-workspace instance could kill terminal/agent sessions in OTHER workspaces sharing the same checkout path — sibling instances, and even worktrees of a different repo rooted under that directory. Both pi and Claude Code agent sessions died at once with no recovery. The `cwdOwned` path fallback in killAllProcessesForWorktree() derives its match path via splitWorktreeIdForFilesystem(), which strips the `::workspace:<uuid>` suffix and collapses a folder instance's path to the shared checkout dir. Every untagged session under that dir then path-matched and got swept (worst case: a home directory registered as a folder repo). Disable the path fallback for folder-workspace instances — their filesystem path can't identify a single instance. The exact `${worktreeId}@@` prefix and authoritative `session.worktreeId` matches (both carrying the instance uuid) still tear down the deleted instance's own sessions; normal git worktrees (unique paths) keep the fallback. The runtime and registry sweeps already matched by exact worktreeId. Adds isFolderWorkspaceInstanceId() and regression tests. See docs/delete-workspace-cwd-owned-sibling-kill.md. * rm design doc
What
Deleting one folder-workspace could kill terminal/agent sessions belonging to other workspaces that share the same checkout path — sibling instances, and even worktrees of a different repo rooted under that directory. Both
piand Claude Code agent sessions died at the same instant with no recovery. Fixes #10252.Root cause
killAllProcessesForWorktree()runs three sweeps to find PTYs to tear down. The runtime and registry sweeps match by exactworktreeId; only the provider sweep'scwdOwnedpath fallback matches by path:worktreePathis derived viasplitWorktreeIdForFilesystem(), which strips the::workspace:<uuid>suffix for folder-workspace instances. So deleting instancerepo::/Users/me::workspace:<uuid>collapsesworktreePathto the shared dir/Users/me, and every untagged session under it gets swept — sibling workspaces, other repos, and, worst case (a home directory registered as a folder repo), nearly every session for that user.Fix
Disable the path fallback when the worktree being torn down is a folder-workspace instance — its filesystem path can't identify a single instance. The exact
${worktreeId}@@prefix and authoritativesession.worktreeIdmatches (both carrying the instance uuid) still tear down the deleted instance's own sessions. Normal git worktrees (unique paths) keep the fallback.isFolderWorkspaceInstanceId()insrc/shared/worktree-id.ts(reuses the existingFOLDER_WORKSPACE_INSTANCE_SUFFIXregex)worktreePathinkillAllProcessesForWorktree()(src/main/runtime/worktree-teardown.ts)Testing
worktree-teardown.test.ts: folder-instance delete no longer sweeps untagged siblings; still tears down its own prefix-/worktreeId-matched sessions; a combined 4-quadrant list kills exactly the two own sessions. PlusisFolderWorkspaceInstanceIdunit tests. The sibling test fails onmainand passes with the fix.oxlint,oxfmt, andtscclean; 52 touched-suite tests + 26 folder-scoped tests in the broader suites pass.Scope / notes
Design rationale, alternatives, and edge cases:
docs/delete-workspace-cwd-owned-sibling-kill.md.Made with Orca 🐋