Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ProviderModelsSection.tsx

648 lines24.2 KB

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