Skip to content

feat: long links wrap with an inline icon instead of cutting off - #19

Merged
juliusmarminge merged 6 commits into
pingdotgg:fork/t3-mobilefrom
ipanasenko:t3/link-inline-icons
Nov 26, 2026
Merged

juliusmarminge merged 6 commits into
pingdotgg:fork/t3-mobilefrom
ipanasenko:t3/link-inline-icons

Conversation

@ipanasenko

@ipanasenko ipanasenko commented Nov 25, 2026 •

Copy link
Copy Markdown

Note

🤖 Written by Claude Opus 5.5 on behalf of Illia

A link pill is one unbreakable unit, so on mobile a long label (a thread title, a PR title) is cut off with "…" at the end of the line. This adds linkVariants[pattern].inlineIcon: the icon is drawn before the link's own text, which stays ordinary link text and wraps. Pills are unchanged, and a variant that sets pill ignores inlineIcon.

Summary

linkVariants: {
  '^app://thread/': {
    color: '#0F766E',
    inlineIcon: { iconUri: 'thread_icon', iconTintColor: '#0F766E' },
  },
}

How each platform draws it:

iOS      [U+FFFC icon attachment][U+2060 word joiner]link text…
         ENRMAttributedStringByExpandingLinkPills drops both wherever text leaves the view
         (copy, Copy as Markdown, HTML/RTF export, accessibility, link titles)

Android  link text is not changed
         LinkIconSpan (ReplacementSpan) covers the first word and draws icon + word
           ends at the first line-break opportunity, a font change, or 24 chars
           applies the word's draw-only styles (link color, strikethrough)
           dropped in paragraphs with right-to-left text (a replacement is bidi-neutral)
         LinkFontSpan applies the link font while measuring too, so wrapped lines match drawing

Also fixes the normalized style cache: isSubStyleEqual treated { pill: undefined } as equal to a variant with a different key of the same count, so a cached style could hide a new inlineIcon.

macOS and web ignore inlineIcon, as they do pill. Docs: guides/link-pills.md#inline-icons and style-properties.md#inline-icon.

Evidence

Made-up content, in the T3 Code dev client with this branch packed (1.2.0-t3.19-6c97dc41).

Before (fork/t3-mobile) After
iOS 27.2 iOS before iOS after
Android 14 Android before Android after

Android edge cases: a Chinese title wraps, a Hebrew title keeps its order (no icon), strikethrough and an enclosing bold reach the covered word, a leading space keeps the icon with its word, and an RTL paragraph keeps its direction.

Android edge cases Android edge cases 2
  • jest: 65 suites, 1890 tests pass, including new cases in __tests__/link-pill-style.test.ts for inlineIcon normalization and the cache fix (that one fails without the styleUtils.ts change).
  • tsc, eslint, clang-format, ktlint, Android compileDebugKotlin and unit tests pass. iOS built in the T3 Code dev client.
  • On device: tapping the wrapped second line opens the link on both platforms; iOS VoiceOver link names contain no icon characters.
  • Not exercised on device: copy and selection, long-press menus, links in tables, a remote icon that fails to load.

Merge Danger

Door: two-way

New opt-in style key; nothing changes until a variant sets it.

Blast Radius: small

The Android LinkSpan font split and the iOS pill-expansion range remapping touch paths that pills and ordinary links also use. The cache-equality fix changes when a normalized style is reused.

The fork's README asks for an open upstream PR for each fork change; none is open yet for this one.

Model and harness: Claude Opus 5.5 in Claude Code.

Note

Add inlineIcon link variant so long links wrap instead of cutting off

  • Adds a new inlineIcon option to link variants (LinkInlineIconStyle with iconUri and optional iconTintColor). A variant with a pill keeps pill presentation; inline icons are dropped in that case. Docs updated in style-properties.md and link-pills.md.
  • On Android, LinkIconSpan in LinkIconSpan.kt reserves a font-sized slot, loads local or remote icons, and redraws or reflows when async loads finish. Icons attach to a bounded first-word run (max 24 chars) and are removed in paragraphs containing RTL text.
  • On iOS, ENRMLinkIconAttachment in ENRMLinkIconAttachment.m renders icons as text attachments, stripping placeholder characters from accessibility labels and link titles.
  • Fixes two bugs: isSubStyleEqual in styleUtils.ts now detects objects with same key count but different keys, and the iOS style fingerprint in MeasurementCache.h now includes the inline icon URI.
  • Behavioral Change: link text with an inlineIcon variant now wraps across lines instead of truncating; LinkSpan gained an appliesFont option so icon-bearing links measure with the link font.

Macroscope summarized 6c97dc4.

A pill is one unbreakable unit, so a long label is cut off at the end of
the line. A link variant's inlineIcon draws an icon before the link's own
text, which then wraps like any other link.

iOS inserts an icon attachment and a word joiner, and drops both wherever
text leaves the view. Android draws the icon in a replacement span over
the link's first character, so the stored text is unchanged, and measures
the link with the font it draws with.

Also fixes the normalized style cache treating { pill: undefined } as
equal to a variant with a different key.
…t styles

Links that start with right-to-left text keep their text without the icon,
since a replacement span would move that word.
The link font is set only by LinkFontSpan for these links, so an enclosing bold
measures and draws the same. Paragraphs with right-to-left text drop the icon,
since a replacement span could change their direction.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Link variants now support inline icons with configurable URIs and optional tint colors. Android and iOS render icons before eligible link text, with image loading and layout updates. iOS text expansion and label handling account for icon attachments. Tests and documentation cover the setting and its interaction with pills.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: Minimal · up to 3757a

