Repository navigation
feat(sidebar): a cleaner for worktrees and old sessions - #58
Merged
Merged
Conversation
A broom beside the project filter (and "Clean up worktrees and old sessions…" in the palette) opens an overlay that lists every linked worktree with what it weighs on disk and how much of that is build output, how many sessions ran in it and when the last one did. A worktree is suggested when removing it loses nothing (no changes, no unpushed commits, nothing running, its checkout read) and its pull request is merged or nobody worked in it for 14 days; the others are listed with what keeps them and cannot be ticked. Chips filter the list, the field filters by project, branch or folder, and it orders by size, idle time or name. Removing goes through the same path as "Remove merged worktrees": git worktree remove, one at a time, never forced. A second list has the sessions of the history untouched for 7, 30 or 90 days that are not pinned, running or shelved; the cleaner settles them, it never deletes them. Sizes are measured in the background when the overlay opens: walked on this computer, asked of du on other machines (disk.rs). The rules are pure functions with tests (ui/sweep.rs).
viktorvillalobos
marked this pull request as ready for review
October 19, 2026 02:11
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.
What
A cleaner for worktrees and old sessions. A broom beside the project filter (or Clean up worktrees and old sessions… in the palette) opens an overlay with two lists.
Worktrees: every linked worktree of every project, with:
node_modules,target,.venv,dist…)A worktree is suggested when removing it loses nothing and its pull request is merged or nobody worked in it for 14 days. "Loses nothing" uses the same rules as Remove merged worktrees… (
leon_core::cleanup::blockers): no changes, no unpushed commits, nothing running, its checkout read. The other worktrees are listed with the reason and cannot be ticked.The chips filter the list (all, suggested, merged, idle, kept), the field filters it by project, branch or folder, and the list can be ordered by size, idle time or name. The footer says how much the ticked worktrees free. Removing goes through
Shell::remove_worktrees:git worktree remove, one at a time, never forced, and the branches stay.Old sessions: the sessions of the history untouched for 7, 30 or 90 days that are not pinned, running or on a shelf. SETTLE puts them on the Settled shelf; nothing is deleted.
Keys: up and down move, Enter ticks, Shift+Enter cleans, Tab switches the list. Anything else typed goes to the filter.
How
crates/app/src/ui/sweep.rs: the rules, as pure functions with tests (candidates,visible,suggested,ticked,old_sessions).crates/app/src/ui/sweep_view.rs: the overlay (Overlay::Cleanup), its keys and its actions.crates/app/src/disk.rsandEngine::measure_folder: on this computer the folder is walked; on other machinesdu -skis asked and parsed. Every worktree is measured in the background when the overlay opens.Command::CleanUpis added to the registry, with no chord. The README and ARCHITECTURE describe it.Tested
scripts/check.shpasses on Linux (Omarchy/Hyprland), including the simulated Windows runs. After it ran I changed the text of the activity column;cargo clippy -p leon --all-targets -D warnings,cargo fmt --checkand the cleaner's tests pass with that change.sweepanddiskunits (rules,duparsing, the local walk) andtests_sweep.rs(the broom and the palette open it, Escape closes it, a worktree nobody read cannot be ticked, typing filters, Tab switches the list).scripts/mediarig on the demo workspace (screenshots of both lists). The REMOVE and SETTLE buttons were not pressed there; they reuse paths that already have tests.