[Feature] Render Mermaid diagrams as inline Unicode art in chat (as pi already does) #1460
Closed
ruttybob
started this conversation in
Feature requests
Replies: 2 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Area: TUI / Coding agent and CLI
Problem
When the assistant generates a Mermaid diagram (flowchart, sequence, etc.), the raw fenced source is shown in a code block. Terminal users cannot visualize it without copying it out to a renderer, which breaks the flow of reading the response.
Proposed direction
Render Mermaid code blocks as inline Unicode box-drawing art directly in the chat.
The strongest argument for feasibility: pi already ships exactly this feature. Prime Agent's TUI is built on top of pi, and pi renders Mermaid via
grok-mermaidinpackages/coding-agent/src/modes/interactive/components/mermaid.ts— a markdown transformer that finds mermaid fenced blocks, renders them to styled Unicode art, and maps spans to theme colors. As a daily pi user I found this genuinely convenient and useful: diagrams become readable without leaving the terminal. Porting the same approach should be low-risk since it is proven in the upstream project.Concretely:
transformcallback on the TUIMarkdowncomponent, applied after tab normalization and before markdown parsingmermaid-transformermodule inpackages/coding-agentusinggrok-mermaidstreaming(default) /off(raw source)Alternatives considered
Additional context
I have a working implementation (transform hook + transformer module + settings toggle + tests) on a branch, modeled on pi's approach, and can share or rebase it if invited.
All reactions