fix(commit-widget): sort files and subdirectories alphabetically in renderDirectoryNode#235
Merged
Merged
Conversation
…enderDirectoryNode Files inside a directory rendered in the order the model emitted them in filesToStage, which made it hard to scan a commit with many files in one folder (the issue example: .claude/commands/ rendered analyze-code.md, roadmap.md, bug-report.md, design.md, posthog-analysis.md instead of alphabetical order). Sort subdirectories by displayPath and files by basename inside renderDirectoryNode. Folders-before-files convention is preserved by the existing render order. Used at both render sites (root + expanded subdirectory) so the tree renders deterministically. Fixes #233.
Extract the two inline sort callbacks from renderDirectoryNode into named module-level exports (compareSubdirectoriesByDisplayPath and compareFilesByBasename) and add a focused helper test that covers the issue #233 example, basename-vs-full-path semantics, root-level paths, and collapsed compound displayPath nodes. Also export the DirectoryNode interface so the test can build fixture nodes without re-declaring the shape. Corrects my prior claim that vitest + jsdom test infrastructure was not in place: it is (vitest.config.ts environment: 'jsdom', jsdom@26.1.0 in package.json, sibling __tests__/TranscriptWidgets.test.tsx).
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
Fixes #233. Files inside the commit proposal widget rendered in the order the model emitted them in
filesToStagerather than alphabetically. Sort subdirectories bydisplayPathand files by basename insiderenderDirectoryNode. Folders-before-files convention is preserved by the existing render order.Changes
packages/runtime/src/ui/AgentTranscript/components/CustomToolWidgets/GitCommitConfirmationWidget.tsx:compareSubdirectoriesByDisplayPathandcompareFilesByBasename.renderDirectoryNode, computesortedSubdirectoriesandsortedFilesonce via the comparators and use them at both render sites (root node + expanded subdirectory).DirectoryNodeinterface so tests can build fixture nodes without re-declaring the shape.packages/runtime/src/ui/AgentTranscript/components/__tests__/GitCommitConfirmationWidget.helpers.test.ts(new):.claude/commands/reordering to alphabetical).deep/nested/...with basenamezebra.tsshould sort after a shallow path with basenameapple.ts).npm run test:unit -- --run packages/runtime/src/ui/AgentTranscript/components/__tests__/GitCommitConfirmationWidget.helpers.test.ts).CHANGELOG.md(+1): entry under### Fixedreferencing #233.Test plan
Issue example to reproduce:
.claude/commands/should renderanalyze-code.md, bug-report.md, design.md, posthog-analysis.md, roadmap.md(alphabetical) rather than the model's emission order.Single-concern PR. No new dependencies.