fix(mobile): keep Android markdown icons aligned with text #11079
main fromrefs/pull/11079/head·merged by shivamhwp(GitHub profile, opens in a new tab) View on GitHubAndroid renders inline Go/file icons on unrelated lines in Markdown lists, even with #10983 applied. Reproduced on upstream d29c56a5c4 with a Pixel 9 Pro / Android API 36 emulator and a synthetic version of the reported message.
Use the existing block renderer on Android so paragraph/list spacer line heights no longer share one native text layout. Keep the existing heading and paragraph spacing through one shared spacing helper. Add a nonbreaking space to keep each inline icon with its label when wrapping; the Android selection sanitizer removes that injected spacer together with the icon, while preserving authored whitespace. Native selection is now scoped to a paragraph or list item; the message copy button still copies the whole message. This is documented in the user guide.
The shared renderer covers messages and Markdown file previews. The change is Android-only, with no provider, wire-contract, or connection-mode changes.
Validation: clean Metro before/after bundles, repeated fixture loads, wrapped Go references, external-link icons, native text selection and file-reference navigation. Mobile typecheck and 136 focused Markdown/feed tests passed. Review follow-up verification includes all 35 Markdown tests, four Android API 36 Robolectric copy tests, and a rebuilt Android debug app. Targeted lint has no errors (two existing warnings in untouched code); formatting passed. The sanitizer change requires a new native Android build. The other reported activity-label overlaps did not reproduce on current upstream; this PR makes no claim to fix every timing-dependent overlap from the old Android release.
| Before — September 10, 2026 | After — September 10, 2026 |
|---|---|
Model: GPT-6. Harness: Codex.
Summary by CodeRabbit#
Bug Fixes
- Improved Android markdown rendering to keep file and link icons visually separated from their text.
- Prevented inline images from shifting when displayed alongside paragraphs and list items.
- Improved text selection behavior across Android markdown content.
- Copied selections now exclude inline images and their spacing while preserving authored whitespace.
Documentation
- Added guidance for selecting text in paragraphs or list items with a long press.
- Documented how to copy an entire message using the copy button.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/mobile/modules/t3-markdown-text/src/SelectableMarkdownText.ios.tsx line 90Resolvedby SunkenInTime(GitHub profile, opens in a new tab)@@ -84,5 +84,7 @@8484 the resulting single-line width instead of reflowing it. */}8585 <View style={{ flexShrink: 1, minWidth: 0, marginTop, marginBottom }}>8686 {chunks.map((chunk, index) => {87+ // Android inline images drift when one Text mixes paragraph and list88+ // spacer line heights. Keep those layouts in separate native blocks.8789 const content =88- chunk.kind === "rich" ? (90+ chunk.kind === "rich" || Platform.OS === "android" ? (
🟡 Medium
src/SelectableMarkdownText.ios.tsx:90Android ordinary Markdown now uses
NativeMarkdownBlock, which applies a fixedgap: 8and compresses the established heading and paragraph/list spacing (20px before headings, 10px after headings, and 12px between ordinary blocks). Restrict this renderer to icon-containing layouts, or preserve the existingnativeMarkdownChunkSpacing/per-node spacing for all other selectable chunks.🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/mobile/modules/t3-markdown-text/src/SelectableMarkdownText.ios.tsx around line 90: Android ordinary Markdown now uses `NativeMarkdownBlock`, which applies a fixed `gap: 8` and compresses the established heading and paragraph/list spacing (20px before headings, 10px after headings, and 12px between ordinary blocks). Restrict this renderer to icon-containing layouts, or preserve the existing `nativeMarkdownChunkSpacing`/per-node spacing for all other selectable chunks.Fixed in 66e9443026. Android document blocks now use the same spacing helper as selectable text runs: 20 before headings, 10 after headings, and 12 between ordinary blocks. Inter-chunk spacing remains unchanged. Extended the existing spacing regression test to cover block rendering; all 35 Markdown tests and mobile typecheck pass. Rebuilt the Android app and checked wrapped file icons on the API 36 emulator.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Approvability#
Verdict: Approved at
66e9443Macroscope's review found this PR approvable — This is a localized Android markdown rendering fix that keeps inline icons aligned, preserves block spacing, and cleans injected selection whitespace. Production changes stay within the markdown component and are accompanied by focused TypeScript and Robolectric tests.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
9482d66b-0049-4b62-b5e7-3cb75602a287📥 Commits
Reviewing files that changed from the base of the PR and between 8e520d38f46d94bd55ab5b3998400aa65613f8fa and 66e94430264c394e30b560cd559eea6318fdca98.
📒 Files selected for processing (6)
apps/mobile/modules/t3-markdown-text/android/build.gradleapps/mobile/modules/t3-markdown-text/android/src/main/java/expo/modules/t3markdowntext/T3MarkdownTextSelectionModule.ktapps/mobile/modules/t3-markdown-text/android/src/test/java/expo/modules/t3markdowntext/MarkdownSelectionCopyTest.ktapps/mobile/modules/t3-markdown-text/src/NativeMarkdownBlock.ios.tsxapps/mobile/modules/t3-markdown-text/src/nativeMarkdownText.tsapps/mobile/src/lib/nativeMarkdownText.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
Android markdown rendering now uses native blocks for all chunks. Android block spacing is calculated by document structure, and copied selections remove inline images with their injected spacers. Composer documentation describes Android text selection and full-message copying.
Changes#
Android Markdown selection
Layer / File(s) Summary Native Android chunk rendering
apps/mobile/modules/t3-markdown-text/src/SelectableMarkdownText.ios.tsx,apps/mobile/modules/t3-markdown-text/src/NativeMarkdownSelectableText.ios.tsx,docs/user/composer.mdAndroid renders all chunks through NativeMarkdownBlock. Runs with file or link icons receive a leading non-breaking space. The composer documentation describes long-press selection and full-message copying.Android block spacing
apps/mobile/modules/t3-markdown-text/src/nativeMarkdownText.ts,apps/mobile/modules/t3-markdown-text/src/NativeMarkdownBlock.ios.tsx,apps/mobile/src/lib/nativeMarkdownText.test.tsThe shared spacing helper returns distinct values for headings, post-heading blocks, body blocks, and the first block. Android applies these values to per-child views, with tests covering the resulting sequence. Android selection copy sanitization
apps/mobile/modules/t3-markdown-text/android/src/main/java/expo/modules/t3markdowntext/T3MarkdownTextSelectionModule.kt,apps/mobile/modules/t3-markdown-text/android/src/test/java/expo/modules/t3markdowntext/MarkdownSelectionCopyTest.kt,apps/mobile/modules/t3-markdown-text/android/build.gradleCopied selections omit inline images and their injected non-breaking spaces. Robolectric tests and Android unit-test configuration were added. Estimated code review effort: 3 (Moderate) | ~20 minutes
Possibly related PRs
- pingdotgg/t3code#8779: Adds related Android markdown text-selection and copy-sanitization work in the same native module.
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
66e94Android Markdown spacing and selection-copy behavior are covered for the changed cases, with no remaining merge-blocking risk identified.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ 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 13 functions across 7 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. Title check ✅ Passed The title clearly summarizes the primary Android Markdown fix: keeping inline icons aligned with their text. Description check ✅ Passed The description clearly explains the problem, implementation, scope, UI impact, validation, screenshots, and known limitations. It does not use the exact template headings or checklist, but it provide… 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 13 functions across 7 files. (1 skipped: 1 unsupported.)
- Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Comment `@coderabbitai help` to get the list of available commands.Note: GPT-6 on behalf of shivam (@shivamhwp).
The wrapping fix works: Go icons stay with their filenames, including wrapped and nested list items. File navigation, paragraph/list-item selection, and whole-message copy behave as expected.
One minor issue remains with native selection copy. The added nonbreaking space is copied along with the label. Selecting and copying the first list item produces
\u00a0main.go:12 starts the server and registers routes.The icon placeholder is removed, but the injected U+00A0 remains.Consider removing the injected spacing character alongside its inline image in the native copy sanitizer, while preserving spaces authored in the message. Whole-message copy is unaffected.
@shivamhwp Fixed in 66e9443026. The Android copy sanitizer now removes the one injected NBSP immediately following an inline image, including when selection begins after the image. Authored whitespace and literal object-replacement characters without image spans are preserved.
Added four focused Robolectric tests on API 36, all passing, and rebuilt the Android debug app successfully. The emulator still renders the wrapped Go references correctly. This native sanitizer change needs a new Android build; an older installed binary will keep the previous copy behavior.
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
shivamhwp(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed