Summary
Mermaid diagrams render inline in assistant markdown (#567) but cannot be opened full-screen or zoomed. Chat images already use a lightbox (#715, polish in #723). Operators expect the same affordance for diagrams: tap/click to maximize, especially on mobile.
Problem
MermaidDiagram (web/src/components/assistant-ui/mermaid-diagram.tsx) renders SVG via dangerouslySetInnerHTML with horizontal scroll only. There is no cursor-zoom-in, no modal viewer, and no way to inspect dense flowcharts on a phone.
Related work
| PR |
What it ships |
| #567 |
Inline mermaid render in chat |
| #715 |
Shared ImagePreview (zoom/pan/full-screen) for attachments |
| #723 |
Lightbox interaction polish (backdrop dismiss, propagation) |
| #509 |
Tool-result inline images + lightbox (not mermaid) |
Proposal
1. Per-diagram maximize (required)
- Wrap each rendered
[data-mermaid-diagram] block in a clickable surface (cursor-zoom-in, keyboard: Enter/Space).
- On activate: open modal/sheet reusing
ImagePreview interaction model (pinch/wheel zoom, pan, backdrop close) OR a thin shared MediaLightbox shell used by images + mermaid.
- Prefer re-render from source at larger size: store
data-mermaid-source (escaped) on the container; modal calls mermaid.render() again rather than scaling rasterized inline SVG only.
- Preserve theme (
data-theme light/dark) in modal render.
2. Per-message "all diagrams" view (nice-to-have, can be follow-up)
- When an assistant message contains N > 1 mermaid blocks, show a compact control (e.g. "View N diagrams") in the message chrome or on first diagram.
- Opens scrollable full-screen gallery; each item uses the same viewer as (1).
3. Accessibility
- Focus trap in modal; Escape closes.
aria-label on diagram trigger: "Open diagram full screen".
Acceptance criteria
Implementation notes
- Touch points:
mermaid-diagram.tsx, possibly extract shared viewer from web/src/components/ImagePreview.tsx.
- Tests: extend
mermaid-diagram.test.tsx for click opens viewer; optional live test for re-render in modal.
- Security: keep
securityLevel: 'strict' on mermaid init; modal must not execute arbitrary HTML from model output beyond mermaid SVG.
Non-goals
- Export to PNG/SVG download (separate enhancement).
- Editing mermaid source in viewer.
Summary
Mermaid diagrams render inline in assistant markdown (#567) but cannot be opened full-screen or zoomed. Chat images already use a lightbox (#715, polish in #723). Operators expect the same affordance for diagrams: tap/click to maximize, especially on mobile.
Problem
MermaidDiagram(web/src/components/assistant-ui/mermaid-diagram.tsx) renders SVG viadangerouslySetInnerHTMLwith horizontal scroll only. There is nocursor-zoom-in, no modal viewer, and no way to inspect dense flowcharts on a phone.Related work
ImagePreview(zoom/pan/full-screen) for attachmentsProposal
1. Per-diagram maximize (required)
[data-mermaid-diagram]block in a clickable surface (cursor-zoom-in, keyboard: Enter/Space).ImagePreviewinteraction model (pinch/wheel zoom, pan, backdrop close) OR a thin sharedMediaLightboxshell used by images + mermaid.data-mermaid-source(escaped) on the container; modal callsmermaid.render()again rather than scaling rasterized inline SVG only.data-themelight/dark) in modal render.2. Per-message "all diagrams" view (nice-to-have, can be follow-up)
3. Accessibility
aria-labelon diagram trigger: "Open diagram full screen".Acceptance criteria
data-rendered="false") is not clickable.Implementation notes
mermaid-diagram.tsx, possibly extract shared viewer fromweb/src/components/ImagePreview.tsx.mermaid-diagram.test.tsxfor click opens viewer; optional live test for re-render in modal.securityLevel: 'strict'on mermaid init; modal must not execute arbitrary HTML from model output beyond mermaid SVG.Non-goals