Skip to content

fix(tui): don't swallow Kimi/Qwen ~! ~? kaomoji as subscript spans#13715

Merged
OutThisLife merged 1 commit into
mainfrom
bb/tui-markdown-tilde-subscript
Apr 21, 2026
Merged

fix(tui): don't swallow Kimi/Qwen ~! ~? kaomoji as subscript spans#13715
OutThisLife merged 1 commit into
mainfrom
bb/tui-markdown-tilde-subscript

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

Summary

User report — brand-new build, Konsole terminal, mostly Kimi:

I have one small visual error with some models, they write ~? ~! all the time and sometimes that gets changed to ! or ? which messes with the md format... when I switch to the regular cli the models are only writing ~? ~!.

The inline markdown regex has a Pandoc-style subscript alternative (H~2~O) defined as ~([^~\\s][^~]*?)~. That's too permissive: ~! is a valid opener (first char ! isn't whitespace or tilde) and pairs with the next stray ~ on the line. So a message like:

Aww ~! Building me up step by step, I love it!
Let me do a thorough investigation~! First, let me...

renders as dim text from the first ~! through investigation~, with a leading _ prefix from the subscript render path. You can see the _ in the reporter's screenshot at investigation_!.

Fix

Tighten the subscript pattern to ~([A-Za-z0-9]{1,8})~ — short, alphanumeric-only content. Real Pandoc subscript is H~2~O / CO~2~ / X~n~, never punctuation or spaces. Matches:

  • H~2~O → matches ~2~
  • CO~2~ → matches ~2~
  • X~n~ → matches ~n~
  • Aww ~! blah ~! → no match ✓ (regression fixed)
  • cool ~? yeah ~? → no match ✓
  • ~good idea~ → no match ✓ (whitespace inside bails out)

Same tightening applied to stripInlineMarkup so width measurement stays aligned. Prior fix b17eb949 was for _..._ intraword italics — a different regex. This one targets the tilde path.

Test plan

  • npm test (167/167, incl. 5 new markdown cases)
  • npm run type-check clean
  • npm run lint clean on touched files
  • Visual check with a Kimi-heavy transcript in the TUI

The inline markdown regex had `~([^~\s][^~]*?)~` for Pandoc-style subscript
(H~2~O, CO~2~). On models that decorate prose with kaomoji like `thing ~!`
and `cool ~?` — Kimi especially — the opener `~!` paired with the next
stray `~` on the line and dim-formatted everything between them with a
leading `_` character, mangling markdown output.

Tighten the pattern to short alphanumeric-only content (`~[A-Za-z0-9]{1,8}~`)
since real subscript never contains punctuation, spaces, or long runs.
Same tightening applied to stripInlineMarkup so width measurement stays
consistent. Classic CLI was unaffected because it renders these literally.
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Apr 21, 2026
@OutThisLife OutThisLife merged commit 5504ee8 into main Apr 21, 2026
9 of 10 checks passed
@OutThisLife OutThisLife deleted the bb/tui-markdown-tilde-subscript branch April 21, 2026 23:13
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
…wn-tilde-subscript

fix(tui): don't swallow Kimi/Qwen ~! ~? kaomoji as subscript spans
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
…wn-tilde-subscript

fix(tui): don't swallow Kimi/Qwen ~! ~? kaomoji as subscript spans
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…wn-tilde-subscript

fix(tui): don't swallow Kimi/Qwen ~! ~? kaomoji as subscript spans
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…wn-tilde-subscript

fix(tui): don't swallow Kimi/Qwen ~! ~? kaomoji as subscript spans
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…wn-tilde-subscript

fix(tui): don't swallow Kimi/Qwen ~! ~? kaomoji as subscript spans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants