import React from 'react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { useAgentsStore } from '@/stores/useAgentsStore'; import { useUIStore } from '@/stores/useUIStore'; import { useDeviceInfo } from '@/lib/device'; import { RiArrowDownSLine, RiRobot2Line } from '@remixicon/react'; import { cn } from '@/lib/utils'; import { MobileOverlayPanel } from '@/components/ui/MobileOverlayPanel'; interface AgentSelectorProps { agentName: string; onChange: (agentName: string) => void; className?: string; } export const AgentSelector: React.FC = ({ agentName, onChange, className }) => { const { loadAgents, getVisibleAgents } = useAgentsStore(); const agents = getVisibleAgents(); const isMobile = useUIStore(state => state.isMobile); const { isMobile: deviceIsMobile } = useDeviceInfo(); const isActuallyMobile = isMobile || deviceIsMobile; const [isMobilePanelOpen, setIsMobilePanelOpen] = React.useState(false); React.useEffect(() => { loadAgents(); }, [loadAgents]); const closeMobilePanel = () => setIsMobilePanelOpen(false); const handleAgentChange = (newAgentName: string) => { onChange(newAgentName); }; const renderMobileAgentPanel = () => { if (!isActuallyMobile) return null; return (
{agents.map((agent) => { const isSelected = agent.name === agentName; return ( ); })}
); }; return ( <> {isActuallyMobile ? ( ) : (
{agentName || 'Not selected'}
{agents.map((agent) => ( handleAgentChange(agent.name)} > {agent.name} ))} handleAgentChange('')} > No agent (optional)
)} {renderMobileAgentPanel()} ); };