AI agent JS behaviour

Thinking trace

A collapsible reasoning panel: a shimmering “Thinking…” header with the elapsed time, steps that arrive one by one, folding itself into “Thought for 12s” when done.

Real scenarios

The component as it is used in a product — not a specimen grid.

Orders by status are slow in the admin panel. Should I add an index?

Assistant Assistant

Yes — a composite index on (status, created_at) covers both the filter and the sort. The migration is reversible and safe to run online.

Earlier today

The checkout bug came from casting an empty coupon to null; a guard fixes it.

Important props

Important props
Prop Type Default What it does
steps array [] Each step: id, label, status (pending · running · done · error) and an optional detail.
active bool false Still reasoning: shimmer and clock on; turning false freezes the time and folds the panel.
started-at / duration int null Start (ms) for the live clock; or the total (seconds) for a trace loaded from history.
auto-collapse bool true Fold away once reasoning ends.
labels array English thinking and thought (with :time) for translation.

Snippet

<x-nx::thinking-trace :active="$thinking" :started-at="$startedAtMs" :steps="$steps"
    :labels="['thinking' => 'در حال فکر…', 'thought' => ':time فکر کرد']" />