Summary
The "Delete merged worktrees" cleanup rule never removes a worktree when the thread's branch is renamed after T3 Code creates it. A common case is an agent that renames the generated t3code/... branch to a ticket branch name before it opens the PR.
Steps to reproduce
- Turn on Settings → Storage cleanup → Delete merged worktrees.
- Start a thread in a new worktree. T3 Code creates a branch such as
t3code/revert-login-screen.
- In the worktree, rename the branch, for example
git branch -m feature/ABC-123-remove-login-theme.
- Open a PR from the renamed branch and merge it into the default branch.
- Leave the thread idle and wait for the storage cleanup sweep.
Expected result
The cleanup sweep removes the worktree, because its PR is merged and its commits are in the default branch.
Actual result
The worktree stays. StorageCleanup.cleanWorktrees runs and exits with success, but it removes nothing.
Cause
The thread projection keeps the original branch name (thread.branch = "t3code/revert-login-screen"). It does not update after the rename. cleanWorktrees then exits early on this check:
const status = yield* git.statusDetailsLocal(worktreePath);
if (!status.isRepo || status.branch !== thread.branch || status.hasWorkingTreeChanges) return;
The same mismatch also makes gitManager.branchPullRequest look up the PR for the old branch name. That lookup cannot find the merged PR either.
Suggested fix
Update thread.branch when the branch checked out in the thread's worktree changes. Or, in cleanup, use the branch that is checked out in the worktree when it differs from the recorded branch.
Environment
- T3 Code 0.0.46-nightly.20261005.2702
- macOS
Summary
The "Delete merged worktrees" cleanup rule never removes a worktree when the thread's branch is renamed after T3 Code creates it. A common case is an agent that renames the generated
t3code/...branch to a ticket branch name before it opens the PR.Steps to reproduce
t3code/revert-login-screen.git branch -m feature/ABC-123-remove-login-theme.Expected result
The cleanup sweep removes the worktree, because its PR is merged and its commits are in the default branch.
Actual result
The worktree stays.
StorageCleanup.cleanWorktreesruns and exits with success, but it removes nothing.Cause
The thread projection keeps the original branch name (
thread.branch = "t3code/revert-login-screen"). It does not update after the rename.cleanWorktreesthen exits early on this check:The same mismatch also makes
gitManager.branchPullRequestlook up the PR for the old branch name. That lookup cannot find the merged PR either.Suggested fix
Update
thread.branchwhen the branch checked out in the thread's worktree changes. Or, in cleanup, use the branch that is checked out in the worktree when it differs from the recorded branch.Environment