Generation stats
The small print under an AI answer: model, tokens, time, speed, cost, and an unusual stop. No live counting; numbers formatted in PHP.
Anatomy
inline: div[data-ds-generation-stats=inline]
├── dl[aria-label] div(sep "·" aria-hidden, dt.sr-only, dd value + unit aria-hidden) …
└── badge (warning) "Stopped: length"
table: div > dl.grid dt / dd … (+ "Finished" / badge)
popover: div[data-ds-generation-stats=popover]
├── details[x-data][toggle, click.outside, focusout, Escape]
│ ├── summary info icon + sr-only label
│ └── div popover surface, x-ds-anchor, placement classes as fallback
│ └── p label + the table
└── badge
Formatting
- tokens:
Chart::format, grouped ("1,234"), orcompact("1.2K") with the exact count as the value's title - duration (ms):
AgentState::durationshort ("2.4s", "1m 4s"), the long form as title - speed: output ÷ seconds when not given, "148 tok/s"
- cost:
Support\Moneywith the currency's symbol; under one unit, enough places for two significant figures (at most six) - finish reason:
stop,end_turn,stop_sequence,eos,complete(d),tool_use,tool_calls,function_call,pause_turnare normal; anything else is a warning badge (finishText),max_tokensworded "length"
The popover
A native details: with no script, its summary opens and closes it, the
panel absolutely placed (placement, top-start by default). Inline Alpine
(no shared behaviour) mirrors open and closes it on a press outside, on
focus leaving, and on Escape (stopping it only when it consumed it, and
returning focus to the summary). x-ds-anchor, an enhancement, keeps it on
screen. The panel grows in from @starting-style, motion-safe.
Accessibility
| Role | a description list (dl) named by label |
| Name | each value by its dt (visually hidden inline) |
| Keyboard | popover: Tab to the info button, Enter or Space opens, Escape closes |
| Focus | the info button draws the system ring |
Do not
- Do not render bare numbers. Every value has its label.
- Do not count up. These describe a finished answer.
From the package repo: edit this page on GitHub.