Repository navigation
Worktree GC: per-project retention, batch cleanup, visible disk usage (#316) - #330
Merged
currentbits merged 9 commits intoAug 17, 2026
Merged
Conversation
Replace the gcScan/gcClean placeholders with a read-only scan and a re-scan-then-remove cleaner. GC never deletes a branch. Per-project worktreeRetention is optional on the project row. New coder/ branches get -2, -3, … when a local or remote ref is already taken.
Settings now scans worktree disk usage on open and offers one confirm to reclaim selected directories. Edit project exposes the per-project settled-thread retention limit. Branches are never deleted from this UI.
…into coder/worktree-garbage-collection-with-ui-rete-c4df92
Provenance: entries.source column, agent/source persisted and returned on every read path, agent is now an actual search filter. Trust: per-agent evidence rollup derived from helpful/harmful/invalidated, cached agent_trust() folded into ranking, suspect writers flagged in the maintenance report. Co-Authored-By: Claude Opus 5 <[email protected]>
…into coder/worktree-garbage-collection-with-ui-rete-c4df92
The scan surfaced retention candidates but nothing acted on them, so a per-project limit only applied when the user opened the cleanup dialog. enforceRetention runs gcClean over the retention candidates after the orphan sweep: opt-in (no limit = no-op), directories only, branches kept. Orphans stay the dialog's job — those need a human look. Co-Authored-By: Claude Opus 5 <[email protected]>
An archived thread is further out of attention than a settled one, but the renderer filters archived threads before the settle split, so they never carry a settled override and retention could not see them. On the reporting machine that was 108 of 127 worktree-holding threads — the invisible worktrees the issue is about. Co-Authored-By: Claude Opus 5 <[email protected]>
…e-collection-with-ui-rete-c4df92
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/worktree-garbage-collection-with-ui-rete-c4df92
branch
October 3, 2026 16:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #316.
Solenta had
scripts/prune-worktrees.shbut no in-app garbage collection, so worktrees accumulated invisibly. Measured on a real state dir while building this: 108 worktrees, 58 GB.What changed
Scan and batch cleanup (
electron/worktrees.js)gcScan— sizes every worktree directory (du -sk, no JS tree walking), classifies each as anorphan(no thread references it) or aretentioncandidate (a settled thread past its project's limit), rolls usage up per project, and returns ablockedreason instead of silently skipping anything unsafe (uncommitted changes, unreadable directory). Read-only, never rejects.gcClean— batch removal. Re-runs the scan internally and only removes paths the fresh scan still reports as unblocked candidates, so a stale UI selection can never delete live work. One store save and one broadcast for the whole batch.Per-project retention
ProjectInfo.worktreeRetention— how many settled threads keep their worktree. Absent or 0 means unlimited, so existing behaviour is unchanged until a project opts in.enforceRetentionruns on the boot sweep after the existing orphan pass. Orphans are deliberately left to the dialog: those warrant a human look, whereas a project's own retention limit is a standing instruction.Collision-safe branch names
uniqueCoderBranchchecks local and all remote refs before using acoder/<slug>-<shortId>name and suffixes-2,-3on collision. Colliding with a fetched PR branch is what made Conductor surface unrelated merged PRs. A rename that finds no free name leaves the existing branch untouched, keeping that path best-effort and non-throwing.UI (
src/components/WorktreeGcSection.tsx,EditProjectModal)Delete N worktrees (X MB)that makes onegcCleancall, then re-scans and reports what was reclaimed. Explicitly not a per-item nag.Verification
Beyond the suites, the scan was run read-only against the live
coder-store.json: at a simulated retention of 10, 26 GB reclaimable; at 3, 44 GB. That exercise is what surfaced the two integration gaps above (nothing enforced retention on boot; archived threads were invisible to it) — both green under unit tests and both wrong against real data.electron/test/worktree-gc.test.js— 13 cases: orphan detection, dirty candidates blocked and refused bygcClean, retention keeping the newest N, archived counted as settled, boot enforcement leaving orphans alone, branch refs surviving removal,-2collision suffixtest/worktreeGc.test.tsx— usage rendering, blocked rows unselectable, singlegcCleancall with the selected paths, retention round-triptsc --noEmitclean. The single electron failure is the pre-existingweb-integrationreconnect case, which fails onmainindependently of this branch.Note for review
Reclaiming is opt-in per project, so by default disk usage becomes visible but nothing is deleted. Shipping a sane default limit for new projects would be a one-line change if that is preferred.