ReactMarkdown plugins disabled during streaming to prevent removeChild crash

Two commits fix a real `removeChild` exception in `AssistantMessage.tsx` that hits any React chat UI running `rehypeKatex` or `remarkGfm` while a stream is in flight. The fix took two passes to get right.

chat-ui

The root cause is React reconciliation fighting against shifting DOM trees produced by remark/rehype plugins parsing partial markdown. Commit 4872c90 adds a key prop to <ReactMarkdown> that toggles between "streaming" and "done", forcing a full remount when the stream settles. That alone wasn't enough: the plugins still crashed mid-stream because they were still running.

Commit 78e2b03 is the actual solution. During streaming, remarkPlugins and rehypePlugins are both set to []. On the final remount (key flips to "done"), the full plugin list comes back, so equations and GFM tables render correctly in the settled message. The isStreaming prop threads down from AssistantMessage to MarkdownContent only for the last content block - earlier blocks in a multi-part message get isStreaming: false regardless.

The diff is 14 lines net. Both commits touch only AssistantMessage.tsx.

If you skip 4872c90 and only take 78e2b03, you lose the remount: plugins re-enable correctly but there's no key change to trigger the clean render. You need both.

So what Worth pulling if your fork uses ReactMarkdown with rehype/remark plugins during streaming. The fix is small, surgical, and addresses a bug you'd otherwise have to rediscover yourself. Take both commits.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

2 commits from brauliogusmao/mike, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
4872c90b fix: corrige removeChild durante streaming do ReactMarkdown Braulio Gabriel Gusmao 2026-05-12 ↗ GitHub
commit body
Adiciona key="streaming"/"done" no ReactMarkdown para forçar remount
ao fim do streaming. Evita que rehypeKatex/remarkGfm produzam árvores
DOM inconsistentes durante reconciliação com markdown parcial.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
78e2b036 fix: desativa plugins do ReactMarkdown durante streaming para evitar conflito de DOM Braulio Gabriel Gusmao 2026-05-12 ↗ GitHub
commit body
Durante streaming usa ReactMarkdown sem plugins (árvore DOM estável).
Ao fim do streaming, key muda para "done" forçando remount único com
rehypeKatex e remarkGfm ativos para renderização final completa.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-386.md from inside the repo you want the changes in.

⬇ Download capture-thread-386.md