Skip to content

Removing a deleted thread's worktree also deletes its forks' working directory #517

Description

@Tryanks

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

  1. Start a thread in a new worktree.
  2. Fork it.
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions