anomalyco / anomalyco/opencode

[FEATURE]: Detect Mermaid diagrams in untagged fences, not only ```mermaid

Open
#43,304 3 comments 0 reactions 1 assignee View on GitHub

@Brendonovich is already working on this.

Since Aug 18, 2026.

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

Description

Feature hasn't been suggested before.
  • I checked #39816 (closed) and #40508 (open). Both cover rendering Mermaid; neither mentions detection of untagged fences, which is what this asks for.
Describe the enhancement you want to request

decorateMermaid (from the merged, unreleased #43024) only acts on tagged fences:

if (!code.classList.contains("language-mermaid")) {
  clearMermaid(wrapper)
  return
}

Correct by the letter — but models often don't tag the fence, even when explicitly asked for a Mermaid diagram.

Measured across the stored sessions of one instance (opencode-ai@1.18.13, Nemotron 3 Ultra 550B):

fence count
``` (untagged) 50
```text 26
```mermaid 22
```bash 2

Not every untagged block is a diagram. But the diagrams that were there arrived untagged more often than tagged, and the user just sees a code block — with no way to tell whether the feature is missing or the tag is.

The mechanism is already in the PR. renderMermaidSvg does:

if (!(await mermaid.parse(source, { suppressErrors: true }))) return

That alone identifies a diagram; non-diagram code doesn't parse. So the class check could be relaxed rather than replaced — attempt untagged (and text) blocks too and let parse decide, keeping the fast path for tagged ones. Cost is one suppressed parse per candidate, and it can be limited to complete blocks, which the code already distinguishes, so streaming is unaffected.

I first tried matching the first word against Mermaid's diagram keywords. It works, but ages badly — every new diagram type has to be added by hand. parse always knows.

Caveat: I haven't run your build; #43024 is merged but not in a published release (latest 1.18.18, 2026-08-13). This comes from reading the diff. The measurement is from our own sessions and stands on its own.

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.