fix(vscode): sort slash commands by relevance (exact > prefix > substring) - #11557
Conversation
| action?: () => void | ||
| } | ||
|
|
||
| const getMatchScore = (cmd: SlashCommandEntry, lower: string): number => { |
There was a problem hiding this comment.
WARNING: This test reimplements the production matcher instead of exercising it
getMatchScore() and sortResults() here are a second copy of the new hook logic, so the suite can stay green even if useSlashCommand().results() regresses or the two copies drift apart later. Testing the hook directly, or asserting through a single shared helper, would give this PR real protection against future ordering bugs.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous Review Summaries (4 snapshots, latest commit 14a8d7a)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 14a8d7a)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Previous review (commit d086710)Status: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Previous review (commit 590d8e4)Status: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 121c12d)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Reviewed by gpt-5.4-20260305 · Input: 39.3K · Output: 4.2K · Cached: 151.5K Review guidance: REVIEW.md from base branch |
markijbema
left a comment
There was a problem hiding this comment.
Can you please extract the sorting in a function and test that instead? I feel this could be the most readable unittest in the world, and doesnt need mocking at all.
so extract sortByScore, which gets the array of matches and the search string, and returns an array.
|
Updated the PR: extracted "sortByScore" and rewrote the tests as pure function tests with no mocking. |
|
Nice fix, @rakshith1928 ! |
|
@rakshith1928 I'll merge it, no need to do additional merges from main; we got some issues with flakey tests, I'm also looking into them! |
|
Hey @rakshith1928, could you please link your GitHub account to the Kilo account? This way, we can grant you credits for the merged PRs. |
…lash-command-sorting fix(vscode): sort slash commands by relevance (exact > prefix > substring)
Issue
Fixes #11534
Context
When a user types a slash-command (e.g., /commit), the dropdown results appear in their loading order rather than sorted by relevance. Since the first result is selected by default, typing an exact command name and hitting Enter frequently inserts a different command frustrating for users who expect /commit to match /commit first.
Implementation
Added a getMatchScore() function in webview-ui/src/hooks/useSlashCommand.ts that scores each command by match quality against the typed query:
The results() function now sorts descending by score, placing exact matches at the top, followed by prefix matches, then substring matches. Stable sort preserves original order for same-score items.
Screenshots / Video
How to Test
Manual/local verification
Reviewer test steps
Blocked checks and substitute verification
Checklist
Get in Touch
TRAVIX 26 Discord