import { Button, Spin, Empty, Tabs } from 'antd'; import { PlusOutlined } from '@ant-design/icons'; import { useEffect, useState, useMemo } from 'react'; import type { Agent } from '../../../api'; import './AgentSidebar.css'; const isImageUrl = (url: string) => url?.startsWith('http') || url?.startsWith('/'); export default function AgentSidebar(props: { agentList: Agent[]; activeAgentId?: string; onCreate: () => void; onSelect: (agentId: string) => void; isSidebar?: boolean; }) { const { agentList, activeAgentId, onCreate, onSelect, isSidebar = true } = props; const [loadingTimeout, setLoadingTimeout] = useState(false); const [activeTab, setActiveTab] = useState('mine'); useEffect(() => { if (agentList.length > 0) return; const timer = setTimeout(() => { setLoadingTimeout(true); }, 5000); return () => clearTimeout(timer); }, [agentList.length]); const filteredList = useMemo(() => { if (activeTab === 'public') return agentList.filter(a => a.visibility === 'public'); if (activeTab === 'private') return agentList.filter(a => a.visibility === 'private'); return agentList; // 'mine' tab shows all for now or filter by owner_id if available }, [agentList, activeTab]); // 模拟分组逻辑 const groupedAgents = useMemo(() => { const groups: Record = { '我的智能体': [], '推荐': [] }; filteredList.forEach(a => { if (a.visibility === 'public') { groups['推荐'].push(a); } else { groups['我的智能体'].push(a); } }); return Object.entries(groups).filter(([_, list]) => list.length > 0); }, [filteredList]); return ( ); }