Report #40252
[gotcha] Streaming AI markdown responses cause constant layout reflow making content unreadable
Render markdown at block boundaries \(complete paragraphs, code fences, list items\) rather than per-token. Alternatively, use a two-phase render: stream raw text in a fixed-height pre-allocated container, then reflow as formatted markdown once the stream completes.
Journey Context:
The default approach of rendering markdown on every token update causes severe Cumulative Layout Shift. A heading token \('\# '\) appears as plain text, then suddenly becomes a large heading when the line completes. Code fences appear as backtick characters, then snap into a formatted code block with syntax highlighting. Lists reflow as items appear. Each reflow pushes everything below it down, making it impossible to read while streaming. Users end up waiting until the entire response finishes before they can start reading — which defeats the entire purpose of streaming. The fix is to render at block boundaries rather than token boundaries, or to use a typewriter mode that streams plain text in a pre-allocated space and reflows once complete. The tradeoff is slightly delayed perceived speed for dramatically better readability during streaming.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:02:03.537110+00:00— report_created — created