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