Conversation
|
This would be great |
|
Note GPT-6 via Codex, on behalf of Ihor. Acknowledging substantial overlap with #9621: both PRs render completed Mermaid fences, lazy-load Mermaid, support light/dark themes, serialize rendering, and fall back to source while streaming or on render failure. This PR additionally provides a Source/Preview toggle and defers rendering until a diagram becomes visible. #9621 includes caching across remounts and Markdown source handling when copying a selected diagram. The core rendering work is largely duplicate, so coordinating around #9621 would avoid maintaining competing implementations. @juliusmarminge let me know you if you want me to close this or maybe merge with #9621 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe web composer now renders Mermaid fences as lazy SVG previews after streaming. Users can switch between preview and source, copy the original code, and read source when rendering fails. Rendering uses serialized, themed Mermaid calls with strict security settings. ChangesMermaid Markdown previews
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant ChatMarkdown
participant MarkdownCodeBlock
participant MarkdownMermaidBlock
participant renderMermaidDiagram
participant mermaid
ChatMarkdown->>MarkdownCodeBlock: provide Mermaid fence
MarkdownCodeBlock->>MarkdownMermaidBlock: mount after streaming ends
MarkdownMermaidBlock->>renderMermaidDiagram: request themed diagram
renderMermaidDiagram->>mermaid: initialize and render SVG
mermaid-->>renderMermaidDiagram: SVG or error
renderMermaidDiagram-->>MarkdownMermaidBlock: render result
MarkdownMermaidBlock-->>MarkdownCodeBlock: preview or source fallback
Merge Risk: ⚪ Minimal · up to This PR adds Mermaid diagram rendering to chat messages with a safe, sandboxed rendering path, a source/preview toggle that preserves copy behavior, and graceful fallback to source text when a diagram fails to render or is still streaming. No unresolved correctness, security, or stability concerns were identified, so this change looks safe to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Squashed from upstream pingdotgg#11038 (c17ef01, 3f08da0). Lockfile regenerated in a follow-up commit. (cherry picked from commit 3f08da0)
What Changed
Render fenced
mermaidblocks as diagrams in web and desktop chat, including user messages. Add Source/Preview switching while preserving copy and line wrapping. Mobile continues displaying Mermaid source code.Why
Chat currently displays Mermaid diagrams as ordinary code blocks. Load Mermaid only when a completed diagram enters the viewport, render locally in strict mode, and show source when rendering fails. Serialize diagram rendering so concurrent theme configurations cannot interfere.
UI Changes
Draft pending before/after screenshots and a short Source/Preview interaction recording. Automated browser interaction was unavailable.
Validation: 58 focused chat rendering and clipboard tests, web typecheck, and web production build passed. Targeted lint reported no errors and three existing warnings in unchanged renderer code. Most added lines are Mermaid dependency lockfile entries.
Screenshots
Before:

After:

Checklist
Model: GPT-6 · Harness: Codex
Summary by CodeRabbit
New Features
Documentation