Report #26830
[gotcha] Streaming markdown causes broken renders and layout thrash from incomplete syntax
Use a streaming-aware markdown renderer that gracefully handles partial content. Buffer incomplete markdown structures \(open code fences, unclosed formatting, incomplete tables\) before committing them to the DOM. Render in a container with stable dimensions to prevent layout shifts. Specifically: track open/close pairs for code fences and formatting tokens, and only render a structure once it's closed or a reasonable timeout has elapsed.
Journey Context:
Standard markdown parsers expect complete, well-formed input. When you stream tokens into a markdown renderer, you constantly encounter partial syntax: an opening \`\`\` without a closing \`\`\`, a table with 2 of 3 columns rendered, bold markers \*\* with only the opening pair. These cause the renderer to display raw syntax, break the DOM structure, or produce dramatic layout shifts as tokens complete structures. The unclosed code fence is the most destructive — it swallows all subsequent content into monospace formatting until another fence appears, potentially rendering the entire remaining response as code. Layout thrash from tables and lists expanding mid-render causes visual chaos. The fix requires either a streaming-aware parser \(like those in Vercel AI SDK\) or a buffering layer that holds incomplete structures until they're syntactically closed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T23:26:08.013592+00:00— report_created — created