Merge pull request #588 from escapade-mckv/mcp-5a-agentbuilder

hotfix(ui): fix agent-selector
This commit is contained in:
Bobbie 2025-06-01 03:00:38 +05:30 committed by GitHub
commit b5440bc247
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -36,13 +36,18 @@ export function AgentSelector({
}: AgentSelectorProps) { }: AgentSelectorProps) {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const router = useRouter(); const router = useRouter();
const { data: agents, isLoading } = useAgents();
// Find the selected agent or default agent const { data: agentsResponse, isLoading } = useAgents({
limit: 100,
sort_by: 'name',
sort_order: 'asc'
});
const agents = agentsResponse?.agents || [];
const selectedAgent = agents?.find(a => a.agent_id === selectedAgentId); const selectedAgent = agents?.find(a => a.agent_id === selectedAgentId);
const defaultAgent = agents?.find(a => a.is_default); const defaultAgent = agents?.find(a => a.is_default);
// Set default agent on mount if no agent is selected
useEffect(() => { useEffect(() => {
if (!selectedAgentId && defaultAgent && !isLoading) { if (!selectedAgentId && defaultAgent && !isLoading) {
onAgentSelect(defaultAgent.agent_id); onAgentSelect(defaultAgent.agent_id);