You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Adds Mermaid diagram support to Markdown rendering. package.json adds runtime deps: mermaid and unist-util-visit. A new remark plugin (remark-mermaid-to-tag.ts) converts fenced mermaid code blocks into HTML nodes wrapped with a mermaidblock element. frontend/app/element/markdown.tsx is extended: dynamic mermaid import with one-time initialization, a Mermaid React component that normalizes text and renders via mermaid.run with loading/error state, code-path routing for language-mermaid blocks, new helper getTextContent, mermaidblock handling in remarkPlugins and rehypeSanitize, and a defensive default for text assembly.
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Pre-merge checks and finishing touches
❌ Failed checks (1 warning, 1 inconclusive)
Check name
Status
Explanation
Resolution
Docstring Coverage
⚠️ Warning
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check
❓ Inconclusive
No pull request description was provided, so there is no author-written context beyond the title and diffs; under the check rules a very vague or empty description is treated as inconclusive. While the changes clearly add Mermaid support in Markdown, the absence of a description prevents confirmation of intent, testing instructions, or migration notes. Therefore this check cannot be conclusively passed.
Request that the author add a short PR description summarizing what was changed and why, list added dependencies (mermaid, unist-util-visit), and include brief testing steps or any migration/compatibility notes; a one-paragraph description with these points will allow this check to pass.
✅ Passed checks (1 passed)
Check name
Status
Explanation
Title Check
✅ Passed
The title "mermaid support in markdown" directly and concisely states the primary change: adding Mermaid diagram support to the Markdown renderer. It is short, specific, and aligned with the changes in the diff (new Mermaid rendering, remark plugin, and added dependencies). This satisfies the requirement for a clear single-sentence summary of the main change.
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between a6bf816 and daf4314.
29-36: Set explicit security level and theme source.
Explicitly configure securityLevel: "strict" (default today, but make intent clear) and consider wiring theme to the app’s theme instead of hardcoding "dark".
Reviewing files that changed from the base of the PR and between 8874774 and 4f65387.
⛔ Files ignored due to path filters (1)
package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
frontend/app/element/markdown.tsx (3 hunks)
package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
GitHub Check: Build for TestDriver.ai
GitHub Check: Analyze (go)
GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
frontend/app/element/markdown.tsx (1)
68-90: LGTM overall on the Mermaid component.
Ref/attribute reset and node-scoped render via run() is correct for re-renders.
The reason will be displayed to describe this comment to others. Learn more.
⚠️ Potential issue
Fix: copy/execute actions return empty text for Mermaid blocks.
When Code returns a Mermaid component, CodeBlock’s getTextContent traverses React children, not DOM textContent set later; result is empty copy/execute payload.
Apply this diff so the original source is still available for copy/execute:
Optionally, also teach getTextContent to read data-raw if present.
📝 Committable suggestion
‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Suggested change
constCode=({ className ="", children }: {className?: string;children: React.ReactNode})=>{
In frontend/app/element/markdown.tsx around lines 92 to 97, Code currently
returns a Mermaid component with the chart text derived from children, which
makes the original raw source unavailable to CodeBlock.getTextContent; modify
Code so when it detects language-mermaid it preserves the original source by
attaching the raw text to the output (e.g., pass the computed text through a
prop or render a wrapper element with a data-raw attribute containing that text)
so copy/execute can read it instead of traversing children; ensure the
prop/attribute uses the same exact raw string produced now; optionally also
update getTextContent to fall back to reading data-raw when DOM textContent is
empty.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
frontend/app/element/markdown.tsx (1)
124-129: Fix: copy/execute actions return empty text for Mermaid blocks.
When Code returns a Mermaid component, the original source is no longer a child string; CodeBlock’s traversal yields empty text. Preserve the raw text alongside the rendered chart.
Reviewing files that changed from the base of the PR and between 4f65387 and 283eac8.
📒 Files selected for processing (1)
frontend/app/element/markdown.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
GitHub Check: Analyze (javascript-typescript)
GitHub Check: Analyze (go)
GitHub Check: Build for TestDriver.ai
🔇 Additional comments (2)
frontend/app/element/markdown.tsx (2)
92-96: Good call on clearing data-processed before run.
This avoids Mermaid skipping re-renders on updates.
329-330: LGTM: safe default for Markdown text.
Defaulting to empty string prevents undefined from leaking into transformBlocks.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
GitHub Check: Analyze (go)
GitHub Check: Analyze (javascript-typescript)
GitHub Check: Build for TestDriver.ai
🔇 Additional comments (1)
frontend/app/element/remark-mermaid-to-tag.ts (1)
14-17: LGTM: safe HTML wrapper with escaping.
Replacing mermaid code fences with an escaped <mermaidblock> HTML node is correct and works with rehype-raw + sanitize.
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.
No description provided.