Open History to see the last commit
1"use client";
2
3import { ArrowDownIcon, ArrowUpIcon, PencilIcon, PlusIcon, StarIcon, XIcon } from "lucide-react";
4import { useEffect, useMemo, useRef, useState } from "react";
5import {
6 ProviderDriverKind,
7 type ProviderInstanceId,
8 type ServerProviderModel,
9} from "@t3tools/contracts";
10import { type CustomModelDefinition, normalizeCustomModelSlug } from "@t3tools/shared/model";
11
12import { cn } from "../../lib/utils";
13import { sortModelsForProviderInstance } from "../../modelOrdering";
14import { MAX_CUSTOM_MODEL_LENGTH } from "../../modelSelection";
15import { Button } from "../ui/button";
16import { Input } from "../ui/input";
17import { Switch } from "../ui/switch";
18import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
19import { CustomModelEditor } from "./CustomModelEditor";
20
21/**
22 * Placeholder text for the "add a custom model" input, keyed by driver
23 * kind. Mirrors the prior hardcoded switch in `SettingsPanels.tsx` so the
24 * UX is unchanged — only the owning component has moved.
25 */
26const CUSTOM_MODEL_PLACEHOLDER_BY_KIND: Partial<Record<ProviderDriverKind, string>> = {
27 [ProviderDriverKind.make("codex")]: "gpt-6.7-codex-ultra-preview",
28 [ProviderDriverKind.make("claudeAgent")]: "claude-sonnet-5",
29 [ProviderDriverKind.make("opencode")]: "openai/gpt-5",
30};
31
32function providerSupportsCustomModels(driverKind: ProviderDriverKind | null): boolean {
33 // cursor-agent and Antigravity only accept their account catalogs.
34 return driverKind !== "antigravity" && driverKind !== "cursor";
35}
36
37/** Above this many models the list gets a filter input. */
38const FILTER_THRESHOLD = 8;
39
40/**
41 * Short capability words shown after a model's slug. Claude and Cursor report
42 * fast mode as a boolean `fastMode` option; Codex reports it as a
43 * `serviceTier` select whose fast tier is labelled "Fast" (catalog id
44 * `priority`, or `fast` from the speed-tier fallback), matching the composer.
45 */
46function describeModelCapabilities(model: ServerProviderModel): string[] {
47 const descriptors = model.capabilities?.optionDescriptors ?? [];
48 const labels: string[] = [];
49 const hasFastMode = descriptors.some(
50 (descriptor) =>
51 descriptor.id === "fastMode" ||
52 (descriptor.id === "serviceTier" &&
53 descriptor.type === "select" &&
54 descriptor.options.some((option) => option.id === "fast" || option.label === "Fast")),
55 );
56 if (hasFastMode) labels.push("Fast mode");
57 if (descriptors.some((descriptor) => descriptor.id === "thinking")) labels.push("Thinking");
58 if (
59 descriptors.some(
60 (descriptor) =>
61 descriptor.type === "select" &&
62 (descriptor.id === "reasoningEffort" ||
63 descriptor.id === "effort" ||
64 descriptor.id === "reasoning" ||
65 descriptor.id === "variant"),
66 )
67 ) {
68 labels.push("Reasoning");
69 }
70 return labels;
71}
72
73/**
74 * Display order for the models list: favorites first (in user order), then
75 * visible models, then hidden ones. Hidden models sink so the list reads
76 * top-down as "what the picker shows"; moves only swap rows within the same
77 * group, and the resulting display order is what gets persisted as
78 * `modelOrder`.
79 */
80export function groupModelsForDisplay<
81 T extends { readonly slug: string; readonly isCustom: boolean },
82>(
83 models: ReadonlyArray<T>,
84 options: {
85 readonly favoriteModels: ReadonlySet<string>;
86 readonly hiddenModels: ReadonlySet<string>;
87 readonly modelOrder: ReadonlyArray<string>;
88 },
89): T[] {
90 const ordered = sortModelsForProviderInstance(models, {
91 favoriteModels: options.favoriteModels,
92 groupFavorites: true,
93 modelOrder: options.modelOrder,
94 });
95 const isHidden = (model: T) => !model.isCustom && options.hiddenModels.has(model.slug);
96 return [
97 ...ordered.filter((model) => options.favoriteModels.has(model.slug)),
98 ...ordered.filter((model) => !options.favoriteModels.has(model.slug) && !isHidden(model)),
99 ...ordered.filter((model) => !options.favoriteModels.has(model.slug) && isHidden(model)),
100 ];
101}
102
103export function nextHiddenModelsForBulkToggle(
104 models: ReadonlyArray<Pick<ServerProviderModel, "slug" | "isCustom">>,
105 hiddenModels: ReadonlyArray<string>,
106): string[] {
107 const builtInSlugs = models.filter((model) => !model.isCustom).map((model) => model.slug);
108 const builtInSlugSet = new Set(builtInSlugs);
109 const allBuiltInModelsHidden = builtInSlugs.every((slug) => hiddenModels.includes(slug));
110
111 if (allBuiltInModelsHidden) {
112 return hiddenModels.filter((slug) => !builtInSlugSet.has(slug));
113 }
114
115 return [...new Set([...hiddenModels, ...builtInSlugs])];
116}
117
118interface ProviderModelsSectionProps {
119 /** Identifier used to namespace input ids within the DOM. */
120 readonly instanceId: ProviderInstanceId;
121 /**
122 * Driver kind for slug normalization + input placeholder. `null` when
123 * the section is rendered without enough provider metadata.
124 */
125 readonly driverKind: ProviderDriverKind | null;
126 /**
127 * The live model list to display. Includes both built-in (probe-reported)
128 * and custom entries, distinguished by `isCustom`.
129 */
130 readonly models: ReadonlyArray<ServerProviderModel>;
131 /**
132 * The persisted custom-model list for this instance, resolved. Drives
133 * dedup, and is the list we hand back (with an entry appended / replaced /
134 * removed) via `onChange`.
135 */
136 readonly customModels: ReadonlyArray<CustomModelDefinition>;
137 /** Server-returned model slugs hidden from the model picker. */
138 readonly hiddenModels: ReadonlyArray<string>;
139 /** Model slugs favorited for this provider instance. */
140 readonly favoriteModels: ReadonlyArray<string>;
141 /** Explicit user-authored model ordering for this provider instance. */
142 readonly modelOrder: ReadonlyArray<string>;
143 /**
144 * Commit the new custom-model list. Caller is responsible for routing the
145 * write to the correct storage (legacy `settings.providers[kind]` vs.
146 * `providerInstances[id].config`).
147 */
148 readonly onChange: (next: ReadonlyArray<CustomModelDefinition>) => void;
149 readonly onHiddenModelsChange: (next: ReadonlyArray<string>) => void;
150 readonly onFavoriteModelsChange: (next: ReadonlyArray<string>) => void;
151 readonly onModelOrderChange: (next: ReadonlyArray<string>) => void;
152}
153
154/**
155 * Shared "Models" section rendered on both the built-in default and custom
156 * provider-instance cards. Owns its own input + error local state so two
157 * cards on screen don't fight over the input value.
158 *
159 * Validation mirrors the pre-consolidation logic in `SettingsPanels`:
160 * - empty / whitespace → "Enter a model slug."
161 * - duplicate of a non-custom (probe-reported) slug → "already built in"
162 * - exceeds `MAX_CUSTOM_MODEL_LENGTH` → length error
163 * - duplicate of an already-saved custom slug → already-saved error
164 */
165export function ProviderModelsSection({
166 instanceId,
167 driverKind,
168 models,
169 customModels,
170 hiddenModels,
171 favoriteModels,
172 modelOrder,
173 onChange,
174 onHiddenModelsChange,
175 onFavoriteModelsChange,
176 onModelOrderChange,
177}: ProviderModelsSectionProps) {
178 const [input, setInput] = useState("");
179 const [isAdding, setIsAdding] = useState(false);
180 const [filter, setFilter] = useState("");
181 const [error, setError] = useState<string | null>(null);
182 // Slug of the custom model whose inline editor is open, if any.
183 const [editingSlug, setEditingSlug] = useState<string | null>(null);
184 const listRef = useRef<HTMLDivElement>(null);
185 // Slug of a just-added custom model, scrolled into view once its row exists.
186 const scrollToSlugRef = useRef<string | null>(null);
187 const hiddenModelSet = useMemo(() => new Set(hiddenModels), [hiddenModels]);
188 const favoriteModelSet = useMemo(() => new Set(favoriteModels), [favoriteModels]);
189 const displayModels = useMemo(
190 () =>
191 groupModelsForDisplay(models, {
192 favoriteModels: favoriteModelSet,
193 hiddenModels: hiddenModelSet,
194 modelOrder,
195 }),
196 [favoriteModelSet, hiddenModelSet, modelOrder, models],
197 );
198 const favoriteCount = displayModels.filter((model) => favoriteModelSet.has(model.slug)).length;
199 const hiddenCount = displayModels.filter(
200 (model) => !model.isCustom && hiddenModelSet.has(model.slug),
201 ).length;
202 const builtInModels = useMemo(() => models.filter((model) => !model.isCustom), [models]);
203 const allBuiltInModelsHidden =
204 builtInModels.length > 0 && builtInModels.every((model) => hiddenModelSet.has(model.slug));
205 const showFilter = models.length > FILTER_THRESHOLD;
206 const normalizedFilter = filter.trim().toLowerCase();
207 const isFiltering = showFilter && normalizedFilter.length > 0;
208 const visibleModels = isFiltering
209 ? displayModels.filter(
210 (model) =>
211 model.name.toLowerCase().includes(normalizedFilter) ||
212 model.slug.toLowerCase().includes(normalizedFilter),
213 )
214 : displayModels;
215
216 // The parent commits the new custom model and hands back an updated
217 // `models` list, so the row can only be scrolled to after that render.
218 useEffect(() => {
219 const slug = scrollToSlugRef.current;
220 if (slug === null) return;
221 const row = listRef.current?.querySelector<HTMLElement>(
222 `[data-model-slug="${CSS.escape(slug)}"]`,
223 );
224 if (!row) return;
225 scrollToSlugRef.current = null;
226 row.scrollIntoView({ block: "nearest" });
227 }, [displayModels]);
228
229 const handleAdd = () => {
230 if (!providerSupportsCustomModels(driverKind)) return;
231 const normalized = normalizeCustomModelSlug(input);
232 if (!normalized) {
233 setError("Enter a model slug.");
234 return;
235 }
236 if (models.some((model) => !model.isCustom && model.slug === normalized)) {
237 setError("That model is already built in.");
238 return;
239 }
240 if (normalized.length > MAX_CUSTOM_MODEL_LENGTH) {
241 setError(`Model slugs must be ${MAX_CUSTOM_MODEL_LENGTH} characters or less.`);
242 return;
243 }
244 if (customModels.some((entry) => entry.slug === normalized)) {
245 setError("That custom model is already saved.");
246 return;
247 }
248
249 // Clear the filter so the new row renders even when it does not match,
250 // which is also what lets the pending scroll target resolve and clear.
251 scrollToSlugRef.current = normalized;
252 setFilter("");
253 onChange([...customModels, { slug: normalized, name: normalized, capabilities: null }]);
254 setInput("");
255 setError(null);
256 setIsAdding(false);
257 };
258
259 const cancelAdd = () => {
260 setInput("");
261 setError(null);
262 setIsAdding(false);
263 };
264
265 const handleRemove = (slug: string) => {
266 if (editingSlug === slug) setEditingSlug(null);
267 onChange(customModels.filter((entry) => entry.slug !== slug));
268 onModelOrderChange(modelOrder.filter((model) => model !== slug));
269 onFavoriteModelsChange(favoriteModels.filter((model) => model !== slug));
270 setError(null);
271 };
272
273 const handleSaveEdit = (next: CustomModelDefinition) => {
274 onChange(customModels.map((entry) => (entry.slug === next.slug ? next : entry)));
275 setEditingSlug(null);
276 };
277
278 const setHidden = (slug: string, hidden: boolean) => {
279 if (hidden === hiddenModelSet.has(slug)) return;
280 onHiddenModelsChange(
281 hidden ? [...hiddenModels, slug] : hiddenModels.filter((model) => model !== slug),
282 );
283 };
284
285 const handleToggleFavorite = (slug: string) => {
286 if (favoriteModelSet.has(slug)) {
287 onFavoriteModelsChange(favoriteModels.filter((model) => model !== slug));
288 return;
289 }
290 onFavoriteModelsChange([...favoriteModels, slug]);
291 };
292
293 // Rows only trade places with a neighbour in the same group (favorites,
294 // visible, hidden), and the display order is persisted as the new order.
295 const groupOf = (model: (typeof displayModels)[number]) =>
296 favoriteModelSet.has(model.slug)
297 ? "favorite"
298 : !model.isCustom && hiddenModelSet.has(model.slug)
299 ? "hidden"
300 : "visible";
301 const handleMove = (slug: string, direction: -1 | 1) => {
302 const index = displayModels.findIndex((model) => model.slug === slug);
303 const nextIndex = index + direction;
304 if (index < 0 || nextIndex < 0 || nextIndex >= displayModels.length) return;
305 if (groupOf(displayModels[index]!) !== groupOf(displayModels[nextIndex]!)) return;
306 const next = displayModels.map((model) => model.slug);
307 [next[index], next[nextIndex]] = [next[nextIndex]!, next[index]!];
308 onModelOrderChange(next);
309 };
310
311 type DisplayModel = (typeof displayModels)[number];
312
313 const starButton = (model: DisplayModel, isFavorite: boolean) => (
314 <Tooltip>
315 <TooltipTrigger
316 render={
317 <Button
318 size="icon-micro"
319 variant="ghost-muted"
320 onClick={() => handleToggleFavorite(model.slug)}
321 aria-label={`${isFavorite ? "Remove" : "Add"} ${model.name} ${
322 isFavorite ? "from" : "to"
323 } favorites`}
324 />
325 }
326 >
327 <StarIcon className={cn("size-3", isFavorite && "fill-current text-warning")} />
328 </TooltipTrigger>
329 <TooltipPopup side="top">
330 {isFavorite ? "Remove from favorites" : "Add to favorites"}
331 </TooltipPopup>
332 </Tooltip>
333 );
334
335 // Reorder and remove stay in the row at all times (dimmed when unavailable)
336 // so ordering is discoverable without hovering.
337 const rowActions = (
338 model: DisplayModel,
339 options: {
340 readonly isHidden: boolean;
341 readonly canMoveUp: boolean;
342 readonly canMoveDown: boolean;
343 },
344 ) => (
345 <span className="flex shrink-0 items-center justify-end gap-0.5">
346 {!options.isHidden && !isFiltering ? (
347 <>
348 <Tooltip>
349 <TooltipTrigger
350 render={
351 <Button
352 size="icon-micro"
353 variant="ghost-muted"
354 disabled={!options.canMoveUp}
355 onClick={() => handleMove(model.slug, -1)}
356 aria-label={`Move ${model.name} up`}
357 />
358 }
359 >
360 <ArrowUpIcon className="size-3" />
361 </TooltipTrigger>
362 <TooltipPopup side="top">Move up</TooltipPopup>
363 </Tooltip>
364 <Tooltip>
365 <TooltipTrigger
366 render={
367 <Button
368 size="icon-micro"
369 variant="ghost-muted"
370 disabled={!options.canMoveDown}
371 onClick={() => handleMove(model.slug, 1)}
372 aria-label={`Move ${model.name} down`}
373 />
374 }
375 >
376 <ArrowDownIcon className="size-3" />
377 </TooltipTrigger>
378 <TooltipPopup side="top">Move down</TooltipPopup>
379 </Tooltip>
380 </>
381 ) : null}
382 {model.isCustom && providerSupportsCustomModels(driverKind) ? (
383 <Tooltip>
384 <TooltipTrigger
385 render={
386 <Button
387 size="icon-micro"
388 variant="ghost-muted"
389 aria-label={`Edit ${model.slug}`}
390 onClick={() =>
391 setEditingSlug((current) => (current === model.slug ? null : model.slug))
392 }
393 />
394 }
395 >
396 <PencilIcon className="size-3" />
397 </TooltipTrigger>
398 <TooltipPopup side="top">Edit name and options</TooltipPopup>
399 </Tooltip>
400 ) : null}
401 {model.isCustom ? (
402 <>
403 <Tooltip>
404 <TooltipTrigger
405 render={
406 <Button
407 size="icon-micro"
408 variant="ghost-muted"
409 aria-label={`Remove ${model.slug}`}
410 onClick={() => handleRemove(model.slug)}
411 />
412 }
413 >
414 <XIcon className="size-3" />
415 </TooltipTrigger>
416 <TooltipPopup side="top">Remove custom model</TooltipPopup>
417 </Tooltip>
418 </>
419 ) : null}
420 </span>
421 );
422
423 const catalogOnlyCustom = (model: DisplayModel) =>
424 model.isCustom && !providerSupportsCustomModels(driverKind);
425
426 const pickerTooltip = (model: DisplayModel, isHidden: boolean) =>
427 catalogOnlyCustom(model)
428 ? "Not offered in the picker. This provider only runs its account catalog."
429 : model.isCustom
430 ? "Custom models are always shown in the picker"
431 : isHidden
432 ? "Hidden from picker"
433 : "Shown in picker";
434
435 // The trigger is a wrapper span: a disabled switch gets no pointer events,
436 // so it could not open the tooltip itself.
437 const pickerSwitch = (model: DisplayModel, isHidden: boolean) => (
438 <Tooltip>
439 <TooltipTrigger render={<span className="flex shrink-0 items-center" />}>
440 <Switch
441 size="sm"
442 checked={catalogOnlyCustom(model) ? false : !isHidden}
443 disabled={model.isCustom}
444 onCheckedChange={(checked) => setHidden(model.slug, !checked)}
445 aria-label={
446 catalogOnlyCustom(model)
447 ? `${model.name} is not offered in the model picker`
448 : `Show ${model.name} in the model picker`
449 }
450 />
451 </TooltipTrigger>
452 <TooltipPopup side="top">{pickerTooltip(model, isHidden)}</TooltipPopup>
453 </Tooltip>
454 );
455
456 const renderRow = (model: DisplayModel) => {
457 const capLabels = describeModelCapabilities(model);
458 const group = groupOf(model);
459 // Hidden is read from the preference itself: a favorited model can still be
460 // hidden, and its switch must say so even though it sits in the favorites group.
461 const isHidden = !model.isCustom && hiddenModelSet.has(model.slug);
462 const isFavorite = group === "favorite";
463 const index = displayModels.indexOf(model);
464 const previousModel = displayModels[index - 1];
465 const nextModel = displayModels[index + 1];
466 // Reordering a filtered view would be ambiguous, so arrows only show on
467 // the full list.
468 const canMoveUp =
469 !isFiltering && previousModel !== undefined && groupOf(previousModel) === group;
470 const canMoveDown = !isFiltering && nextModel !== undefined && groupOf(nextModel) === group;
471 const nameClassName = cn("text-xs", isHidden ? "text-muted-foreground" : "text-foreground/90");
472
473 return (
474 <div
475 key={`${instanceId}:${model.slug}`}
476 data-model-slug={model.slug}
477 className={cn(
478 // Actions column is at least wide enough for the four custom-row
479 // buttons so capability labels line up across built-in and custom rows.
480 "grid h-7 grid-cols-[1.5rem_minmax(0,1fr)_auto_minmax(5.5rem,auto)_auto] items-center gap-2 rounded-md px-2 transition-colors hover:bg-muted/30",
481 isHidden && "opacity-50",
482 )}
483 >
484 {starButton(model, isFavorite)}
485 <span className="flex min-w-0 items-baseline gap-2">
486 <span className={cn(nameClassName, "truncate")}>{model.name}</span>
487 {model.name !== model.slug ? (
488 <code className="truncate font-mono text-2xs text-muted-foreground/70">
489 {model.slug}
490 </code>
491 ) : null}
492 {model.isCustom ? (
493 <span className="text-2xs text-muted-foreground/70">custom</span>
494 ) : null}
495 </span>
496 {/*
497 Always a grid item so the columns line up across rows; the text
498 itself drops out on phone widths where it would starve the name.
499 */}
500 <span className="text-2xs text-muted-foreground/70">
501 {capLabels.length > 0 ? (
502 <span className="hidden sm:inline">{capLabels.join(" · ")}</span>
503 ) : null}
504 </span>
505 {rowActions(model, { isHidden, canMoveUp, canMoveDown })}
506 {pickerSwitch(model, isHidden)}
507 </div>
508 );
509 };
510
511 const groupLabel = (label: string, isFirst: boolean) => (
512 <div className={cn("px-2 pb-1.5 text-2xs text-muted-foreground", isFirst ? "pt-1" : "pt-5")}>
513 {label}
514 </div>
515 );
516
517 return (
518 <div className="lg:flex lg:h-full lg:min-h-0 lg:flex-col">
519 <div className="flex flex-wrap items-center justify-between gap-2">
520 {showFilter ? (
521 <Input
522 value={filter}
523 onChange={(event) => setFilter(event.target.value)}
524 placeholder="Filter models"
525 size="sm"
526 className="w-56 max-w-full"
527 spellCheck={false}
528 aria-label="Filter models"
529 />
530 ) : null}
531 <div className="flex items-center gap-2">
532 {builtInModels.length > 0 ? (
533 <Button
534 type="button"
535 size="xs"
536 variant="ghost-muted"
537 onClick={() =>
538 onHiddenModelsChange(nextHiddenModelsForBulkToggle(models, hiddenModels))
539 }
540 >
541 {allBuiltInModelsHidden ? "Enable all" : "Disable all"}
542 </Button>
543 ) : null}
544 <span className="text-xs text-muted-foreground">
545 {models.length} model{models.length === 1 ? "" : "s"}
546 {favoriteCount > 0
547 ? ` · ${favoriteCount} favorite${favoriteCount === 1 ? "" : "s"}`
548 : ""}
549 {hiddenCount > 0 ? ` · ${hiddenCount} hidden` : ""}
550 </span>
551 </div>
552 {providerSupportsCustomModels(driverKind) && !isAdding ? (
553 <Button
554 type="button"
555 size="xs"
556 variant="ghost-muted"
557 className="ml-auto"
558 onClick={() => setIsAdding(true)}
559 >
560 <PlusIcon className="size-3" />
561 Add custom model
562 </Button>
563 ) : null}
564 </div>
565 <div
566 ref={listRef}
567 className="mt-2 -mx-2 max-h-64 overflow-y-auto lg:max-h-none lg:min-h-0 lg:flex-1"
568 >
569 {visibleModels.length === 0 ? (
570 <p className="px-2 py-2 text-xs text-muted-foreground">
571 {isFiltering ? "No models match." : "No models reported for this provider yet."}
572 </p>
573 ) : null}
574 {visibleModels.map((model, index) => {
575 const group = groupOf(model);
576 const previous = visibleModels[index - 1];
577 const startsGroup = previous === undefined || groupOf(previous) !== group;
578 const editingEntry =
579 model.isCustom && editingSlug === model.slug
580 ? customModels.find((entry) => entry.slug === model.slug)
581 : undefined;
582 return (
583 <div key={`${instanceId}:${model.slug}:group`}>
584 {startsGroup && favoriteCount > 0 && group === "favorite"
585 ? groupLabel("Favorites", index === 0)
586 : null}
587 {startsGroup && favoriteCount > 0 && group === "visible"
588 ? groupLabel("All", index === 0)
589 : null}
590 {startsGroup && group === "hidden"
591 ? groupLabel("Hidden from picker", index === 0)
592 : null}
593 {renderRow(model)}
594 {editingEntry ? (
595 <CustomModelEditor
596 key={`${instanceId}:${model.slug}:editor`}
597 instanceId={instanceId}
598 driverKind={driverKind}
599 entry={editingEntry}
600 builtInModels={builtInModels}
601 onSave={handleSaveEdit}
602 onCancel={() => setEditingSlug(null)}
603 />
604 ) : null}
605 </div>
606 );
607 })}
608 </div>
609
610 {!providerSupportsCustomModels(driverKind) ? null : isAdding ? (
611 <div className="mt-3 flex flex-col gap-2 sm:flex-row">
612 <Input
613 id={`provider-instance-${instanceId}-custom-model`}
614 size="sm"
615 autoFocus
616 value={input}
617 onChange={(event) => {
618 setInput(event.target.value);
619 if (error) setError(null);
620 }}
621 onKeyDown={(event) => {
622 if (event.key === "Escape") {
623 event.preventDefault();
624 cancelAdd();
625 return;
626 }
627 if (event.key !== "Enter") return;
628 event.preventDefault();
629 handleAdd();
630 }}
631 placeholder={driverKind ? CUSTOM_MODEL_PLACEHOLDER_BY_KIND[driverKind] : "model-slug"}
632 spellCheck={false}
633 />
634 <div className="flex shrink-0 gap-2">
635 <Button size="sm" variant="outline" onClick={handleAdd}>
636 Add
637 </Button>
638 <Button size="sm" variant="ghost" onClick={cancelAdd}>
639 Cancel
640 </Button>
641 </div>
642 </div>
643 ) : null}
644
645 {providerSupportsCustomModels(driverKind) && error ? (
646 <p className="mt-2 text-xs text-destructive">{error}</p>
647 ) : null}
648 </div>
649 );
650}