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.
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
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