Skip to content

Fix #573: model search steals literal s and ranks loose matches first#640

Open
dennisonbertram wants to merge 1 commit into
mainfrom
deep-claude/issue-573-bug---model-search-steals-literal-s-and-ranks-loos
Open

Fix #573: model search steals literal s and ranks loose matches first#640
dennisonbertram wants to merge 1 commit into
mainfrom
deep-claude/issue-573-bug---model-search-steals-literal-s-and-ranks-loos

Conversation

@dennisonbertram

Copy link
Copy Markdown
Owner

Summary

Fixes two bugs in the /model picker search/autocomplete:

Bug 1: s key steals literal "s" during search

The star toggle condition in the TUI key handler (cmd/harnesscli/tui/model.go) was:

if msg.String() == "s" && (m.modelSwitcher.BrowseLevel() == 1 || m.modelSwitcher.SearchQuery() != "")

This allowed s to 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==1 with no active search:

if msg.String() == "s" && m.modelSwitcher.BrowseLevel() == 1 && m.modelSwitcher.SearchQuery() == ""

Bug 2: Search ranks loose substring matches ahead of prefix matches

visibleModels() in components/modelswitcher/model.go only filtered by DisplayName and 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:

  1. Expand search to match across DisplayName, ProviderLabel, Provider (key), and ID
  2. Rank prefix matches above substring matches, with starred models first within each tier
  3. Also expanded filteredProviders() to match on ProviderID in addition to Label

Files changed

  • cmd/harnesscli/tui/model.go — fix star shortcut condition
  • cmd/harnesscli/tui/components/modelswitcher/model.go — expand search fields and implement prefix-first ranking

Testing

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:

  1. Open TUI, run /model
  2. Type d — verify DeepSeek provider appears before Anthropic/Claude
  3. Type deeps — verify "s" is appended to search query, not consumed as star toggle
  4. Verify star toggle still works at level 1 when no search query is active

Closes #573

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: /model search steals literal s and ranks loose matches first

1 participant