"use client"; import { useState } from "react"; import { IconSelector } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Popover, PopoverContent, PopoverTrigger } from "@kandev/ui/popover"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@kandev/ui/command"; import type { ModelEntry } from "@/lib/types/http"; type ModelComboboxProps = { value: string; onChange: (value: string) => void; models: ModelEntry[]; currentModelId?: string; placeholder?: string; disabled?: boolean; }; /** * Searchable model picker. The user can only choose from the agent's * advertised model list — custom model IDs are not allowed for ACP agents * since the agent CLI is authoritative for what it will accept. */ export function ModelCombobox({ value, onChange, models, currentModelId, placeholder = "Select a model", disabled, }: ModelComboboxProps) { const [open, setOpen] = useState(false); const effectiveValue = value || currentModelId || ""; const selectedModel = models.find((m) => m.id === effectiveValue); const copilotUsage = (model: ModelEntry): string | undefined => { const raw = model.meta?.copilotUsage; return typeof raw === "string" ? raw : undefined; }; return ( e.stopPropagation()} > e.stopPropagation()} > No model found. {models.map((model) => { const usage = copilotUsage(model); return ( { onChange(model.id); setOpen(false); }} data-checked={effectiveValue === model.id} className="cursor-pointer" >
{model.name} {model.id === currentModelId && ( (default) )}
{model.description && model.description !== model.name && (

{model.description}

)}
{usage && ( {usage} )}
); })}
); }