fix: preserve CLI argument order for files#474
Merged
tomasz-tomczyk merged 3 commits intomainfrom May 6, 2026
Merged
Conversation
`crit a.md b.md` was always sorting files alphabetically in the frontend, ignoring the order the user passed on the command line. Backend already preserves the order in NewSessionFromFiles; only the frontend's fileSortComparator was clobbering it. Skip sort when session.mode === 'files' (both top-level file list and tree sibling sort) so user-provided order flows through. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pairs with the previous commit. Now that the frontend trusts backend file order in files mode, walkDirectory must produce the order users expect for directory args like `crit .`: at each depth, recurse into subdirectories (alphabetical) before listing files (alphabetical). This recovers the "directories before files at each depth" grouping the frontend used to impose via fileSortComparator. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #474 +/- ##
==========================================
+ Coverage 69.17% 69.24% +0.07%
==========================================
Files 36 36
Lines 10744 10754 +10
==========================================
+ Hits 7432 7447 +15
+ Misses 2747 2744 -3
+ Partials 565 563 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The two `e edits` / `d deletes` tests assumed alphabetical sort placed handler.js first, so pressing `j` from cleared focus landed on it. With CLI argument order preserved, plan.md (first arg in the fixture) is now the first focusable file. Update the tests to seed and target plan.md. Co-Authored-By: Claude Opus 4.7 (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
crit a.md b.mdwas always sorting files alphabetically in the frontend, ignoring CLI argument order. Backend already preserved order inNewSessionFromFiles; only the frontend'sfileSortComparatorwas clobbering it.session.mode === 'files'(top-level file list + tree sibling sort), so user-provided order flows through.walkDirectoryto yield "directories first at each depth, then alphabetical files" — the order the frontend used to impose for directory args likecrit .— so backend is now the single source of truth for display order.Review
Test plan
go test -race ./...passesgolangci-lint run ./...cleanmulti-file-modesuite passes (19 tests, including new regression test asserting CLI order)crit beta.md alpha.mddisplays beta first🤖 Generated with Claude Code