anomalyco / anomalyco/opencode

TUI: Markdown code blocks containing JSON (curly braces) render incorrectly — leading content truncated

Open
#38,475 0 comments 0 reactions 1 assignee View on GitHub

@kommander is already working on this.

Since Jul 23, 2026.

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

Description

Description

When the assistant outputs markdown containing fenced code blocks with JSON content (i.e., curly braces { }), the TUI rendering is broken. The code block's opening fence and initial content appear to be truncated or merged with preceding text, making the JSON configuration examples unreadable.
Specifically, when multiple json code blocks appear consecutively in the response, the rendering collapses — the first code block's opening `json `` line is missing, and subsequent blocks may display with their content pushed into the preceding paragraph rather than in a properly fenced block.
The underlying markdown is valid and renders correctly in other markdown viewers (GitHub, VS Code preview). The issue appears to be in the TUI's CommonMark renderer when parsing consecutive fenced code blocks.

Plugins

git-ai.ts (git-ai plugin)

OpenCode version

1.18.4

Steps to reproduce
  1. Start opencode in TUI mode in any project directory
  2. Ask: "opencode 有什么优化配置?" (or any question that triggers the assistant to output multiple consecutive JSON code blocks)
  3. Observe the rendered output — the JSON code blocks are displayed incorrectly, with missing fences and merged content

Example prompt to reliably reproduce:
输出几个 json 配置示例,每个用独立的 ```json 代码块包裹

Screenshot and/or share link
Image
Operating System

Linux (Ubuntu), kernel 7.0.0-28-generic, x86_64

Terminal

xterm-256color, running under bash

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.