From ea6f2bc626d75dec26ce46d471df85144de0238a Mon Sep 17 00:00:00 2001 From: DominikScholz Date: Fri, 6 Nov 2026 02:14:13 +0100 Subject: [PATCH 1/6] feat(composer): machines lead the @ menu Co-Authored-By: Claude Opus 5.5 --- .../threads/use-composer-command-menu.ts | 3 ++- .../components/chat/useComposerMenuItems.ts | 23 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/mobile/src/features/threads/use-composer-command-menu.ts b/apps/mobile/src/features/threads/use-composer-command-menu.ts index b5b6ce681c018..b036a5ab29ec6 100644 --- a/apps/mobile/src/features/threads/use-composer-command-menu.ts +++ b/apps/mobile/src/features/threads/use-composer-command-menu.ts @@ -542,8 +542,9 @@ export function useComposerCommandMenu({ ? buildComposerModelItems(modelOptions, trigger.query, modelProviders) : []; return [ - ...threadItems, + // Machines lead: there are few, and the user names one on purpose. ...environmentItems, + ...threadItems, ...modelItems, ...pathSearch.entries.map((entry) => { const parts = entry.path.normalize("NFC").split("/"); diff --git a/apps/web/src/components/chat/useComposerMenuItems.ts b/apps/web/src/components/chat/useComposerMenuItems.ts index 295260528d7f5..9054a7186ce08 100644 --- a/apps/web/src/components/chat/useComposerMenuItems.ts +++ b/apps/web/src/components/chat/useComposerMenuItems.ts @@ -212,17 +212,7 @@ export function useComposerMenuItems({ if (!composerTrigger) return []; if (composerTrigger.kind === "path") { return [ - ...matchComposerThreadItems( - { - shells: environmentThreadShells, - environmentId, - linkedEnvironments, - excludeThreadId: activeThreadId, - query: composerTrigger.query, - now, - }, - messages, - ), + // Machines lead: there are few, and the user names one on purpose. // An answer to an agent's question carries thread links, not machines. ...(questionAttachmentTarget === null && offersMachines ? matchComposerEnvironmentItems( @@ -235,6 +225,17 @@ export function useComposerMenuItems({ messages, ) : []), + ...matchComposerThreadItems( + { + shells: environmentThreadShells, + environmentId, + linkedEnvironments, + excludeThreadId: activeThreadId, + query: composerTrigger.query, + now, + }, + messages, + ), ...matchComposerModelItems({ instanceEntries: modelMentions.instanceEntries, modelOptionsByInstance: modelMentions.modelOptionsByInstance, From dd7ae74608ab30cb78f8ddadf96ddfdafb46075b Mon Sep 17 00:00:00 2001 From: DominikScholz Date: Fri, 6 Nov 2026 12:39:01 +0100 Subject: [PATCH 2/6] feat(composer): rank @ results by how surely they match A machine now matches only from the start of a word, and a file named exactly what was typed outranks it. Files starting with the query outrank threads that only match mid-word. Co-Authored-By: Claude Opus 5.5 --- .../threads/use-composer-command-menu.ts | 37 ++++---- .../components/chat/useComposerMenuItems.ts | 85 ++++++++++--------- .../src/composerThreadItems.test.ts | 47 ++++++++++ .../client-runtime/src/composerThreadItems.ts | 35 +++++++- 4 files changed, 144 insertions(+), 60 deletions(-) diff --git a/apps/mobile/src/features/threads/use-composer-command-menu.ts b/apps/mobile/src/features/threads/use-composer-command-menu.ts index b036a5ab29ec6..bd77ae292280f 100644 --- a/apps/mobile/src/features/threads/use-composer-command-menu.ts +++ b/apps/mobile/src/features/threads/use-composer-command-menu.ts @@ -11,6 +11,7 @@ import { type ComposerEnvironmentCandidate, matchComposerEnvironmentItems, matchComposerThreadItems, + rankComposerMentionItems, } from "@t3tools/client-runtime/composerThreadItems"; import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/models"; @@ -541,23 +542,25 @@ export function useComposerCommandMenu({ modelOptions && modelProviders ? buildComposerModelItems(modelOptions, trigger.query, modelProviders) : []; - return [ - // Machines lead: there are few, and the user names one on purpose. - ...environmentItems, - ...threadItems, - ...modelItems, - ...pathSearch.entries.map((entry) => { - const parts = entry.path.normalize("NFC").split("/"); - return { - id: `path:${entry.path}`, - type: "path" as const, - path: entry.path, - kind: entry.kind, - label: parts[parts.length - 1] ?? entry.path, - description: parts.length > 1 ? parts.slice(0, -1).join("/") : "", - }; - }), - ]; + return rankComposerMentionItems( + [ + ...threadItems, + ...environmentItems, + ...modelItems, + ...pathSearch.entries.map((entry) => { + const parts = entry.path.normalize("NFC").split("/"); + return { + id: `path:${entry.path}`, + type: "path" as const, + path: entry.path, + kind: entry.kind, + label: parts[parts.length - 1] ?? entry.path, + description: parts.length > 1 ? parts.slice(0, -1).join("/") : "", + }; + }), + ], + trigger.query, + ); } return []; diff --git a/apps/web/src/components/chat/useComposerMenuItems.ts b/apps/web/src/components/chat/useComposerMenuItems.ts index 9054a7186ce08..a85ccb5dc4188 100644 --- a/apps/web/src/components/chat/useComposerMenuItems.ts +++ b/apps/web/src/components/chat/useComposerMenuItems.ts @@ -6,6 +6,7 @@ import { import { matchComposerEnvironmentItems, matchComposerThreadItems, + rankComposerMentionItems, } from "@t3tools/client-runtime/composerThreadItems"; import { useAtomValue } from "@effect/atom-react"; import { useState } from "react"; @@ -211,48 +212,50 @@ export function useComposerMenuItems({ const items = ((): ComposerCommandItem[] => { if (!composerTrigger) return []; if (composerTrigger.kind === "path") { - return [ - // Machines lead: there are few, and the user names one on purpose. - // An answer to an agent's question carries thread links, not machines. - ...(questionAttachmentTarget === null && offersMachines - ? matchComposerEnvironmentItems( - { - environments: mentionableEnvironments, - linkedEnvironments, - environmentId, - query: composerTrigger.query, - }, - messages, - ) - : []), - ...matchComposerThreadItems( - { - shells: environmentThreadShells, - environmentId, - linkedEnvironments, - excludeThreadId: activeThreadId, + return rankComposerMentionItems( + [ + ...matchComposerThreadItems( + { + shells: environmentThreadShells, + environmentId, + linkedEnvironments, + excludeThreadId: activeThreadId, + query: composerTrigger.query, + now, + }, + messages, + ), + // An answer to an agent's question carries thread links, not machines. + ...(questionAttachmentTarget === null && offersMachines + ? matchComposerEnvironmentItems( + { + environments: mentionableEnvironments, + linkedEnvironments, + environmentId, + query: composerTrigger.query, + }, + messages, + ) + : []), + ...matchComposerModelItems({ + instanceEntries: modelMentions.instanceEntries, + modelOptionsByInstance: modelMentions.modelOptionsByInstance, query: composerTrigger.query, - now, - }, - messages, - ), - ...matchComposerModelItems({ - instanceEntries: modelMentions.instanceEntries, - modelOptionsByInstance: modelMentions.modelOptionsByInstance, - query: composerTrigger.query, - }), - ...workspaceEntries.entries.map((entry) => ({ - id: `path:${entry.kind}:${entry.path}`, - type: "path" as const, - path: entry.path, - pathKind: entry.kind, - searchTarget: workspaceEntries.searchedTarget, - label: basenameOfPath(entry.path).normalize("NFC"), - description: entry.path - .slice(0, Math.max(0, entry.path.lastIndexOf("/"))) - .normalize("NFC"), - })), - ]; + }), + ...workspaceEntries.entries.map((entry) => ({ + id: `path:${entry.kind}:${entry.path}`, + type: "path" as const, + path: entry.path, + pathKind: entry.kind, + searchTarget: workspaceEntries.searchedTarget, + label: basenameOfPath(entry.path).normalize("NFC"), + description: entry.path + .slice(0, Math.max(0, entry.path.lastIndexOf("/"))) + .normalize("NFC"), + })), + ], + composerTrigger.query, + ); } if (composerTrigger.kind === "slash-command") { const builtInSlashCommandItems = [ diff --git a/packages/client-runtime/src/composerThreadItems.test.ts b/packages/client-runtime/src/composerThreadItems.test.ts index 26ec3e7fde0cd..b1333b43579a2 100644 --- a/packages/client-runtime/src/composerThreadItems.test.ts +++ b/packages/client-runtime/src/composerThreadItems.test.ts @@ -4,6 +4,7 @@ import { describe, expect, it } from "vite-plus/test"; import { matchComposerEnvironmentItems, matchComposerThreadItems, + rankComposerMentionItems, type ComposerThreadCandidate, } from "./composerThreadItems.ts"; @@ -113,6 +114,19 @@ describe("matchComposerEnvironmentItems", () => { { environmentId: EnvironmentId.make("env-mini"), label: "Mac mini", machine: "mac-mini" }, ] as const; + it("matches a machine only from the start of a word", () => { + const labels = (query: string) => + matchComposerEnvironmentItems({ + environments, + environmentId: EnvironmentId.make("env-here"), + query, + }).map((item) => item.label); + expect(labels("het")).toEqual(["Hetzner VPS"]); + expect(labels("mini")).toEqual(["Mac mini"]); + expect(labels("mac mi")).toEqual(["Mac mini"]); + expect(labels("ner")).toEqual([]); + }); + it("offers the other machines matching the query, never the composer's own", () => { expect( matchComposerEnvironmentItems({ @@ -180,3 +194,36 @@ describe("matchComposerEnvironmentItems", () => { ).toEqual(["cloud"]); }); }); + +describe("rankComposerMentionItems", () => { + const thread = (label: string) => ({ type: "thread", label }); + const machine = (label: string) => ({ type: "environment", label }); + const file = (label: string) => ({ type: "path", label }); + + it.each([ + [ + "he", + [ + thread("The other one"), + thread("He said no"), + machine("Hetzner VPS"), + file("the.json"), + file("Hexyz.json"), + file("He.json"), + ], + ["He.json", "Hetzner VPS", "He said no", "Hexyz.json", "The other one", "the.json"], + ], + [ + "ner", + [thread("Partner sync"), thread("ner plan"), file("planner.md"), file("ner-notes.md")], + ["ner plan", "ner-notes.md", "Partner sync", "planner.md"], + ], + ])("orders results for %s", (query, items, expected) => { + expect(rankComposerMentionItems(items, query).map((item) => item.label)).toEqual(expected); + }); + + it("leaves a bare @ in the order it arrived", () => { + const items = [file("a.ts"), file(".env")]; + expect(rankComposerMentionItems(items, " ")).toEqual(items); + }); +}); diff --git a/packages/client-runtime/src/composerThreadItems.ts b/packages/client-runtime/src/composerThreadItems.ts index 0dd14bae76839..f0997762cef9a 100644 --- a/packages/client-runtime/src/composerThreadItems.ts +++ b/packages/client-runtime/src/composerThreadItems.ts @@ -101,6 +101,18 @@ export interface ComposerEnvironmentItem { readonly description: string; } +function startsWord(label: string, lowerCaseQuery: string): boolean { + const text = label.toLowerCase(); + for ( + let index = text.indexOf(lowerCaseQuery); + index !== -1; + index = text.indexOf(lowerCaseQuery, index + 1) + ) { + if (index === 0 || !/[\p{L}\p{N}]/u.test(text.charAt(index - 1))) return true; + } + return false; +} + /** * The machines the `@` picker offers, so the agent can link or work there: the client's paired * machines and those the composer's environment links to. The composer's own environment is @@ -127,8 +139,7 @@ export function matchComposerEnvironmentItems( return [...input.environments, ...linkedOnly] .filter( (environment) => - environment.environmentId !== input.environmentId && - environment.label.toLowerCase().includes(query), + environment.environmentId !== input.environmentId && startsWord(environment.label, query), ) .map((environment) => ({ id: `environment:${environment.environmentId}`, @@ -139,3 +150,23 @@ export function matchComposerEnvironmentItems( description: resolve(msg("Machine", { $context: "noun, search result type" })), })); } + +/** + * Orders `@` results by how surely they are what was typed: a file with exactly that name, then + * machines, threads with a word starting with it, files starting with it, and the rest. + */ +export function rankComposerMentionItems< + T extends { readonly type: string; readonly label: string }, +>(items: ReadonlyArray, rawQuery: string): T[] { + const query = rawQuery.trim().toLowerCase(); + if (query.length === 0) return [...items]; + const rank = ({ type, label }: T) => { + if (type === "environment") return 1; + if (type === "thread") return startsWord(label, query) ? 2 : 4; + const name = label.toLowerCase(); + if (name === query || name.startsWith(`${query}.`)) return 0; + return name.startsWith(query) ? 3 : 5; + }; + // Hermes lacks toSorted. + return [...items].sort((left, right) => rank(left) - rank(right)); +} From 529ffa3619c5d2cd5c2b1faa78cf018b88be2872 Mon Sep 17 00:00:00 2001 From: DominikScholz Date: Fri, 6 Nov 2026 12:42:46 +0100 Subject: [PATCH 3/6] fix(composer): thread ranking uses the search's own word rules Co-Authored-By: Claude Opus 5.5 --- .../src/composerThreadItems.test.ts | 10 +++++++ .../client-runtime/src/composerThreadItems.ts | 30 ++++++++----------- packages/shared/src/paletteSearch.ts | 13 ++++++++ 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/packages/client-runtime/src/composerThreadItems.test.ts b/packages/client-runtime/src/composerThreadItems.test.ts index b1333b43579a2..a1f792e6b37df 100644 --- a/packages/client-runtime/src/composerThreadItems.test.ts +++ b/packages/client-runtime/src/composerThreadItems.test.ts @@ -218,6 +218,16 @@ describe("rankComposerMentionItems", () => { [thread("Partner sync"), thread("ner plan"), file("planner.md"), file("ner-notes.md")], ["ner plan", "ner-notes.md", "Partner sync", "planner.md"], ], + [ + "model", + [file("model-notes.md"), thread("FixModelPicker")], + ["FixModelPicker", "model-notes.md"], + ], + [ + "resume", + [file("resume-notes.md"), thread("Résumé fixes")], + ["Résumé fixes", "resume-notes.md"], + ], ])("orders results for %s", (query, items, expected) => { expect(rankComposerMentionItems(items, query).map((item) => item.label)).toEqual(expected); }); diff --git a/packages/client-runtime/src/composerThreadItems.ts b/packages/client-runtime/src/composerThreadItems.ts index f0997762cef9a..56f926b5c38e9 100644 --- a/packages/client-runtime/src/composerThreadItems.ts +++ b/packages/client-runtime/src/composerThreadItems.ts @@ -5,7 +5,12 @@ import { type ScopedThreadRef, type ThreadId, } from "@t3tools/contracts"; -import { foldSearchQuery, rankSearchItems, scoreThreadSearch } from "@t3tools/shared/paletteSearch"; +import { + foldSearchQuery, + rankSearchItems, + scoreThreadSearch, + startsSearchWord, +} from "@t3tools/shared/paletteSearch"; import type { EnvironmentThreadShell } from "./state/models.ts"; import { threadSearchSubject, type ThreadSearchShell } from "./state/threadSearch.ts"; @@ -101,18 +106,6 @@ export interface ComposerEnvironmentItem { readonly description: string; } -function startsWord(label: string, lowerCaseQuery: string): boolean { - const text = label.toLowerCase(); - for ( - let index = text.indexOf(lowerCaseQuery); - index !== -1; - index = text.indexOf(lowerCaseQuery, index + 1) - ) { - if (index === 0 || !/[\p{L}\p{N}]/u.test(text.charAt(index - 1))) return true; - } - return false; -} - /** * The machines the `@` picker offers, so the agent can link or work there: the client's paired * machines and those the composer's environment links to. The composer's own environment is @@ -128,7 +121,7 @@ export function matchComposerEnvironmentItems( }, resolve: MFunctionType = mFallback, ): ComposerEnvironmentItem[] { - const query = input.query.trim().toLowerCase(); + const query = foldSearchQuery(input.query); if (query.length === 0) return []; const paired = new Set(input.environments.map((environment) => environment.environmentId)); const linkedOnly = Array.from(input.linkedEnvironments, ([environmentId, label]) => ({ @@ -139,7 +132,8 @@ export function matchComposerEnvironmentItems( return [...input.environments, ...linkedOnly] .filter( (environment) => - environment.environmentId !== input.environmentId && startsWord(environment.label, query), + environment.environmentId !== input.environmentId && + startsSearchWord(environment.label, query), ) .map((environment) => ({ id: `environment:${environment.environmentId}`, @@ -158,12 +152,12 @@ export function matchComposerEnvironmentItems( export function rankComposerMentionItems< T extends { readonly type: string; readonly label: string }, >(items: ReadonlyArray, rawQuery: string): T[] { - const query = rawQuery.trim().toLowerCase(); + const query = foldSearchQuery(rawQuery); if (query.length === 0) return [...items]; const rank = ({ type, label }: T) => { if (type === "environment") return 1; - if (type === "thread") return startsWord(label, query) ? 2 : 4; - const name = label.toLowerCase(); + if (type === "thread") return startsSearchWord(label, query) ? 2 : 4; + const name = foldSearchQuery(label); if (name === query || name.startsWith(`${query}.`)) return 0; return name.startsWith(query) ? 3 : 5; }; diff --git a/packages/shared/src/paletteSearch.ts b/packages/shared/src/paletteSearch.ts index a2de064ca4969..c01f1b9e72841 100644 --- a/packages/shared/src/paletteSearch.ts +++ b/packages/shared/src/paletteSearch.ts @@ -142,6 +142,19 @@ export function foldSearchQuery(query: string): string { .join(" "); } +/** Whether `foldedQuery`, from `foldSearchQuery`, begins a word of `text`. */ +export function startsSearchWord(text: string, foldedQuery: string): boolean { + const field = prepareSearchField(text); + for ( + let index = field.text.indexOf(foldedQuery); + index !== -1; + index = field.text.indexOf(foldedQuery, index + 1) + ) { + if (field.wordStarts[index]) return true; + } + return false; +} + function wordEnd(field: SearchField, index: number): number { let end = index + 1; while (end < field.text.length && !field.wordStarts[end] && ALPHANUMERIC.test(field.text[end]!)) { From f1153a01b646c6104c3db769f46d3ed990568ad9 Mon Sep 17 00:00:00 2001 From: DominikScholz Date: Thu, 19 Nov 2026 12:14:22 +0100 Subject: [PATCH 4/6] perf(composer): rank each @ result once before sorting Co-Authored-By: Claude Opus 5.5 --- packages/client-runtime/src/composerThreadItems.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/client-runtime/src/composerThreadItems.ts b/packages/client-runtime/src/composerThreadItems.ts index 56f926b5c38e9..280eb27676b9f 100644 --- a/packages/client-runtime/src/composerThreadItems.ts +++ b/packages/client-runtime/src/composerThreadItems.ts @@ -162,5 +162,8 @@ export function rankComposerMentionItems< return name.startsWith(query) ? 3 : 5; }; // Hermes lacks toSorted. - return [...items].sort((left, right) => rank(left) - rank(right)); + return items + .map((item) => ({ item, rank: rank(item) })) + .sort((left, right) => left.rank - right.rank) + .map(({ item }) => item); } From 125601a007c31a5d5be9560c54d802a38d3d47e1 Mon Sep 17 00:00:00 2001 From: DominikScholz Date: Thu, 19 Nov 2026 12:25:55 +0100 Subject: [PATCH 5/6] fix(composer): keep exact directory matches below machines --- apps/mobile/src/features/threads/ComposerCommandPopover.tsx | 4 ++-- .../src/features/threads/use-composer-command-menu.ts | 2 +- packages/client-runtime/src/composerThreadItems.test.ts | 5 ++++- packages/client-runtime/src/composerThreadItems.ts | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/mobile/src/features/threads/ComposerCommandPopover.tsx b/apps/mobile/src/features/threads/ComposerCommandPopover.tsx index bf34ff7777262..e0d1dda22aaa7 100644 --- a/apps/mobile/src/features/threads/ComposerCommandPopover.tsx +++ b/apps/mobile/src/features/threads/ComposerCommandPopover.tsx @@ -37,7 +37,7 @@ export type ComposerCommandItem = readonly id: string; readonly type: "path"; readonly path: string; - readonly kind: "file" | "directory"; + readonly pathKind: "file" | "directory"; readonly label: string; readonly description: string; } @@ -198,7 +198,7 @@ const CommandRow = memo(function CommandRow(props: { style={{ borderBottomWidth: props.isLast ? 0 : StyleSheet.hairlineWidth }} > {props.item.type === "path" ? ( - + ) : props.item.type === "model" ? ( 1 ? parts.slice(0, -1).join("/") : "", }; diff --git a/packages/client-runtime/src/composerThreadItems.test.ts b/packages/client-runtime/src/composerThreadItems.test.ts index a1f792e6b37df..8fdec6aa4dc0d 100644 --- a/packages/client-runtime/src/composerThreadItems.test.ts +++ b/packages/client-runtime/src/composerThreadItems.test.ts @@ -198,9 +198,12 @@ describe("matchComposerEnvironmentItems", () => { describe("rankComposerMentionItems", () => { const thread = (label: string) => ({ type: "thread", label }); const machine = (label: string) => ({ type: "environment", label }); - const file = (label: string) => ({ type: "path", label }); + const file = (label: string) => ({ type: "path", label, pathKind: "file" }); + const directory = (label: string) => ({ type: "path", label, pathKind: "directory" }); + const model = (label: string) => ({ type: "model", label }); it.each([ + ["dev", [directory("dev"), machine("Dev box")], ["Dev box", "dev"]], [ "he", [ diff --git a/packages/client-runtime/src/composerThreadItems.ts b/packages/client-runtime/src/composerThreadItems.ts index 280eb27676b9f..9d195b6cba047 100644 --- a/packages/client-runtime/src/composerThreadItems.ts +++ b/packages/client-runtime/src/composerThreadItems.ts @@ -150,15 +150,15 @@ export function matchComposerEnvironmentItems( * machines, threads with a word starting with it, files starting with it, and the rest. */ export function rankComposerMentionItems< - T extends { readonly type: string; readonly label: string }, + T extends { readonly type: string; readonly label: string; readonly pathKind?: string }, >(items: ReadonlyArray, rawQuery: string): T[] { const query = foldSearchQuery(rawQuery); if (query.length === 0) return [...items]; - const rank = ({ type, label }: T) => { + const rank = ({ type, label, pathKind }: T) => { if (type === "environment") return 1; if (type === "thread") return startsSearchWord(label, query) ? 2 : 4; const name = foldSearchQuery(label); - if (name === query || name.startsWith(`${query}.`)) return 0; + if (pathKind === "file" && (name === query || name.startsWith(`${query}.`))) return 0; return name.startsWith(query) ? 3 : 5; }; // Hermes lacks toSorted. From df2b468b55a04f8bd56bf71340ea1f9566704417 Mon Sep 17 00:00:00 2001 From: DominikScholz Date: Sun, 22 Nov 2026 20:29:19 +0100 Subject: [PATCH 6/6] fix(composer): models keep their order beside word-start threads in @ Co-Authored-By: Claude Opus 5.5 --- .../client-runtime/src/composerThreadItems.test.ts | 11 +++++++++++ packages/client-runtime/src/composerThreadItems.ts | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/client-runtime/src/composerThreadItems.test.ts b/packages/client-runtime/src/composerThreadItems.test.ts index 8fdec6aa4dc0d..38543bea61c9e 100644 --- a/packages/client-runtime/src/composerThreadItems.test.ts +++ b/packages/client-runtime/src/composerThreadItems.test.ts @@ -118,6 +118,7 @@ describe("matchComposerEnvironmentItems", () => { const labels = (query: string) => matchComposerEnvironmentItems({ environments, + linkedEnvironments: new Map(), environmentId: EnvironmentId.make("env-here"), query, }).map((item) => item.label); @@ -221,6 +222,16 @@ describe("rankComposerMentionItems", () => { [thread("Partner sync"), thread("ner plan"), file("planner.md"), file("ner-notes.md")], ["ner plan", "ner-notes.md", "Partner sync", "planner.md"], ], + [ + "sonnet", + [ + thread("Sonnet pricing"), + model("Sonnet 5.5"), + model("Claude Sonnet 4"), + file("sonnet-notes.md"), + ], + ["Sonnet pricing", "Sonnet 5.5", "Claude Sonnet 4", "sonnet-notes.md"], + ], [ "model", [file("model-notes.md"), thread("FixModelPicker")], diff --git a/packages/client-runtime/src/composerThreadItems.ts b/packages/client-runtime/src/composerThreadItems.ts index 9d195b6cba047..b099c871208cb 100644 --- a/packages/client-runtime/src/composerThreadItems.ts +++ b/packages/client-runtime/src/composerThreadItems.ts @@ -147,7 +147,8 @@ export function matchComposerEnvironmentItems( /** * Orders `@` results by how surely they are what was typed: a file with exactly that name, then - * machines, threads with a word starting with it, files starting with it, and the rest. + * machines, threads with a word starting with it, models (in their own order), files starting + * with it, and the rest. */ export function rankComposerMentionItems< T extends { readonly type: string; readonly label: string; readonly pathKind?: string }, @@ -156,6 +157,7 @@ export function rankComposerMentionItems< if (query.length === 0) return [...items]; const rank = ({ type, label, pathKind }: T) => { if (type === "environment") return 1; + if (type === "model") return 2; if (type === "thread") return startsSearchWord(label, query) ? 2 : 4; const name = foldSearchQuery(label); if (pathKind === "file" && (name === query || name.startsWith(`${query}.`))) return 0;