feat(mobile): draw a changed file's diff natively, on a screen of its own
DA
3h ago+879+879+012345678901234567890123456789-33-33-01234567890123456789
Stacked on #10549. The second step of the iOS code viewer (STAG-3904).
What
A press on a file in Files changed now opens its diff on a screen of its own (…/<number>/file?path=). Before, it opened GitHub.
- Bar: the file's name, its folder under it, and ↑/↓ arrows that step to the previous or next file in place, as Mail and our Inbox thread step.
- ⋯ menu: Wrap lines (on by default, as Dean picked) and Open on GitHub.
- No diff: binary, too-large, or secret files say why in the panel's words (
fileNotice), with Open on GitHub. - Folded: a file the desktop starts folded (deleted, more than 1,000 changed lines, a lockfile) says so, with Show diff.
- Data: the screen draws from the list's own read (
staleTime: Infinity), so opening a file reads nothing.
The native diff view
apps/mobile/modules/diff-view (Swift, autolinked), wrapped by @repo/ui-native's DiffView:
- Drawing: a
UICollectionViewwith one recycled cell per row. Hunk headers are rows too. Each row has old and new line numbers and GitHub's tints for added and removed lines. - No text layout: the custom layout works each row's height out from the monospaced face: its columns over the columns that fit, times the line height. Opening a diff of thousands of lines is one pass over integers, and the rows a scroll shows are found by binary search over one array of tops.
- Wrap off: the diff scrolls sideways, locked to one direction. That fixes GitHub Mobile's known issue of vertical swipes read as horizontal.
- Bridge: the patch crosses as four columns (
diffColumnsindiff-view-model.ts), not an object per row. - Timing: the time from a diff handed to its first frame is an
os_signpostinterval and aDiffView first frame: N ms, R rowsdevice log line, so the Mac's timing lane can read it against the 100 ms target.
Not here yet: syntax colors (tree-sitter, next PR), the pinned gutter when wrap is off, inline review threads, and the iPad split.
Tests
- Ran:
packages/ui-native/src/diff-view-model.test.ts(a hand-worked hunk: header row, side numbering, tabs as spaces) andpackages/features/src/changed-files.test.ts. - Typechecked
@repo/mobilewith its dependencies; ran oxlint and Biome on the changed files. - The Swift hasn't been compiled: this sandbox has no Xcode. It needs a native build on the Mac before it merges.
apps/mobile/maestro/pull-request-files.yamlnow opens a diff, steps to the next file, and unfolds the 5,000-line fixture file. - Left to CI: the rest.
🤖 Generated with Claude Code
Summary by CodeRabbit
- New Features
- Added an in-app pull request file-diff screen with previous/next file navigation, line wrapping, and links to view diffs on GitHub.
- Added support for expanding folded diffs and viewing large generated files.
- Added native diff rendering for iOS, including line numbers and distinct styling for added, removed, and context lines.
- Bug Fixes
- Pull request file changes remain available until refreshed, avoiding unnecessary reloads.