import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Command, CommandEmpty, CommandGroup, CommandItem, CommandList, } from "@/components/ui/command"; import { SLASH_COMMANDS } from "../lib/slash-commands"; import { cn } from "../lib/utils"; interface ChatSlashCommandPopoverProps { open: boolean; onOpenChange: (open: boolean) => void; onSelect: (command: string) => void; query: string; children: React.ReactNode; } export function ChatSlashCommandPopover({ open, onOpenChange, onSelect, query, children, }: ChatSlashCommandPopoverProps) { const filtered = SLASH_COMMANDS.filter((cmd) => cmd.command.toLowerCase().includes(query.toLowerCase()), ); return ( {children} e.preventDefault()} > No matching commands {filtered.map((cmd) => ( { if (!cmd.disabled) { onSelect(cmd.command); onOpenChange(false); } }} className={cn("flex flex-col items-start", cmd.disabled && "opacity-50")} > {cmd.command} {cmd.description} {cmd.disabled && " (Coming soon)"} ))} ); }