Open History to see the last commit
1import {
2 type ProviderInstanceId,
3 type ProviderDriverKind,
4 type ResolvedKeybindingsConfig,
5} from "@t3tools/contracts";
6import { resolveSelectableModel } from "@t3tools/shared/model";
7import { LegendList, type LegendListRef } from "@legendapp/list/react";
8import { memo, useMemo, useState, useCallback, useEffect, useLayoutEffect, useRef } from "react";
9import { SearchIcon } from "lucide-react";
10import { ModelListRow } from "./ModelListRow";
11import { ModelPickerSidebar } from "./ModelPickerSidebar";
12import { isModelPickerNewModel } from "./modelPickerModelHighlights";
13import { buildModelPickerSearchText, scoreModelPickerSearch } from "./modelPickerSearch";
14import { Combobox, ComboboxEmpty, ComboboxInput, ComboboxListVirtualized } from "../ui/combobox";
15import { ModelEsque } from "./providerIconUtils";
16import {
17 modelPickerJumpCommandForIndex,
18 modelPickerJumpIndexFromCommand,
19 resolveShortcutCommand,
20 shortcutLabelForCommand,
21} from "../../keybindings";
22import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
23import { cn } from "~/lib/utils";
24import { TooltipProvider } from "../ui/tooltip";
25import {
26 isProviderInstancePickerReady,
27 isProviderInstancePickerVisible,
28 type ProviderInstanceEntry,
29} from "../../providerInstances";
30import { providerModelKey, sortProviderModelItems } from "../../modelOrdering";
31
32type ModelPickerItem = {
33 slug: string;
34 name: string;
35 shortName?: string;
36 subProvider?: string;
37 instanceId: ProviderInstanceId;
38 driverKind: ProviderDriverKind;
39 instanceDisplayName: string;
40 instanceAccentColor?: string | undefined;
41 continuationGroupKey?: string | undefined;
42};
43
44const EMPTY_MODEL_JUMP_LABELS = new Map<string, string>();
45
46function ModelListSeparator() {
47 return <div className="h-0.5" />;
48}
49
50// Split a `${instanceId}:${slug}` combobox key back into its pieces. Slugs
51// can contain colons (e.g. some vendor model ids), so we only split on the
52// first colon — anything after that is the slug.
53function splitInstanceModelKey(key: string): { instanceId: ProviderInstanceId; slug: string } {
54 const colonIndex = key.indexOf(":");
55 if (colonIndex === -1) {
56 return { instanceId: key as ProviderInstanceId, slug: "" };
57 }
58 return {
59 instanceId: key.slice(0, colonIndex) as ProviderInstanceId,
60 slug: key.slice(colonIndex + 1),
61 };
62}
63
64export const ModelPickerContent = memo(function ModelPickerContent(props: {
65 /** The instance currently selected in the composer (combobox "value"). */
66 activeInstanceId: ProviderInstanceId;
67 model: string;
68 /**
69 * When set, the picker is locked to the given driver kind — typically
70 * because the user is editing a previously-sent message and can't change
71 * which driver served the turn. Multiple instances of the same kind
72 * remain selectable (e.g. locked to `codex` still lets the user switch
73 * between the default Codex and a custom Codex Personal).
74 */
75 lockedProvider: ProviderDriverKind | null;
76 lockedContinuationGroupKey?: string | null;
77 /**
78 * All configured provider instances in display order. Used to render
79 * the sidebar (one button per instance) and to resolve display names
80 * for the locked-mode header.
81 */
82 instanceEntries: ReadonlyArray<ProviderInstanceEntry>;
83 keybindings?: ResolvedKeybindingsConfig;
84 /**
85 * Model options per instance. Keyed by `ProviderInstanceId` so the
86 * default Codex instance and any custom Codex instances each have their
87 * own list (custom instances typically start with the same built-in
88 * model set but are free to diverge via customModels).
89 */
90 modelOptionsByInstance: ReadonlyMap<ProviderInstanceId, ReadonlyArray<ModelEsque>>;
91 terminalOpen: boolean;
92 onRequestClose?: () => void;
93 getModelDisabledReason?: (instanceId: ProviderInstanceId, model: string) => string | null;
94 onInstanceModelChange: (instanceId: ProviderInstanceId, model: string) => void;
95}) {
96 const {
97 keybindings: providedKeybindings,
98 modelOptionsByInstance,
99 instanceEntries,
100 getModelDisabledReason,
101 onInstanceModelChange,
102 } = props;
103 const [searchQuery, setSearchQuery] = useState("");
104 const [showTopScrollFade, setShowTopScrollFade] = useState(false);
105 const [showBottomScrollFade, setShowBottomScrollFade] = useState(false);
106 const searchInputRef = useRef<HTMLInputElement>(null);
107 const modelListRef = useRef<LegendListRef | null>(null);
108 const highlightedModelKeyRef = useRef<string | null>(null);
109 const favorites = useClientSettings((s) => s.favorites ?? []);
110 const [selectedInstanceId, setSelectedInstanceId] = useState<ProviderInstanceId | "favorites">(
111 () => {
112 if (props.lockedProvider !== null) {
113 // When locked, prime the sidebar to the currently-active instance
114 // so jumping into the picker keeps the focused instance visible.
115 return props.activeInstanceId;
116 }
117 return favorites.length > 0 ? "favorites" : props.activeInstanceId;
118 },
119 );
120 const keybindings = useMemo<ResolvedKeybindingsConfig>(
121 () => providedKeybindings ?? [],
122 [providedKeybindings],
123 );
124 const updateSettings = useUpdateClientSettings();
125
126 const focusSearchInput = useCallback(() => {
127 searchInputRef.current?.focus({ preventScroll: true });
128 }, []);
129
130 const handleSelectInstance = useCallback(
131 (instanceId: ProviderInstanceId | "favorites") => {
132 setSelectedInstanceId(instanceId);
133 window.requestAnimationFrame(() => {
134 focusSearchInput();
135 });
136 },
137 [focusSearchInput],
138 );
139
140 useLayoutEffect(() => {
141 focusSearchInput();
142 const frame = window.requestAnimationFrame(() => {
143 focusSearchInput();
144 });
145 const timeout = window.setTimeout(() => {
146 focusSearchInput();
147 }, 0);
148 return () => {
149 window.cancelAnimationFrame(frame);
150 window.clearTimeout(timeout);
151 };
152 }, [focusSearchInput]);
153
154 // Create a Set for efficient lookup. Favorites are keyed by
155 // `${instanceId}:${slug}`; the storage schema widened from ProviderDriverKind
156 // to ProviderInstanceId so pre-migration favorites keyed by driver slugs
157 // (e.g. `"codex:gpt-5"`) still resolve — the default instance id equals
158 // the driver slug.
159 const favoritesSet = useMemo(() => {
160 return new Set(favorites.map((fav) => providerModelKey(fav.provider, fav.model)));
161 }, [favorites]);
162
163 /**
164 * Lookup table keyed by `instanceId`. Used for display name + driver
165 * kind enrichment and for `ready`/enabled filtering before flattening
166 * models into the search list.
167 */
168 const entryByInstanceId = useMemo(
169 () => new Map(instanceEntries.map((entry) => [entry.instanceId, entry])),
170 [instanceEntries],
171 );
172 const matchesLockedProvider = useCallback(
173 (entry: Pick<ProviderInstanceEntry, "driverKind" | "continuationGroupKey">): boolean => {
174 if (props.lockedProvider === null) return true;
175 if (entry.driverKind !== props.lockedProvider) return false;
176 if (!props.lockedContinuationGroupKey) return true;
177 return entry.continuationGroupKey === props.lockedContinuationGroupKey;
178 },
179 [props.lockedContinuationGroupKey, props.lockedProvider],
180 );
181
182 const readyInstanceSet = useMemo(() => {
183 const ready = new Set<ProviderInstanceId>();
184 for (const entry of instanceEntries) {
185 if (isProviderInstancePickerReady(entry)) {
186 ready.add(entry.instanceId);
187 }
188 }
189 return ready;
190 }, [instanceEntries]);
191
192 // Flatten models into a searchable array. One pass over the
193 // instance-keyed map; each model carries its instance id + driver kind
194 // so the list row can render the right icon and display name without
195 // another lookup.
196 const flatModels = useMemo(() => {
197 const out: ModelPickerItem[] = [];
198 for (const [instanceId, models] of modelOptionsByInstance) {
199 const entry = entryByInstanceId.get(instanceId);
200 if (!entry) {
201 // Instance disappeared between renders (configuration change). Skip
202 // its models — stale options shouldn't appear in the picker.
203 continue;
204 }
205 if (!readyInstanceSet.has(instanceId)) {
206 continue;
207 }
208 for (const model of models) {
209 out.push({
210 slug: model.slug,
211 name: model.name,
212 ...(model.shortName ? { shortName: model.shortName } : {}),
213 ...(model.subProvider ? { subProvider: model.subProvider } : {}),
214 instanceId,
215 driverKind: entry.driverKind,
216 instanceDisplayName: entry.displayName,
217 ...(entry.accentColor ? { instanceAccentColor: entry.accentColor } : {}),
218 ...(entry.continuationGroupKey
219 ? { continuationGroupKey: entry.continuationGroupKey }
220 : {}),
221 });
222 }
223 }
224 return out;
225 }, [modelOptionsByInstance, entryByInstanceId, readyInstanceSet]);
226
227 const isLocked = props.lockedProvider !== null;
228 const isSearching = searchQuery.trim().length > 0;
229 const lockedDisabledInstanceIds = useMemo(() => {
230 if (!isLocked) {
231 return undefined;
232 }
233 const disabled = new Set<ProviderInstanceId>();
234 for (const entry of instanceEntries) {
235 if (!matchesLockedProvider(entry)) {
236 disabled.add(entry.instanceId);
237 }
238 }
239 return disabled;
240 }, [instanceEntries, isLocked, matchesLockedProvider]);
241 const sidebarInstanceEntries = useMemo(() => {
242 const enabledEntries = instanceEntries.filter(isProviderInstancePickerVisible);
243 if (!isLocked) {
244 return enabledEntries;
245 }
246 const available: ProviderInstanceEntry[] = [];
247 const disabled: ProviderInstanceEntry[] = [];
248 for (const entry of enabledEntries) {
249 if (matchesLockedProvider(entry)) {
250 available.push(entry);
251 } else {
252 disabled.push(entry);
253 }
254 }
255 return [...available, ...disabled];
256 }, [instanceEntries, isLocked, matchesLockedProvider]);
257 const showSidebar = !isSearching && sidebarInstanceEntries.length > 0;
258 const instanceOrder = useMemo(
259 () => instanceEntries.map((entry) => entry.instanceId),
260 [instanceEntries],
261 );
262
263 // Filter models based on search query and selected instance
264 const filteredModels = useMemo(() => {
265 let result = flatModels;
266
267 // Apply tokenized fuzzy search across the combined provider/model search fields.
268 if (searchQuery.trim()) {
269 const rankedMatches = result
270 .map((model) => ({
271 model,
272 score: scoreModelPickerSearch(
273 {
274 name: model.name,
275 ...(model.shortName ? { shortName: model.shortName } : {}),
276 ...(model.subProvider ? { subProvider: model.subProvider } : {}),
277 driverKind: model.driverKind,
278 providerDisplayName: model.instanceDisplayName,
279 isFavorite: favoritesSet.has(providerModelKey(model.instanceId, model.slug)),
280 },
281 searchQuery,
282 ),
283 isFavorite: favoritesSet.has(providerModelKey(model.instanceId, model.slug)),
284 tieBreaker: buildModelPickerSearchText({
285 name: model.name,
286 ...(model.shortName ? { shortName: model.shortName } : {}),
287 ...(model.subProvider ? { subProvider: model.subProvider } : {}),
288 driverKind: model.driverKind,
289 providerDisplayName: model.instanceDisplayName,
290 }),
291 }))
292 .filter(
293 (
294 rankedModel,
295 ): rankedModel is {
296 model: ModelPickerItem;
297 score: number;
298 isFavorite: boolean;
299 tieBreaker: string;
300 } => rankedModel.score !== null,
301 );
302
303 // When searching, we only respect locked provider (by driver kind),
304 // ignoring sidebar selection so account-scoped searches can find a
305 // model before the user chooses a specific instance rail item.
306 if (props.lockedProvider !== null) {
307 const lockedProviderMatches: Array<(typeof rankedMatches)[number]> = [];
308 for (const rankedModel of rankedMatches) {
309 if (matchesLockedProvider(rankedModel.model)) {
310 lockedProviderMatches.push(rankedModel);
311 }
312 }
313 return lockedProviderMatches
314 .toSorted((a, b) => {
315 const scoreDelta = a.score - b.score;
316 if (scoreDelta !== 0) {
317 return scoreDelta;
318 }
319 if (a.isFavorite !== b.isFavorite) {
320 return a.isFavorite ? -1 : 1;
321 }
322 return a.tieBreaker.localeCompare(b.tieBreaker);
323 })
324 .map((rankedModel) => rankedModel.model);
325 }
326
327 return rankedMatches
328 .toSorted((a, b) => {
329 const scoreDelta = a.score - b.score;
330 if (scoreDelta !== 0) {
331 return scoreDelta;
332 }
333 if (a.isFavorite !== b.isFavorite) {
334 return a.isFavorite ? -1 : 1;
335 }
336 return a.tieBreaker.localeCompare(b.tieBreaker);
337 })
338 .map((rankedModel) => rankedModel.model);
339 }
340
341 if (props.lockedProvider !== null) {
342 result = result.filter((m) => matchesLockedProvider(m));
343 if (selectedInstanceId === "favorites") {
344 result = result.filter((m) => favoritesSet.has(providerModelKey(m.instanceId, m.slug)));
345 } else {
346 result = result.filter((m) => m.instanceId === selectedInstanceId);
347 }
348 } else if (selectedInstanceId === "favorites") {
349 result = result.filter((m) => favoritesSet.has(providerModelKey(m.instanceId, m.slug)));
350 } else {
351 result = result.filter((m) => m.instanceId === selectedInstanceId);
352 }
353
354 return sortProviderModelItems(result, {
355 favoriteModelKeys: favoritesSet,
356 groupFavorites: selectedInstanceId !== "favorites",
357 instanceOrder: selectedInstanceId === "favorites" ? instanceOrder : [],
358 });
359 }, [
360 favoritesSet,
361 flatModels,
362 instanceOrder,
363 matchesLockedProvider,
364 props.lockedProvider,
365 searchQuery,
366 selectedInstanceId,
367 ]);
368
369 const handleModelSelect = useCallback(
370 (modelSlug: string, instanceId: ProviderInstanceId) => {
371 if (getModelDisabledReason?.(instanceId, modelSlug)) {
372 return;
373 }
374 const options = modelOptionsByInstance.get(instanceId);
375 if (!options) {
376 return;
377 }
378 const entry = entryByInstanceId.get(instanceId);
379 if (!entry) {
380 return;
381 }
382 // `resolveSelectableModel` uses the driver kind for normalization
383 // (slug casing etc.). Custom instances share their driver's
384 // normalization rules, so pass the driver kind here.
385 const resolvedModel = resolveSelectableModel(entry.driverKind, modelSlug, options);
386 if (resolvedModel) {
387 onInstanceModelChange(instanceId, resolvedModel);
388 }
389 },
390 [entryByInstanceId, getModelDisabledReason, modelOptionsByInstance, onInstanceModelChange],
391 );
392
393 const toggleFavorite = useCallback(
394 (instanceId: ProviderInstanceId, model: string) => {
395 const newFavorites = [...favorites];
396 const index = newFavorites.findIndex((f) => f.provider === instanceId && f.model === model);
397 if (index >= 0) {
398 newFavorites.splice(index, 1);
399 } else {
400 newFavorites.push({ provider: instanceId, model });
401 }
402 updateSettings({ favorites: newFavorites });
403 },
404 [favorites, updateSettings],
405 );
406
407 const modelJumpCommandByKey = useMemo(() => {
408 const mapping = new Map<
409 string,
410 NonNullable<ReturnType<typeof modelPickerJumpCommandForIndex>>
411 >();
412 let selectableModelIndex = 0;
413 for (const model of filteredModels) {
414 if (getModelDisabledReason?.(model.instanceId, model.slug)) {
415 continue;
416 }
417 const jumpCommand = modelPickerJumpCommandForIndex(selectableModelIndex);
418 if (!jumpCommand) {
419 return mapping;
420 }
421 mapping.set(`${model.instanceId}:${model.slug}`, jumpCommand);
422 selectableModelIndex += 1;
423 }
424 return mapping;
425 }, [filteredModels, getModelDisabledReason]);
426 const modelJumpModelKeys = useMemo(
427 () => [...modelJumpCommandByKey.keys()],
428 [modelJumpCommandByKey],
429 );
430 const allModelKeys = useMemo(
431 (): string[] => flatModels.map((model) => `${model.instanceId}:${model.slug}`),
432 [flatModels],
433 );
434 const filteredModelKeys = useMemo(
435 (): string[] => filteredModels.map((model) => `${model.instanceId}:${model.slug}`),
436 [filteredModels],
437 );
438 const filteredModelByKey = useMemo(
439 (): ReadonlyMap<string, ModelPickerItem> =>
440 new Map(filteredModels.map((model) => [`${model.instanceId}:${model.slug}`, model] as const)),
441 [filteredModels],
442 );
443 const updateModelListScrollFades = useCallback(() => {
444 const scrollElement = modelListRef.current?.getScrollableNode();
445 if (!(scrollElement instanceof HTMLElement)) {
446 return;
447 }
448 const maxScrollOffset = Math.max(0, scrollElement.scrollHeight - scrollElement.clientHeight);
449 setShowTopScrollFade(scrollElement.scrollTop > 1);
450 setShowBottomScrollFade(maxScrollOffset - scrollElement.scrollTop > 1);
451 }, []);
452 const modelJumpShortcutContext = useMemo(
453 () =>
454 ({
455 terminalFocus: false,
456 terminalOpen: props.terminalOpen,
457 modelPickerOpen: true,
458 }) as const,
459 [props.terminalOpen],
460 );
461 const modelJumpLabelByKey = useMemo((): ReadonlyMap<string, string> => {
462 if (modelJumpCommandByKey.size === 0) {
463 return EMPTY_MODEL_JUMP_LABELS;
464 }
465 const shortcutLabelOptions = {
466 platform: navigator.platform,
467 context: modelJumpShortcutContext,
468 };
469 const mapping = new Map<string, string>();
470 for (const [modelKey, command] of modelJumpCommandByKey) {
471 const label = shortcutLabelForCommand(keybindings, command, shortcutLabelOptions);
472 if (label) {
473 mapping.set(modelKey, label);
474 }
475 }
476 return mapping.size > 0 ? mapping : EMPTY_MODEL_JUMP_LABELS;
477 }, [keybindings, modelJumpCommandByKey, modelJumpShortcutContext]);
478
479 useEffect(() => {
480 const onWindowKeyDown = (event: globalThis.KeyboardEvent) => {
481 if (event.defaultPrevented || event.repeat) {
482 return;
483 }
484
485 const command = resolveShortcutCommand(event, keybindings, {
486 platform: navigator.platform,
487 context: modelJumpShortcutContext,
488 });
489 const jumpIndex = modelPickerJumpIndexFromCommand(command ?? "");
490 if (jumpIndex === null) {
491 return;
492 }
493
494 const targetModelKey = modelJumpModelKeys[jumpIndex];
495 if (!targetModelKey) {
496 return;
497 }
498 const { instanceId, slug } = splitInstanceModelKey(targetModelKey);
499 event.preventDefault();
500 event.stopPropagation();
501 handleModelSelect(slug, instanceId);
502 };
503
504 window.addEventListener("keydown", onWindowKeyDown, true);
505
506 return () => {
507 window.removeEventListener("keydown", onWindowKeyDown, true);
508 };
509 }, [handleModelSelect, keybindings, modelJumpModelKeys, modelJumpShortcutContext]);
510
511 useLayoutEffect(() => {
512 setShowTopScrollFade(false);
513 setShowBottomScrollFade(filteredModelKeys.length > 5);
514 let nestedFrame = 0;
515 const frame = window.requestAnimationFrame(() => {
516 updateModelListScrollFades();
517 nestedFrame = window.requestAnimationFrame(updateModelListScrollFades);
518 });
519 return () => {
520 window.cancelAnimationFrame(frame);
521 window.cancelAnimationFrame(nestedFrame);
522 };
523 }, [filteredModelKeys, updateModelListScrollFades]);
524
525 return (
526 <TooltipProvider delay={0}>
527 <div
528 className="dropdown-glass model-picker-surface relative flex h-screen max-h-86.5 w-screen max-w-90 flex-row overflow-hidden rounded-lg text-popover-foreground [clip-path:inset(0_round_var(--radius-lg))]"
529 data-model-picker-content="true"
530 >
531 {/* Sidebar */}
532 {showSidebar && (
533 <ModelPickerSidebar
534 selectedInstanceId={selectedInstanceId}
535 onSelectInstance={handleSelectInstance}
536 instanceEntries={sidebarInstanceEntries}
537 showFavorites
538 {...(lockedDisabledInstanceIds
539 ? {
540 disabledInstanceIds: lockedDisabledInstanceIds,
541 getDisabledInstanceTooltip: (entry: ProviderInstanceEntry) =>
542 `${entry.displayName} is unavailable in this thread. Start a new thread to switch providers.`,
543 }
544 : {})}
545 />
546 )}
547
548 {/* Main content area */}
549 <Combobox
550 inline
551 items={allModelKeys}
552 filteredItems={filteredModelKeys}
553 filter={null}
554 autoHighlight
555 open
556 virtualized
557 value={`${props.activeInstanceId}:${props.model}`}
558 onItemHighlighted={(modelKey, eventDetails) => {
559 highlightedModelKeyRef.current = typeof modelKey === "string" ? modelKey : null;
560 if (eventDetails.reason === "keyboard" && eventDetails.index >= 0) {
561 void modelListRef.current?.scrollIndexIntoView?.({
562 index: eventDetails.index,
563 animated: false,
564 });
565 }
566 }}
567 onValueChange={(modelKey) => {
568 if (typeof modelKey !== "string") {
569 return;
570 }
571 const { instanceId, slug } = splitInstanceModelKey(modelKey);
572 handleModelSelect(slug, instanceId);
573 }}
574 >
575 <div
576 className={cn(
577 "flex min-h-0 flex-1 flex-col overflow-hidden bg-muted/40",
578 showSidebar && "border-l border-border/70",
579 )}
580 >
581 {/* Search bar */}
582 <div className="px-2 pt-2">
583 <div className="border-b border-border/70 pb-2.5 transition-colors focus-within:border-ring">
584 <ComboboxInput
585 ref={searchInputRef}
586 className="[&_input]:h-6.5 [&_input]:font-sans [&_input]:leading-6.5"
587 inputClassName="rounded-none bg-transparent text-sm"
588 placeholder="Search models..."
589 showTrigger={false}
590 startAddon={
591 <SearchIcon className="-translate-x-0.5 size-4 shrink-0 text-muted-foreground opacity-70" />
592 }
593 value={searchQuery}
594 onChange={(e) => setSearchQuery(e.target.value)}
595 onKeyDown={(e) => {
596 if (e.key === "Escape") {
597 e.preventDefault();
598 e.stopPropagation();
599 props.onRequestClose?.();
600 return;
601 }
602 if (e.key === "Enter" && highlightedModelKeyRef.current) {
603 (
604 e as typeof e & { preventBaseUIHandler?: () => void }
605 ).preventBaseUIHandler?.();
606 e.preventDefault();
607 e.stopPropagation();
608 const { instanceId, slug } = splitInstanceModelKey(
609 highlightedModelKeyRef.current,
610 );
611 handleModelSelect(slug, instanceId);
612 return;
613 }
614 e.stopPropagation();
615 }}
616 onMouseDown={(e) => e.stopPropagation()}
617 onTouchStart={(e) => e.stopPropagation()}
618 size="sm"
619 unstyled
620 />
621 </div>
622 </div>
623
624 {/* Model list */}
625 <div className="relative min-h-0 flex-1 overflow-hidden pr-px">
626 <ComboboxListVirtualized className="size-full min-w-0 p-0 not-empty:p-0">
627 <LegendList<string>
628 ref={modelListRef}
629 data={filteredModelKeys}
630 extraData={favoritesSet}
631 keyExtractor={(modelKey) => modelKey}
632 renderItem={({ item: modelKey, index }) => {
633 const model = filteredModelByKey.get(modelKey);
634 if (!model) {
635 return null;
636 }
637 const disabledReason =
638 getModelDisabledReason?.(model.instanceId, model.slug) ?? null;
639 return (
640 <ModelListRow
641 key={modelKey}
642 index={index}
643 model={model}
644 instanceId={model.instanceId}
645 driverKind={model.driverKind}
646 providerDisplayName={model.instanceDisplayName}
647 providerAccentColor={model.instanceAccentColor}
648 isFavorite={favoritesSet.has(modelKey)}
649 isSelected={modelKey === `${props.activeInstanceId}:${props.model}`}
650 showProvider
651 preferShortName={!isLocked}
652 useTriggerLabel={false}
653 showNewBadge={isModelPickerNewModel(model.driverKind, model.slug)}
654 jumpLabel={modelJumpLabelByKey.get(modelKey) ?? null}
655 disabledReason={disabledReason}
656 onToggleFavorite={() => toggleFavorite(model.instanceId, model.slug)}
657 />
658 );
659 }}
660 estimatedItemSize={60}
661 drawDistance={480}
662 recycleItems
663 contentContainerClassName="pl-2 pr-px"
664 ItemSeparatorComponent={ModelListSeparator}
665 onLayout={updateModelListScrollFades}
666 onScroll={updateModelListScrollFades}
667 className={cn(
668 "model-picker-list h-full overflow-x-hidden overscroll-y-contain py-1.5 [--fade-size:1.5rem]",
669 showTopScrollFade && "model-picker-list-scroll-fade-top",
670 showBottomScrollFade && "model-picker-list-scroll-fade-bottom",
671 )}
672 />
673 </ComboboxListVirtualized>
674 </div>
675 <ComboboxEmpty className="not-empty:py-6 empty:h-0 text-xs font-normal leading-snug">
676 No models found
677 </ComboboxEmpty>
678 </div>
679 </Combobox>
680 </div>
681 </TooltipProvider>
682 );
683});