Repository navigation
feat(markdown): improve formatting, CJK emphasis and dark diagram contrast - #29644
niconicohu wants to merge 27 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments: 3
mobile/src/components/mobile-code-highlight.ts: 1
66-70: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueCorrect the cache character accounting on eviction.
Line 65 adds
code.lengthtocachedCharacters. Eviction subtractsoldest.length - oldest.indexOf('\0') - 1. A language name can contain\0, because Line 18 only splits on whitespace. In that caseindexOffinds the wrong separator, and the counter drifts. Store the code length with each cache entry. Subtract that stored value on eviction.Proposed fix
-const cache = new Map<string, CodeToken[]>() +const cache = new Map<string, { tokens: CodeToken[]; size: number }>() ... - const oldest = cache.keys().next().value! - cache.delete(oldest) - cachedCharacters -= oldest.length - oldest.indexOf('\0') - 1 + const [oldest, entry] = cache.entries().next().value! + cache.delete(oldest) + cachedCharacters -= entry.sizemobile/src/components/mobile-markdown-presentation.test.tsx: 1
17-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the duplicate mocks.
Lines 1-5 already mock
lucide-react-nativeand../platform/clipboard. Lines 17-20 register the same mocks again. Remove one set of mocks.mobile/modules/orca-markdown-inline-code/android/src/main/java/expo/modules/orcamarkdown/OrcaMarkdownInlineCodeModule.kt: 1
49-52: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAvoid rebuilding the full string on each loop iteration.
Line 52 calls
text.toString()on every iteration of the loop. Line 50 also allocates a substring on every iteration. On long text with many ranges, this is O(n²) work on the UI thread. Computetext.toString()once before the loop and reuse it.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ab2a75d1-6d79-4274-b9a1-326d48d06e92
📒 Files selected for processing: 49
mobile/modules/orca-markdown-inline-code/.gitignoremobile/modules/orca-markdown-inline-code/README.mdmobile/modules/orca-markdown-inline-code/android/build.gradlemobile/modules/orca-markdown-inline-code/android/src/main/java/expo/modules/orcamarkdown/InlineCodeSpan.ktmobile/modules/orca-markdown-inline-code/android/src/main/java/expo/modules/orcamarkdown/OrcaMarkdownInlineCodeModule.ktmobile/modules/orca-markdown-inline-code/expo-module.config.jsonmobile/modules/orca-markdown-inline-code/package.jsonmobile/src/components/MobileMarkdown.file-links.test.tsmobile/src/components/MobileMarkdown.rendering.test.tsxmobile/src/components/MobileMarkdown.tsxmobile/src/components/MobileMarkdownCodeBlock.test.tsxmobile/src/components/MobileMarkdownCodeBlock.tsxmobile/src/components/MobileMarkdownNativeText.android.test.tsxmobile/src/components/MobileMarkdownNativeText.android.tsxmobile/src/components/MobileMarkdownNativeText.tsxmobile/src/components/MobileMarkdownTable.tsxmobile/src/components/MobileSelectableText.android.tsxmobile/src/components/mobile-code-highlight-theme.tsmobile/src/components/mobile-code-highlight.test.tsmobile/src/components/mobile-code-highlight.tsmobile/src/components/mobile-markdown-android-selection.test.tsxmobile/src/components/mobile-markdown-blocks.tsxmobile/src/components/mobile-markdown-inline-code-ranges.test.tsxmobile/src/components/mobile-markdown-inline-code-ranges.tsmobile/src/components/mobile-markdown-inline.tsxmobile/src/components/mobile-markdown-mermaid-routing.test.tsmobile/src/components/mobile-markdown-native-code-contract.tsmobile/src/components/mobile-markdown-native-code.android.tsmobile/src/components/mobile-markdown-native-code.tsmobile/src/components/mobile-markdown-presentation.test.tsxmobile/src/components/mobile-markdown-selectable.test.tsxmobile/src/components/mobile-markdown-styles.tsmobile/src/components/mobile-markdown-table-columns.test.tsmobile/src/components/mobile-markdown-table-columns.tsmobile/src/components/mobile-markdown-table.test.tsxmobile/src/components/mobile-markdown-text.tsxmobile/src/components/mobile-selectable-text-ios.test.tsxmobile/src/components/mobile-transcript-layout.tsmobile/src/components/pr-sidebar/CommentMarkdown.tsxmobile/src/components/pr-sidebar/MermaidDiagram.tsxmobile/src/components/pr-sidebar/mermaid-diagram-config.tsmobile/src/components/pr-sidebar/mermaid-initial-layout.test.tsxmobile/src/terminal/document/terminal-theme.tsmobile/src/terminal/terminal-webview-html/theme.tsmobile/src/theme/mobile-dark-colors.tsmobile/src/theme/mobile-theme.tsmobile/src/theme/mobile-themed-styles.test.tsmobile/src/theme/mobile-themed-styles.tsmobile/src/theme/use-mobile-theme.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
|
@coderabbitai review |
|
|
Addressed the three remaining review nits in 5c1ac13:
Validation on this independent branch: 10,810 mobile tests, application/test typechecks, changed-code quality gate, full mobile-web bundle verification, and Android native/release compilation plus V2 APK signature verification. This is compiled and automated coverage; the native layout change has not been profiled on a physical device. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
311e89ef-172d-4527-8e1d-447952278e50
📒 Files selected for processing: 49
mobile/modules/orca-markdown-inline-code/.gitignoremobile/modules/orca-markdown-inline-code/README.mdmobile/modules/orca-markdown-inline-code/android/build.gradlemobile/modules/orca-markdown-inline-code/android/src/main/java/expo/modules/orcamarkdown/InlineCodeSpan.ktmobile/modules/orca-markdown-inline-code/android/src/main/java/expo/modules/orcamarkdown/OrcaMarkdownInlineCodeModule.ktmobile/modules/orca-markdown-inline-code/expo-module.config.jsonmobile/modules/orca-markdown-inline-code/package.jsonmobile/src/components/MobileMarkdown.file-links.test.tsmobile/src/components/MobileMarkdown.rendering.test.tsxmobile/src/components/MobileMarkdown.tsxmobile/src/components/MobileMarkdownCodeBlock.test.tsxmobile/src/components/MobileMarkdownCodeBlock.tsxmobile/src/components/MobileMarkdownNativeText.android.test.tsxmobile/src/components/MobileMarkdownNativeText.android.tsxmobile/src/components/MobileMarkdownNativeText.tsxmobile/src/components/MobileMarkdownTable.tsxmobile/src/components/MobileSelectableText.android.tsxmobile/src/components/mobile-code-highlight-theme.tsmobile/src/components/mobile-code-highlight.test.tsmobile/src/components/mobile-code-highlight.tsmobile/src/components/mobile-markdown-android-selection.test.tsxmobile/src/components/mobile-markdown-blocks.tsxmobile/src/components/mobile-markdown-inline-code-ranges.test.tsxmobile/src/components/mobile-markdown-inline-code-ranges.tsmobile/src/components/mobile-markdown-inline.tsxmobile/src/components/mobile-markdown-mermaid-routing.test.tsmobile/src/components/mobile-markdown-native-code-contract.tsmobile/src/components/mobile-markdown-native-code.android.tsmobile/src/components/mobile-markdown-native-code.tsmobile/src/components/mobile-markdown-presentation.test.tsxmobile/src/components/mobile-markdown-selectable.test.tsxmobile/src/components/mobile-markdown-styles.tsmobile/src/components/mobile-markdown-table-columns.test.tsmobile/src/components/mobile-markdown-table-columns.tsmobile/src/components/mobile-markdown-table.test.tsxmobile/src/components/mobile-markdown-text.tsxmobile/src/components/mobile-selectable-text-ios.test.tsxmobile/src/components/mobile-transcript-layout.tsmobile/src/components/pr-sidebar/CommentMarkdown.tsxmobile/src/components/pr-sidebar/MermaidDiagram.tsxmobile/src/components/pr-sidebar/mermaid-diagram-config.tsmobile/src/components/pr-sidebar/mermaid-initial-layout.test.tsxmobile/src/terminal/document/terminal-theme.tsmobile/src/terminal/terminal-webview-html/theme.tsmobile/src/theme/mobile-dark-colors.tsmobile/src/theme/mobile-theme.tsmobile/src/theme/mobile-themed-styles.test.tsmobile/src/theme/mobile-themed-styles.tsmobile/src/theme/use-mobile-theme.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
|
@coderabbitai review |
|
|
@coderabbitai resume |
✅ Action performedReviews resumed and review finished. |
|
@coderabbitai review |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2c24d2d6-7b0a-4493-bf0d-23ee3af25db7
📒 Files selected for processing: 8
config/scripts/mobile-web-app-mermaid-render.test.mjsmobile/src/components/pr-sidebar/MermaidDiagram.tsxmobile/src/components/pr-sidebar/MermaidDiagram.web.tsxmobile/src/components/pr-sidebar/mermaid-diagram-config.tsmobile/src/components/pr-sidebar/mermaid-diagram-contrast.test.tssrc/renderer/src/components/editor/MermaidBlock.tsxsrc/shared/mermaid-flowchart-contrast.test.tssrc/shared/mermaid-flowchart-contrast.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
|
|
@coderabbitai review |
|
|
@coderabbitai review |
|
|
@coderabbitai run pre-merge checks |
✅ Action performedReview finished.
|
|
@coderabbitai review Please review the incremental main-merge resolution at 5c7b6fe. Main c054e94 added bottom-row terminal backdrop painting; this head retains it alongside this branch's static dark fallback. The combined regression failed without the painter call and passed after restoration. The complete mobile suite passed 11,289 tests; desktop and phone Markdown/CJK checks passed. The PR description lists current evidence and limitations. This is one incremental review request for the new head. No full review or resume is requested. The existing standalone dark-only limitation remains accepted; the paused Appearance PR is outside this work. |
✅ Action performedReview finished.
|
|
@coderabbitai review Please review the increment at c029467: the main merge retains the security overrides/patches and resolves the CJK plugin against Markdown-it 14.3.3. Two equivalent browser expression simplifications keep inherited files within the existing line limit. Frozen installs, CJK/security regressions, 11,387 mobile tests, browser checks, typechecks and PR quality passed; details are in the updated description. |
✅ Action performedReview finished.
|
|
@coderabbitai review Please review the increment at 0171cec after merging main 2a45fdc. The actual browser prop-type conflict is resolved by adopting main’s complete component unchanged. Existing Markdown/CJK behavior is retained. The standard one-worker mobile suite passed 11,440 tests; desktop regressions, typechecks, current-main ratchets and PR-scoped quality passed. The updated description records current evidence and the source-only boundary. |
✅ Action performedReview finished.
|
|
@coderabbitai review Please review a0878d8, the normal merge of 0171cec with main d053ff9. The only actual conflict was the Mermaid component's documentation block after main relocated the browser test; the resolved component is byte-identical to 0171. Existing CJK parsing, static dark fallback, bottom-row painting, diagram queue/timeouts and contrast fixes are retained, along with main's newer code and tooling paths. Fresh background validation: 11,518 mobile tests /1,121 files passed (same six tests/two files skipped); 68 desktop/shared Mermaid, CJK and image-preview checks /six files passed; all root/mobile typechecks, mobile lint/tests ratchet, all root ratchets, frozen installs and the 48-code-file PR quality gate passed. Normal hooks passed without changing the tested tree. The root test wrapper used pinned Bun1.4.3. The mobile dependency diff against main remains only the CJK plugin/width dependency, binding Markdown-it14.3.3; no limits, assertions, baselines or exclusions were weakened. No fresh rendered Electron/browser, physical-phone, app build/package/install/deployment or service/profile actions are claimed. Prior017 coverage is historical for this new merge commit. |
✅ Action performedReview finished.
|
|
@coderabbitai review Please review 0ba3984, the normal merge of a0878d8 and main 6a96733. The only actual conflict was CommentMarkdown's plugin list: the resolution retains both this PR's CJK emphasis parser and main's URL boundary plugin. Removing either reproduces its existing regression; both pass together. Existing file links, images, callouts, streaming, Mermaid contrast/queue and terminal fallback/bottom-row behavior remain retained. Fresh background validation: 179 desktop/shared checks in 16 files; 11,551 mobile tests in 1,125 files (same six tests/two files skipped, standard threads/one worker on existing Node24.19); all four root typechecks; mobile app typecheck/lint/test ratchet; all root ratchets; frozen root/mobile installs; and the 48-code-file PR quality gate passed. Normal commit hooks passed without changing the tested tree. Mobile dependencies differ from adopted main only by the CJK plugin/width dependency, still bound to Markdown-it14.3.3. The PR description records the current evidence and source-only boundary. No fresh rendered Electron, device, live-SSH UI, app build/package/install/deployment or service/profile action is claimed. |
✅ Action performedReview finished.
|
|
@coderabbitai review Please review the increment at 41f6c69, the normal merge of 0ba3984 and main 2570d8f. Main #32020 now owns CJK emphasis: both parser files, manifests and lockfiles exactly match main. This PR keeps code/table formatting and Mermaid retry/queue/contrast changes, without a duplicate CJK implementation or dependency patch. Existing additional CJK regressions remain. Fresh background checks: 11,395 phone tests passed (six skipped, zero failed, 1,121 files; completed JSON report), 165 desktop/shared checks in 12 files, all four root typechecks, phone app/typecheck-test ratchet/lint, all ratchets, shared dependency check, frozen installs and the final 46-file PR quality gate passed. Tested tree equals the normal commit tree. No thresholds or assertions changed. No fresh rendered UI, app build, installation, deployment or service/profile action; previous pictures are historical. The accepted phone dark-only limitation is unchanged. |
|
|
@coderabbitai review Please review 4fc2396 after merging upstream 7d6603a. Six actual comment-cleanup conflicts preserve the theme-aware diagram queue, layout completion and sanitized readable SVG. A checked-HTMLElement fixture incompatibility, the new typed-property/naming lint requirements, and two obsolete table-test imports were fixed without changing assertions or rules. Final mobile, typecheck, shared and headless component results and the remaining flaky-ratchet limitation are in the current PR body. This is one request for the final new head; intermediate ee1 was not requested. |
✅ Action performed
|
|
Thanks a lot for this, @niconicohu. The UI direction here was really good, so we split it into two smaller PRs that build on it and credit you: #34452 (merged) keeps Mermaid flowchart labels readable on custom node fills, and #34456 brings the code block, table, quote, list and diagram styling to the phone chat, reusing the highlighter and table sizing mobile already has. The CJK emphasis part is covered by #32020. Closing this one in favour of those. |
ELI5
Phone chat replies have readable code blocks, aligned tables and Mermaid diagrams without breaking selection, links or streaming.
What Changed
Code blocks add syntax colours, line numbers, horizontal scrolling and copying without line numbers. Tables share measured column widths and scroll inside the message. Quotes, lists and inline code use consistent spacing and contrast.
The existing Mermaid engine serializes renders, retries after theme/source changes and falls back to source when a render fails. Sanitized flowchart labels stay readable on custom fills on both desktop and phone. This extends the existing parser and engine instead of adding another renderer.
This branch adopts main
7d6603aa1766. Main's #32020 already supplies the desktop and phone CJK emphasis fix; both parser files, package manifests and lockfiles now exactly match main. This PR retains its additional CJK regressions, but no longer carries an independent CJK implementation or dependency change. Main's URL boundaries, file links, image handling, security overrides and terminal bottom-row painting remain intact. Main's native fallback behavior and the page renderer's theme-aware retries are retained.Why
Long replies should remain readable on a small screen. Reusing the existing Markdown and diagram pipeline preserves the host's file routing, selection and incremental output.
Linked Issue
Fixes #29630
Visual Proof
Earlier mobile-web captures are historical evidence for the formatting work; this merge has no fresh rendered UI run.
Testing
Merged upstream
7d6603aa1766eb4cac079f8d6d2f4e67f251574athrough a normal merge. Six comment-cleanup conflict resolutions retain the theme-aware mobile Mermaid queue, fallback/layout completion and readable SVG adjustment, desktop sanitization, custom diagram fixture and theme subscriptions. Their production ASTs match the prior clean merged tree after removing comments, except BrowserAddressBar retains main's equivalent expression.A real compatibility failure was caught in the initial full mobile run: six Mermaid tests failed because main now checks for an
HTMLElement, while the branch fixture supplied plain objects in a Node environment. The existing fixture now runs in the already-installed happy-dom environment and returns actual DOM elements. The production check and all 35 assertion lines are retained. The focused suite went from six failures to six passes; no assertion, timeout, rule, or baseline was relaxed. This is DOM fixture validation, not a browser/device rendering claim.New upstream lint rules are satisfied with typed style-property access and domain-specific node-boundary names; no rule was disabled. The table fixture's two imports now follow the existing relocated dependency and preview-harness modules.
Final-tree validation: all four root typechecks; mobile app/test typechecks (1,120 program files, five intentional exclusions, zero grandfathered), lint and shared-dependency/runner checks. The focused theme/Mermaid suite passed 7 tests. Desktop/shared and isolated Chromium/WebKit Mermaid/table fixture tests passed 27 tests across 4 files. The completed full mobile JSON records 11,346 passed, 6 skipped, zero failures across 1,125 file results. Counts overlap. Normal hooks passed and tested tree
7c4f294c6071a0f30b89ec3451a3fb70237fb9d6exactly matches the final commit tree.Required
pnpm check:changed --base=upstream/main --maxWorkers=2passed 24 of 25 selected checks on this head, including the previously failing lint and affected/colocated tests. The remaining flaky-test ratchet fails withENOBUFSwhile diffing this fork's ancientorigin/main; no baseline or rule was changed to suppress it. The full required GitHub PR workflow still needs to pass for this exact head.No rendered Electron, physical phone, Windows-machine, live SSH, app deployment, installation or service/profile operation was performed.
AI Disclosure
Implemented and verified with OpenAI Codex.
Review
Please check table sizing, diagram settlement and readable labels. The exact new commit still needs bot review and the full required PR workflow; clean local checks do not substitute for the aggregate gate.
Agent skill upstream boundary
Checklist