feat(markdown): add mermaid diagram rendering - #23
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 5 minutes and 9 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (9)
✨ 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 |
| overflow: hidden; | ||
| border: 1px solid color-mix(in srgb, var(--border-strong) 88%, transparent); | ||
| border-radius: var(--radius-lg); | ||
| background: var(--surface-primary); |
There was a problem hiding this comment.
CRITICAL: CSS variable --surface-primary is not defined anywhere in :root or .dark. The mermaid frame will have no background color, falling back to transparent. Based on existing naming conventions (--surface, --surface-strong, --surface-elevated, --surface-code), this should likely be --surface-strong to match other artifact containers.
| background: var(--surface-primary); | |
| background: var(--surface-strong); |
|
|
||
| .mermaid-error-message { | ||
| margin: 0 0 0.75rem; | ||
| color: var(--text-danger, #e53e3e); |
There was a problem hiding this comment.
WARNING: CSS variable --text-danger is not defined in the design system. The codebase defines --danger (line 22/57) for danger-colored elements. The fallback #e53e3e will work in light mode but won't respond to dark theme changes.
| color: var(--text-danger, #e53e3e); | |
| color: var(--danger); |
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
WARNING
Files Reviewed (10 files)
Notes
Reviewed by mimo-v2-pro-20260318 · 1,073,533 tokens |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 845b933882
ℹ️ 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".
| if (cancelled || !containerRef.current) return; | ||
|
|
||
| containerRef.current.innerHTML = svg; | ||
| setError(null); |
There was a problem hiding this comment.
Clear Mermaid error state after successful re-render
When a diagram render fails once, error becomes non-null and the component renders only the fallback (no containerRef). On later renders (for example after switching to a different markdown artifact with valid mermaid syntax but the same component position), mermaid.render() can succeed but this guard returns early because containerRef.current is still null, so setError(null) never runs and the component stays stuck in the error view until unmount. This creates a persistent false failure state across artifact changes.
Useful? React with 👍 / 👎.
Mermaid fenced code blocks inside markdown artifacts now render as interactive SVG diagrams instead of plain code. The mermaid library is dynamically imported on first encounter to avoid bloating the initial bundle. Diagrams respond to theme changes and fall back to raw source on render failure. Security level is set to strict. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
845b933 to
6ee128e
Compare
Summary
```mermaidfenced code blocks inside markdown artifactsTest plan
npm run lint,npm run test,npm run typecheck— all pass🤖 Generated with Claude Code