feat: support Mermaid diagram rendering in chat messages
在对话消息中支持 ```mermaid fenced block 自动渲染为交互式 SVG 图表。
- MermaidDiagram 组件(懒加载 mermaid、暗/亮主题自适应、三态渲染)
- Markdown.tsx 集成,拦截 language-mermaid
- SVG 内 <a> 链接通过 openExternal 打开
- 对齐现有设计规范(CSS 变量、lucide-react 图标)
@codex review
@codex review
Resolved the merge conflicts by merging the latest main-v2 into this PR.
Conflict resolution notes:
- Kept the current
main-v2MarkdownRenderer plain-status-block flow. - Re-applied Mermaid fenced-block rendering on top of that flow.
- Kept the current
main-v2frontend dependency versions and preserved[email protected]in the lockfile.
Verified:
wails generate modulepassedpnpm --dir desktop/frontend check:csspassedpnpm --dir desktop/frontend typecheckpassedpnpm --dir desktop/frontend exec tsx src/__tests__/math-golden.test.tspassedpnpm --dir desktop/frontend exec tsx src/__tests__/typography-overflow-contract.test.tspassedpnpm --dir desktop/frontend buildpassed
Thanks @ttmouse. I consolidated this PR into #5554 so the Mermaid work can land through one integration branch instead of merging the overlapping Mermaid PRs independently.
What was kept/adapted from this PR:
- scoped
mermaidfenced-block routing from MarkdownRenderer - lazy Mermaid loading
- serialized Mermaid render queue
- theme re-rendering
- SVG sanitization and external-link routing
- keeping Mermaid bindFunctions disabled for untrusted chat content
#5554 also adds the source/preview, zoom/pan, fullscreen UX from the related PR and dedicated Mermaid regression/browser DOM coverage.
Verified on #5554:
pnpm --dir desktop/frontend check:csspnpm --dir desktop/frontend typecheckpnpm --dir desktop/frontend exec tsx src/__tests__/mermaid-rendering.test.tsxpnpm --dir desktop/frontend testpnpm --dir desktop/frontend build- GitHub CI is green
Closing this PR as superseded by #5554. Your contribution is credited there.