Skip to content

fix: preserve whitespace chunks in stream to fix markdown heading rendering#488

Open
Salman-Ahamed wants to merge 1 commit intodevfrom
fix/markdown-heading-rendering
Open

fix: preserve whitespace chunks in stream to fix markdown heading rendering#488
Salman-Ahamed wants to merge 1 commit intodevfrom
fix/markdown-heading-rendering

Conversation

@Salman-Ahamed
Copy link
Contributor

@Salman-Ahamed Salman-Ahamed commented Feb 25, 2026

🎯 What’s this PR about?

Fixes markdown headings rendering as plain text in Chat/Chatbot UIs.

Root cause: parseChunk() used .trim() to validate content, which silently
dropped whitespace-only chunks (e.g., \n\n). This caused headings to glue
to previous text (e.g., Q2## Executive Summary), preventing react-markdown
from parsing them as headings.

Fix: Changed hasContent check from chunk.content.trim() !== '' to
chunk.content !== '' so newline chunks are preserved in the stream output.


📎 Related ClickUp Ticket

https://app.clickup.com/t/86ewq89f0


💻 Demo (optional)


✅ Checklist

  • Self-reviewed the code
  • Linked the correct ClickUp ticket
  • Tested locally (MANDATORY)
  • Marked as Draft if not ready for review

- Updated the hasContent check to ensure it correctly validates the presence of content by checking for null values, enhancing error handling and robustness of the function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant