Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Add a project whose folder holds several git repos, so new-worktree threads get a task folder:
~/.t3/worktrees/<project>/<id>/{repoA,repoB}. - Start a thread in a new worktree and let it settle.
- In one of the checkouts, rename or switch the branch (
git branch -m new-nameorgit checkout -b other). Agents do this often. - In Settings → Maintenance, set settled-thread cleanup to 0 days and click Delete now.
Expected behavior
The settled thread's task folder is removed. The checkout is on some branch, the tree is clean, and the branch survives removal.
Actual behavior
The checkout is kept with "Repository or branch changed", on every run. In my case the result was 0 removed and 24 kept, with every thread settled.
This is #17813 / #22312 again, but for task folders. Those fixes (followBranch in cleanup, WorktreeBranchSync) only cover single worktrees:
storageCleanup.tsinspectCheckoutcallsbranchChanged(checkoutPath, thread.branch), which does a strictname !== branchcheck. Unlike the single-worktree path, it never callsfollowBranch, so the next run doesn't catch up.WorktreeBranchSyncmatches threads onthread.worktreePath === cwd. For a task folder that path is the root, while git runs inroot/<repo>, sothread.branchis never updated.- A single
thread.branchalso can't describe checkouts that are on different branches.
Suggested fix
The branch-name check isn't needed for task folders:
- They are only removed by age, settling or deletion; the merged/unchanged rules that compare branches don't apply (see the comment above the
taskFolderbranch instorageCleanup.ts). taskFolders.removeis called withoutdeleteBranch, so the branches survive.
In inspectCheckout, drop the name comparison and keep only the safety checks: repo missing, an index lock, an operation in progress, or a detached HEAD with commits no branch or remote holds. One way is to let branchChanged take branch: undefined meaning "any branch is fine" (return branch !== undefined && name !== branch) and pass undefined from inspectCheckout.
Impact
Major degradation or frequent failure
Version or commit
0.1.13
Environment
macOS, desktop app, multi-repo project (task folders)
Logs or stack traces
# thread branch (statev2.sqlite) vs. actual checkout HEAD, clean trees
<id-1>/repoB thread=feature/foo head=feature/foo-renamed
<id-2>/repoB thread=feature/bar head=feature/bar-v2
<id-3>/repoA thread=feature/baz head=feature/baz-split
<id-4>/repoA thread=feature/qux head=feature/qux-stack-1
# ...about 12 more, all "Repository or branch changed"Workaround
Remove the checkouts by hand with git worktree remove.
Activity