This change adds an opt-in inline icon for link variants, so long links wrap instead of truncating. Existing pill behavior is unchanged and the option is ignored when a variant sets pill. No actionable merge-blocking risk remains after the review.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: long links wrap with an inline icon instead of being cut off. The changeset adds the opt-in inlineIcon link variant style across JS types, Android LinkIconSpan/LinkRen…
Description check Passed The description explains the purpose (link pills are unbreakable, so long labels are truncated; inlineIcon lets link text wrap), gives a usage example, describes per-platform behavior, the styleUtils …
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.
Full details: Title check

Explanation

The title names the main change: long links wrap with an inline icon instead of being cut off. The changeset adds the opt-in inlineIcon link variant style across JS types, Android LinkIconSpan/LinkRenderer, and iOS ENRMLinkIconAttachment, which matches the title.

Full details: Description check

Explanation

The description explains the purpose (link pills are unbreakable, so long labels are truncated; inlineIcon lets link text wrap), gives a usage example, describes per-platform behavior, the styleUtils cache fix, and test evidence. It matches the changeset, which adds inlineIcon, LinkIconSpan, ENRMLinkIconAttachment, and the isSubStyleEqual fix.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 32cf7982-b6c9-4863-8c31-193b1f3ce446
Commits

Reviewing files that changed from the base of the PR and between a19cb78 and 3757a44.

Files selected for processing: 1

  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/renderer/LinkRenderer.kt

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 26a96e07-d442-4492-9d23-df146fb9b97f
Commits

Reviewing files that changed from the base of the PR and between a01cbf4 and 6c97dc4.

Files selected for processing: 31

  • docs/docs/react-native/api-reference/style-properties.md
  • docs/docs/react-native/guides/link-pills.md
  • packages/react-native-enriched-markdown/__tests__/link-pill-style.test.ts
  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/accessibility/AccessibleMarkdownTextView.kt
  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/renderer/LinkRenderer.kt
  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/segments/TableContainerView.kt
  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkIconSpan.kt
  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/spans/LinkSpan.kt
  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkInlineIconStyle.kt
  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/styles/LinkVariantEntry.kt
  • packages/react-native-enriched-markdown/ios/attachments/ENRMLinkIconAttachment.h
  • packages/react-native-enriched-markdown/ios/attachments/ENRMLinkIconAttachment.m
  • packages/react-native-enriched-markdown/ios/attachments/ENRMLinkPillText.h
  • packages/react-native-enriched-markdown/ios/attachments/ENRMLinkPillText.m
  • packages/react-native-enriched-markdown/ios/internals/MeasurementCache.h
  • packages/react-native-enriched-markdown/ios/renderer/LinkRenderer.m
  • packages/react-native-enriched-markdown/ios/segments/TableContainerView.m
  • packages/react-native-enriched-markdown/ios/styles/StyleConfig.h
  • packages/react-native-enriched-markdown/ios/styles/StyleConfig.mm
  • packages/react-native-enriched-markdown/ios/utils/LinkTapUtils.m
  • packages/react-native-enriched-markdown/ios/utils/MarkdownAccessibilityElementBuilder.m
  • packages/react-native-enriched-markdown/ios/utils/StylePropsUtils.h
  • packages/react-native-enriched-markdown/src/EnrichedMarkdownNativeComponent.ts
  • packages/react-native-enriched-markdown/src/EnrichedMarkdownTextNativeComponent.ts
  • packages/react-native-enriched-markdown/src/index.tsx
  • packages/react-native-enriched-markdown/src/linkVariantUtils.ts
  • packages/react-native-enriched-markdown/src/normalizeMarkdownStyle.ts
  • packages/react-native-enriched-markdown/src/normalizeMarkdownStyle.web.ts
  • packages/react-native-enriched-markdown/src/styleUtils.ts
  • packages/react-native-enriched-markdown/src/types/MarkdownStyle.ts
  • packages/react-native-enriched-markdown/src/types/MarkdownStyleInternal.ts

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bba06849-8aa0-4d8d-868e-cb2fae0b4957
Commits

Reviewing files that changed from the base of the PR and between 6c97dc4 and a19cb78.

Files selected for processing: 1

  • packages/react-native-enriched-markdown/android/src/main/java/com/swmansion/enriched/markdown/renderer/LinkRenderer.kt

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

@juliusmarminge

Copy link
Copy Markdown
Member

Upstream PR: software-mansion#1242 (same change, squashed onto upstream main). Landing this by fast-forwarding fork/t3-mobile to 3757a44 together with pingdotgg/t3code#43122.

@juliusmarminge
juliusmarminge merged commit 3757a44 into pingdotgg:fork/t3-mobile Nov 26, 2026
3 checks passed
Yash-Singh1 added a commit that referenced this pull request Nov 26, 2026
Yash-Singh1 added a commit that referenced this pull request Nov 26, 2026
Brings in fork/t3-mobile's changes since this branch's base as one commit:
links wrap with an inline icon instead of a pill (#19), the off-screen code
block bitmap fix, the clipboard cleanup, and packing Package.swift.
@ipanasenko
ipanasenko deleted the t3/link-inline-icons branch November 26, 2026 05:22
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.

2 participants