Loading component…
Loading component…
A lead and its sub-agents as one live tree of cards – each card shows what the agent does right now, its context and tools, with handoffs running along the connectors
To reuse this local React demo, copy all files from the Code tab into the same folder, then import AgentCrew from ./agent-crew.
import { useState } from "react";
import { AgentCrew, type CrewAgent, type CrewHandoff } from "@/components/ui/agent-crew";
const root: CrewAgent = {
id: "lead",
name: "Lead",
model: "Claude Opus",
status: "active",
activity: "Assigning the patch",
context: 0.29,
contextLimit: 200_000,
children: [
{ id: "research", name: "Researcher", status: "done", activity: "Found the cause", context: 0.52 },
{
id: "coder",
name: "Coder",
status: "active",
activity: "Editing cart.ts",
context: 0.38,
last: { from: "Lead", text: "Guard empty carts" },
children: [{ id: "lint", name: "Linter", status: "idle", activity: "Idle" }],
},
],
};
export function Crew() {
const [handoffs, setHandoffs] = useState<CrewHandoff[]>([]);
return <AgentCrew title="Fix the checkout crash" root={root} handoffs={handoffs} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| root | CrewAgent | The lead – its children sit side by side below it, their children hang under them as smaller cards | |
| CrewAgent.status | "active" \| "idle" \| "paused" \| "waiting" \| "done" \| "failed" | active twinkles its pixel mark and shimmers its line; idle, paused and done rest; waiting and failed show their color – every card stays fully visible | |
| CrewAgent.activity | string | One line – what it's doing, or resting, what it did last | |
| CrewAgent.context / contextLimit | number / number | How full its context window is (0–1), as a thin bar in the agent's color – orange from 80%, red from 95% – and its size in tokens for "136k / 200k" | |
| CrewAgent.model / tools / last | string / { logo, name }[] / { from, text } | The model under its name, the tools as small tiles (by name in the details) and the last thing it was handed | |
| CrewAgent.task / modelLogo / started / ended / cost | string / ReactNode / number / number / number | In the details a click opens, as wide as the card: what it was asked, its model with the maker's logo, its usage (time – counting while it works – cost and tokens), its tools by name and the last thing it was handed | |
| CrewAgent.logo | ReactNode | A mark instead of its pixel pattern | |
| handoffs | { id, from, to, label? }[] | Each new id runs a light along the connectors – through the agents between them – and the card it reaches lights up: a Gradient Floor in that agent's color rises from the edge it came in by and fades. The ones there on mount don't run | |
| title | string | The header's name, with how many agents work, need you and how many there are | |
| projects / project / onProjectChange | { id, name, working?, needsYou? }[] / string / (id) => void | A project switcher takes the title's place, top left – each project with how many of its agents work or need you. Pass the chosen project's crew as root: its cards rise in and the connectors draw themselves | |
| onSteer | (agent, action, message?) => void | Adds steering to the details: Message (a short instruction) always, Pause and Stop while it works, Resume when paused, Approve / Decline when it needs you, Retry when it failed – update the agent from your data | |
| onSelect | (agent) => void | A click or Enter on a card – its details open as well | |
| formatCost | (amount) => string | dollars | Formats the cost in the details – "$0.52", "<$0.01" |
| className | string | Extra class on the root – set the color variables on it |
Every agent is a white card on a soft gray tray, like the rest of the library – its tools and last handoff sit on the tray below the card
Wide: sub-agents side by side under the lead; narrow: every level indented, the cards as wide as there's room
Rows are fixed, so a changing activity or context never moves a card or a connector
The details float in the top layer, as wide as their card – they never push the page or get cut off, stay inside the crew where they fit and follow the card on scroll
Long names, activities, tasks and messages end in … with the full text on hover
More than four tools show three tiles and "+N"; a long sender in the last handoff gives way to the message
Broken numbers from an API hold: a context of NaN, below 0 or above 1 is kept in 0–100%, a NaN cost is left out, a start in the future reads 0s, and times past a day read "3d 0h"
Touch screens get bigger buttons, close button and project rows to tap; on phones the switcher's list uses the width there is
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"