import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { cn } from "@/lib/utils"; import { openSettingsWindow } from "@/modules/settings/openSettingsWindow"; import { AbsoluteIcon, ArrowDown01Icon, CodeIcon, PaintBrush04Icon, PencilEdit02Icon, Settings01Icon, ShieldUserIcon, SparklesIcon, Tick02Icon, } from "@hugeicons/core-free-icons"; import { HugeiconsIcon } from "@hugeicons/react"; import type { AgentIconId } from "../lib/agents"; import { useAgentsStore } from "../store/agentsStore"; const ICONS: Record = { coder: CodeIcon, architect: AbsoluteIcon, reviewer: PencilEdit02Icon, security: ShieldUserIcon, designer: PaintBrush04Icon, spark: SparklesIcon, }; export function AgentSwitcher({ isMiniWindow }: { isMiniWindow?: boolean }) { // Subscribe to customAgents + activeId so the trigger updates live. const customAgents = useAgentsStore((s) => s.customAgents); const activeId = useAgentsStore((s) => s.activeId); const setActiveId = useAgentsStore((s) => s.setActiveId); const list = useAgentsStore.getState().all(); void customAgents; // keeps the store subscription alive const active = list.find((a) => a.id === activeId) ?? list[0]; const builtIn = list.filter((a) => a.builtIn); const custom = list.filter((a) => !a.builtIn); const ActiveIcon = ICONS[active.icon] ?? SparklesIcon; return (
Built-in
{builtIn.map((a) => { const Icon = ICONS[a.icon] ?? SparklesIcon; return ( setActiveId(a.id)} className={cn( "flex items-start gap-2 pr-2 text-[12px]", a.id === activeId && "bg-accent/40", )} > {a.name} {a.description} {a.id === activeId ? ( ) : null} ); })} {custom.length > 0 ? ( <>
Custom
{custom.map((a) => { const Icon = ICONS[a.icon] ?? SparklesIcon; return ( setActiveId(a.id)} className={cn( "flex items-start gap-2 text-[12px]", a.id === activeId && "bg-accent/40", )} > {a.name} {a.description ? ( {a.description} ) : null} {a.id === activeId ? ( ) : null} ); })} ) : null} void openSettingsWindow("agents")} className="gap-2 text-[12px] text-muted-foreground" > Manage agents…
); } export { ICONS as AGENT_ICONS };