Fix #573: model search steals literal s and ranks loose matches first#640
Open
dennisonbertram wants to merge 1 commit into
Open
Conversation
Bug 1 (s steals literal): The star toggle condition in the TUI key handler allowed 's' to trigger star when SearchQuery() != ''. This meant typing e.g. 'deeps' in search would toggle a star instead of appending literal 's'. Fix: restrict star toggle to BrowseLevel==1 && SearchQuery()==. Bug 2 (ranking): visibleModels() matched only DisplayName in original catalog order (alpha by ProviderLabel then DisplayName). This caused e.g. typing 'd' to show Anthropic/Claude models (containing 'd' in 'Claude') ahead of DeepSeek models where 'd' is a prefix match. Fix: search across DisplayName, ProviderLabel, Provider key, and model ID. Rank prefix matches above substring matches, with starred models first within each tier. Also expand filteredProviders() to match ProviderID. Co-Authored-By: Claude <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
Fixes two bugs in the
/modelpicker search/autocomplete:Bug 1:
skey steals literal "s" during searchThe star toggle condition in the TUI key handler (
cmd/harnesscli/tui/model.go) was:This allowed
sto trigger the star shortcut whenever search was active, preventing users from typing literal "s" in queries like "deeps".Fix: Changed condition to only allow star toggle at
BrowseLevel==1with no active search:Bug 2: Search ranks loose substring matches ahead of prefix matches
visibleModels()incomponents/modelswitcher/model.goonly filtered byDisplayNameand preserved original catalog order (alphabetical by ProviderLabel then DisplayName). Typing "d" would show Anthropic/Claude results (containing "d" in "Claude") ahead of DeepSeek models where "d" is a provider/label prefix.Fix:
DisplayName,ProviderLabel,Provider(key), andIDfilteredProviders()to match onProviderIDin addition toLabelFiles changed
cmd/harnesscli/tui/model.go— fix star shortcut conditioncmd/harnesscli/tui/components/modelswitcher/model.go— expand search fields and implement prefix-first rankingTesting
Go runtime was not available in the CI environment, so tests could not be executed. The code was verified against the existing test suite patterns and should be compatible. Manual verification steps:
/modeld— verify DeepSeek provider appears before Anthropic/Claudedeeps— verify "s" is appended to search query, not consumed as star toggleCloses #573
🤖 Generated with Claude Code