"use client"; import { BotIcon, PenToolIcon, PlayIcon, SearchIcon } from "lucide-react"; import type { JobKind, JobRecord } from "@/src/core"; import { useTreePanelMode } from "@/components/tree-panel"; /** * The sub-agents sidebar section (vision ยง2.5 live observability): what the * teacher's background fleet is doing RIGHT NOW in this session โ€” one card * per running sub-agent with its live activity line (current tool + args) * and elapsed time, fed by the central jobs poll. * * Renders nothing when the fleet is idle (zero clutter); finished jobs * vanish from the list โ€” their artifacts live in the transcript. Sits at * the top of the right sidebar, above the plan-tree panel. */ const KIND_META: Record = { research: { label: "Researcher", Icon: SearchIcon }, demo: { label: "Demo builder", Icon: PlayIcon }, visual: { label: "Figure maker", Icon: PenToolIcon }, }; /** The collapsed fleet: a quiet strip on the sidebar rail โ€” bot icon + * running count, exactly like the plan's node-count rail below it. Click * expands the sidebar back to the full fleet list. */ function SubAgentsRail({ count, onExpand }: { count: number; onExpand: () => void }) { return (
{count} running
); } export function SubAgentsPanel({ jobs }: { jobs: JobRecord[] }) { const { mode, go } = useTreePanelMode(); const running = jobs.filter((j) => j.status === "running"); if (running.length === 0) return null; if (mode === "rail") return go("list")} />; return ( ); } function elapsedOf(job: JobRecord): string { if (!job.createdAt) return ""; const seconds = Math.max(0, Math.round((Date.now() - Date.parse(job.createdAt)) / 1000)); return seconds < 60 ? `${seconds}s` : `${Math.floor(seconds / 60)}m ${seconds % 60}s`; }