fix(mobile): respect word wrap in diffs - #12590
jakeleventhal wants to merge 3 commits into
Conversation
The Code & Diffs "Word break" setting only reached the file viewers. The native review diff view never received it, so long diff lines always ran off-screen behind a horizontal pan. Pass wordWrap through the native diff style. When it is on, iOS and Android split each code line into fixed-width column segments, grow the row by one line height per extra segment, split word diff highlights at the same boundaries, and disable horizontal code panning. Layout rebuilds when the view width changes. Comment card snippets stay unwrapped because their height is sized from the row count. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — The change wires an existing word-wrap preference into native iOS and Android diff rendering, adding dynamic row layout, multiline drawing, highlight splitting, and scroll behavior. Its cross-platform runtime scope and newly added static-analysis suppressions warrant human review. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: pingdotgg/t3code/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe change adds configurable word wrapping to native review-diff views on Android and iOS. Wrapped rows recalculate heights, disable horizontal panning, render code across visual lines, and split word-diff highlights at wrap boundaries. ChangesReview diff word wrapping
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Appearance
participant NativeStyle
participant ReviewDiffView
participant DiffRenderer
Appearance->>NativeStyle: provide codeWordBreak
NativeStyle->>ReviewDiffView: provide wordWrap
ReviewDiffView->>ReviewDiffView: calculate wrapped row layout
ReviewDiffView->>DiffRenderer: draw wrapped code and diff highlights
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Wrap breaks now move back to a composed character boundary so emoji and combining marks never split across visual lines. Each wrapped row's line starts are computed once during layout and shared by the row height, the drawn segments, and the word diff highlights. On Android, code text drawing moves into ReviewDiffCanvasDrawing, which keeps drawLineRow and DiffCanvasView within detekt's size limits. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CodeWrapLayout owns the wrap columns, line height, and per-row line starts, built by ReviewDiffCanvasDrawing. DiffCanvasView keeps a single field, which brings it back under detekt's LargeClass threshold. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
What Changed
The mobile diff view now follows the Settings → Appearance → Code & Diffs → Word break setting. When it's on, long lines wrap to the screen width instead of running off-screen.
createNativeReviewDiffStylepasseswordWrapthrough the native diff style.Why
The setting only reached the file viewers. The native review diff view never received it, so diff rows kept a fixed height and scrolled sideways, and wrap had no effect on diffs.
Each wrapped row's line starts are computed once during layout, as UTF-16 offsets (the same indices the word-diff ranges use). The row height, the drawn text, and the highlights all read those offsets, so they can't drift apart. TextKit and Android's text layout would each wrap at their own points, especially around tabs, which diff content does not expand.
UI Changes
Offscreen renders of the real
T3ReviewDiffView(iOS source, Mac Catalyst UIKit) with the same rows, tokens, andwordWrap: truestyle. Before uses the parent commit's view; after uses this branch.With
wordWrap: false, the before and after renders are byte-identical.Validation
kotlincagainst Android API stubs, and pass ktlint and detekt with the repo config.wrapLineStartswas run on ASCII, emoji, combining-mark, and ZWJ-cluster boundary cases.tsc --noEmitpasses.vp test run src/features/review src/features/diffs: 98/98 pass.Checklist
Model: Claude Opus 5. Harness: Claude Code in T3 Code.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes