fix(web): cmd+k search hides subagents and favors recent, whole-word matches #24032
Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit into
main fromrefs/pull/24032/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -437,3 +441,8 @@437441 });438442 }439443444+const ALPHANUMERIC = /[\p{L}\p{N}]/u;445+446+function startsWord(field: string, token: string): boolean {447+ for (let index = field.indexOf(token); index !== -1; index = field.indexOf(token, index + 1)) {448+ if (index === 0 || !ALPHANUMERIC.test(field[index - 1]!)) return true;
- @@ -459,16 +472,15 @@472+ if (queryTokens.every((token) => startsWord(normalizedField, token))) {459473 return 1;460474 }461475 return 0;462476 }463477478+// A word-start match in any field beats a mid-word match, then earlier fields win.479+// Thread titles collapse prefix and word-start into one tier so recency picks between them.464480 function rankCommandPaletteItemMatch(465481 item: CommandPaletteActionItem | CommandPaletteSubmenuItem,466482 normalizedQuery: string,467483 queryTokens: ReadonlyArray<string>,468484 ): number {469- const terms = item.searchTerms.filter((term) => term.length > 0);470- if (terms.length === 0) {471- return 0;472- }473-474- for (const [index, field] of terms.entries()) {485+ let best = 0;486+ for (const [index, field] of item.searchTerms.filter((term) => term.length > 0).entries()) {
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed