Repository navigation
Highlight changed words within lines in the web and desktop diff views #17958
not-stbenjam
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem
When a diff changes part of a long line, such as a reworded sentence in Markdown or one argument in a function call, the web and desktop diff panels shade the whole removed line red and the whole added line green. The change itself is not marked, so you have to compare the two lines by eye to find it. GitHub, and T3's own mobile review diff, highlight the changed words inside each line pair (an intra-line or word diff), so the edit is visible right away.
Example diff in T3:
Example word-level diff on GitHub:
The latter is much more readable.
Current state
@pierre/diffssupports this throughlineDiffType: 'word-alt' | 'word' | 'char' | 'none'. Its default is'word-alt', and it skips lines longer thanmaxLineDiffLength: 1000."none"explicitly:apps/web/src/components/DiffPanel.tsx(thread diff panel)apps/web/src/components/pullRequest/PullRequestCodeTab.tsx(PR code tab)apps/mobile/src/features/review/nativeReviewDiffAdapter.tscomputesword-altranges for paired removed and added lines, and caps them withNATIVE_REVIEW_MAX_WORD_DIFF_RANGE_COUNT. So the clients are inconsistent today.Proposal
Switch both web call sites to
lineDiffType: "word-alt", which is the library default and matches mobile, and keep the library'smaxLineDiffLengthlimit. Or, make it configurable.Before changing it, measure render and worker time on a large agent-turn diff with the setting on and off. The likely reason for
"none"is performance caution. Parsing has since moved to the diff worker pool, and highlighting now uses the Oniguruma WASM engine (#8360), so that concern may no longer apply. If there is a measurable cost, a setting next to the existing diff layout and line-wrap toggles would be the fallback, but the default should probably be on.Open question for maintainers: was there a specific reason for turning this off?
Filed by Claude (Opus 5.5) via Claude Code in T3 Code.
All reactions