"use client"; import { useState } from "react"; import { IconSelector } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@kandev/ui/command"; import { Popover, PopoverContent, PopoverTrigger } from "@kandev/ui/popover"; import type { ModeEntry } from "@/lib/types/http"; type ModeComboboxProps = { value: string; onChange: (value: string) => void; modes: ModeEntry[]; currentModeId: string | undefined; }; /** * Searchable session-mode picker. Same Popover+Command pattern as * ModelCombobox so descriptions in the dropdown don't leak into the * trigger text (which happens with Radix Select). */ export function ModeCombobox({ value, onChange, modes, currentModeId }: ModeComboboxProps) { const [open, setOpen] = useState(false); const selected = value || currentModeId || modes[0]?.id || ""; const activeMode = modes.find((m) => m.id === selected); return ( e.stopPropagation()} > e.stopPropagation()} > No mode found. {modes.map((m) => ( { onChange(m.id); setOpen(false); }} data-checked={selected === m.id} className="cursor-pointer" >
{m.name} {m.id === currentModeId && ( (default) )}
{m.description && m.description !== m.name && (

{m.description}

)}
))}
); }