Skip to content

feat(app): render Mermaid code blocks - #43024

Merged
Hona merged 1 commit into
v2from
desktop-mermaid
Aug 17, 2026
Merged

Hona merged 1 commit into
v2from
desktop-mermaid

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Render fenced mermaid code blocks with Mermaid's own parser and SVG renderer, loaded only when a Mermaid fence appears.
  • Keep the existing code block visible while streamed Mermaid is invalid; replace it after Mermaid successfully renders and restore code if the completed source is invalid.
  • Preserve fenced-language metadata in completed Shiki output so Mermaid works both during streaming and after reloading an existing message.
  • Import Mermaid through its public typed entrypoint; prebundle the linked Mermaid and KaTeX paths so Vite works with Bun's isolated linker.
  • Upgrade UI to KaTeX 0.16.47 so UI and Mermaid share one resolved instance and one optimizer path.
  • Match the active light/dark scheme and use Mermaid's strict security mode.

Validation

  • bun typecheck in packages/session-ui
  • bun test src/components/markdown-stream.test.ts — 23 passed
  • bun --bun run build in packages/app
  • Replayed the supplied exported message in 36-character chunks — both diagrams rendered
  • Loaded the supplied exported message as an already completed response — both diagrams rendered

Requested by: @Hona (Luke Parker via Slack)

@opencode-agent
opencode-agent Bot force-pushed the desktop-mermaid branch 3 times, most recently from b21a0b8 to 9e4439c Compare August 17, 2026 11:23
@opencode-agent

Copy link
Copy Markdown
Contributor Author

@opencode-agent
opencode-agent Bot enabled auto-merge (squash) August 17, 2026 21:59
@Hona
Hona disabled auto-merge August 17, 2026 22:02
@Hona
Hona merged commit 8644db2 into v2 Aug 17, 2026
9 of 10 checks passed
@Hona
Hona deleted the desktop-mermaid branch August 17, 2026 22:02
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant