Skip to content

feat(web): syntax and word highlighting in diffs, visible dark tints, collapsed commit bodies - #362

Merged
PastaPastaPasta merged 7 commits into
masterfrom
feat/e8-diffs
Oct 4, 2026
Merged

PastaPastaPasta merged 7 commits into
masterfrom
feat/e8-diffs

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

What

The diff half of the theming review (E8, T-5/6/7/11/12):

  • Syntax highlighting in diffs. Each side of a changed file (old: everything not added; new: everything not deleted) runs through the blob view's highlightBlob, so multi-line strings and comments colour correctly. It reuses the same lazily loaded highlight.js chunk and the same size and line caps. The language comes from the file name only. Guessing could pick different languages for the two sides, so a file with no known extension stays plain.
  • Changed words. Each deleted line is paired with the added line at the same place in the run that follows (the side-by-side pairing). A token-level LCS then marks the words that differ. A pair that shares less than 30% is a rewrite and gets no marks; lines over 400 tokens are skipped; each file stops after 4M comparison cells. The marks show at once, and the syntax colours follow when the chunk loads.
  • Word breaks. Side-by-side cells use overflow-wrap: anywhere instead of break-all, so environment no longer renders as env│ironment.
  • Visible dark tints. Row tints come from CSS tokens: 10% in light, 16% in dark (was 10%, about 1.1:1 against the page). Each changed line's code cell also gets a 2 px edge in its marker colour, a cue that does not depend on the tint. The colour-blind palette is a data-diff-palette override of the same tokens.
  • Collapsed commit bodies. A long body (over 4 lines or 360 characters) starts at its first 3 lines with "Show full message" at every width, not only on phones, and renders in mono. On the dash commit c41035f7, the first diff moves from y=1557 to y=967.
  • Accent and semantic leaks. Syntax colours become --syn-* tokens, so one rule serves both themes. Keywords move off the ember accent to violet, so they no longer read as links. A selected line or range uses an accent tint instead of the amber "availability risk" colour, and the "unchanged lines" row uses a raised surface instead of Dash blue.

How tested

  • tsc, eslint --max-warnings 0, vitest. The new and updated tests are:
    • lib/view/word-diff.test.ts: tokenizing, spans, pairing and the budget.
    • lib/view/diff-highlight.test.ts: side reconstruction, escaping, word marks inside highlight.js HTML, a multi-line comment, no guessed language, an added file.
    • lib/design/contrast.test.ts: every syntax colour on every row and changed-word tint in both palettes and themes, on the page and on a selected line. It also checks that the CSS diff tokens equal DIFF_PALETTES and that keywords are not the accent.
  • Static export against sakura. On the commit page, a long-task observer saw no main-thread task over 100 ms after highlighting (/tmp/claude-501/e8/perf.mjs).
  • Screenshots (1280 px, light and dark), with the PR1 changes underneath:
    • after: dash-forge-qa/evidence/p0/e8/after-pr2/ (commit-dash-word-diff-*: the changed .c_str() marked; commit-dash-cpp-diff-*, commit-dash-diff-*, commit-dash-*)
    • before: dash-forge-qa/evidence/p0/e8/before/

Review

A high-effort code review found no XSS path (markSpans only sees highlight.js spans or escaped text) and eight other items, fixed here: a side over 128 KiB, or one highlight.js cannot colour, leaves both sides plain; the page's files are coloured one side per task so many open diffs never block at once; line HTML is built once per line; a pair over the token cap no longer spends the file's word budget; tokens keep combining marks and emoji sequences whole; a collapsed commit body renders only its first lines, so hidden links take no focus (new commit-body.test.tsx); word marks are square so one change across syntax spans reads as one; the selected-line contrast check uses each theme's own token. Not changed: in split view, a pair cut by "Show more" keeps its word marks; its partner appears with the next page.

Limits

  • No "Wrap lines" toggle with per-side horizontal scroll yet. Wrapping at word boundaries fixes the mid-word breaks.
  • Highlighting is cached per rendered file, not by blob OID across pages.
  • Pairing follows the side-by-side layout, so a deletion followed by an unrelated insertion gets no word marks, like a rewrite.

#360 is merged; this now targets master. #365 contains this branch's head, so it lands with #365 if that merges first.

🤖 Generated with Claude Code

… collapsed commit bodies

Diffs reuse the blob view's lazy highlight.js chunk on both sides of the file (by file name, never a guess) and mark the changed words of each paired line, within a per-file comparison budget. Row tints come from CSS tokens (10% light, 16% dark) with a 2px edge in the marker colour; split cells wrap at word boundaries instead of break-all. Syntax colours become --syn-* tokens with keywords off the accent, all checked on every diff tint. Selected lines use an accent tint instead of amber, the unchanged-lines row a raised surface instead of Dash blue, and long commit bodies start at three mono lines with Show full message.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 344bc4e0-4f14-4369-bbaa-44be59c5442b
📥 Commits

Reviewing files that changed from the base of the PR and between e5ba904 and 4604b60.

📒 Files selected for processing (15)
  • docs/design/style-guide.md
  • forge-web/app/globals.css
  • forge-web/components/repo/blame-content.tsx
  • forge-web/components/repo/blob-content.tsx
  • forge-web/components/repo/commit-body.test.tsx
  • forge-web/components/repo/commit-content.tsx
  • forge-web/components/repo/diff-view.tsx
  • forge-web/lib/design/contrast.test.ts
  • forge-web/lib/view/diff-highlight.test.ts
  • forge-web/lib/view/diff-highlight.ts
  • forge-web/lib/view/highlight.ts
  • forge-web/lib/view/prefs.ts
  • forge-web/lib/view/word-diff.test.ts
  • forge-web/lib/view/word-diff.ts
  • forge-web/tailwind.config.js
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

PastaPastaPasta and others added 5 commits October 4, 2026 12:19
…apsed body

A diff side over 128 KiB, or one highlight.js cannot colour, leaves both sides plain, and the page's files are coloured one side per task so many open diffs never block at once. Line HTML is built once per line. A pair over the token cap no longer spends the file's word-diff budget, and tokens keep combining marks and emoji sequences whole. A collapsed commit body renders only its first lines, so hidden links take no focus. Word marks are square so a change across syntax spans reads as one, and the selected-line contrast check uses each theme's own token.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@PastaPastaPasta
PastaPastaPasta deleted the branch master October 4, 2026 18:33
@PastaPastaPasta
PastaPastaPasta changed the base branch from feat/e8-visual-p0 to master October 4, 2026 18:33
@PastaPastaPasta
PastaPastaPasta merged commit 8e344db into master Oct 4, 2026
12 of 13 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the feat/e8-diffs branch October 4, 2026 23:43
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.

1 participant