import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { Box, FormControl, Select, MenuItem, Typography, Chip, Avatar, IconButton, Tooltip } from '@mui/material'; import { Diamond as DiamondIcon, SwapHoriz as SwitchIcon, Add as AddIcon } from '@mui/icons-material'; import { useAgents } from '../contexts/AgentContext'; const AgentSwitcher = ({ currentAgentName, onSwitch }) => { const navigate = useNavigate(); const { agents, loading } = useAgents(); // Filter only ready agents const readyAgents = agents.filter(a => a.status === 'ready'); const handleChange = (event) => { const newAgentName = event.target.value; if (newAgentName === '__create__') { navigate('/create'); } else if (newAgentName !== currentAgentName) { if (onSwitch) { onSwitch(newAgentName); } else { navigate(`/chat/${newAgentName}`); } } }; const getStatusColor = (status) => { switch (status) { case 'ready': return 'success'; case 'failed': return 'error'; case 'compiling': return 'warning'; default: return 'default'; } }; if (loading) { return null; } return ( ); }; export default AgentSwitcher;