Skip to content

Commit f6afef2

Browse files
fix(web): avoid overmatching skill prefixes
Co-authored-by: maria <[email protected]>
1 parent b86f1ff commit f6afef2

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

‎apps/web/src/components/chat/composerSlashCommandSearch.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ describe("searchSlashCommandItems", () => {
136136
expect(searchSlashCommandItems(items, "/skill:brow").map((item) => item.id)).toEqual([
137137
"skill:claudeAgent:browser",
138138
]);
139+
expect(searchSlashCommandItems(items, "/sk")).toEqual([]);
140+
expect(searchSlashCommandItems(items, "/ill")).toEqual([]);
139141
});
140142

141143
it("keeps skills alongside commands for an empty slash query", () => {

‎apps/web/src/components/chat/composerSlashCommandSearch.ts‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,9 @@ type SlashSearchItem = Extract<
1414

1515
function scoreSlashCommandItem(item: SlashSearchItem, query: string): number | null {
1616
if (item.type === "skill") {
17-
const scores = [
18-
scoreProviderSkill(item.skill, query),
19-
scoreQueryMatch({
20-
value: item.label.toLowerCase(),
21-
query,
22-
exactBase: 0,
23-
prefixBase: 2,
24-
boundaryBase: 4,
25-
includesBase: 6,
26-
boundaryMarkers: ["-", "_", "/", ":"],
27-
}),
28-
].filter((score): score is number => score !== null);
29-
return scores.length === 0 ? null : Math.min(...scores);
17+
const skillQuery =
18+
query === "skill" ? "" : query.startsWith("skill:") ? query.slice("skill:".length) : query;
19+
return skillQuery ? scoreProviderSkill(item.skill, skillQuery) : 0;
3020
}
3121

3222
const primaryValue =

0 commit comments

Comments
 (0)