The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 18:15 UTC
fix(web): cmd+k search hides subagents and favors recent, whole-word matches (#24032)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 23, 2026 at 03:25 UTC
4812dcad02a86874533540e6a0c4b7f5eaea297a
4 files changed
+142
-18
apps/mobile/src/features/keyboard/CommandPalette.tsx
+4
-1
@@ -324,7 +324,10 @@ export function CommandPalette(props: {
324
}),
325
}));
326
const threadItems: CommandPaletteItem[] = threads
327
- .filter((thread) => thread.archivedAt === null)
327
+ .filter(
328
+ (thread) =>
329
+ thread.archivedAt === null && thread.lineage.relationshipToParent !== "subagent",
330
+ )
331
.sort((left, right) =>
332
(right.latestUserMessageAt ?? right.updatedAt).localeCompare(
333
left.latestUserMessageAt ?? left.updatedAt,
apps/web/src/components/CommandPalette.logic.test.ts
+110
@@ -300,6 +300,116 @@ describe("buildThreadActionItems", () => {
300
expect.objectContaining({ value: `thread:${idThread.id}` }),
301
]);
302
});
303
+
304
+ it("hides subagent threads but keeps forks", () => {
305
+ const parentId = ThreadId.make("parent");
306
+ const items = buildThreadActionItems({
307
+ threads: [
308
+ makeThread({ id: parentId, title: "Parent" }),
309
+ makeThread({
310
+ id: ThreadId.make("subagent"),
311
+ title: "Subagent",
312
+ lineage: {
313
+ rootThreadId: parentId,
314
+ parentThreadId: parentId,
315
+ relationshipToParent: "subagent",
316
+ },
317
+ }),
318
+ makeThread({
319
+ id: ThreadId.make("fork"),
320
+ title: "Fork",
321
+ lineage: {
322
+ rootThreadId: parentId,
323
+ parentThreadId: parentId,
324
+ relationshipToParent: "fork",
325
+ },
326
+ }),
327
+ ],
328
+ projectTitleById: new Map(),
329
+ sortOrder: "updated_at",
330
+ icon: null,
331
+ runThread: async () => undefined,
332
+ });
333
+
334
+ expect(items.map((item) => item.value).toSorted()).toEqual(["thread:fork", "thread:parent"]);
335
+ });
336
+
337
+ it("ranks word-start title matches above newer mid-word matches", () => {
338
+ const items = buildThreadActionItems({
339
+ threads: [
340
+ makeThread({
341
+ id: ThreadId.make("mid-word"),
342
+ title: "Fix oauth redirect",
343
+ updatedAt: "2026-03-20T00:00:00.000Z",
344
+ }),
345
+ makeThread({
346
+ id: ThreadId.make("word-start"),
347
+ title: "Clean up auth tokens",
348
+ updatedAt: "2026-03-02T00:00:00.000Z",
349
+ }),
350
+ makeThread({
351
+ id: ThreadId.make("branch-word-start"),
352
+ title: "Refactor login",
353
+ branch: "feature/auth-cleanup",
354
+ updatedAt: "2026-03-01T00:00:00.000Z",
355
+ }),
356
+ ],
357
+ projectTitleById: new Map(),
358
+ sortOrder: "updated_at",
359
+ icon: null,
360
+ runThread: async () => undefined,
361
+ });
362
+
363
+ const groups = filterCommandPaletteGroups({
364
+ activeGroups: [],
365
+ query: "auth",
366
+ isInSubmenu: false,
367
+ projectSearchItems: [],
368
+ threadSearchItems: items,
369
+ });
370
+
371
+ expect(groups[0]?.items.map((item) => item.value)).toEqual([
372
+ "thread:word-start",
373
+ "thread:branch-word-start",
374
+ "thread:mid-word",
375
+ ]);
376
+ });
377
+
378
+ it("breaks ties within a match tier by latest user message", () => {
379
+ const items = buildThreadActionItems({
380
+ threads: [
381
+ makeThread({
382
+ id: ThreadId.make("prefix-stale"),
383
+ title: "Auth refactor",
384
+ updatedAt: "2026-03-20T00:00:00.000Z",
385
+ latestUserMessageAt: "2025-09-01T00:00:00.000Z",
386
+ }),
387
+ makeThread({
388
+ id: ThreadId.make("word-fresh"),
389
+ title: "Fix auth refresh",
390
+ updatedAt: "2026-03-10T00:00:00.000Z",
391
+ latestUserMessageAt: "2026-03-10T00:00:00.000Z",
392
+ }),
393
+ ],
394
+ projectTitleById: new Map(),
395
+ sortOrder: "updated_at",
396
+ icon: null,
397
+ runThread: async () => undefined,
398
+ });
399
+
400
+ const groups = filterCommandPaletteGroups({
401
+ activeGroups: [],
402
+ query: "auth",
403
+ isInSubmenu: false,
404
+ projectSearchItems: [],
405
+ threadSearchItems: items,
406
+ });
407
+
408
+ expect(groups[0]?.items.map((item) => item.value)).toEqual([
409
+ "thread:word-fresh",
410
+ "thread:prefix-stale",
411
+ ]);
412
+ });
413
});
414
415
describe("filterPinnedBrowseEntries", () => {
apps/web/src/components/CommandPalette.logic.ts
+27
-16
@@ -25,6 +25,7 @@ import { getThreadSortTimestamp, sortThreads } from "../lib/threadSort";
25
import { normalizeSearchText } from "../lib/utils";
26
import { formatRelativeTimeLabel } from "../timestampFormat";
27
import { type Project, type SidebarThreadSummary, type Thread } from "../types";
28
+import { isSidebarSubagentThread } from "./Sidebar.logic";
29
30
export const RECENT_THREAD_LIMIT = 12;
31
export const ITEM_ICON_CLASS = "size-4 text-icon-muted";
@@ -353,6 +354,7 @@ export type BuildThreadActionItemsThread = Pick<
354
| "createdAt"
355
| "environmentId"
356
| "id"
357
+ | "lineage"
358
| "modelSelection"
359
| "projectId"
360
| "runtime"
@@ -378,7 +380,9 @@ export function buildThreadActionItems<TThread extends BuildThreadActionItemsThr
380
limit?: number;
381
}): CommandPaletteActionItem[] {
382
const sortedThreads = sortThreads(
381
- input.threads.filter((thread) => thread.archivedAt === null),
383
+ input.threads.filter(
384
+ (thread) => thread.archivedAt === null && !isSidebarSubagentThread(thread),
385
+ ),
386
input.sortOrder,
387
);
388
const visibleThreads =
@@ -437,6 +441,16 @@ export function buildThreadActionItems<TThread extends BuildThreadActionItemsThr
441
});
442
}
443
444
+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;
449
+ }
450
+ return false;
451
+}
452
+
453
+// 3 exact, 2 field prefix, 1 every token starts a word, 0 a token only matches mid-word.
454
function rankSearchFieldMatch(
455
field: string,
456
normalizedQuery: string,
@@ -455,33 +469,30 @@ function rankSearchFieldMatch(
469
if (normalizedField.startsWith(normalizedQuery)) {
470
return 2;
471
}
458
- if (normalizedField.includes(normalizedQuery)) {
472
+ if (queryTokens.every((token) => startsWord(normalizedField, token))) {
473
return 1;
474
}
475
return 0;
476
}
477
478
+// 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.
480
function rankCommandPaletteItemMatch(
481
item: CommandPaletteActionItem | CommandPaletteSubmenuItem,
482
normalizedQuery: string,
483
queryTokens: ReadonlyArray<string>,
484
): 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()) {
487
const fieldRank = rankSearchFieldMatch(field, normalizedQuery, queryTokens);
476
- if (fieldRank !== Number.NEGATIVE_INFINITY) {
477
- if (index === 0 && item.searchRecency !== undefined) {
478
- return 1_000 + Number(fieldRank === 3);
479
- }
480
- return 1_000 - index * 100 + fieldRank;
481
- }
488
+ if (fieldRank === Number.NEGATIVE_INFINITY) continue;
489
+ const fieldScore =
490
+ index === 0 && item.searchRecency !== undefined
491
+ ? 1_000 + Number(fieldRank === 3)
492
+ : 1_000 - index * 100 + fieldRank;
493
+ best = Math.max(best, (fieldRank > 0 ? 10_000 : 0) + fieldScore);
494
}
483
-
484
- return 0;
495
+ return best;
496
}
497
498
export function filterCommandPaletteGroups(input: {
apps/web/src/components/Sidebar.logic.ts
+1
-1
@@ -512,7 +512,7 @@ export function buildMultiSelectThreadContextMenuItems(input: {
512
];
513
}
514
515
-function isSidebarSubagentThread(thread: Pick<SidebarThreadSummary, "lineage">): boolean {
515
+export function isSidebarSubagentThread(thread: Pick<SidebarThreadSummary, "lineage">): boolean {
516
return thread.lineage.relationshipToParent === "subagent";
517
}
518