Skip to content

fix(site): correct diff viewer colors across all themes - #32073

Merged
jaaydenh merged 3 commits into
mainfrom
fix/diff-viewer-theme-colors
Nov 12, 2026
Merged

jaaydenh merged 3 commits into
mainfrom
fix/diff-viewer-theme-colors

Conversation

@jaaydenh

@jaaydenh jaaydenh commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

The code diff viewers (Agents git panel, inline edit_files/write_file diffs, SyntaxHighlighter diffs, audit log diff) rendered wrong colors in every theme. This PR applies the corrected standard dark palette and extrapolates it to the light and colorblind themes.

Two causes:

  • The --surface-git-* token values were off, and there were no tokens for word-level highlights.
  • @pierre/diffs 1.5.1 uses --diffs-bg-*-override only as a color-mix target. In dark mode it renders changed lines as 80% code background and 20% token, so the tokens came out much darker than defined. fix: use theme git colors in the agents diff viewer #31867 routed the theme tokens into the viewer, which made this more visible. The new DIFFS_GIT_COLOR_CSS (passed as unsafeCSS) sets that mix to 0% on changed lines, so lines render the token exactly. Hover still tints changed lines.

Changes:

  • index.css: new line colors for each theme, plus new --surface-git-added-emphasis and --surface-git-deleted-emphasis tokens for word highlights.
  • diffsGitColors.ts: one shared module for the diff style overrides and the CSS. SyntaxHighlighter, DiffViewer, and the tool diffs now all use it, so SyntaxHighlighter no longer keeps its own copy.
  • DiffFileHeader now uses bg-surface-secondary, matching the git panel header (#18181B in dark).
  • Git panel diff viewer: each file is a rounded surface-secondary card with the code inset 4px inside it, cards are 8px apart, and the header has no bottom border. CodeView computes item heights from itemMetrics rather than measuring them, so the 4px frame below the code is added to paddingBottom.
  • Git panel code background is pinned to --surface-primary (#09090B dark, white light). The app's DiffsWorkerPoolProvider theme (coder-dark/coder-light) replaces each viewer's theme option, and its editor background is the same gray as the card, so the code and header were indistinguishable. Storybook has no worker pool, which is why it looked correct there.
  • File headers (git panel and inline tool diffs) show plain colored +N −N counts through a shared DiffStatsText instead of badges.
  • Line numbers on changed lines keep a 25% blend with the code background, so the gutter is slightly darker than the line in every renderer.
  • Audit log diff highlights now use the emphasis tokens.
  • New EditFilesSingleSuccess{Light,ProtanDeuter,Tritan} stories, so Pixel has baselines outside the default dark theme.
Theme Added line Deleted line Added word Deleted word
dark #1F2F1F #382423 #1F4F28 #5F2F2E
light #E2F7E2 #FFEBE9 #BDE8BC #FFCDCA
dark-protan-deuter #182D3A #37261D #03496A #5D321D
light-protan-deuter #E2F3FF #FFECE3 #B6E1FF #FFCFB9
dark-tritan #182D3A #382423 #03496A #5F2F2E
light-tritan #E2F3FF #FFEBE9 #B6E1FF #FFCDCA

The colors were checked in Storybook with Playwright, reading computed styles inside the diff shadow DOM. Every theme and all three renderers match the table exactly, and the header is #18181B in dark and #F4F4F5 in light. The card frame and the gaps were checked from painted pixels, and the gap between cards stays at exactly 8px while scrolling a large diff, which confirms the height metrics match the DOM.

Screenshots

Coder Agents git panel diff viewer, rendered with the app's coder-dark/coder-light highlighting theme (the one DiffsWorkerPoolProvider applies).

Dark Light
Standard Diff viewer, dark theme Diff viewer, light theme
Protanopia / deuteranopia Diff viewer, dark protan-deuter theme Diff viewer, light protan-deuter theme
Tritanopia Diff viewer, dark tritan theme Diff viewer, light tritan theme
Color derivation and decision log

Given (standard dark): added line #1F2F1F, file header #18181B, added word highlight #1F4F28, deleted word highlight #5F2F2E.

Method: convert the reference colors to OKLCH. Keep each role's lightness and chroma, and rotate the hue to the theme's added or deleted hue. This keeps perceived contrast consistent across hues.

  • Hues: green 144.6 and red 22.3 come from the references. Sky 238.1 (199 89% 48%) and orange 46.7 (24 95% 53%) come from the existing colorblind --git-added/--git-deleted tokens.
  • Dark deleted line (not supplied): uses the added line's lightness, with chroma scaled by the deleted/added word-highlight chroma ratio, so it stays as muted as the supplied red. Result: #382423.
  • Light themes: line L 0.955 and C 0.035, word highlight L 0.89 and C 0.075. The light red/green values come out almost identical to GitHub's light diff palette (#FFEBE9/#FFCECB), which is a useful sanity check.
  • Protan-deuter swaps to the sky/orange hues and tritan to sky/red, matching the existing palette rationale in index.css.
  • Chroma is reduced where needed to stay inside sRGB. HSL tokens are rounded so they map back to the same 8-bit hex.

Header: --surface-secondary in dark is already #18181B, so the git panel header was correct. The inline tool diff header was transparent over the Shiki theme background (#0A0C10), so it now uses bg-surface-secondary.

Placement: diffsGitColors.ts sits next to shikiTheme.ts, which is already the shared @pierre/diffs theming module used outside AgentsPage (for example by DiffsWorkerPoolProvider).

Risk: DIFFS_GIT_COLOR_CSS depends on --mix-light, --mix-dark, and --diffs-mixer, which are internal to @pierre/diffs 1.5.1. The JSDoc says so; recheck after library upgrades.

Card layout: taken from a dark-mode reference screenshot, measured by pixel: #18181B card on the #09090B page, code inset with rounded corners, plain-text stats, and a changed-line gutter slightly darker than the line. The inline tool diffs keep their existing bordered card and header border; only their stats changed, so both headers match. The reference also showed a collapse chevron, which is a new feature and is not included. Its added count is #16A34A; this keeps --git-added-bright (#22C55E in dark), so colorblind themes still apply.

Contrast: in light-protan-deuter, the --git-*-bright stat text on #F4F4F5 is about 2.6:1. The tokens and that contrast are unchanged from the previous badges.

Self-review: ran frontend-deep-review (8 roles) and frontend-review (FE1 to FE10). Fixed: an inlined single-use constant, trimmed comments, renamed the module to avoid confusion with AgentsPage/utils/diffColors, and added theme stories (SyntaxHighlighter renders inside data-pixel="ignore", so its stories would not give Pixel coverage). Left as is: a pre-existing near-duplicate between DiffViewer's HeaderContent and DiffFileHeader (nit, out of scope).

🤖 This PR was generated by Coder Agents on behalf of @jaaydenh.

Use the supplied standard dark diff colors and extrapolate them to the light and colorblind themes. Add word-highlight tokens, stop @pierre/diffs from blending changed-line backgrounds into the code background, and give the inline tool diff header the same surface as the git panel header.
@jaaydenh
jaaydenh requested a review from a team as a code owner November 12, 2026 09:13
@jaaydenh
jaaydenh temporarily deployed to main November 12, 2026 09:13 — with GitHub Actions Inactive
Match the reference design: each file in the git panel diff viewer is a rounded surface-secondary card with the code inset inside it, file headers show plain coloured line counts, and changed-line gutters are slightly darker than the line.
@jaaydenh
jaaydenh temporarily deployed to main November 12, 2026 09:58 — with GitHub Actions Inactive
@jaaydenh
jaaydenh temporarily deployed to main November 12, 2026 09:58 — with GitHub Actions Inactive
The app's worker pool theme replaces the CodeView theme option, and its editor background matches the card, so the code area rendered the same gray as the header. Pin the git panel code background to surface-primary.
@jaaydenh
jaaydenh temporarily deployed to main November 12, 2026 10:12 — with GitHub Actions Inactive
@jaaydenh
jaaydenh temporarily deployed to main November 12, 2026 10:13 — with GitHub Actions Inactive
@jaaydenh
jaaydenh temporarily deployed to main November 12, 2026 10:56 — with GitHub Actions Inactive
@jaaydenh
jaaydenh merged commit 362f360 into main Nov 12, 2026
36 of 37 checks passed
@jaaydenh
jaaydenh deleted the fix/diff-viewer-theme-colors branch November 12, 2026 11:42
@jaaydenh
jaaydenh temporarily deployed to main November 12, 2026 11:42 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 12, 2026

This branch was previously deployed

1 inactive deployment
main — c56fa58c Deployed Nov 12, 2026 by jaaydenh via cla #254881
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants