Skip to content
GitHub11 stars

The building block for reasoning, tool calls, sources and more.

@implements IDisposable

<div class="flex min-h-72 w-full max-w-sm flex-col gap-4 py-6 text-sm">

Trace is a list of lines. Each line has an icon, a title, and an optional description and status. A line can expand to show more detail, link to a page, or open a dialog or sheet.

Every line has the same shape, so reasoning, tool calls, sources and plans built from Trace look and behave the same.

Use Trace for the steps an agent takes, like calling a tool, running a subagent or editing a file. Use Message for its reply, and Marker for notes and dividers between turns.

Built with Trace

Every pattern below is a composition of Trace parts. See AI Elements for examples and code.

PatternShows
Chain of ThoughtA summary that expands into the steps behind it.
PlanThe steps the agent plans to take, and how far it has got.
QueueThe agent's todo list, split into what is left and what is done.
ReasoningThe agent's thinking as it streams.
SourcesThe links the agent used for a reply.
Stack TraceA failed tool call and its stack frames.
SubagentA subagent run, with its tool calls and result.
TaskThe steps the agent takes, as it takes them.
TerminalA command the agent runs, with its output as it streams.
Test ResultsA test run by the agent, with its suites and failures.
ToolA tool call the agent makes, from input to output.

Installation

dnx Blazix.Cli add trace

Usage

Use a TraceLine for a single step:

<Trace>
    <TraceLine>
        <TraceIcon><Icon Data="LucideIcons.Search" /></TraceIcon>
        <TraceTitle>Searched for minimumReleaseAge</TraceTitle>
    </TraceLine>
</Trace>

Wrap the line in a TraceCollapsible to show more detail when it expands:

<Trace>
    <TraceCollapsible>
        <TraceCollapsibleTrigger>
            <TraceLine>
                <TraceIcon><Icon Data="LucideIcons.Terminal" /></TraceIcon>
                <TraceTitle>Ran node --version</TraceTitle>
            </TraceLine>
        </TraceCollapsibleTrigger>
        <TraceCollapsibleContent>v24.18.0</TraceCollapsibleContent>
    </TraceCollapsible>
</Trace>

Composition

Use the following composition to build a trace line:

Trace
└── TraceLine
    ├── TraceIcon
    ├── TraceTitle
    ├── TraceDescription
    └── TraceIcon

Wrap the line in a TraceCollapsible to show more detail when it expands:

Trace
└── TraceCollapsible
    ├── TraceCollapsibleTrigger
    │   └── TraceLine
    └── TraceCollapsibleContent

TraceLine is always the line. To make a line do something, wrap it in that thing's trigger.

Features

  • One row for reasoning, tool calls, sources, plans and tasks
  • Rows that expand, link out, or open a dialog, sheet, drawer or popover
  • running, error and pending states, with a shimmer while running
  • Nested rows, so a summary expands into steps and a step into its output
  • Works with reasoning, tool and source parts from the AI SDK
  • Keyboard and screen reader support from the trigger that wraps each row
  • Customizable styling through the Class parameter on every part

Trace Line

Use a TraceLine on its own for a step with no detail to show. It reads as plain text.

Created branch fix/frozen-lockfile
<Trace Class="max-w-sm">
    <TraceLine>
        <TraceIcon><Icon Data="LucideIcons.GitBranch" /></TraceIcon>
        <TraceTitle>Created branch fix/frozen-lockfile</TraceTitle>
    </TraceLine>
</Trace>

Status

Set Status on TraceLine when a step is running, has failed or hasn't started yet.

Ran pnpm install Failed to run pnpm lint Running pnpm build Run pnpm test
<Trace Class="max-w-sm">
    <TraceLine>
        <TraceIcon><Icon Data="LucideIcons.CircleCheck" /></TraceIcon>
StatusUse for
TraceLineStatus.NoneWork that is done: "Ran pnpm install".
ErrorWork that failed. Say so in the title: "Failed to run pnpm lint".
RunningWork in progress. Write the title in the present tense: "Running pnpm build".
PendingWork that has not started, such as a plan step: "Run pnpm test".

Description

Put secondary text such as a diff stat, a duration or a count in a TraceDescription after the TraceTitle. It does not truncate.

Edited components/settings/notification-preferences-form.tsx +48 −12 Ran pnpm test 14s Searched for useChat 8 results
<Trace Class="max-w-sm">
    <TraceLine>
        <TraceIcon><Icon Data="LucideIcons.FilePen" /></TraceIcon>

Collapsible

Wrap the line in a TraceCollapsible to show more detail when it expands. Put the TraceLine inside TraceCollapsibleTrigger and the detail in TraceCollapsibleContent.

<div class="w-full max-w-sm">
    <TraceCollapsible>
        <TraceCollapsibleTrigger>

Open State

Rows start closed. Use Open on TraceCollapsible to start open, or Open with OpenChanged to control a row.

$ node --version
v24.18.0
<div class="flex w-full max-w-sm flex-col items-start gap-4">
    <TraceCollapsible Open="true">
        <TraceCollapsibleTrigger>

To open a row while it streams and let the reader's click win, pass _open ?? running and keep the reader's choice in _open.

<TraceCollapsible Open="@(_open ?? running)" OpenChanged="@(open => _open = open)">
    <TraceCollapsibleTrigger>
        <TraceLine Status="@(running ? TraceLineStatus.Running : TraceLineStatus.None)">…</TraceLine>
    </TraceCollapsibleTrigger>
    <TraceCollapsibleContent>@text</TraceCollapsibleContent>
</TraceCollapsible>

@code {
    private bool? _open;
}

Wrap the TraceLine in an anchor. For a new tab, use an arrow-up-right icon and sr-only "(opens in a new tab)".

<Trace Class="max-w-sm">
    <a href="#link">
        <TraceLine>
<a href="https://docs.astro.build" target="_blank" rel="noreferrer">
    <TraceLine>
        <TraceTitle>
            Install Astro
            <span class="sr-only">(opens in a new tab)</span>
        </TraceTitle>
        <TraceIcon><Icon Data="LucideIcons.ArrowUpRight" /></TraceIcon>
    </TraceLine>
</a>

Dialog

Wrap the TraceLine in the dialog's trigger. The dialog owns its open state, Escape and focus return.

<Trace Class="max-w-sm">
    <Dialog>
        <DialogTrigger>
<Dialog>
    <DialogTrigger>
        <TraceLine>
            <TraceTitle>Searched the web for cache keys</TraceTitle>
            <TraceIcon><Icon Data="LucideIcons.ChevronRight" /></TraceIcon>
        </TraceLine>
    </DialogTrigger>
    <DialogContent>…</DialogContent>
</Dialog>

Sheet

The same shape as the dialog. Drawer and Popover work the same way.

<Trace Class="max-w-sm">
    <Sheet>
        <SheetTrigger>

Group

Put rows that sit next to each other in a Trace. It also styles any trigger or link that wraps a TraceLine.

Searched for minimumReleaseAge Read pnpm-workspace.yaml Ran pnpm install
<Trace Class="max-w-sm">
    <TraceLine>
        <TraceIcon><Icon Data="LucideIcons.Search" /></TraceIcon>

Sources

A collapsible row whose detail is a Trace of link rows.

<div class="w-full max-w-sm">
    <TraceCollapsible Open="true">
        <TraceCollapsibleTrigger>

See Sources for more examples.

Chain of Thought

A chain of thought is a collapsible row with step rows inside. Set the parent's status and title from its children.

Read the last twelve deploys
<div class="w-full max-w-sm">
    <TraceCollapsible Open="true">
        <TraceCollapsibleTrigger>

See Chain of Thought and Task for more examples.

Commit

A commit is a collapsible row with a line for each changed file. Say what changed in the title, Added, Edited or Deleted, and put the line counts in the description. Each file opens its diff in a Sheet.

<Trace Class="max-w-sm">
    <TraceCollapsible Open="true">
        <TraceCollapsibleTrigger>

Whole Turn

Three levels: the turn, a summary, and the rows. Text between steps sits between two Trace lists.

Ran node --version

Node is installed and pnpm is not. Reading the docs config.

<div class="w-full max-w-sm">
    <TraceCollapsible Open="true">
        <TraceCollapsibleTrigger>

Reasoning

Render a reasoning part from the AI SDK. The row is a TraceLine until the first text arrives. See Open State.

@implements IDisposable

<div class="flex min-h-72 w-full max-w-sm flex-col gap-4 py-6 text-sm">

See Reasoning for more examples.

Tool

Render tool parts from the AI SDK. Map the tool part as in Tool.

@implements IDisposable

<div class="flex min-h-72 w-full max-w-sm flex-col gap-4 py-6 text-sm">

See Tool for more examples.

Accessibility

Trace adds no roles of its own. Each line gets its semantics from the element that wraps it.

  • A TraceLine on its own is a span. It is read as text and is not a tab stop.
  • Wrap it in a TraceCollapsibleTrigger and it becomes a button with aria-expanded. Wrap it in a link, or in the trigger for a dialog or sheet, and it takes the keyboard and focus behavior of that element.
  • TraceIcon is hidden from assistive tech, so TraceTitle is the accessible name. Write it as a sentence that says what happened, like "Edited trace.tsx", not just "trace.tsx".
  • When a link opens a new tab, add "(opens in a new tab)" to the title with sr-only.
  • Status is shown with color and motion, so put it in the title too. Write "Running pnpm build" while it runs and "Failed to run pnpm build" when it errors.
  • The shimmer on a running title stops when the reader prefers reduced motion. The title still says what is happening.
  • TraceCollapsibleContent mutes its text. If you put a block with a muted background inside it, give the block text-foreground so it keeps its contrast. CodeBlock sets its own text color.

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

كُتب ملف القفل بإصدار أحدث من pnpm مما يشغّله CI، لذلك يرفض التثبيت تحديثه.
بحث عن minimumReleaseAge قرأ pnpm-workspace.yaml فشل تشغيل pnpm install
<Trace Class="max-w-sm">
    <TraceCollapsible Open="true">
        <TraceCollapsibleTrigger>

API Reference

Trace

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

TraceCollapsible

ParameterTypeDefault
Open bool false
OpenChanged EventCallback<bool> -
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

TraceCollapsibleContent

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

TraceCollapsibleTrigger

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

TraceDescription

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

TraceIcon

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

TraceLine

ParameterTypeDefault
Status TraceLineStatus TraceLineStatus.None
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

TraceTitle

ParameterTypeDefault
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.