Skip to content

Draw mermaid code blocks in answers as diagrams - #90

Merged
splitbrain merged 1 commit into
splitbrain:mainfrom
splitbrain-bot:claude/mermaid-diagrams
Oct 4, 2026
Merged

splitbrain merged 1 commit into
splitbrain:mainfrom
splitbrain-bot:claude/mermaid-diagrams

Conversation

@splitbrain-bot

Copy link
Copy Markdown

Closes #88

What changed

  • A ```mermaid code block in an answer now shows as a diagram. The diagram follows the light or dark mode.
  • While the answer is still streaming, the block shows its source text. The diagram appears when the message is complete.
  • If the source does not parse, the block keeps its source text and adds the note "This diagram could not be drawn."
  • The header with the copy button stays, so the source can still be copied.
  • A tap opens the diagram in the full screen view that images use. ImageZoom takes one new optional prop, so the diagram fills the screen width on a solid background.
  • Mermaid loads only when a thread contains a diagram. The main bundle did not grow.
  • A new image skill, diagrams, tells Claude and Codex that the dashboard draws these blocks, and when a diagram helps.

Zoom

There is no zoom code. The browser's own pinch zoom works in the full screen view. I tested this in Chromium with phone settings and a two-finger touch pinch: the view zoomed in, a one-finger drag moved it, and the view stayed open. The diagram is an SVG, so it stays sharp at any zoom level. After you close the view, the page stays zoomed until you pinch back out.

Diagram types

All built-in mermaid types are allowed. Each type loads only when a diagram uses it. The ELK layout is not included.

Tests

  • A new e2e test checks the source text while streaming, the diagram afterwards, the note for a broken diagram, and the full screen view.
  • I tested in Chromium only. The diagram labels are HTML inside the SVG image. This is the part to check on an iPhone.

Agents could only explain structure and flow in text. A mermaid code block
in an answer now shows as a diagram that follows the light or dark mode.
While the answer is still streaming, or when the source does not parse, the
block shows its source text instead.

A tap opens the diagram in the full screen view that images use. The
browser's own pinch zoom works there, so phones need no zoom code of their
own. Mermaid loads only when a thread contains a diagram.

A new image skill tells Claude and Codex that the dashboard draws these
blocks, and when a diagram helps.

Closes splitbrain#88
@splitbrain
splitbrain merged commit 4c84603 into splitbrain:main Oct 4, 2026
3 checks passed
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.

mermaid support

2 participants