You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optional setting to auto-remove an archived thread's managed worktree after N days when clean and pushed
#43870
Keep worktrees with local changes (worktreeKeepWhen)
There is a gap for users who archive threads instead of deleting them (to keep searchable conversation history) and want disk space reclaimed automatically without risking active or unpushed work:
worktreeOnDelete only runs when a thread is deleted, not archived.
worktreeOnMerge only removes worktrees whose PR is merged into the default branch — worktrees for archived threads whose branches were pushed for review, left as parked experiments, or closed without merging stay on disk indefinitely.
worktreeAfterDays and worktreeSettledAfterDays apply to non-archived threads too and do not require local commits to be pushed to a remote first, so turning them on with a short window risks removing checkouts for threads still in the sidebar or branches with unpushed local commits.
Proposal
Add an opt-in worktree cleanup rule (off by default, available globally and per project under Settings → Storage → Cleanup) to automatically remove an archived thread's managed worktree after N days since archival (archivedAt), only when:
The thread is archived (archivedAt !== null) and idle (no active run, pending tasks, live provider session, or open terminal — reusing the existing StorageCleanup guards).
The worktree passes the existing worktreeKeepWhen cleanliness check (no uncommitted/local changes).
All commits on the worktree's branch are pushed to a remote (no unpushed local commits ahead of its upstream / remote-tracking refs, and no unpushed submodule commits).
The branch ref and thread history remain intact so unarchiving and resuming the thread recreates the checkout cleanly, matching existing StorageCleanup behavior.
Why opt-in and scoped to archived + clean + pushed
Archiving is an explicit user signal that a thread is done for now, making it a much safer trigger than global inactivity alone.
Requiring both a clean working tree and pushed commits prevents silent loss of local-only branches while still reclaiming multi-gigabyte worktrees (build caches, node_modules, etc.) that otherwise accumulate over weeks of archived threads.
Fits directly alongside worktreeSettledAfterDays and worktreeAfterDays in WorktreeCleanupRules and the existing Last run cleanup report.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem
Settings → Storage → Cleanupalready offers helpful automatic worktree cleanup rules:worktreeOnDelete)worktreeOnMerge)worktreeAfterDays)worktreeSettledAfterDays)worktreeUnchanged)worktreeKeepWhen)There is a gap for users who archive threads instead of deleting them (to keep searchable conversation history) and want disk space reclaimed automatically without risking active or unpushed work:
worktreeOnDeleteonly runs when a thread is deleted, not archived.worktreeOnMergeonly removes worktrees whose PR is merged into the default branch — worktrees for archived threads whose branches were pushed for review, left as parked experiments, or closed without merging stay on disk indefinitely.worktreeAfterDaysandworktreeSettledAfterDaysapply to non-archived threads too and do not require local commits to be pushed to a remote first, so turning them on with a short window risks removing checkouts for threads still in the sidebar or branches with unpushed local commits.Proposal
Add an opt-in worktree cleanup rule (off by default, available globally and per project under
Settings → Storage → Cleanup) to automatically remove an archived thread's managed worktree after N days since archival (archivedAt), only when:archivedAt !== null) and idle (no active run, pending tasks, live provider session, or open terminal — reusing the existingStorageCleanupguards).worktreeKeepWhencleanliness check (no uncommitted/local changes).StorageCleanupbehavior.Why opt-in and scoped to archived + clean + pushed
node_modules, etc.) that otherwise accumulate over weeks of archived threads.worktreeSettledAfterDaysandworktreeAfterDaysinWorktreeCleanupRulesand the existingLast runcleanup report.All reactions