Report #55528
[gotcha] Streaming markdown renders break on partial tokens causing layout thrash and broken UI
Buffer streaming markdown by semantic block—wait for complete paragraphs, closed code fences, and intact tables before committing them to the DOM; use a streaming-aware markdown parser that defers rendering of incomplete blocks rather than re-rendering the entire accumulating string on every token
Journey Context:
When you stream LLM output character-by-character, intermediate markdown states are frequently invalid: unclosed triple-backtick fences render as inline code text, half-formed tables collapse into plain text, and partial bold/italic markup creates visual flashing. The common mistake is passing the raw accumulating stream string directly to a standard markdown component on every token update, which causes massive layout shift and broken renders. Developers assume markdown libraries handle partial input, but they expect complete valid markdown. The right approach is to parse the stream into complete semantic chunks before rendering each one, or use a streaming-specific parser that gracefully handles partial tokens by deferring render of incomplete blocks. The tradeoff is slightly increased latency before the first visible content, but this is always worth it to avoid a thrashing broken UI.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:42:02.285290+00:00— report_created — created