Loading component…
Loading component…
Where the time and money of an agent run go – every LLM call, tool call and sub-agent as a bar on a live timeline, with cost per step and the slowest call marked
To reuse this local React demo, copy all files from the Code tab into the same folder, then import TraceWaterfall from ./trace-waterfall.
import { TraceWaterfall, type TraceSpan } from "@/components/ui/trace-waterfall";
const run: TraceSpan = {
id: "run", name: "Orchestrator", kind: "agent", status: "running", start: 0,
input: "Launch the new pricing page",
children: [
{ id: "plan", name: "Plan the launch", kind: "llm", model: "Opus 5.5", detail: "Opus 5.5", status: "done",
start: 900, end: 7800, tokensIn: 3240, tokensOut: 880, cost: 0.115 },
{ id: "search", name: "web_search", kind: "tool", detail: "Linear pricing", status: "running", start: 8100 },
],
};
export function Run({ startedAt }: { startedAt: number }) {
// Times are ms from the start of the run; with startedAt the component keeps its own clock while it runs
return <TraceWaterfall root={run} startedAt={startedAt} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| root | TraceSpan | { id, name, kind, status, start, end?, detail?, icon?, model?, tokensIn?, tokensOut?, cost?, input?, output?, error?, children? } – the whole run as a tree, rebuilt as it goes on | |
| kind | "agent" \| "subagent" \| "llm" \| "tool" | Per span – picks the bar's tint: agents slate, LLM calls violet, tool calls teal; failed spans are red | |
| status | "running" \| "done" \| "failed" | Per span – a running span has no end yet and grows into "now" | |
| start / end | number | Per span, in ms from the start of the run; leave end out while it runs | |
| detail | string | Per span – a few muted words after the name, e.g. the model or the query | |
| icon | ReactNode | Per span – a small mark, e.g. the model maker's or the tool's logo; defaults to a swatch in the kind's color | |
| cost / tokensIn / tokensOut | number | Per span, its own – agents add up their children, so don't pre-sum | |
| input / output / error | string | Per span – short previews shown in the details window | |
| now | number | The clock in ms from the start of the run – e.g. a faster one for a demo or a replay | |
| startedAt | number | When the run started (epoch ms) – without now, the component ticks its own clock from here while a span runs | |
| collapsed / defaultCollapsed | string[] | [] | Ids of folded spans, controlled or uncontrolled |
| onCollapsedChange | (collapsed: string[]) => void | A span was folded or opened | |
| openId / defaultOpenId | string \| null | null | The span whose details are open, controlled or uncontrolled |
| onOpenChange | (id: string \| null, span?: TraceSpan) => void | Details opened (with the span) or closed | |
| markSlowest | boolean | true | Marks the slowest finished LLM or tool call with a small "Slowest" tag |
| minRange | number | 10000 | The shortest time the axis shows, in ms – it grows in round steps as the run gets longer |
| formatCost | (amount: number) => string | dollars, e.g. "$0.042" | Formats every cost |
| title | string | "Trace" | Heading of the bar; next to it the root's input (or name) |
| className | string | Extra class on the root |
Built on a container query: wide, the span tree sits on the left and the timeline on the right
Under 560px each row stacks – name, duration and cost on one line, the bar across the whole width under it; the numbers wrap to three columns
Under 360px the muted detail after each name drops out, so names keep their room
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"