Skip to content
Source
Sign inSign up
pingdotgg/t3code

Storage cleanup never removes a worktree that a subagent thread used #19144

Closedjlcara(GitHub profile, opens in a new tab) opened this issue 0 comments

What happens

Delete merged worktrees, Delete unchanged worktrees and Delete worktrees with deleted threads are all on, yet a cleanup run reports 0 removed, 111 kept. Most entries say "Shared by N threads".

Why

Each subagent that a thread starts is stored as its own thread (createdBy: "agent") with the parent's worktreePath. storageCleanup.ts groups every thread by worktreePath (L426) and keeps any worktree with more than one thread (L457: if (shared > 1) return keep(...)). Subagent threads are never archived or deleted with their parent. So a worktree whose thread ever started a subagent is kept forever, even after the user deletes the parent thread.

In my project this blocked 45 of 81 worktrees. Subagent threads caused 44 of them.

Repro

  1. Turn on "Delete unchanged worktrees".
  2. In a worktree thread, have the agent start one subagent.
  3. Settle or delete the thread, then run Settings → Storage → Delete now.
  4. The worktree is kept: "Shared by 2 threads".

Expected

Subagent threads should not count as users of a worktree. Their state should follow the parent thread's state (open, archived or deleted).

  1. maria-rcks closed this

Sign in to join this conversation.