-
Notifications
You must be signed in to change notification settings - Fork 11
🤖 Migrate markdown rendering to streamdown #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Replace react-markdown with streamdown, a drop-in replacement optimized for AI streaming - Replace rehype-sanitize with rehype-harden for improved security - Add streamdown source path to Tailwind v4 config for proper styling - Enable parseIncompleteMarkdown for better handling of streaming content - Update plugin configuration to match streamdown's API (typed Pluggable arrays) - Remove old dependencies: react-markdown, rehype-sanitize Streamdown provides the same functionality with additional features: - Better handling of incomplete/unterminated markdown blocks during streaming - Built-in security with rehype-harden - Optimized for AI-powered content streaming - Full compatibility with our existing custom components and styling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Move rehype-harden after rehypeRaw to ensure all HTML is sanitized. Previously, harden ran before rehypeRaw, allowing unsanitized HTML to be injected after the security check.
Override streamdown's default 'space-y-4' className to prevent extra vertical padding on markdown content. We handle spacing at the component level in MarkdownRenderer/TypewriterMarkdown.
Use space-y-0 instead of empty string to properly override streamdown's default space-y-4 wrapper spacing.
Explicitly set margin-top: 0 on streamdown's block children to prevent double-spacing. Our paragraph/heading margins already provide appropriate spacing between elements.
- Change message content padding from p-3 to px-3 (horizontal only) - Remove CSS override that was fighting streamdown's spacing - Use streamdown's default space-y-4 wrapper for proper block spacing - Apply MarkdownRenderer to user messages for consistent formatting This allows streamdown's block spacing (space-y-4) to provide vertical spacing while px-3 provides horizontal padding, eliminating the double-spacing issue.
- Change content wrapper from p-3/px-3 to m-3 (margin instead of padding) - Revert UserMessage to use <pre> tags (not markdown) This prevents double-spacing when streamdown's space-y-4 adds margin-top to blocks. Margins collapse, padding doesn't.
Use space-y-2 instead of the default space-y-4 to reduce excessive vertical spacing between markdown blocks.
Remove .markdown-content p margin rule - streamdown's space-y-2 wrapper provides sufficient spacing between blocks.
Replaces
react-markdownwithstreamdown, a drop-in replacement specifically designed for streaming AI content.Changes
react-markdownwithstreamdowninMarkdownCore.tsxrehype-sanitizewithrehype-hardenfor improved securityglobals.css)Pluggable[]arrays matching streamdown's APIparseIncompleteMarkdownfor better handling of incomplete markdown blocks during AI streamingreact-markdownandrehype-sanitizedependenciesBenefits
Streamdown provides enhanced functionality while maintaining full compatibility:
rehype-hardenwith safe defaults for link/image prefixesreact-markdownAll existing custom components (code highlighting with Shiki, Mermaid diagrams, custom styling) work without changes.
Testing
make typecheck)make test)make build)Generated with
cmux