Skip to content

No.233 · AI & Chat

Stream Reply

An assistant answer arriving token by token: words settle in from a soft blur, code types with highlighting in place, and you can stop and regenerate.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Paper

Build an assistant reply that streams in token by token. Content is structured blocks — paragraphs, a list, and a code block whose code is a list of pre-highlighted runs (keyword, string, function, number, comment) — tokenised into words for prose and 4-character chunks for code, so highlighting is correct from the first character. A timer reveals tokens at about 38 per second with natural burstiness (occasionally two at once, jittered gaps); each new token settles in from opacity 0 and a 5px blur over 420ms instead of popping. A soft glowing caret (accent block with a halo, breathing) rides the end of the newest token; the assistant avatar (a conic gradient) turns slowly while it writes. A footer shows "Writing · 41 tok/s" with a pulse dot and a Stop button; stopping freezes the text exactly where it is ("Stopped"), and Regenerate replays it. Under reduced motion the whole answer appears at once. Selected variant — Paper (paper): Apply the paper theme. Where the brief above gives no colour values for it, choose a restrained paper palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Watch the answer stream in; press Stop to freeze it mid-sentence, then Regenerate to stream it again. Motion: ~38 tokens/s with jitter; each token 420ms blur-in; caret and pulse breathe at 900ms; avatar turns while writing. Accessibility: The streaming text isn't announced token by token (aria-live off); a hidden line announces when the response completes or stops. Stop and Regenerate are real buttons. Reduced motion shows the full answer immediately. Responsive behavior: A card up to about 40rem wide that fills narrower screens; dense rows and side columns stack on phones. Touch: Everything is tap-driven; hover hints have tap or focus equivalents. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Watch the answer stream in; press Stop to freeze it mid-sentence, then Regenerate to stream it again.
Motion
~38 tokens/s with jitter; each token 420ms blur-in; caret and pulse breathe at 900ms; avatar turns while writing.
Accessibility
The streaming text isn't announced token by token (aria-live off); a hidden line announces when the response completes or stops. Stop and Regenerate are real buttons. Reduced motion shows the full answer immediately.
Responsive
A card up to about 40rem wide that fills narrower screens; dense rows and side columns stack on phones.
On touch
Everything is tap-driven; hover hints have tap or focus equivalents.