Skip to content

Conversation

@kylecarbs
Copy link
Member

Replaces react-markdown with streamdown, a drop-in replacement specifically designed for streaming AI content.

Changes

  • Core migration: Replaced react-markdown with streamdown in MarkdownCore.tsx
  • Security upgrade: Replaced rehype-sanitize with rehype-harden for improved security
  • Styling integration: Added streamdown source path to Tailwind v4 config (globals.css)
  • Plugin configuration: Updated to use typed Pluggable[] arrays matching streamdown's API
  • Streaming optimization: Enabled parseIncompleteMarkdown for better handling of incomplete markdown blocks during AI streaming
  • Cleanup: Removed react-markdown and rehype-sanitize dependencies

Benefits

Streamdown provides enhanced functionality while maintaining full compatibility:

  • Better streaming: Handles unterminated markdown blocks gracefully (bold, italic, code, links, headings)
  • Security-first: Uses rehype-harden with safe defaults for link/image prefixes
  • Performance: Built with streaming in mind, optimized for token-by-token updates
  • Compatibility: Drop-in replacement with the same API as react-markdown
  • Features: Includes GFM, math rendering (KaTeX), and HTML support out of the box

All existing custom components (code highlighting with Shiki, Mermaid diagrams, custom styling) work without changes.

Testing

  • ✅ Type checking passes (make typecheck)
  • ✅ Unit tests pass (make test)
  • ✅ Build succeeds (make build)

Generated with cmux

- 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
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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.
@kylecarbs kylecarbs merged commit 7a0b279 into main Oct 23, 2025
13 checks passed
@kylecarbs kylecarbs deleted the streamdown branch October 23, 2025 07:09
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