You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
V2 TUI: add native Mermaid and LaTeX rendering #40508
Add first-class Mermaid diagram and LaTeX math rendering to the OpenCode V2 TUI.
Mermaid should be the initial priority. LaTeX support should cover both display math and inline math embedded within surrounding prose.
Scope
Render fenced Mermaid blocks as diagrams in session content.
Render display LaTeX expressions.
Render inline LaTeX without forcing the surrounding text onto separate lines.
Define clear fallback behavior when rendering is unsupported or fails so the original source remains readable.
Preserve normal Markdown/code rendering and avoid interpreting ordinary text, such as currency values, as math.
Architecture
Prefer implementing these features as built-in/internal OpenCode plugins rather than adding them to OpenTUI core. This gives OpenCode first-class support without bloating the lower-level renderer and provides a concrete pressure test for the V2 plugin system.
The current plugin API does not appear to expose TUI session-content render slots/hooks. Track and add the minimum plugin API needed for internal plugins to recognize and render custom session content, with Mermaid and LaTeX as the proving use cases.
Acceptance criteria
Mermaid fences render visibly in the V2 TUI, with readable source fallback on failure.
Display and inline LaTeX render correctly in the V2 TUI.
Inline math composes with text before and after it on the same line where space allows.
Rendering works during streaming and after sessions are restored.
The implementation documents or demonstrates the internal plugin/content-rendering extension point.
Existing Markdown, code blocks, selection, scrolling, and copy behavior continue to work.
Reacted by Esau Martinez, WW, TengMMVP, Nayan Mehta, Olivier Delmas, Lin Tianchuan, Orjan Ameye, CaptainGlacier, Kaustubh Kadam, Juan Pablo Romero Mendoza and 14 more
Reacted by Muzimi, Vladimir Ruppel and DINMAY KUMAR BRAHMA
Upvoting this. I ask the agent to diagram code flows and processes all the time, and it reliably emits Mermaid syntax, but the GUI shows the raw fence as text instead of a rendered diagram. I have to copy the source into another tool to actually see it.
For me the essentials are:
Completed mermaid fences render as diagrams in chat.
Raw source stays visible during streaming and on parse failure, never a broken or empty block.
The copy button still copies the Mermaid source.
Re-render on light/dark theme change.
Worth noting: #3366 was closed as completed but no implementation ever merged (zero merged PRs), and PR #39818 has a draft for desktop/web chat via session-ui. Happy to test once a build is available.
Reacted by Starry 24, Jensen, CedarFox, Muzimi, MicicMath and DINMAY KUMAR BRAHMA
This would be very helpful for our workflow. We keep mathematical research notes as Markdown files whose content is standard LaTeX, and assistant responses about those files currently render every formula as raw LaTeX source in the V2 TUI, which makes math-heavy derivations almost unreadable in the terminal.
Beyond $...$ inline and $$...$$ display math, we would also like support for the common LaTeX display environments our documents use — \begin{equation} ... \end{equation}, align/aligned, gather, multline, and cases — ideally rendered with their expected alignment (e.g. multi-line align at the & points). If only a subset is feasible at first, fine, as long as unrecognized blocks fall back to the untouched source, since the raw LaTeX is still compilable and we copy it into documents. Thanks for tracking this!
Reacted by Esau Martinez, Orjan Ameye, Kaustubh Kadam, CedarFox, Muzimi and Hexiang Geng
Activity
dinoesau commentedon Aug 5, 2026
Upvoting this. I ask the agent to diagram code flows and processes all the time, and it reliably emits Mermaid syntax, but the GUI shows the raw fence as text instead of a rendered diagram. I have to copy the source into another tool to actually see it.
For me the essentials are:
mermaidfences render as diagrams in chat.Worth noting: #3366 was closed as completed but no implementation ever merged (zero merged PRs), and PR #39818 has a draft for desktop/web chat via session-ui. Happy to test once a build is available.
StarryJinda commentedon Aug 13, 2026
This would be very helpful for our workflow. We keep mathematical research notes as Markdown files whose content is standard LaTeX, and assistant responses about those files currently render every formula as raw LaTeX source in the V2 TUI, which makes math-heavy derivations almost unreadable in the terminal.
Beyond
$...$inline and$$...$$display math, we would also like support for the common LaTeX display environments our documents use —\begin{equation} ... \end{equation},align/aligned,gather,multline, andcases— ideally rendered with their expected alignment (e.g. multi-line align at the&points). If only a subset is feasible at first, fine, as long as unrecognized blocks fall back to the untouched source, since the raw LaTeX is still compilable and we copy it into documents. Thanks for tracking this!dinoesau commentedon Aug 19, 2026
You'll be glad to know that Mermaid support is now active in OpenCode v2. At least to some extent!
It is still in beta, though.
https://opencode.ai/v2/docs