Trace waterfall
Inspect hierarchical agent, model, and tool spans with elapsed timings, costs, and redacted payloads.
import { TraceWaterfall } from '@uthereal/ui/trace-waterfall'Trace waterfall playground
Report trace
Overview
TraceWaterfall visualizes an agent run as an expandable tree of elapsed-time spans. Selecting any row or timing bar opens an anchored nonmodal details panel showing model name, status, relative start, duration, rolled-up branch totals, and redacted input, output, or error text. The component displays host snapshots only; it never polls, uploads traces, or executes payload strings.
Use TraceWaterfall to debug nested latency, parallel branches, and per-call token cost. For a model's live prompt capacity, use Context window.
Usage
'use client'
import { TraceWaterfall } from '@uthereal/ui/trace-waterfall'
export function ReportTrace() {
return (
<TraceWaterfall
title="Report trace"
spans={[
{
id: 'run',
name: 'Prepare report',
kind: 'agent',
status: 'complete',
startMs: 0,
endMs: 4800,
costUsd: 0,
inputTokens: 0,
outputTokens: 0,
},
{
id: 'plan',
parentId: 'run',
name: 'Plan queries',
kind: 'llm',
status: 'complete',
startMs: 0,
endMs: 1200,
model: 'Reasoning model',
inputTokens: 900,
outputTokens: 300,
costUsd: 0.003,
input: 'Compare this quarter with the previous quarter.',
output: 'Read the revenue aggregate by plan.',
},
{
id: 'query',
parentId: 'run',
name: 'Read revenue',
kind: 'tool',
status: 'error',
startMs: 1400,
endMs: 4800,
costUsd: 0,
inputTokens: 0,
outputTokens: 0,
error: 'Read timeout; no data changed.',
},
]}
/>
)
}Pass collapsed with onCollapsedChange or selectedId with onSelectedIdChange to control branch disclosure and span inspection from your application.
Span hierarchy and aggregation
parentId defines visual nesting only, not billing rollups. Supply each span's own inputTokens, outputTokens, and costUsd excluding descendants so the header counts every span once. Run duration is wall-clock elapsed time, so concurrent children do not add together.
The schema validates unique span IDs, valid parent references, an acyclic hierarchy, nonnegative millisecond offsets, and endMs >= startMs. Imperfect parent containment is shown as supplied instead of rewriting host timestamps.
Span kind | Visual treatment & counting |
|---|---|
agent | Root or nested agent run; excluded from slowest-call highlighting. |
llm | Model call; counts as 1 LLM call unless the span supplies an explicit calls count. |
tool | Tool invocation; eligible for markSlowest highlighting when completed. |
span | Neutral span for non-agent, non-model, non-tool work. |
Use totals ({ calls?, costUsd?, tokens? }) when the host holds authoritative header figures that differ from span sums. Supply a number to override a sum, null to display —, or omit a field to keep the span sum.
For live traces, set live to true, pass startedAt in epoch milliseconds, and omit endMs on open spans. Keep failed retries as separate spans with new IDs. The header badge follows live (Live or Complete) unless status is set to 'live', 'running', 'complete', 'failed', or 'hidden'.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
labels | TraceWaterfallLabels— | Translated transport, grouping, control and feedback text; unspecified labels retain defaults. |
title | stringDefault: "Trace waterfall" | Visible heading and accessible name of this inspector. |
spansRequired | Span[]— | Bounded authoritative span snapshots with stable IDs and valid references; arrays replace. |
live | booleanDefault: false | Follow open host spans with a display clock; never starts or fetches work. |
status | live | running | complete | failed | hidden— | Trace status badge supplied by the host; hidden removes it. Omit to show Live or Complete from live. |
totals | TraceWaterfallTotals— | Header totals supplied by the host: LLM calls, USD cost and tokens. A number replaces the span sum, null shows — (not reported), omitted keeps the sum. |
startedAt | integer— | Run start as epoch milliseconds, used only by the live display clock. |
minRangeMs | integerDefault: 10000 | Minimum horizontal elapsed-time range in milliseconds. |
markSlowest | booleanDefault: true | Mark the longest finished non-agent call. |
defaultCollapsed | string[]Default: [] | Initially collapsed branch IDs; edits preserve existing host disclosure state. |
defaultSelectedId | string— | Initially selected item ID; existing host selection wins over edits. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes preserve interaction behavior. |
theme | TraceWaterfallTheme— | Color mode, accent and typed semantic token overrides. |
motion | none | subtle | expressiveDefault: "subtle" | Animation preset. System reduced-motion preferences take precedence. |
motionOptions | DisclosureMotionOptions— | Disclosure transition overrides; durations are milliseconds. |
dir | ltr | rtl— | Reading direction; inherited from the page when omitted. |
Each Span accepts { id, parentId?, name, kind, status?, startMs, endMs?, model?, calls?, description?, input?, output?, error?, inputTokens, outputTokens, costUsd }. Translate interface labels together through labels.
React integration
| Prop | Purpose |
|---|---|
collapsed | Controlled list of collapsed branch span IDs. |
onCollapsedChange(ids) | Called when branches expand or collapse, in both modes. |
selectedId | Controlled selected span ID, or null when the detail popover is closed. |
onSelectedIdChange(id) | Called when a span is selected or dismissed, in both modes. |
nowMs | Optional clock override (epoch ms) for deterministic live-span rendering. |
preset | Application defaults, overridden by explicit instance arguments. |
tokens | CSS variables applied after the typed theme. |
ref, className, style | Applied to the root <section> element. |
| Native attributes | id, aria-*, data-*, and remaining <section> props forwarded to the root. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
ArrowDown, ArrowUp | Move focus through visible spans in the tree. |
ArrowRight, ArrowLeft | Expand a collapsed branch, or collapse an open branch and move to its parent. |
Home, End | Jump to the first or last visible span. |
Enter, Space | Open or toggle the anchored nonmodal detail dialog for the focused span. |
Escape | Close the detail dialog and return focus to the invoking row. |
The hierarchy uses a Zag tree-view roving focus model and respects RTL arrow direction when dir="rtl" is set or inherited. All timings, statuses, and metrics remain available as plain text, and redacted payloads are never interpreted as HTML. The header status badge uses role="status". Under forced-colors, bars, selection outlines, and focus indicators remain legible.
Motion and theming
The time axis expands in rounded increments, live bars display a moving now-line and leading highlight, folded child calls appear as markers on the parent bar, and departing rows collapse from the bottom. Branch disclosures follow motionOptions. Below 560px, each label and metric pair stacks above a full-width bar and the header summary wraps to three columns. motion="none" and prefers-reduced-motion: reduce disable spatial animations.
theme accepts a mode, an accent, and panel tokens for colors, status tones, typography, surface radius, and span kind colors (series1, series2, series4). An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, TraceWaterfall is a leaf. The host stores /components/instance-<id>/selectedId and /components/instance-<id>/collapsed, seeded from defaultSelectedId and defaultCollapsed. Edits preserve existing valid IDs and drop IDs removed from spans. See Building with agents.
{
"type": "TraceWaterfall",
"props": {
"title": "Report trace",
"spans": [
{
"id": "run",
"name": "Prepare report",
"kind": "agent",
"status": "complete",
"startMs": 0,
"endMs": 1200,
"inputTokens": 0,
"outputTokens": 0,
"costUsd": 0
}
]
},
"children": []
}