Skip to content

fix(markdown): render CJK bold that ends in punctuation in desktop and phone chats - #32020

Merged
AmoabaKelvin merged 2 commits into
mainfrom
cjk-emphasis-punctuation
Oct 23, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
cjk-emphasis-punctuation

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31

ELI5

When Chinese or Japanese bold text ended in punctuation and the next sentence started right after it, chats showed the raw ** instead of bold. Chats now use the same CJK rule the markdown preview already uses.

What Changed

Before: **单算 Runtime 执行引擎,平均每题 29.78 秒。**边界是开始执行到产出结果。 showed literal asterisks in desktop native chat and in the phone chat.
After: the first sentence is bold, including its 。, and the next sentence is normal text. This applies to both surfaces, and to the user's own messages too.

  • Desktop: CommentMarkdown adds remark-cjk-friendly/parseOnly to its remark plugins. The editor preview and table of contents already had it.
  • Phone: the markdown-it parser adds markdown-it-cjk-friendly (2.0.3, the markdown-it 14 line). It comes from the same upstream spec and author as the remark plugin. Mobile keeps markdown-it for speed on Hermes.

Why

CommonMark only lets ** close when it is "right-flanking". A closing ** with punctuation (。) before it and a letter (边) after it does not count, so the pair stays as text. CJK text has no spaces between sentences, so this rule misfires there. The CJK-friendly extension relaxes the check only when the character on either side is CJK. Non-CJK text keeps standard CommonMark behavior: **Note.**Next stays literal.

The editor preview already enabled this rule, but the two chat parsers did not, so the fix goes in those parsers' config. Community PR #29644 bundles a similar change with unrelated work; this PR is an independent fix for the emphasis rule only.

Linked Issue

Fixes #31368

Linear: STA-11478

Visual Proof

Real Claude reply in a hidden dev build of desktop native chat (top: the user's message, bottom: Claude's reply). Rows 3 and 4 must stay literal.

Before After
desktop-before.png desktop-after.png

Phone, iOS simulator on Hermes, with the same text in MobileMarkdown:

Before After
mobile-before.png mobile-after.png

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Added tests on both surfaces for the reported case and for the non-CJK case **Note.**Next. The CJK test fails without the fix on both surfaces.

  • Ran all 652 CommonMark spec examples through mobile's markdown-it with and without the plugin. The output is identical for every one.

  • The plugin's \p{Emoji_Presentation}, \p{sc=Hangul} and \p{Zs} regexes compile under hermesc, and the iOS simulator renders the reported case bold.

  • pnpm run build:mobile-web builds and verifies with the plugin bundled, within the size budget.

  • Ran check:code-quality:changed, check:react-doctor:changed and the mobile tsc --noEmit. All pass.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Mobile lockfile: the diff adds only the two new packages (markdown-it-cjk-friendly, get-east-asian-width), and pnpm install --frozen-lockfile succeeds.
  • There is no wire or version coupling, because each client parses text locally. SSH and folder workspaces are unaffected.
  • The Tiptap rich editor uses marked, which has no equivalent extension, so it is left as is (it is a file editor, not chat).
  • Autolink punctuation (STA-11317) is handled separately.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@AmoabaKelvin
AmoabaKelvin marked this pull request as ready for review October 22, 2026 21:39
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⛔ Files ignored due to path filters: 1
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ce1c85fd-cafa-4f45-a851-328fdb66f154
📥 Commits

Reviewing files that changed from the base of the PR and between afce523 and 451f0a1.

⛔ Files ignored due to path filters: 1
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3cdfc3ea-3271-4506-991c-fc92595f0d31
📥 Commits

Reviewing files that changed from the base of the PR and between ed5ad7f and fd69b8ac6054b4900bb6b2f23a93f4721526534b.

⛔ Files ignored due to path filters: 1
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing: 5
  • mobile/package.json
  • mobile/src/components/mobile-markdown-tree.test.ts
  • mobile/src/components/mobile-markdown-tree.ts
  • src/renderer/src/components/sidebar/CommentMarkdown.test.tsx
  • src/renderer/src/components/sidebar/CommentMarkdown.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

📝 Walkthrough

The mobile Markdown parser and sidebar comment renderer now enable CJK-friendly parsing. Tests check that bold text ending in punctuation is parsed before following CJK text, and that adjacent non-CJK text retains CommonMark delimiter behavior.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to fd69b

The CJK emphasis change is ready to merge after normal checks; no specific user-facing regression is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: CJK bold rendering fixes for desktop and phone chats.
Description check Passed The description is complete and focused. It includes the user impact, implementation details, rationale, linked issue, visual proof, testing details, compatibility notes, and checklist. The AI Disclos…
Linked Issues check Passed Issue #31368 requires CJK emphasis to close before following CJK text in desktop and phone chats, while preserving non-CJK delimiter behavior. The PR enables remark-cjk-friendly/parseOnly in `Commen…
Out of Scope Changes check Passed The changed production files configure the two chat Markdown parsers. The dependency addition supports the mobile parser. The four test changes verify the requested behavior and the non-CJK safeguard.…
Full details: Description check

Explanation

The description is complete and focused. It includes the user impact, implementation details, rationale, linked issue, visual proof, testing details, compatibility notes, and checklist. The AI Disclosure and Review sections are not filled, but the required change context is otherwise well documented.

Full details: Linked Issues check

Explanation

Issue #31368 requires CJK emphasis to close before following CJK text in desktop and phone chats, while preserving non-CJK delimiter behavior. The PR enables remark-cjk-friendly/parseOnly in CommentMarkdown and markdown-it-cjk-friendly in the mobile parser. Tests cover the reported CJK case and **Note.**Next as a literal string on both surfaces. The reported changes address the linked issue requirements.

Full details: Out of Scope Changes check

Explanation

The changed production files configure the two chat Markdown parsers. The dependency addition supports the mobile parser. The four test changes verify the requested behavior and the non-CJK safeguard. No changed file has a demonstrated unrelated purpose.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AmoabaKelvin
AmoabaKelvin force-pushed the cjk-emphasis-punctuation branch 3 times, most recently from fd69b8a to afce523 Compare October 22, 2026 23:48
The editor preview already used the CJK-friendly emphasis rule; chat
markdown on desktop and phone did not.

Fixes #31368
@AmoabaKelvin
AmoabaKelvin force-pushed the cjk-emphasis-punctuation branch from afce523 to 451f0a1 Compare October 23, 2026 15:11
@AmoabaKelvin
AmoabaKelvin merged commit 2570d8f into main Oct 23, 2026
37 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the cjk-emphasis-punctuation branch October 23, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render Chinese bold text next to punctuation in desktop and phone chats

1 participant