feat: add --sort flag to list, prune, and sync commands#317
Merged
Conversation
Add the ability to sort worktree lists by column with configurable direction. The --sort flag uses +col for ascending and -col for descending (plain col defaults to ascending). Multiple columns can be comma-separated for multi-level sort hierarchy. Sortable columns: branch, path, size, age, owner, activity (aliases: commit, last-commit). Sorting by columns not displayed is supported (e.g., --sort -size without --columns +size). Default sort is +branch. Sort direction indicators appear in column headers when sorting is active. For time-based columns (age, activity), ascending means "most recent first" to match terminal visual flow of displayed values. Defaults can be configured via git config: daft.list.sort, daft.sync.sort, daft.prune.sort. The CLI flag overrides config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The activity sort column now considers both committed and uncommitted work by comparing max(last_commit_timestamp, working_tree_mtime). This means a worktree with recent file edits but an old commit sorts as more active than one with a newer commit but no uncommitted changes. The activity and commit sort columns are now distinct: - activity: overall activity (commits + uncommitted file mtime) - commit / last-commit: last commit timestamp only (pure git) Working tree mtime is computed by stat-ing files from git status --porcelain (already run for staged/unstaged counts), so the cost is marginal. Clean worktrees skip the walk entirely. The activity sort no longer shows a direction indicator on the Last Commit column header since it's a composite signal not tied to a single display column. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sort arrows in column headers now use descending brightness based on their position in the sort key hierarchy. Primary sort column gets a bright white arrow, secondary gets light gray, tertiary+ gets medium gray. This visually communicates sort priority at a glance. Applies to both the list command (ANSI 256-color grayscale) and the TUI (ratatui Color::White / Gray / DarkGray). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Shorter header label that aligns with the --sort commit flag name. The --columns CLI name (last-commit) and JSON field names are unchanged. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All display columns are now sortable. Base, changes, and remote sort by their total magnitude: - base: ahead + behind (commits in summary, lines in --stat lines) - changes: staged + unstaged + untracked (files or lines) - remote: remote_ahead + remote_behind (commits or lines) The sort values respect the --stat mode: summary uses commit/file counts, --stat lines uses line-level insertions + deletions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Display a "Sorted by X ↓, Y ↑" line above the table when the column headers alone cannot convey the full sort specification. This appears when: - Any sort column is not displayed (e.g., --sort activity without a matching column, or --sort size without --columns +size) - 4+ sort keys are used (the brightness gradient only has 3 levels) The summary uses the same brightness gradient as column header arrows. Applies to both the list command and the TUI (sync/prune). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
--sortflag to list, prune, and sync commands with multi-column sort hierarchy (+colascending,-coldescending)activitysort considers both last commit timestamp and uncommitted file modification times;commit/last-commituses commit time only--statmode (commit/file counts vs line-level)daft.list.sort,daft.sync.sort,daft.prune.sort--sort commitTest plan
mise run clippy— zero warningsmise run test:unit— 700+ tests pass (37 new sort tests)mise run test:manual -- --ci list:basic— integration tests passmise run man:verify— man pages up to datemise run docs:cli:verify— CLI docs up to datedaft list --sort -activity,daft list --sort +owner,-size,daft list --sort -changesFixes #316
🤖 Generated with Claude Code