affectUI › Components › Agents
Agent Metro Map
A multi-agent run drawn as a metro map – every agent a line in its own color, every step a station, and where agents hand work over their lines meet at an interchange. Lines run straight and bend at 45°; each agent rides its line as a small white train with its pixel mark, the stretch behind it solid, the stretch ahead faint – when it moves on, the train glides to the next station, the line fills in behind it and a light runs ahead. A station waiting for you turns amber and can be approved in its card. The lines are listed on top with their model's logo; point at a line or a station and it comes forward, click one and its card opens.
Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/agent-metro-map.json · Import from @/components/ui/agent-metro-map
When to use
- Showing a run where several agents work at once – who's where, where their work meets, what's still ahead
- A release, a launch or an onboarding as a route people read at a glance, like a metro map
- Runs with a stop where a person has to approve, right on the map
When not to use
- One agent's states and how often it moved between them – use Agent State Machine
- Who does what when, lane by lane – use Handoff Swimlanes
- Every message and tool call in order – use Agent Sequence
Usage
import { AgentMetroMap, type MetroLine, type MetroStation } from "@/components/ui/agent-metro-map";
const stations: MetroStation[] = [
{ id: "brief", label: "Brief", col: 0, row: 1 },
{ id: "split", label: "Split work", col: 1, row: 1 },
{ id: "code", label: "Write fix", col: 2, row: 0, labelSide: "above", tools: [{ name: "GitHub", logo: <GitHubLogo /> }] },
{ id: "notes", label: "Draft notes", col: 2, row: 2 },
{ id: "review", label: "Review", col: 3, row: 1 },
{ id: "prod", label: "Production", col: 4, row: 1, status: "waiting" },
];
const lines: MetroLine[] = [
{ id: "planner", name: "Planner", model: "Claude Opus 5.5", logo: <ClaudeLogo />, stations: ["brief", "split", "review", "prod"], at: "review", status: "running" },
{ id: "coder", name: "Coder", model: "GPT-5.5 Codex", logo: <OpenAILogo />, stations: ["split", "code", "review"], status: "done" },
{ id: "writer", name: "Writer", model: "Gemini 3 Pro", logo: <GeminiLogo />, stations: ["split", "notes", "review"], at: "notes", status: "running" },
];
export function Release() {
return <AgentMetroMap title="Ship v2.4" lines={lines} stations={stations} onApprove={(s) => api.approve(s.id)} />;
}Props
| Name | Type | Default | Description |
|---|---|---|---|
stations | MetroStation[] | { id, label, col, row, labelSide?, status?, detail?, tools?, duration? } – col and row place it on the map's grid | |
labelSide | "below" | "above" | "left" | "right" | Where its name goes – below by default; put it on the side no line leaves from | |
status (station) | "waiting" | "failed" | Waiting turns amber and can be approved in its card, failed turns red; done and current follow from where the trains are | |
lines | MetroLine[] | { id, name, stations, at?, status?, color?, model?, logo? } – one per agent, its stations in order | |
at | string | The station its train is at – the stretch behind is the full color, the stretch ahead see-through | |
status (line) | "running" | "done" | "idle" | Idle – not started, no train; done – arrived, the whole line in full color | |
color / model / logo | string / string / ReactNode | The line's color – the first is blue, then a palette – and the model with its maker's logo, in the legend and the line's card | |
onApprove / onReject | (station) => void | Show Approve and Reject in the card of a waiting station – the card closes after either | |
onSelect | ({ station } | { line } | null) => void | A station's or a line's card opened or closed | |
title / className | string | The heading and the section's accessible name, and an extra class on the root |
Accessibility
- Every station and every line in the legend is a button with aria-expanded – Enter or Space opens its card
- A station reads as its name, whether it's an interchange, its lines and its state – "Review – interchange, Planner and Coder lines, a train is here"
- A line reads as its agent, its model, where its train is and how far it has come – "Coder line, GPT-5.5 Codex – at Tests, 3 of 5 stations"
- A card opened with the keyboard takes focus – on a waiting station straight to Approve; Esc closes it from anywhere and focus goes back
- The lines, the trains and the light are decoration and hidden from screen readers – each line's card lists its stations
- A focus ring shows only for the keyboard
- The classic style has a rounder card with a hairline border, pill-shaped line chips, tags and buttons and firmer type – the same behavior as the clean one
Responsive
- Fills its container's width – the columns spread out up to a comfortable distance
- Short of room the whole map scales down to fit – it never scrolls sideways
- Lines run straight and bend at 45°; at a station a line always runs through its middle
- Lines between the same two stations run side by side, like on a real metro map; a line passing a station it doesn't stop at is drawn through it – lay stations so lines don't run over each other
- Stations without a place on the grid, lines' stops that don't exist and repeated ids are left out; a train whose station doesn't exist starts at the first one
- Station names sit on a patch of the card's color, so a line running past never cuts through them; long names end in …
- Cards open below what you clicked, above it near the bottom of the screen
- Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
Requirements
- React 19
Related
- Agent State Machine – One agent as a state diagram – every state it can be in is a card, every transition a line with a count of how often the run took it: forward to the right, back to an earlier state around underneath, a retry as a loop on top. The current state glows in the agent's blue with its pixel mark twinkling, a waiting state is amber, the final one carries a bullseye; when the agent moves on, a light runs along that transition and its count rolls up. Point at a state and its transitions come forward; click a state or a count and its card says how long the agent spent there and what made it leave
- Handoff Swimlanes – Who does what in an agent run, and where the work changes hands – a process diagram with a lane for you, every agent and every tool. Each task is a box in the lane of whoever does it, a handoff an arrow to the next one, an approval a diamond; done boxes are quiet, the running one shimmers in its agent's color, waiting is amber, failed is red, and a light runs along every handoff that's happening now. Click a box, a diamond or a lane and its card opens – an approval waiting for you can be approved right there
- Agent Sequence – One agent run as a sequence diagram – a column for you, every agent and every tool, and each message an arrow from one lifeline to the next: calls solid, replies dashed, every label a tag in its line's color, a bar on the lifeline while a participant works, parallel and retried messages in labelled frames; new messages draw themselves across with a light at the tip, and a click on a participant or a message opens its card
- Agent Tree – Who started whom – an orchestrator and its sub-agents as a live tree, with status, cost and time on every card, costs rolling up each branch, and branches that fold to one line