Design a ChatGPT-style streaming chat UI: token streaming, stop and retry, errors mid-stream and minimal re-renders
Problem
Design the part of an AI assistant's web client (ChatGPT, Claude, Gemini) that turns a streamed model response into a smooth, reliable reply on screen. A user types a message and presses Send. Then:
- the answer starts to appear within about a second and grows a few characters at a time, at 50 to 200 tokens per second, for answers of several thousand tokens with markdown and code;
- a Stop button ends the answer early and keeps what has already appeared;
- if anything fails part way (the network drops, the server reports an error, the stream goes silent, the user hits a rate limit), the partial answer stays on screen with a clear reason and a way to retry;
- the conversation may already hold a hundred long messages, and typing, scrolling and the Stop button must stay responsive while text arrives;
- the view follows new text, unless the user has scrolled up to read something;
- screen reader users know when an answer starts and ends without hearing every token.
Ref. UR-1471 · © UIRound · uiround.com/questions/design-a-chatgpt-style-streaming-chat-ui-token-streaming-stop-and-retry-errors-mid-stream-and-minimal-re-renders
Unlock this question
The full problem and its complete answer are part of Pro.
- 4
- code listings
- 4
- follow-up questions
What's inside
- The full problem, with examples
- Step-by-step
- Requirements
- Architecture
- Data model and state
- Key flows and trade-offs
- Performance and reliability
- Follow-up questions
- Card worldwide
- UPI and net banking in India
- One-time payment, nothing renews
Stuck? Take a hint
- 1List the states one assistant reply can be in, from the moment the user presses Send to the last byte. A single isLoading boolean cannot tell a stopped answer from a failed one, and the UI needs to.
Practise this round first
Work through the steps of a design framework on a 45-minute clock, writing notes as you would say them out loud. The model answer stays hidden until you finish, then you check your design against 10 checkpoints.
Requirements, Architecture, Data model, Interface, Optimizations. The common choice for frontend rounds. How it works
Private, and saved in this browser as you type. All your notes are on My lists.