Parsing and rendering token streams
Comes up in: Frontend system design, Machine coding, AI system design
This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.
What it covers
- reading
fetchbody streams - buffering partial SSE lines and UTF-8 boundaries (
TextDecoderStream) - batching renders per animation frame
- incremental markdown rendering (re-parse cost, stable prefixes)
- auto-scroll that respects the user scrolling up
- stop/cancel with AbortController
- regenerate and edit
Words you will know
What you will practise
- chat UI with streaming, stop and regenerate (machine-coding style, 90 min)
Interview questions this answers
- How do you keep auto-scroll from fighting a user who scrolls up?
- How do you render markdown that arrives token by token without re-parsing everything?