feat(web,mobile): machines come first in the @ menu #31966
ClosedDominikScholz(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/31966/headopened View on GitHubPushed84d2e5c
- @@ -124,3 +129,20 @@124129 description: resolve(msg("Machine", { $context: "noun, search result type" })),125130 }));126131 }132+133+/**134+ * Orders `@` results by how surely they are what was typed: a file with exactly that name, then135+ * machines, threads with a word starting with it, models (in their own order), files starting136+ * with it, and the rest.137+ */138+export function rankComposerMentionItems<139+ T extends { readonly type: string; readonly label: string },140+>(items: ReadonlyArray<T>, rawQuery: string): T[] {141+ const query = foldSearchQuery(rawQuery);142+ if (query.length === 0) return [...items];143+ const rank = ({ type, label }: T) => {144+ if (type === "environment") return 1;145+ if (type === "model") return 2;146+ if (type === "thread") return startsSearchWord(label, query) ? 2 : 4;147+ const name = foldSearchQuery(label);148+ if (name === query || name.startsWith(`${query}.`)) return 0;
Pusheddf2b468
juliusmarminge closed this
Sign in to join this conversation.


coderabbitai[bot](GitHub profile, opens in a new tab) reviewed
Actionable comments posted: 1
45d76539-bc69-4bb2-aae8-090e20f27d91Reviewing files that changed from the base of the PR and between 206462e945bea2b282f7fa80037dd7fd23d03bd0 and 84d2e5cf98962c6600d6afb03d3af2fde86c1886.
apps/mobile/src/features/threads/use-composer-command-menu.tsapps/web/src/components/chat/useComposerMenuItems.tspackages/client-runtime/src/composerThreadItems.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.