Repository navigation
feat(markdown): add Mermaid diagram rendering support (#1497) - #1534
Conversation
- Add MermaidDiagram component for rendering mermaid code blocks - Integrate mermaid support into MarkdownCodeBlock - Improve fallback handling for invalid diagrams - Optimize mermaid initialization and theme handling
|
@Ryan-PG is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@Ryan-PG Thanks for this. Really appreciate it. |
…ring feat(markdown): add Mermaid diagram rendering support (MODSetter#1497)
Summary
Adds Mermaid diagram rendering support to markdown code blocks in the assistant UI.
Changes
MermaidDiagramcomponent for rendering Mermaid code blocksMarkdownCodeBlockDescription
This PR introduces support for rendering Mermaid diagrams inside markdown code blocks. When a code block is labeled as
mermaid, it is rendered as a live SVG diagram using Mermaid. If rendering fails due to invalid syntax or runtime errors, the component safely falls back to the standard code block renderer.Motivation and Context
Mermaid diagrams are widely used for visualizing flows, graphs, and sequences in technical documentation. This feature improves readability and user experience in the assistant UI by enabling inline diagram rendering instead of plain text code blocks.
Fixes #1497
API Changes
Change Type
Testing Performed
Checklist
High-level PR Summary
This PR adds support for rendering Mermaid diagrams in markdown code blocks within the assistant UI. When a code block is marked with the
mermaidlanguage, it renders as an interactive SVG diagram instead of plain text. The implementation includes proper error handling that falls back to standard code block rendering if the diagram syntax is invalid or rendering fails. The feature also handles theme switching between dark and light modes and optimizes Mermaid initialization to avoid redundant setup.⏱️ Estimated Review Time: 5-15 minutes
💡 Review Order Suggestion
surfsense_web/components/assistant-ui/mermaid-diagram.tsxsurfsense_web/components/assistant-ui/markdown-code-block.tsx