The best way to control Claude Code, Codex and more from any computer or phone
fix(web): model picker search lists newest models first (#18494)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Gabriel De Andrade <gabrieldeandradeleal@gmail.com>
Christopher Ehrlich committed
Oct 16, 2026 at 03:37 UTC
ede3f2d6ba4943ba0a14aa4af656cfa537a1efe6
4 files changed
+272
-77
apps/web/src/components/chat/ModelPickerContent.tsx
+14
-71
@@ -21,7 +21,7 @@ import {
21
parseModelPickerLegacySectionKey,
22
parseModelPickerModelKey,
23
} from "./modelPickerKeys";
24
-import { buildModelPickerSearchText, scoreModelPickerSearch } from "./modelPickerSearch";
24
+import { rankModelPickerSearch } from "./modelPickerSearch";
25
import {
26
Combobox,
27
ComboboxEmpty,
@@ -451,77 +451,20 @@ export const ModelPickerContent = memo(function ModelPickerContent(props: {
451
let result = flatModels;
452
453
// Apply tokenized fuzzy search across the combined provider/model search fields.
454
+ // When searching, we only respect locked provider (by driver kind),
455
+ // ignoring sidebar selection so account-scoped searches can find a
456
+ // model before the user chooses a specific instance rail item.
457
if (searchQuery.trim()) {
455
- const rankedMatches = result
456
- .map((model) => ({
457
- model,
458
- score: scoreModelPickerSearch(
459
- {
460
- name: model.name,
461
- ...(model.shortName ? { shortName: model.shortName } : {}),
462
- ...(model.subProvider ? { subProvider: model.subProvider } : {}),
463
- driverKind: model.driverKind,
464
- providerDisplayName: model.instanceDisplayName,
465
- isFavorite: favoritesSet.has(providerModelKey(model.instanceId, model.slug)),
466
- },
467
- searchQuery,
468
- ),
469
- isFavorite: favoritesSet.has(providerModelKey(model.instanceId, model.slug)),
470
- tieBreaker: buildModelPickerSearchText({
471
- name: model.name,
472
- ...(model.shortName ? { shortName: model.shortName } : {}),
473
- ...(model.subProvider ? { subProvider: model.subProvider } : {}),
474
- driverKind: model.driverKind,
475
- providerDisplayName: model.instanceDisplayName,
476
- }),
477
- }))
478
- .filter(
479
- (
480
- rankedModel,
481
- ): rankedModel is {
482
- model: ModelPickerItem;
483
- score: number;
484
- isFavorite: boolean;
485
- tieBreaker: string;
486
- } => rankedModel.score !== null,
487
- );
488
-
489
- // When searching, we only respect locked provider (by driver kind),
490
- // ignoring sidebar selection so account-scoped searches can find a
491
- // model before the user chooses a specific instance rail item.
492
- if (props.lockedProvider !== null) {
493
- const lockedProviderMatches: Array<(typeof rankedMatches)[number]> = [];
494
- for (const rankedModel of rankedMatches) {
495
- if (matchesLockedProvider(rankedModel.model)) {
496
- lockedProviderMatches.push(rankedModel);
497
- }
498
- }
499
- return lockedProviderMatches
500
- .toSorted((a, b) => {
501
- const scoreDelta = a.score - b.score;
502
- if (scoreDelta !== 0) {
503
- return scoreDelta;
504
- }
505
- if (a.isFavorite !== b.isFavorite) {
506
- return a.isFavorite ? -1 : 1;
507
- }
508
- return a.tieBreaker.localeCompare(b.tieBreaker);
509
- })
510
- .map((rankedModel) => rankedModel.model);
511
- }
512
-
513
- return rankedMatches
514
- .toSorted((a, b) => {
515
- const scoreDelta = a.score - b.score;
516
- if (scoreDelta !== 0) {
517
- return scoreDelta;
518
- }
519
- if (a.isFavorite !== b.isFavorite) {
520
- return a.isFavorite ? -1 : 1;
521
- }
522
- return a.tieBreaker.localeCompare(b.tieBreaker);
523
- })
524
- .map((rankedModel) => rankedModel.model);
458
+ const candidates =
459
+ props.lockedProvider !== null ? result.filter((m) => matchesLockedProvider(m)) : result;
460
+ return rankModelPickerSearch(candidates, searchQuery, (model) => ({
461
+ name: model.name,
462
+ ...(model.shortName ? { shortName: model.shortName } : {}),
463
+ ...(model.subProvider ? { subProvider: model.subProvider } : {}),
464
+ driverKind: model.driverKind,
465
+ providerDisplayName: model.instanceDisplayName,
466
+ isFavorite: favoritesSet.has(providerModelKey(model.instanceId, model.slug)),
467
+ }));
468
}
469
470
if (props.lockedProvider !== null) {
apps/web/src/components/chat/modelPickerSearch.test.ts
+189
-1
@@ -1,6 +1,10 @@
1
import { describe, expect, it } from "vite-plus/test";
2
3
-import { buildModelPickerSearchText, scoreModelPickerSearch } from "./modelPickerSearch";
3
+import {
4
+ buildModelPickerSearchText,
5
+ rankModelPickerSearch,
6
+ scoreModelPickerSearch,
7
+} from "./modelPickerSearch";
8
9
describe("buildModelPickerSearchText", () => {
10
it("builds provider-agnostic search text from generic fields", () => {
@@ -129,3 +133,187 @@ describe("scoreModelPickerSearch", () => {
133
).not.toBeNull();
134
});
135
});
136
+
137
+type CatalogModel = {
138
+ driverKind: string;
139
+ providerDisplayName: string;
140
+ name: string;
141
+ subProvider?: string;
142
+ isFavorite?: boolean;
143
+};
144
+
145
+function instanceModels(
146
+ driverKind: string,
147
+ providerDisplayName: string,
148
+ names: ReadonlyArray<string>,
149
+): CatalogModel[] {
150
+ return names.map((name) => ({ driverKind, providerDisplayName, name }));
151
+}
152
+
153
+// Each provider lists its models newest first, as the picker receives them.
154
+// Claude, Codex, and Antigravity mirror apps/server/src/provider/model-manifest.json;
155
+// Grok and OpenCode report their catalogs at runtime.
156
+const catalog: CatalogModel[] = [
157
+ ...instanceModels("claudeAgent", "Claude", [
158
+ "Claude Opus 5.5",
159
+ "Claude Sonnet 5.5",
160
+ "Claude Fable 5.1",
161
+ "Claude Fable 5",
162
+ "Claude Opus 5",
163
+ "Claude Opus 4.8",
164
+ "Claude Opus 4.7",
165
+ "Claude Opus 4.6",
166
+ "Claude Opus 4.5",
167
+ "Claude Sonnet 5",
168
+ "Claude Sonnet 4.6",
169
+ "Claude Haiku 5.5",
170
+ "Claude Haiku 4.5",
171
+ ]),
172
+ ...instanceModels("codex", "Codex", [
173
+ "GPT-6.1 Sol",
174
+ "GPT-6 Astra",
175
+ "GPT-6 Luna",
176
+ "GPT-6 Sol",
177
+ "GPT-5.6 Sol",
178
+ "GPT-5.6 Terra",
179
+ "GPT-5.6 Luna",
180
+ "GPT-5.5",
181
+ ]),
182
+ ...instanceModels("grok", "Grok", ["Grok 4.7", "Grok 4.6", "Grok 4.5"]),
183
+ ...instanceModels("antigravity", "Antigravity", [
184
+ "Gemini 3.8 Flash (High)",
185
+ "Gemini 3.8 Flash (Medium)",
186
+ "Gemini 3.8 Flash (Low)",
187
+ "Gemini 3.7 Flash (High)",
188
+ "Gemini 3.7 Flash (Medium)",
189
+ "Gemini 3.7 Flash (Low)",
190
+ "Gemini 3.6 Flash (High)",
191
+ "Gemini 3.6 Flash (Medium)",
192
+ "Gemini 3.6 Flash (Low)",
193
+ "Gemini 3.1 Pro (High)",
194
+ "Gemini 3.1 Pro (Low)",
195
+ ]),
196
+ {
197
+ driverKind: "opencode",
198
+ providerDisplayName: "OpenCode",
199
+ name: "Kimi K3",
200
+ subProvider: "Moonshot",
201
+ },
202
+ {
203
+ driverKind: "opencode",
204
+ providerDisplayName: "OpenCode",
205
+ name: "Kimi K2.5",
206
+ subProvider: "Moonshot",
207
+ },
208
+ {
209
+ driverKind: "opencode",
210
+ providerDisplayName: "OpenCode",
211
+ name: "Kimi K2",
212
+ subProvider: "Moonshot",
213
+ },
214
+];
215
+
216
+function search(query: string, models: ReadonlyArray<CatalogModel> = catalog): string[] {
217
+ return rankModelPickerSearch(models, query, (model) => model).map((model) => model.name);
218
+}
219
+
220
+describe("rankModelPickerSearch", () => {
221
+ it.each([
222
+ [
223
+ "opus",
224
+ [
225
+ "Claude Opus 5.5",
226
+ "Claude Opus 5",
227
+ "Claude Opus 4.8",
228
+ "Claude Opus 4.7",
229
+ "Claude Opus 4.6",
230
+ "Claude Opus 4.5",
231
+ ],
232
+ ],
233
+ ["sonnet", ["Claude Sonnet 5.5", "Claude Sonnet 5", "Claude Sonnet 4.6"]],
234
+ ["fable", ["Claude Fable 5.1", "Claude Fable 5"]],
235
+ ["haiku", ["Claude Haiku 5.5", "Claude Haiku 4.5"]],
236
+ [
237
+ "gpt",
238
+ [
239
+ "GPT-6.1 Sol",
240
+ "GPT-6 Astra",
241
+ "GPT-6 Luna",
242
+ "GPT-6 Sol",
243
+ "GPT-5.6 Sol",
244
+ "GPT-5.6 Terra",
245
+ "GPT-5.6 Luna",
246
+ "GPT-5.5",
247
+ ],
248
+ ],
249
+ ["sol", ["GPT-6.1 Sol", "GPT-6 Sol", "GPT-5.6 Sol"]],
250
+ ["luna", ["GPT-6 Luna", "GPT-5.6 Luna"]],
251
+ ["grok", ["Grok 4.7", "Grok 4.6", "Grok 4.5"]],
252
+ [
253
+ "flash",
254
+ [
255
+ "Gemini 3.8 Flash (High)",
256
+ "Gemini 3.8 Flash (Medium)",
257
+ "Gemini 3.8 Flash (Low)",
258
+ "Gemini 3.7 Flash (High)",
259
+ "Gemini 3.7 Flash (Medium)",
260
+ "Gemini 3.7 Flash (Low)",
261
+ "Gemini 3.6 Flash (High)",
262
+ "Gemini 3.6 Flash (Medium)",
263
+ "Gemini 3.6 Flash (Low)",
264
+ ],
265
+ ],
266
+ ["kimi", ["Kimi K3", "Kimi K2.5", "Kimi K2"]],
267
+ ])("lists equally good matches for %j newest first", (query, expected) => {
268
+ // Loose fuzzy matches from other families may follow; they rank last.
269
+ expect(search(query).slice(0, expected.length)).toEqual(expected);
270
+ });
271
+
272
+ it("keeps newest first when a version token narrows the family", () => {
273
+ expect(search("opus 4")).toEqual([
274
+ "Claude Opus 4.8",
275
+ "Claude Opus 4.7",
276
+ "Claude Opus 4.6",
277
+ "Claude Opus 4.5",
278
+ ]);
279
+ // "5" only appears mid-version in 4.5, a weaker match.
280
+ expect(search("opus 5")).toEqual(["Claude Opus 5.5", "Claude Opus 5", "Claude Opus 4.5"]);
281
+ expect(search("opus 5.")).toEqual(["Claude Opus 5.5"]);
282
+ });
283
+
284
+ it("still ranks an exact name above newer models that extend it", () => {
285
+ expect(search("gpt-6 sol").slice(0, 2)).toEqual(["GPT-6 Sol", "GPT-6.1 Sol"]);
286
+ expect(search("claude opus 5").slice(0, 2)).toEqual(["Claude Opus 5", "Claude Opus 5.5"]);
287
+ expect(search("Grok 4.6")[0]).toBe("Grok 4.6");
288
+ });
289
+
290
+ it("matches an exact name regardless of extra whitespace in the query", () => {
291
+ expect(search(" claude opus 5 ")[0]).toBe("Claude Opus 5");
292
+ });
293
+
294
+ it("ranks an exact name above a favorite partial match", () => {
295
+ const models = catalog.map((model) =>
296
+ model.name === "Claude Opus 5.5" ? { ...model, isFavorite: true } : model,
297
+ );
298
+ expect(search("claude opus 5", models)[0]).toBe("Claude Opus 5");
299
+ });
300
+
301
+ it("matches the provider when the name does not", () => {
302
+ expect(search("moonshot")).toEqual(["Kimi K3", "Kimi K2.5", "Kimi K2"]);
303
+ });
304
+
305
+ it("ranks a favorite above newer models in the same family", () => {
306
+ const models = catalog.map((model) =>
307
+ model.name === "Claude Opus 4.5" ? { ...model, isFavorite: true } : model,
308
+ );
309
+ expect(search("opus", models).slice(0, 3)).toEqual([
310
+ "Claude Opus 4.5",
311
+ "Claude Opus 5.5",
312
+ "Claude Opus 5",
313
+ ]);
314
+ });
315
+
316
+ it("follows the order it is given, including a user's custom model order", () => {
317
+ expect(search("grok", catalog.toReversed())).toEqual(["Grok 4.5", "Grok 4.6", "Grok 4.7"]);
318
+ });
319
+});
apps/web/src/components/chat/modelPickerSearch.ts
+50
@@ -16,6 +16,8 @@ type ModelPickerSearchableModel = {
16
};
17
18
const MODEL_PICKER_FAVORITE_SCORE_BOOST = 24;
19
+// Far below any token-scored match, favorites included.
20
+const MODEL_PICKER_EXACT_NAME_SCORE = -1000;
21
22
function getModelPickerSearchFields(model: ModelPickerSearchableModel): string[] {
23
return [
@@ -41,9 +43,14 @@ function scoreModelPickerSearchToken(
43
boundaryBase: fieldBase + 4,
44
includesBase: fieldBase + 6,
45
...(token.length >= 3 ? { fuzzyBase: fieldBase + 100 } : {}),
46
+ ignorePosition: true,
47
});
48
}
49
50
+function normalizeModelName(name: string): string {
51
+ return normalizeSearchQuery(name).replace(/\s+/gu, " ");
52
+}
53
+
54
export function buildModelPickerSearchText(model: ModelPickerSearchableModel): string {
55
return normalizeSearchQuery(
56
[model.name, model.shortName, model.subProvider, model.driverKind, model.providerDisplayName]
@@ -64,6 +71,14 @@ export function scoreModelPickerSearch(
71
return 0;
72
}
73
74
+ const normalizedQuery = tokens.join(" ");
75
+ if (
76
+ normalizedQuery === normalizeModelName(model.name) ||
77
+ normalizedQuery === normalizeModelName(model.shortName ?? "")
78
+ ) {
79
+ return MODEL_PICKER_EXACT_NAME_SCORE;
80
+ }
81
+
82
const fields = getModelPickerSearchFields(model);
83
let score = 0;
84
@@ -85,3 +100,38 @@ export function scoreModelPickerSearch(
100
101
return model.isFavorite ? score - MODEL_PICKER_FAVORITE_SCORE_BOOST : score;
102
}
103
+
104
+/**
105
+ * Filters `items` to those matching `query`, best match first. Equal matches
106
+ * keep their order in `items`, which is the provider's own newest-first order.
107
+ */
108
+export function rankModelPickerSearch<T>(
109
+ items: ReadonlyArray<T>,
110
+ query: string,
111
+ toSearchable: (item: T) => ModelPickerSearchableModel,
112
+): T[] {
113
+ const ranked: Array<{
114
+ item: T;
115
+ score: number;
116
+ isFavorite: boolean;
117
+ order: number;
118
+ }> = [];
119
+ items.forEach((item, order) => {
120
+ const searchable = toSearchable(item);
121
+ const score = scoreModelPickerSearch(searchable, query);
122
+ if (score !== null) {
123
+ ranked.push({
124
+ item,
125
+ score,
126
+ isFavorite: searchable.isFavorite === true,
127
+ order,
128
+ });
129
+ }
130
+ });
131
+ return ranked
132
+ .toSorted(
133
+ (a, b) =>
134
+ a.score - b.score || Number(b.isFavorite) - Number(a.isFavorite) || a.order - b.order,
135
+ )
136
+ .map((entry) => entry.item);
137
+}
packages/shared/src/searchRanking.ts
+19
-5
@@ -19,7 +19,11 @@ export function normalizeSearchQuery(
19
: trimmed.toLowerCase();
20
}
21
22
-export function scoreSubsequenceMatch(value: string, query: string): number | null {
22
+export function scoreSubsequenceMatch(
23
+ value: string,
24
+ query: string,
25
+ options?: { ignorePosition?: boolean },
26
+): number | null {
27
if (!query) return 0;
28
29
let queryIndex = 0;
@@ -43,6 +47,9 @@ export function scoreSubsequenceMatch(value: string, query: string): number | nu
47
queryIndex += 1;
48
if (queryIndex === query.length) {
49
const spanPenalty = valueIndex - firstMatchIndex + 1 - query.length;
50
+ if (options?.ignorePosition) {
51
+ return gapPenalty * 3 + spanPenalty;
52
+ }
53
const lengthPenalty = Math.min(64, value.length - query.length);
54
return firstMatchIndex * 2 + gapPenalty * 3 + spanPenalty + lengthPenalty;
55
}
@@ -92,8 +99,15 @@ export function scoreQueryMatch(input: {
99
includesBase?: number;
100
fuzzyBase?: number;
101
boundaryMarkers?: readonly string[];
102
+ /**
103
+ * Score by match tier alone, ignoring where the match lands and how long the
104
+ * value is, so callers can keep their own order among equal matches.
105
+ */
106
+ ignorePosition?: boolean;
107
}): number | null {
108
const { value, query } = input;
109
+ const ignorePosition = input.ignorePosition === true;
110
+ const penalty = ignorePosition ? 0 : lengthPenalty(value, query);
111
112
if (!value || !query) {
113
return null;
@@ -104,7 +118,7 @@ export function scoreQueryMatch(input: {
118
}
119
120
if (input.prefixBase !== undefined && value.startsWith(query)) {
107
- return input.prefixBase + lengthPenalty(value, query);
121
+ return input.prefixBase + penalty;
122
}
123
124
if (input.boundaryBase !== undefined) {
@@ -114,19 +128,19 @@ export function scoreQueryMatch(input: {
128
input.boundaryMarkers ?? [" ", "-", "_", "/"],
129
);
130
if (boundaryIndex !== null) {
117
- return input.boundaryBase + boundaryIndex * 2 + lengthPenalty(value, query);
131
+ return input.boundaryBase + (ignorePosition ? 0 : boundaryIndex * 2) + penalty;
132
}
133
}
134
135
if (input.includesBase !== undefined) {
136
const includesIndex = value.indexOf(query);
137
if (includesIndex !== -1) {
124
- return input.includesBase + includesIndex * 2 + lengthPenalty(value, query);
138
+ return input.includesBase + (ignorePosition ? 0 : includesIndex * 2) + penalty;
139
}
140
}
141
142
if (input.fuzzyBase !== undefined) {
129
- const fuzzyScore = scoreSubsequenceMatch(value, query);
143
+ const fuzzyScore = scoreSubsequenceMatch(value, query, { ignorePosition });
144
if (fuzzyScore !== null) {
145
return input.fuzzyBase + fuzzyScore;
146
}