Skip to content

AI response

An AI response with a state for everything that happens: nothing drawn for a fast start, then thinking, each tool call as a step with its arguments one click away, text revealed at an even pace instead of in bursts, citations that only link when a source is behind them, a 'still working' with Stop when nothing arrives, and Retry that keeps what came. Screen readers hear the finished answer once, not every token. The demo replays real runs from a local model at their recorded pace, including a tool timing out and the model reading the wrong component.

  • Streaming
  • Tool calls
  • aria-live
  • Latency states
  • Recorded replay

Ask

Pick a question. Each answer is a real run, recorded and replayed at its recorded pace.

Usage

Drop it in

import
import { AIResponse } from "@/app/lib/components/ai-response";
example 1
const a = useAssistant();
<AIResponse {...a} onStop={a.stop} onRetry={() => a.start(source)} />

API

Props

PropTypeDefault
phase*

Where the response is, from `useAssistant`.

AssistantPhase—
text*

Everything that has arrived so far.

string—
steps*

Tool calls in the order they were made.

ToolStep[]—
sources*

Sources the tools returned. Only the ones the text cites are listed.

Source[]—
stalledS

Seconds since anything arrived, once that is past the slow threshold; 0 otherwise.

number0
error

Shown when the response fails.

string—
onStop() => void—
onRetry() => void—
name

Who is answering. Default: "Assistant"

string"Assistant"
classNamestring""

Read from the component's source at build time. * required.

Accessibility

Works with

Cursor
Reacts to where the pointer is, not just whether it's over the element.
Touch
Follows your finger while it's down, then settles a moment after you lift.
Keyboard
Focus lights it up the way the cursor does. Every action has a key.
Reduced motion
Nothing moves or springs. Colour still answers, without drifting.