feat: support mermaid diagrams#53
Open
maxy-shpfy wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

TL;DR
Adds native Mermaid diagram rendering to the chat markdown renderer, with a magnifier loupe and fullscreen zoom/pan viewer.
What changed?
Fenced
```mermaidcode blocks in chat messages now render as interactive SVG diagrams instead of plain code blocks. The implementation includes:MermaidDiagram— the top-level component that gates rendering on stream completion, falls back to a code block while streaming or on parse failure, and shows a red error banner if Mermaid rejects the source. Once rendered, it sizes the diagram to fit within 90% of the viewport in both dimensions.MermaidFullscreen— a portalled fullscreen overlay with wheel-to-cursor zoom, drag-to-pan, zoom in/out buttons, and a reset. Dismissible via Escape or backdrop click.MermaidLoupe— a circular magnifier lens that follows the cursor over the inline diagram, zooming to a readable scale based on how much the diagram has been shrunk to fit its container.useMermaidSvg— a hook that lazily imports Mermaid, re-renders on source or theme changes, and isolates concurrent render calls with a per-call ID to avoid DOM collisions during streaming and React StrictMode double-invokes. The last successfully rendered SVG is retained so a transient failure never drops a good diagram.isStreamingprop is threaded fromChatMessagethroughMarkdowndown toMermaidDiagramso rendering is deferred until the full source is available, preventing flicker from transiently-valid half-written diagrams."default"/"dark"options.Screen Recording 2026-07-01 at 12.21.47 PM.mov (uploaded via Graphite)
How to test?
Why make this change?
Agents frequently emit Mermaid diagrams as part of their responses. Displaying them as raw code blocks forces users to copy the source and render it elsewhere. Rendering diagrams inline — with tools to inspect dense or large diagrams — significantly improves the readability and usefulness of agent output.