Skip to content

TUI: single-tilde runs (\~x~\) vanish from rendered assistant text #44935

Description

@yuanyang1991

Bug

When an assistant text part contains content wrapped in single tildes (e.g. 3~5 or 30~60%), the TUI markdown renderer swallows the ~ (and sometimes content between delimiters). Data is intact in the session store; this is purely a rendering-layer issue.

Example from a real session (assistant text part, verified via opencode.db):

  • Stored text: 按 3~5 倍放大,应用在选择器中赢得 30~60%
  • Rendered as: 按 35 倍放大,应用在选择器中赢得 3060%

The same part contained 19 occurrences of ~ (+15%~30%, ~1,100/天, 7 功能 ~26,000 次/天 ...); all were swallowed on display. Verified the raw bytes: 33 7E 35 and 33 30 7E 36 30 25 — the 0x7E is present in storage, absent from screen.

Repro

  1. opencode (v1.18.23, Windows 10, Windows Terminal)
  2. Ask the model to output text like 按 3~5 倍放大,赢得 30~60% (any ~x~ fragment works)
  3. Observe rendered output shows 35 and 3060%

Live reproduction (v1.18.23, this session)

Assistant message sent (contains 10 tildes total: 6 single + 2 double runs):

- 单波浪号测试: 3~5 倍、30~60%、~1,100/天、a~b~c、~/Downloads/foo
- 双波浪号测试: ~~这段应该被删除线处理~~

What actually renders in the TUI (copy-pasted from screen, 0 tildes remain):

- 单波浪号测试: 35 倍、3060%、1,100/天、abc、/Downloads/foo
- 双波浪号测试: 这段应该被删除线处理

Notes:

  • Every ~ is swallowed. Single tildes are paired across the whole line into del spans: 3~5 倍、30~60% pairs as one span, ~1,100/天、a~ as another, and the trailing ~ of a~b~c pairs all the way with the tilde in ~/Downloads/foo (strikethrough-styling c、 in between).
  • For readers the text silently changes meaning: 3~5 倍 reads as 35 倍, 30~60% as 3060%.

Expected

Single tildes pass through as literal text. Only ~~text~~ should trigger strikethrough (per GFM spec, ~x~ is not strikethrough; marked's del rule /^(~~?)…/ is overly permissive here).

Related

Environment

  • opencode v1.18.23 (opencode-windows-x64)
  • Windows 10, Windows Terminal

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions