anomalyco / anomalyco/opencode

V2 TUI: add native Mermaid and LaTeX rendering

Open
#40,508 3 comments 10 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 4, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.