t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: apps/mobile markdownDocument & EnrichedMarkdownText (md4c) turn single tildes (~) into strikethrough in both user and assistant messages

Open andirtew opened this issue 3 days ago • 0 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/mobile

Steps to reproduce

Not a duplicate of #29254 (opening a focused apps/mobile report because #41858 was auto-closed as a duplicate of #29254 without reopening):

  • #29254 and its open PR #29270 target only apps/web (and even #35859 for sent user messages only updated apps/web).
  • apps/mobile uses a completely separate native Markdown pipeline (apps/mobile/src/lib/markdownDocument.ts + apps/mobile/src/native/EnrichedMarkdownText.tsx backed by react-native-enriched-markdown / C md4c). Even if #29254 / #29270 merges, zero files under apps/mobile are modified, and mobile remains broken for both user messages and assistant replies.
  1. Open any thread in the T3 Code mobile app (iOS or Android).
  2. Send or view a message containing two single tildes (~) in the same paragraph — common in numeric ranges, CJK prose, or macOS iCloud paths, e.g.:
    Latency is around 10~20ms (about 80~90% faster), saved under com~apple~CloudDocs.
    
  3. Observe how MobileEnrichedMarkdownText renders the message.

Expected behavior

Only double tildes (~~text~~) should render as GFM strikethrough, matching apps/web user messages (#35859) and singleTilde: false. Single tildes (~) in numeric ranges (10~20, 80~90%) and paths (com~apple~CloudDocs) should render literally without striking through intervening text.

Actual behavior

In apps/mobile, pairs of single tildes (~) in the same paragraph are parsed as strikethrough and the ~ characters themselves disappear — e.g. 10~20ms (about 80~90% faster) renders with 20ms (about 80 struck through and both ~ dropped, and com~apple~CloudDocs strikes through apple. This affects both sent user messages and assistant replies on mobile.

Root cause (apps/mobile, verified on main @ 772f8d40ce)

  1. apps/mobile/src/lib/markdownDocument.ts (lines 14 and 501) configures unified().use(remarkParse).use(remarkGfm) without { singleTilde: false }, so mobile's own AST preprocessing treats ~...~ as delete nodes.
  2. apps/mobile/src/native/EnrichedMarkdownText.tsx (lines 272–288, 463–499) passes the preprocessed Markdown directly to react-native-enriched-markdown (1.2.0-t3.19), whose underlying C md4c parser (MD_FLAG_STRIKETHROUGH) treats single ~...~ as strikethrough by default, and markdownForNativeParsing() / markdownForNativeRendering() does not escape unescaped single ~ in prose before handing off to md4c.

Suggested fix

  • Pass { singleTilde: false } to remarkGfm in apps/mobile/src/lib/markdownDocument.ts (lines 14 and 501).
  • Either:
    • Add a prose-escaping step in apps/mobile/src/lib/markdownDocument.ts (following the existing applyMarkdownEdits pattern used by markdownWithTableBreaks, markdownWithEscapedWindowsDestinations, etc.) that escapes single unescaped ~ characters outside code fences, inline code, links/URLs, and double/triple ~~/~~~ delimiters as \~ before EnrichedMarkdownText renders them (verifiable directly with Vitest unit tests in apps/mobile/src/lib/markdownDocument.test.ts); or
    • Expose a singleTilde: false / double-tilde-only strikethrough option in md4cFlags in the forked react-native-enriched-markdown package (apps/mobile/deps/).

Impact

Minor bug or occasional failure

Version or commit

main @ 772f8d40ce (reproduced on mobile builds; untouched since #41858)

Environment

T3 Code Mobile (iOS / Android, apps/mobile using react-native-enriched-markdown 1.2.0-t3.19 / md4c)

Logs or stack traces


Screenshots, recordings, or supporting files

No response

Workaround

Wrap numeric ranges or paths containing ~ in inline code backticks, or escape single tildes as ~.

andirtew avatar Nov 28 '26 07:11 andirtew