Skip to content

fix(swift-ios): enable granular text selection - #6110

Draft
saphid wants to merge 2 commits into
pingdotgg:t3code/rebuild-mobile-app-swiftfrom
saphid:saphid/swiftui-text-selection
Draft

fix(swift-ios): enable granular text selection#6110
saphid wants to merge 2 commits into
pingdotgg:t3code/rebuild-mobile-app-swiftfrom
saphid:saphid/swiftui-text-selection

Conversation

@saphid

@saphid saphid commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What Changed

  • render Markdown paragraphs, headings, lists, tables, and code blocks with selectable native text
  • preserve bold, italic, inline-code, strike-through, link, and Dynamic Type styling
  • keep selections stable while a streaming response appends text
  • retain code-block wrapping/copy controls and route link actions through SwiftUI openURL
  • add focused coverage for formatting, Dynamic Type, code reuse, and selection restoration

Why

The native SwiftUI thread view only offered whole-message copying. People could not select a word, sentence, or code fragment with standard iOS selection handles.

This adds granular native selection while keeping message-level copy actions, streaming updates, accessibility actions, safe link routing, and the existing Markdown layout behavior.

Closes #6089.

UI Changes

Long-pressing rendered assistant prose or code now shows the native iOS selection handles and edit menu (Copy, Look Up, Translate). The appearance of messages is otherwise unchanged.

Verified in the iOS Simulator inside a live thread: native selection appeared on prose and the existing code-block controls remained available. A physical-phone acceptance pass will be attached after the approved-based combined build is installed.

Verification

  • MarkdownDocumentTests: 15 passed, 0 failed on iOS Simulator
  • combined simulator pass with PR fix(swift-ios): restore thread scrolling and back swipe #6090: native selection menu appeared and full-surface back swipe returned to the thread list
  • git diff --check: passed
  • fresh direct Claude Opus 5 high review of the final diff: exit 0, no actionable findings

Checklist

  • This PR is focused on one native behavior
  • I explained what changed and why
  • Before/after screenshots are not applicable because message appearance is unchanged
  • I included a video for the interaction change

Implemented with GPT-5.6 Sol in T3 Code/Codex. Independently reviewed by Claude Opus 5 high.

Note

Enable granular text selection in chat markdown messages

  • Replaces SwiftUI Text-based inline rendering with UITextView-backed MarkdownInlineText views, enabling native text selection across all block types (paragraphs, headings, lists, tables, code blocks).
  • Introduces MarkdownSelectionContext and MarkdownSelectionSource to propagate copy action metadata and stable selection state through the block view hierarchy.
  • Adds MarkdownSelectableTextAttributes to build NSAttributedString with dynamic type fonts, colors, links, and code styling for selectable rendering.
  • Preserves user text selection across streaming message updates via MarkdownSelectionRestoration, which restores ranges only when new text safely extends the previous content.
  • Adds a code style to MarkdownInlineStyle with monospaced UIFont resolution, and pre-renders code block inline runs in MarkdownRenderCache for reuse.
  • Risk: Table cell accessibility structure changes due to removal of the children-combine modifier; keyboard dismissal in the transcript view is now delegated to onDismissKeyboard instead of calling window.endEditing directly.

Macroscope summarized f2657ef.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 635f006a-bcf5-46d0-a20d-bf6849602c82

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

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.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant