Summary
Deleting a thread with "remove worktree" can delete the working directory of a fork that runs in the same worktree.
Where
- Forks copy the source's cwd but intentionally leave
worktree unset, because it is an ownership/cleanup marker (fork creation in crates/runtime/src/app/sessions.rs).
- Whether a worktree is shared is decided in the UI by
worktree_orphaned_by_delete (crates/ui/src/store/mod.rs), which only compares worktree.branch of other sessions plus archived_worktree_branches. Forks have no worktree, so they never count as sharers.
- The delete dialog therefore offers to remove the worktree, and
delete_session(remove_worktree = true) runs git worktree remove --force on the directory the fork is using.
Scenario
- Start a thread in a new worktree.
- Fork it.
- Delete the source and choose to remove its worktree → the fork's cwd is gone.
Found by reading the code; not reproduced.
Expected
The host decides whether a worktree is still in use, counting every session whose cwd is inside it, and either transfers ownership or refuses the removal. See #530 for the full model.
Summary
Deleting a thread with "remove worktree" can delete the working directory of a fork that runs in the same worktree.
Where
worktreeunset, because it is an ownership/cleanup marker (fork creation incrates/runtime/src/app/sessions.rs).worktree_orphaned_by_delete(crates/ui/src/store/mod.rs), which only comparesworktree.branchof other sessions plusarchived_worktree_branches. Forks have noworktree, so they never count as sharers.delete_session(remove_worktree = true)runsgit worktree remove --forceon the directory the fork is using.Scenario
Found by reading the code; not reproduced.
Expected
The host decides whether a worktree is still in use, counting every session whose cwd is inside it, and either transfers ownership or refuses the removal. See #530 for the full model.