feat(web): render Mermaid diagrams in markdown - #4989
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
ApprovabilityVerdict: Needs human review This PR introduces a new feature with ~400 lines of new component code for rendering Mermaid diagrams with interactive pan/zoom controls. New user-facing capabilities with substantial new logic warrant human review. You can customize Macroscope's approvability policy. Learn more. |
8509c4f to
a245ae8
Compare
PR pingdotgg#4989 was based on code predating pingdotgg#5301, so its Mermaid container reintroduced the bordered/rounded/muted frame that pingdotgg#5301 had just removed from code blocks. Diagrams rendered with a heavier frame than the code fences beside them. Follow pingdotgg#5301's structure rather than only dropping the border: the frame lives in Tailwind classes on the element, and the stylesheet keeps just margin, overflow, and radius. - .chat-markdown-mermaid: drop hardcoded border, 0.75rem radius, and muted background; use border-radius: var(--radius) - MermaidDiagram container: adopt the same class string MarkdownCodeBlock uses (border-border/70, bg-secondary, dark variants) - toolbar: drop border-bottom and muted background; match the code block header's padding and color-mix(foreground 72%) text - toolbar buttons: add chat-markdown-chrome-action so hover and pressed states track the code block controls Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit 98ed283bbff799e6721ddb0730f5e7e771232848) (cherry picked from commit 1c4035e46136ffb224740ea35ad7c192c33e5824) (cherry picked from commit 35e5d4569bda9c36627df15b9102e43fc5084781)
Both go in the Fixes table ahead of the build, so the fork overview ships current. No change to the carried pull requests: pingdotgg#4989 and pingdotgg#5114 are both still open upstream as of today, and pingdotgg#5114's head is still the pinned b9f2090. Written by Claude Opus 5 in T3 Code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Note 🤖 GPT-5.6 Sol responding on behalf of Theo We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together. #6191 is the smaller and safer Mermaid implementation. It lazy-loads Mermaid, uses strict security mode, preserves source text, handles failures, and covers shared Markdown views without this branch's extra pan and zoom code. If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed. |
What Changed
T3 Code now renders fenced Mermaid diagrams in chat messages and rendered Markdown file previews.
The diagram viewport supports pointer controls, keyboard controls, bounded pan, 50–300 percent zoom, and a reset action.
Why
Markdown diagrams appeared as source code. This made agent plans and architecture notes harder to read.
A stable Markdown component prevents diagram flicker when thread data changes. The viewport limits zoom and pan positions.
Fixes #4571
UI Changes
Before
After
Interaction
Watch the zoom, pan, and reset controls
Checklist
About 790 changed lines come from the generated lockfile update for Mermaid.
Validation
pnpm exec vp test run apps/web/src/components/MermaidDiagram.test.tspnpm exec vp lint apps/web/src/components/MermaidDiagram.tsx apps/web/src/components/MermaidDiagram.test.ts apps/web/src/components/ChatMarkdown.tsx apps/web/src/components/FileMarkdownViewer.tsxpnpm --filter @t3tools/web typecheckpnpm --filter @t3tools/web buildModel: GPT-5.6 Codex
Harness: T3 Code Codex harness
Note
Render Mermaid diagrams in chat markdown with pan/zoom support
MermaidDiagramcomponent (MermaidDiagram.tsx) that renders mermaid code fences as interactive diagrams with toolbar controls for zoom in/out and reset.MarkdownRenderContextin ChatMarkdown.tsx to passdiffThemeName,isStreaming, andresolvedThemeto child renderers without prop drilling.mermaidpackage (~11.x) as a dependency, which is dynamically imported at render time.Macroscope summarized 22a0072.