# Chat and Streaming Interfaces

> Render streamed tokens, markdown, code and tool activity in a responsive chat UI with stop, retry and edit controls. Free notes, key concepts, resources and a...

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/chat-ui-streaming
Last updated: 2026-11-28

Render streamed tokens, markdown, code and tool activity in a responsive chat UI with stop, retry and edit controls.

Intermediate · about 6 hours · difficulty 3/5

Learn first: [Streaming Responses](https://www.internhack.in/roadmaps/tracks/ai-engineer/streaming-responses)

The chat box looks simple but hides many details that decide whether a product feels polished or broken.

### Streaming on the client

- Consume **server-sent events** or a streaming fetch body and append chunks to the message as they arrive.
- Render **markdown incrementally** without flicker, including code blocks with syntax highlighting and copy buttons. Sanitize HTML, because model output is untrusted.
- Keep the view scrolled to the bottom unless the user has scrolled up to read.
- Show **tool and agent activity** ("Searching documents...", "Running query...") so long waits feel purposeful.

### Essential controls

- **Stop generation**, which should abort the upstream model request too, not just hide the output.
- **Retry / regenerate**, **edit and resend** a previous message, and **copy**.
- Clear loading, error and rate-limit states with a way to recover.
- Attachments for files and images with progress and size limits.

### Libraries

The **Vercel AI SDK** provides React, Vue and Svelte hooks for streaming chat and tool UIs; assistant-ui and similar kits offer ready components. You can also build it yourself with fetch and a markdown renderer.

### Beyond chat

Chat is not always the best interface. Inline suggestions, one-click actions, forms that the model pre-fills and side panels often fit a workflow better than an empty text box.

### Good enough to move on

You can build a chat UI that streams markdown safely, shows tool progress, supports stop, retry and edit, and handles network errors without losing the conversation.

## Key concepts

- **Consuming SSE on the client**
- **Incremental markdown rendering**
- **Sanitizing model output**
- **Stop, retry and edit controls**
- **Tool activity indicators**
- **Vercel AI SDK UI hooks**
- **Non-chat AI interfaces**

## Mini project

Build a React chat interface that streams responses from your backend, renders markdown and code safely, shows when a tool is running, and supports stop, regenerate and editing earlier messages.

## Check yourself

Why must the Stop button cancel the request on the server, not just stop rendering on the client?

## Free resources

- [AI SDK UI: chatbot](https://ai-sdk.dev/docs/ai-sdk-ui/chatbot) (Vercel)
- [MDN: Using server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) (MDN)
- [MDN: AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) (MDN)

Previous: [GPU and Hardware Basics for AI Engineers](https://www.internhack.in/roadmaps/tracks/ai-engineer/gpu-basics) · Next: [Conversation State and Persistence](https://www.internhack.in/roadmaps/tracks/ai-engineer/conversation-state)

## More in AI Product and UX Engineering

- [Chat and Streaming Interfaces](https://www.internhack.in/roadmaps/tracks/ai-engineer/chat-ui-streaming)
- [Conversation State and Persistence](https://www.internhack.in/roadmaps/tracks/ai-engineer/conversation-state)
- [Human-in-the-Loop Design](https://www.internhack.in/roadmaps/tracks/ai-engineer/human-in-the-loop)
- [AI Product Thinking and Metrics](https://www.internhack.in/roadmaps/tracks/ai-engineer/ai-product-thinking)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
