fix: solve #3567 — diff pane ignores custom theme colors

Draft
GI
7mo ago
+78-25

Root cause

WorkspaceDiff.tsx (v2 diff pane) spread baseThemeVars from getDiffViewerStyle(activeTheme, ...) and then overwrote --diffs-addition-color-override, --diffs-deletion-color-override, and --diffs-modified-color-override with hardcoded Tailwind CSS variables (var(--color-green-400), etc.). Because those keys are the same ones getDiffViewerStyle derives from the theme's editor.colors.{addition,deletion,modified}, any custom theme's diff colors were silently discarded for the diff view.

Fix

Extracted the theme var construction into a small buildDiffThemeVars helper that returns getDiffViewerStyle(theme, fontSettings) verbatim, and dropped the inline hardcoded override block in WorkspaceDiff.tsx. The v1 LightDiffViewer already did the right thing; this brings v2 into line.

Tests

Added buildDiffThemeVars.test.ts with two cases (dark + light) that build a theme with distinct editor.colors.{addition,deletion,modified} values and assert the matching --diffs-*-color-override vars come through unchanged. These tests fail against the pre-fix logic (they observed var(--color-green-400) / var(--color-green-700)) and pass after the helper is simplified — acting as a regression guard against reintroducing a hardcoded override.

bun test for the new suite passes; repo-wide bun run typecheck and bun run lint:fix are clean.

Closes #3567


Summary by cubic

Restores custom theme diff colors in the v2 diff pane by removing hardcoded overrides and using theme-derived values, aligning v2 with v1 and respecting editor.colors.{addition,deletion,modified}. Closes #3567.

  • Bug Fixes
    • Replaced inline Tailwind color overrides with buildDiffThemeVars, which returns getDiffViewerStyle(...) unchanged.
    • Updated WorkspaceDiff so --diffs-*-color-override values come from the active theme.
    • Added unit tests for dark and light themes to prevent regressions.