Skip to content

feat(chat): render bounded Mermaid diagrams with source fallback - #786

Closed
kilhyeonjun wants to merge 1 commit into
devswha:mainfrom
kilhyeonjun:feat/mermaid-chat-20261011
Closed

kilhyeonjun wants to merge 1 commit into
devswha:mainfrom
kilhyeonjun:feat/mermaid-chat-20261011

Conversation

@kilhyeonjun

Copy link
Copy Markdown
Contributor

Change

Completed Mermaid fences in chat can show a diagram, with Source/Diagram tabs, original-source copy and a native expanded dialog with zoom and fit. Streaming, malformed, unsupported, oversized or unavailable diagrams retain the existing code view. Ordinary code fences keep their current behavior.

This is a focused Mermaid-only contribution for #782, alongside the broader Mermaid/images work in #616. No dependency on that branch. Opening as a draft for the maintainer's feature/dependency decision.

Mermaid 11.16.1 is pinned and lazy loaded; a scoped KaTeX override uses the app's existing 0.18.9. The application fixes strict configuration, refuses input configuration/HTML/custom CSS/resource directives, serializes initialize/render/owned cleanup, and validates bounded SVG before displaying a Blob image. Source, pending work and cache are bounded. Rendering still uses temporary DOM on the main thread; these guards do not guarantee interruption or complete execution isolation.

Includes ko/ja/zh labels, library and bundled runtime notices, documentation, changelog and registered browser regression with synthetic screenshots.

Validation

  • Generated schema freshness, production build, full typecheck: pass. New browser fixture/entrypoint explicitly typechecked too.
  • Full unit suite: 2,511 pass, 50 skip, 0 fail (140.31s). Browser-lane registry test includes the new script.
  • Actual pinned-library browser regression: lazy/unfinished fences; four diagrams and Korean; source/copy; light/dark; native modal focus/Escape; mobile and a >7,000px diagram's fit/zoom-out/0; rejected resources/SVG; delayed import with changed source, unmount and failed import; Blob/container cleanup. No unexpected external or same-origin probe requests observed in that fixture.
  • Existing math browser regression: pass (KaTeX first-expression lazy load, inline/display and offline source fallback).
  • bun audit: no vulnerabilities found in 260 packages.
  • Independent design/implementation review; mobile fit and zoom-out findings fixed and regression tested.
  • Workflow syntax check skipped: actionlint is unavailable; no workflow YAML changed. Broader Native lanes are not claimed passing: the unchanged upstream baseline is being compared with existing server-contract failures. Fork CI still needs maintainer approval.

Synthetic screenshots: mobile diagram, expanded dialog.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thanks for this. Mermaid diagrams in chat are already under review in #616, which the maintainer has reviewed, and as the description says, this PR is a focused alternative to it. Closing as a duplicate to keep the work in one place. If the bounded rendering here (size limits, source fallback, the refused config/HTML input) covers cases #616 misses, a comment on #616 with those cases would be very welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants