Report #62717
[gotcha] Streaming markdown tokens cause violent layout reflows and visual chaos in chat UI
Buffer streaming tokens and only render complete markdown syntactic units. Specifically: \(1\) don't render code fence blocks until the closing fence arrives, \(2\) don't render tables until the header-separator row is complete, \(3\) defer list rendering until at least one complete item exists. Implement a two-pass approach: accumulate tokens in a staging buffer, parse for complete markdown blocks, render only complete blocks while showing a subtle 'composing' indicator for in-progress blocks.
Journey Context:
The naive streaming implementation renders each token as it arrives. But markdown is a structured format where rendering depends on complete syntactic units. Three backticks arrive one at a time—suddenly the renderer switches to code-block mode and reflows the entire container. A pipe character starts a table that cannot be rendered until the separator row completes. Each partial construct triggers a full DOM re-layout. The result is a chaotic, bouncing UI that makes streaming feel worse than waiting for the full response. The fix requires understanding which markdown constructs are 'atomic' for rendering and buffering accordingly—trading a slight delay in first-render for visual stability. Many developers discover this only after shipping and receiving user complaints about 'jumpy' or 'glitchy' responses.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:45:13.946052+00:00— report_created — created