UX for non-deterministic output
Classic UI assumes the same input gives the same output, quickly. LLM features break both: the answer varies, takes seconds, can fail halfway and can be confidently wrong. The UX has to make that manageable.
States a single AI message can be in
ts
type AiMessage =
| { status: 'pending' } // request sent, no tokens yet
| { status: 'streaming'; text: string }
| { status: 'done'; text: string; finish: 'complete' | 'length' }
| { status: 'stopped'; text: string } // user pressed Stop
| { status: 'error'; text: string; error: string }; // may still have partial textModelling these explicitly (a discriminated union, or a state machine) prevents "spinner forever" and "error replaced my half-written answer" bugs.
Patterns
- Regenerate and versions - since output varies, let users ask again and switch between variants (
< 2/3 >) instead of overwriting. - Edit and resend - fixing the prompt is often faster than arguing with the answer.
- Stop always available while streaming; keep the partial result.
- Truncated output (
finish: 'length') - show "Continue" instead of pretending it is complete. - Partial failure - keep the text that arrived, show "Response interrupted - Retry" below it.
- Progress for long tasks - show steps ("Reading 3 files", "Running tests") for agents, not one spinner.
Trust and control
- Show sources for factual answers; mark AI-generated content.
- Human in the loop for side effects: the AI drafts, the user confirms - "Send email", "Apply changes" with a diff preview.
- Undo for anything the AI applies automatically.
- Avoid optimistic UI for AI results - you cannot predict the outcome. Be optimistic about the user's own message (show it instantly), not the answer.
Feedback loop
Thumbs up/down and "copy" / "regenerate" clicks are cheap quality signals - log them with the prompt version so you can tell whether a change helped.
Good AI UX assumes the model will sometimes be slow, wrong or interrupted, and makes each of those cheap for the user to recover from.
updated
did you know it?