Kolkata ·  
AI engineering
retrieval
short · 3 min

Streaming UI

What the screen shows while a streamed answer arrives: before the first word, during, when stopped, and when it breaks.

updated 27 Sept 2026

A user presses Enter on a question. For the next few seconds, what should the screen show?

Streaming gets the model's words to the browser as they're written. That part is plumbing. What the user sees while it happens is a separate job, and it's easy to get subtly wrong. Let's follow one question from Enter to the end.

Four states

First, nothing has come back yet. The message is sent and we're waiting. Vercel's AI SDK calls this submitted, and it's the one moment a spinner or a "thinking" placeholder makes sense, because there's nothing else to show.

Then the first words arrive: streaming. Now the spinner should go. Once text is arriving, the text itself is the progress indicator, and a spinner still turning next to it just looks broken. What we do want here is a Stop button.

When the whole answer is in, we're ready. The input and send button come back, and things like "regenerate" make sense.

And sometimes it fails: error. Say so plainly and offer a retry.

Any chat UI goes through these phases. And one rule falls out of them: don't let anyone send while the status is anything but ready. Otherwise a second question starts while the first answer is still arriving, and the two get tangled.

A few details at the edges. Stop should really abort the request, not just hide the text, so nothing keeps working on an answer nobody will read. But keep the partial answer on screen, marked as stopped; maybe they'd read enough. The error message should say little, something like "Something went wrong", because the raw error from your server or provider can leak details about your setup and means nothing to the user. Log the real one. Regenerate swaps the last answer in place rather than adding a second one below it.

And stopped isn't the same as failed. A user pressing Stop, a dropped connection and a server error all end the stream early, and each needs a different message. The AI SDK's finish callback reports them as separate flags for exactly this reason.

Markdown that isn't finished yet

Here's a problem you only meet while streaming. Models write Markdown, and mid-answer the Markdown is half done. The buffer might hold This is **very with no closing **, or [the docs](https://exa with half a URL. A normal renderer then shows raw asterisks, or drops the formatting, or breaks the layout.

The fix is to patch the text before every render. Vercel's Streamdown does this with a small preprocessor called remend. An open **, *, a backtick or ~~ gets a closing partner, so bold shows as bold straight away; when the real closing marker arrives, it takes over. A half-written link shows as a link that goes nowhere (or as plain text) until the URL is complete. A half-written image is left out instead of showing as broken. It works with any Markdown renderer, and you can add handlers for your own markers too.

Two more things keep the page calm. Tokens can arrive faster than the screen needs to update, so batch re-renders; the AI SDK has a throttle option, with 50 ms in its example. And a streamed message can carry more than text. Reasoning from a thinking model usually arrives before the answer, so it can go first, collapsed or muted. Sources come as their own parts, so they can sit as chips beside the answer instead of being parsed out of the text (citations covers tying each one to a claim).

The patching can guess wrong, though. Take a temperature range written "20~25°C". An auto-closer could read that single tilde as the start of strikethrough. Streamdown escapes single tildes between word characters to avoid exactly that case. But if your model has its own syntax, nobody has written that rule for you yet.

Further reading

  • Chatbot (AI SDK UI), Vercel, undated (AI SDK v7, checked 2026-09-27). The four states, stop, errors and throttling, with code you can lift.
  • Unterminated Block Parsing, Vercel (Streamdown), undated (checked 2026-09-27). How half-finished Markdown gets patched while it streams. Short.