The best way to control Claude Code, Codex and more from any computer or phone
fix(search): keep whole-word title matches above busy prefixes (#32242)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
shivam committed
Nov 8, 2026 at 11:02 UTC
09a54f01bc0ae83865347a965ced50f8c8ec2953
2 files changed
+54
-1
packages/shared/src/paletteSearch.test.ts
+37
@@ -40,6 +40,43 @@ describe("scoreThreadSearch", () => {
40
thread("Share auth across worktrees"),
41
]),
42
).toEqual(["Share auth across worktrees", "Authentication cleanup", "Fix oauth redirect"]);
43
+ expect(
44
+ rankTitles("share auth", [
45
+ thread("Share authentication cleanup", {
46
+ activityAt: NOW,
47
+ opens: { openedAt: NOW, score: 12, picks: [] },
48
+ }),
49
+ thread("Auth across worktrees to share", { activityAt: NOW - 90 * DAY }),
50
+ ]),
51
+ ).toEqual(["Auth across worktrees to share", "Share authentication cleanup"]);
52
+ expect(
53
+ rankTitles("ui", [
54
+ thread("Parse ui tokens", { activityAt: NOW - 200 * DAY }),
55
+ thread("Polish UIs", { activityAt: NOW, opens: { openedAt: NOW, score: 12, picks: [] } }),
56
+ ]),
57
+ ).toEqual(["Polish UIs", "Parse ui tokens"]);
58
+ expect(
59
+ rankTitles("fix in sidebar", [
60
+ thread("Fix sidebar", { activityAt: NOW - 200 * DAY }),
61
+ thread("Fix crash in sidebar", {
62
+ activityAt: NOW,
63
+ opens: { openedAt: NOW, score: 12, picks: [] },
64
+ }),
65
+ thread("Fix sidebar input focus", {
66
+ activityAt: NOW,
67
+ opens: { openedAt: NOW, score: 6, picks: [] },
68
+ }),
69
+ ]),
70
+ ).toEqual(["Fix crash in sidebar", "Fix sidebar input focus", "Fix sidebar"]);
71
+ expect(
72
+ rankTitles("and", [
73
+ thread("Fix auth and sync", { activityAt: NOW - 200 * DAY }),
74
+ thread("Android build", {
75
+ activityAt: NOW,
76
+ opens: { openedAt: NOW, score: 12, picks: [] },
77
+ }),
78
+ ]),
79
+ ).toEqual(["Android build", "Fix auth and sync"]);
80
});
81
82
it("treats camelCase, kebab, path, and digit boundaries as word starts", () => {
packages/shared/src/paletteSearch.ts
+17
-1
@@ -344,6 +344,11 @@ interface WeightedSearchField {
344
interface SearchFieldsMatch {
345
/** Roughly 0.3 (inside a word) to 1.5 (exact title). */
346
readonly quality: number;
347
+ /**
348
+ * Every non-filler token has three or more characters and matched a whole word at full
349
+ * weight, before phrase bonuses. Optional filler words don't count either way.
350
+ */
351
+ readonly wholeWords: boolean;
352
/** Every token matched at a word start, without a typo. */
353
readonly strong: boolean;
354
/** Source ranges matched in the first field, for highlighting. */
@@ -407,6 +412,7 @@ function matchSearchFields(
412
const primaryRanges: SearchRange[] = [];
413
let total = 0;
414
let counted = 0;
415
+ let notWhole = false;
416
let strong = true;
417
for (const token of tokens) {
418
let best = 0;
@@ -433,6 +439,9 @@ function matchSearchFields(
439
if (bestPrimary) primaryRanges.push(...(bestPrimary.letters ?? [bestPrimary]));
440
total += best;
441
counted += 1;
442
+ // Optional filler never decides the whole-word tier; a query of only filler never earns it.
443
+ if (FILLER_WORDS.has(token)) notWhole ||= !fillerOptional;
444
+ else notWhole ||= token.length < PICK_PREFIX_MIN_LENGTH || best < WHOLE_WORD;
445
}
446
let quality = total / counted;
447
if (primary) {
@@ -441,6 +450,7 @@ function matchSearchFields(
450
}
451
return {
452
quality,
453
+ wholeWords: !notWhole,
454
strong,
455
primaryRanges: mergeRanges(primaryRanges),
456
};
@@ -851,7 +861,7 @@ function matchReference(
861
};
862
return (thread.id && matches(thread.id)) ||
863
thread.pullRequests?.some((pullRequest) => pullRequest.references?.some(matches))
854
- ? { quality: 0.6, strong: true, primaryRanges: [] }
864
+ ? { quality: 0.6, wholeWords: false, strong: true, primaryRanges: [] }
865
: null;
866
}
867
@@ -888,6 +898,7 @@ export interface ThreadSearchMatch {
898
readonly score: number;
899
/** Match quality alone; see `rankSearchGroups`. */
900
readonly quality: number;
901
+ readonly wholeWords: boolean;
902
/** Every token matched at a word start; see `rankSearchGroups`. */
903
readonly strong: boolean;
904
/** Matched ranges in the title. */
@@ -1043,6 +1054,7 @@ export function scoreThreadSearch(
1054
return {
1055
score: match.quality * threadUsageBoost(thread, now),
1056
quality: match.quality,
1057
+ wholeWords: match.wholeWords,
1058
// A thread's whole title never lifts its group over a command or project
1059
// of that name: every new thread is titled "New thread" for a while.
1060
groupQuality: Math.min(match.quality, WHOLE_NAME - 0.01),
@@ -1146,6 +1158,7 @@ export function rankSearchGroups<
1158
readonly pickedAt?: number;
1159
readonly pickedExactly?: boolean;
1160
readonly groupQuality?: number;
1161
+ readonly wholeWords?: boolean;
1162
},
1163
>(
1164
groups: ReadonlyArray<{ readonly group: G; readonly items: ReadonlyArray<T> }>,
@@ -1173,12 +1186,15 @@ export function rankSearchGroups<
1186
// A longer-query pick must not pass a whole-name match for the current query.
1187
const wordMatch = (match: M) => Math.min(matchClass(match.quality), 2);
1188
const exactPickAt = (match: M) => (match.pickedExactly ? (match.pickedAt ?? 0) : 0);
1189
+ // Use reorders whole words or prefixes among themselves, never a prefix above a whole word.
1190
+ const wholeWord = (match: M) => Number(match.wholeWords ?? match.quality >= WHOLE_WORD);
1191
const sorted = [...items].sort(
1192
(left, right) =>
1193
wordMatch(right.match) - wordMatch(left.match) ||
1194
exactPickAt(right.match) - exactPickAt(left.match) ||
1195
matchClass(right.match.quality) - matchClass(left.match.quality) ||
1196
(right.match.pickedAt ?? 0) - (left.match.pickedAt ?? 0) ||
1197
+ wholeWord(right.match) - wholeWord(left.match) ||
1198
right.match.score - left.match.score,
1199
);
1200
const best = Math.max(