affectUI › Components › Agents
Response Stream
One agent answer through every state it goes through – words streaming in, stopped and continued from the exact word, failed and retried from there, done – with steer and queued messages above it.
Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/response-stream.json · Import from @/components/ui/response-stream
When to use
- An agent chat where the answer itself shows every state: writing, stopped, failed, done
- Letting people stop an answer, pick it up again from the exact word, or retry after an error without starting over
- Showing messages sent while it writes – a steer that bends the answer now, or a queued one that becomes the next answer
When not to use
- The whole composer with model, mode and permissions – use Run Controls
- Only the thinking before an answer – use Thinking State
Usage
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 }}
/>
);
}Props
| 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 | |
steer | ResponseSteer[] | { id, text, kind: "steer" | "queued" } – chips above the answer; the first queued one reads Next; more than three fold behind “+ n more” | |
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 |
Keyboard
- Esc: Stop the answer while it streams
- Tab: Move through the footer actions and the chips' remove buttons
- Enter / Space: Press Continue, Retry, Dismiss, Copy or Regenerate
Accessibility
- New text is announced politely in whole sentences, never word by word
- Each status change – stopped, failed with its reason, finished – is announced once
- While it writes the answer is marked busy; the steer divider is a separator with what it was steered with
Responsive
- 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"
Requirements
- React 19
Related
- Run Controls – Every control a running agent needs, in one composer – stop it, resume from the word it stopped at, retry or dismiss, steer it mid-answer or queue what's next, with Chat or Act, permissions and how full the context is
- Agent Steering – Steer an agent while it works – queue a note for the next step and watch it glide into the plan when the agent picks it up, or interrupt right away
- Agent Queue – The work waiting for your agents, and how fast it moves – jobs drop into a live queue, glide into free worker slots as growing bars and land in Done or Failed, while a depth chart shows the backlog build up when a rate limit pauses the workers and drain when they resume
- Thinking State – AI working panel with a live timer, searched sources and thinking steps that appear one by one
- Message Actions – The quiet bar under an AI message – copy turns into a check, regenerate spins and unfolds a version switcher, thumbs pop and ask why, read aloud becomes a tiny equalizer