Loading component…
Loading component…
Several agents side by side – each card sums up its sub-agents, and a click opens its tree to the right while the last one folds back into its card.
To reuse this local React demo, copy all files from the Code tab into the same folder, then import AgentFleet from ./agent-fleet.
import { AgentFleet, type FleetAgent } from "@/components/ui/agent-fleet";
const fleet: FleetAgent[] = [
{
id: "launch", name: "Launch lead", model: "Opus 5.5", task: "Launch the new pricing page",
status: "running", cost: 0.42, started: Date.now() - 840_000,
children: [
{ id: "research", name: "Researcher", task: "Compare five competitors", status: "done", cost: 0.31, started: Date.now() - 780_000, ended: Date.now() - 360_000 },
{ id: "copy", name: "Writer", task: "Write the plan copy", status: "waiting", cost: 0.18, started: Date.now() - 720_000 },
],
},
{ id: "support", name: "Support lead", task: "Answer the open tickets", status: "running", cost: 0.12, started: Date.now() - 1_560_000 },
];
export function Fleet() {
return <AgentFleet agents={fleet} onSelect={(agent) => openLog(agent.id)} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| agents | FleetAgent[] | { id, name, task, model?, avatar?, tools?, status, steps?, cost?, started?, ended?, children? } – the main agents, each with its sub-agents; pass them again whenever something changes; tools are small marks shown as overlapping tiles before the task | |
| steps | FleetStep[] | Per sub-agent, { title, status?, tool?, took? } – the tasks it worked through; a click on its card opens them in a small window | |
| status | "queued" \| "running" \| "waiting" \| "done" \| "failed" \| "stopped" | Per agent – "waiting" reads "Needs you"; queued and stopped sub-agents and their connectors are muted | |
| cost | number | Per agent, its own cost – a main agent shows its whole branch, the bar the whole fleet | |
| open / defaultOpen | string \| null | the first agent | Id of the main agent whose tree is open, controlled or uncontrolled – null folds them all |
| onOpenChange | (id: string \| null) => void | An agent was opened – or folded with a second click | |
| ask / error | string | Per sub-agent – what a waiting one needs you to decide, and what went wrong for a failed one; shown at the top of its window above Approve and Reject, or Retry and Dismiss | |
| onResolve | (agent, action: "approve" \| "reject" \| "retry" \| "dismiss") => void | An answer for a sub-agent that needs you or failed – update its status in your data; without it, those cards get no Answer or Resolve button | |
| onSelect | (agent: FleetAgent) => void | A click on a sub-agent – makes the sub-agent cards clickable; one with steps opens its tasks window as well | |
| now | number | Date.now() | The clock for running times – without it the cards tick every second while an agent runs |
| formatCost | (amount: number) => string | dollars, e.g. "$0.42" | Formats every cost |
| title | string | "Agents" | Heading of the bar |
| className | string | Extra class on the root |
Wide enough for the column, a gap and the deepest tree, the tree opens to the right of the column
Narrower, the tree opens under its card and pushes the agents below down – and folds back up before the next one opens
Every card has a fixed height – one line of task, one line of numbers – so nothing jumps when a status changes
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"