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>
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 98ed283)
Upstream be1a836, 54 commits. Both carried pull requests (pingdotgg#4989 mermaid, pingdotgg#5114 inline images) are still open upstream, so this is a plain merge rather than the reset-and-replay that a landed pull request forces. Five files conflicted across eight hunks: ActivityPayloadProjection.ts: dropStaleRateLimitActivities (local) and dropSupersededToolUpdatedActivities (upstream b7d1981) were inserted at the same point. Independent filters, so both are kept and composed. ClaudeAdapter.ts: upstream pingdotgg#5557 fixes the same interrupt bug as the local 4429c29, and fixes it better. It reads the CLI's own terminal_reason field rather than tracking an interrupt flag across the session, and separately filters [ede_diagnostic] strings out of the error banner. Upstream's version is taken and all nine pieces of the local fix are reverted, along with the two tests that covered the reverted implementation. The third test in that group, which asserts a genuine failure still reports as an error, passes against upstream's fix and is kept. Local plan-usage work in the same file is untouched. ChatView.tsx: the local turnInterruptionNotice and upstream's new turnPlans argument collided on one call. deriveTimelineEntries takes both, so both are passed. ComposerPendingUserInputPanel.tsx: local collapsible chrome versus upstream's theme library restyle (85b1734). Upstream's change to this file is five className token swaps and nothing structural, so the local structure is kept and the five swaps applied to it. pnpm-lock.yaml: regenerated on upstream's lockfile; mermaid re-added. Verified: web 1983 tests pass, web and server typechecks clean. The server suite fails 30 files / 116 tests on Windows, which is pre-existing and not from this merge. Every failing file was compared against the pre-merge tree: 27 fail identically, 2 more outside src/ fail identically, one test in ProviderRegistry that failed before now passes, and the only new failures are 3 brand new upstream tests in cloud/http.test.ts that hit a pre-existing Windows incompatibility (fsync on a directory handle in serviceLauncher.ts, from upstream pingdotgg#5181, already present in the base). Upstream CI runs Ubuntu and macOS only, so this suite has never been green on Windows. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.