Skip to content

fix(chat): prioritize slash command name matches and strip skill prefix - #1414

Open
salmanabdurrahman wants to merge 1 commit into
agegr:mainfrom
salmanabdurrahman:fix/slash-command-query-ranking
Open

salmanabdurrahman wants to merge 1 commit into
agegr:mainfrom
salmanabdurrahman:fix/slash-command-query-ranking

Conversation

@salmanabdurrahman

Copy link
Copy Markdown

Fixes #1413

What

Addresses #1413 by refining the slash command palette's search filtering and ranking in components/ChatInput.tsx (and demo/components/ChatInput.tsx):

  • Name-first suppression: When at least one command matches the query in its identifier/name, noisy description-only matches are suppressed (e.g. typing /copy returns solely the built-in /copy command instead of pulling in unrelated skills that mention "copy" in their prose).
  • Skill namespace normalization: Strips the internal skill: prefix for ranking and matching, allowing clean prefix and token-boundary matching on the skill's actual identifier.
  • Description fallback: When no command matches the query by name (e.g. searching concepts or terms like /assistant), the palette smoothly falls back to searching description text across all sources.

How

  • getCleanSlashName(command): strips the "skill:" prefix for skills, allowing clean prefix (startsWith) and token-boundary matching on the actual skill name.
  • slashMatchRank(command, query, t): assigns a deterministic ranking score:
    • Exact match (0)
    • Prefix match (1)
    • Token boundary match (2, -query or _query)
    • Substring match (3)
    • Description match (4)
  • filterSlashCommands(commands, query, t): checks if any command has a name match (hasNameMatch). If true, discards description-only hits. If false, falls back to description searching.
  • Safe getSlashDescription: guards missing/undefined descriptions on built-in and custom commands before calling .toLowerCase().
  • Mirrored logic in demo/components/ChatInput.tsx.
  • Added unit test suite components/ChatInput.slash-filter.test.mjs (9 tests) covering clean name extraction, ranking hierarchy, description suppression on /copy, description fallback across all command types (builtin, extension, prompt, skill), dormancy partitioning, uppercase handling, and safe handling of regex characters.

Checks

  • node --test components/ChatInput.slash-filter.test.mjs (9/9 pass)
  • node --test components/ChatInput.dormancy.test.mjs (1/1 pass)
  • node --experimental-strip-types --test "components/**/*.test.mjs" (all pass)
  • node_modules/.bin/tsc --noEmit (clean, 0 error)
  • npm run lint (clean, 0 error)
  • npm test (passes)

Before

Image

After

Image

- strip skill prefix in getCleanSlashName for prefix and token ranking
- rank exact, prefix, token, and substring name matches ahead of descriptions
- suppress noisy description-only matches when any command matches by name
- retain description matching as fallback when no names match query
- guard getSlashDescription against undefined builtin command descriptions
- add unit tests for slash command ranking across all command sources
Copilot AI balanced review requested due to automatic review settings October 25, 2026 15:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

This branch has not been deployed

No deployments
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.

fix(chat): slash command query matches noisy descriptions over exact command names

2 participants