import { Activity } from "lucide-react"; import type { Agent } from "../api"; import { useLiveTranscript } from "../hooks/useLiveTranscript"; interface LiveAgentCardProps { agent: Agent; } function LiveAgentCard({ agent }: LiveAgentCardProps) { const { entries, isConnected } = useLiveTranscript(agent.taskId); const elapsed = agent.lastHeartbeatAt ? Math.floor((Date.now() - new Date(agent.lastHeartbeatAt).getTime()) / 1000) : 0; return (
{agent.name}
{agent.taskId && ( {agent.taskId} )}
{entries.length === 0 ? (
{isConnected ? "Waiting for output..." : "Connecting..."}
) : ( entries.slice(0, 20).map((entry, i) => (
{entry.content}
)) )}
{formatElapsed(elapsed)} {isConnected && }
); } function formatElapsed(seconds: number): string { if (seconds < 60) return `${seconds}s`; if (seconds < 3600) return `${Math.floor(seconds / 60)}m ${seconds % 60}s`; return `${Math.floor(seconds / 3600)}h ${Math.floor((seconds % 3600) / 60)}m`; } interface ActiveAgentsPanelProps { agents: Agent[]; } export function ActiveAgentsPanel({ agents }: ActiveAgentsPanelProps) { if (agents.length === 0) return null; return (
Active Agents ({agents.length})
{agents.map(agent => ( ))}
); }