fix: Feat: Sorting when using a filter#230
Merged
sammcj merged 2 commits intosammcj:mainfrom Dec 30, 2025
Merged
Conversation
When a filter is active, sorting now preserves the filtered view instead of clearing it. This fixes issue sammcj#166 where sorting would break when using a filter. Added refreshListWithSort() function that: - Sorts the master models list - If a filter is active, also sorts the visible filtered items - Preserves cursor position after sorting Also fixed a pre-existing build error where promptForNewName() return value was not properly handled. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: majiayu000 <1835304752@qq.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #166 by implementing proper sorting behavior when a filter is active. Previously, sorting operations would lose the active filter state by replacing all list items with the sorted master list. The fix introduces a new refreshListWithSort method that preserves filter state while sorting both the master list and visible filtered items.
Key changes:
- Added
refreshListWithSortmethod to handle sorting while preserving active filters - Refactored all sort handlers to use the new method instead of calling
sort.Slice+refreshListseparately - Added cancellation handling for model creation from Modelfile (which was already present in copy and rename operations)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Optimizations: - Replace O(n²) nested loop with O(n) HashMap lookup for better performance - Add early return for empty filtered lists - Remove unnecessary nil assignment to prevent UI flicker - Add proper variable initialization with foundI/foundJ checks Bug fixes: - Add empty name validation after cancellation in handleEditorFinishedMsg - Improve cursor position boundary check (only select if index >= 0) These changes address code review feedback from GitHub Copilot while maintaining the core functionality of preserving filter state during sorting.
Owner
|
fyi some copilot comments @majiayu000, they may not all be valid but could you check? |
Contributor
Author
|
Hi @sammcj, I've reviewed the Copilot comments and addressed them in the latest commit:
Let me know if you'd like any further changes! |
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
This PR fixes #166
Changes
app_model.go