Skip to content

Let a thread drop its worktree without a pull request #22635

Closed

Description

@scriptease

What happened

Some workflows can't use a pull request (Gerrit, cherry-picking into another branch, local-only experiments). Once the work has landed elsewhere, the thread's worktree has no clean exit:

  • Deleting the worktree is only offered when deleting the whole thread.
  • "Delete settled worktrees" (storage cleanup) only removes it after settlement.
  • Asking the agent to git worktree remove it works only until the next message: the next turn recreates the worktree from the thread's branch.

Observed: the agent removed ~/.t3/worktrees/<project>/<branch> at 04:49:43, the next user message started a turn at 04:50:29, and by 04:50:42 the worktree was back as a fresh checkout (without node_modules).

Diagnosis

apps/server/src/orchestration-v2/ProviderTurnStartService.ts (turn start) recreates any missing managed worktree from projection.thread.worktreePath / branch and logs "provider turn start recreating missing worktree". That's correct after storage cleanup or a rollback. But T3 has no way to learn that a removal was intentional, because the thread still holds worktreePath / branch.

Proposal

A "Remove worktree" thread action, available in the sidebar/thread menu, the command palette, mobile, and the MCP t3_thread_organize tool so the agent can run it when asked:

  • refuse, or ask for confirmation, when the worktree has uncommitted changes or unpushed commits
  • stop the session, run git worktree remove, and keep the branch
  • clear the thread's worktreePath (the thread falls back to the project root) and record the detachment, so turn start doesn't recreate the worktree
  • leave the thread settleable

Reverse state: "Recreate worktree" from the kept branch, which is what turn start already does today.

Steps to reproduce

  1. Run a thread in a managed worktree and finish the work without a PR.
  2. Ask the agent to remove the worktree, or run git worktree remove yourself.
  3. Send any follow-up message. The worktree is recreated.

Version

upstream main 8a9d0e0dd (2026-10-21)

Related: #17813, #21372

🤖 Generated with Claude Code

Activity

  1. locked and limited conversation to collaborators on Oct 21, 2026
  2. converted this issue into a discussion #22640 on Oct 21, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions