Loading component…
Loading component…
One agent answer through every state – words streaming in, stopped and continued from the exact word, failed and retried from there, done – with steer and queued messages
To reuse this local React demo, copy all files from the Code tab into the same folder, then import ResponseStream from ./response-stream.
import { ResponseStream } from "@/components/ui/response-stream";
export function Answer({ text, status }) {
return (
<ResponseStream
text={text}
status={status} // "streaming" | "stopped" | "failed" | "done"
agent={{ id: "atlas", name: "Atlas" }}
onStop={() => stream.abort()}
onContinue={() => stream.resume()}
onRetry={() => stream.retry()}
onDismiss={() => removeAnswer()}
meta={{ tokens: 182, ms: 6400 }}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| text | string | The answer so far – keep appending while it streams. A trailing half word waits until it is whole; fences become code blocks | |
| status | "streaming" \| "stopped" \| "failed" \| "done" | Which state the answer is in – the footer, caret and agent mark follow it | |
| error | string | What went wrong, in one sentence – shown when failed | |
| bends | ResponseBend[] | { at, text? } – character offsets where a steer bent the answer; a quiet divider there | |
| agent | { id, name, color? } | Assistant | Who answers – the pixel mark is drawn from the id |
| meta | { tokens?, ms? } | Time and tokens in the done footer | |
| onStop | () => void | Stop button and Esc while it streams | |
| onContinue | () => void | Continue after a stop – keep appending to the same text | |
| onRetry | () => void | Retry after a failure – picks up from the text so far | |
| onDismiss | () => void | Called once the stopped answer has faded out | |
| onRemoveSteer | (id: string) => void | The × on a chip | |
| onCopy | (text: string) => void | Copy in the done footer – the text is also put on the clipboard | |
| onRegenerate | () => void | Regenerate in the done footer – the button shows only with it | |
| escToStop | boolean | true | Esc stops a streaming answer, unless focus is in a text field |
| className | string | Extra class on the answer |
The answer only grows downwards; the footer is one row that keeps its height and never shifts sideways
Below 360px the indent goes and the footer may wrap; the error is its own line under the text; long words and URLs wrap, code scrolls sideways
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"