Components/AgentTrace

AgentTrace

An expandable trace of an agent's steps.

VerifiedSince 0.3.9

Usage

Step Trace

The host drives the timeline: append rows, then set working to false when the run ends.

Loading demo...

Four Forms

variant changes only the row form; the header and the disclosure stay the same.

Loading demo...

Best Practices

  • Keep the timeline in the host: append rows and flip working; don't put playback scripts in the component.
  • Always handle open in the search form, or clicking a source does nothing.
  • Cap long traces with moreLabel instead of laying out dozens of rows.
  • Use reasoning for paragraph prose (it wraps, never truncates) and steps for single-line labels.
  • In streaming UIs, store toggle in the host and pass it back through userOpen so the reader's choice survives a rebuild.

API Reference

Props

PropTypeDefaultDescription
rowsAgentTraceRow[]—The trace rows. Required.
variant'steps' | 'reasoning' | 'search' | 'coding''steps'Row form and typography.
querystring—search: the query echoed above the results.
workingbooleanfalseWhether the trace is still running; drives the shimmer and the spinner.
activeLabelstringper variantHeader text while working.
doneLabelstringper variantHeader text once settled.
moreLabelstring—Trailing overflow note, e.g. +7 more.
defaultOpenboolean—Open state before any interaction; falls back to working.
userOpenboolean—Host-held open state; wins over everything and survives a rebuild.
selectedIdstring—coding: the selected row id. Binding it hands selection to the host.

Default header text per variant is below. Counted text such as "Thought for 4 seconds" depends on a measurement only the host has, so pass doneLabel for it.

VariantactiveLabeldoneLabel
steps / reasoningThinkingThought
searchSearching the webSearched the web
codingRunning toolsRan tools

Events

EventPayloadDescription
toggle(open: boolean)Fires on a header click with the new state.
open(row: AgentTraceRow)search: fires when a linked row is clicked; the component never navigates.
select(id: string | null)coding: fires on select or deselect; null when cleared.

Slots

NameScopeDescription
icon{ working }Replaces the header starburst.
label{ working }Replaces the header text.
row{ row, index }Replaces the row content, keeping the row container and entrance.

Types

AgentTraceRow

FieldTypeDescription
idstringStable row key.
primarystringStep name, prose sentence, site title, or tool name.
secondarystringRight-hand detail: a count, domain, file path, or command.
monobooleanSets secondary in the monospace face.
added / removednumberDiff counters, shown as +N −M with a true minus sign (U+2212).
hrefstringIn the search form, renders the row as a link whose click emits open.
status'pending' | 'active' | 'done' | 'error'steps glyph: active spins, error marks, anything else checks.

Overview

  • Open resolves from userOpen, then the reader's click, then defaultOpen, then working; the click lives only in the instance.
  • The header is a button with aria-expanded and aria-controls; while collapsed the body is inert, so its rows leave the tab order.
  • A search row keeps a real href (copyable, middle-clickable); a click calls preventDefault and emits open, and the host decides how to open it.
  • Without status, only the last row spins while working.
  • coding rows are button elements with aria-pressed.
  • Under reduced motion only the animation stops; opening, closing, and state work as usual.

Technologies

  • Adapted from Beautiful UI (© 2026 Shane Levine, MIT).
  • Source: packages/tuffex/packages/components/src/agent-trace/.
查看源码
packages/tuffex/packages/components/src/agent-trace/index.ts