import { useQuery, useQueryClient } from '@tanstack/react-query' import { listAgents } from '../services/api' import { Activity, AlertTriangle, RefreshCw, Bot, Zap, Coffee, AlertCircle } from 'lucide-react' import type { Agent } from '../types' function statusStats(agents: Agent[]) { const counts = { total: agents.length, active: 0, idle: 0, thinking: 0, error: 0 } for (const a of agents) { if (a.status in counts) counts[a.status as keyof typeof counts]++ } return counts } const STATUS_COLORS: Record = { active: 'bg-green-500', idle: 'bg-yellow-500', thinking: 'bg-blue-500', error: 'bg-red-500', } export default function HubPage() { const queryClient = useQueryClient() const { data, isLoading, error, refetch, isRefetching } = useQuery({ queryKey: ['agents'], queryFn: listAgents, }) const agents = data?.data ?? [] const stats = statusStats(agents) if (isLoading) { return } if (error) { return (

Failed to load agents

) } return (
{/* Header */}

Command Hub

Agent fleet overview

{/* Summary stats */}
{/* Agent grid */} {agents.length === 0 ? (

No agents registered

Agents will appear here once connected.

) : (
{agents.map((agent) => (
{/* Agent identity */}
{agent.displayName.charAt(0)}

{agent.displayName}

{agent.role}

{/* Current task */} {agent.currentTask && (
{agent.currentTask}
)} {/* Progress bar */} {agent.taskProgress !== undefined && agent.taskProgress > 0 && (
)} {/* Footer info */}
{agent.channel} ยท {agent.lastActivity}
))}
)}
) } function StatCard({ icon: Icon, label, value, color }: { icon: React.ElementType; label: string; value: number; color: string }) { return (

{label}

{value}

) } function StatusBadge({ status }: { status: string }) { return (
{status}
) } function HubSkeleton() { return (
{[...Array(4)].map((_, i) => (
))}
{[...Array(6)].map((_, i) => (
))}
) }