Skip to content

Themes: Harvest bundled diff accents from real VS Code tokens - #828

Merged
benvinegar merged 4 commits into
modem-dev:mainfrom
masonmcelvain:fix/theme-diff-color-harvest
Aug 29, 2026
Merged

benvinegar merged 4 commits into
modem-dev:mainfrom
masonmcelvain:fix/theme-diff-color-harvest

Conversation

@masonmcelvain

@masonmcelvain masonmcelvain commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Replaces the hand-collected theme diff colors with auto-generated ones and a script to regenerate them on demand. Also pins the @shikijs/themes package as a devDependency.

Changes

  • Add scripts/generate-theme-diff-colors.ts (bun run generate:theme-colors), which rewrites the table in src/core/theme/catalog.ts between generated markers.
  • Regenerate the table: 60 entries, all values now 6-digit unblended palette tokens.
  • Pin @shikijs/themes as an exact devDependency at 3.23.0 (the version @pierre/diffs' shiki resolves in bun.lock) so the harvest and the runtime highlighter read the same theme JSONs.

Tests

  • A drift test re-harvests the installed @shikijs/themes and compares it to the checked-in table.
  • Policy unit tests cover alpha stripping, hue/saturation rejection, pre-blend rejection, and the slack drop rule.
  • src/core/theme/catalog.test.ts adds independent table-driven checks (6-digit hex, red-family removed, green/teal-family added, no greys) with locally re-derived hue math.
  • A version-sync test fails if the pin and Pierre's resolved shiki drift apart.
  • Update the two themes.test.ts expectations that asserted the old GitHub added accents (#3fb950 → #2ea043, #1a7f37 → #116329).

QA

Smoke-check visually: --theme rose-pine (deleted rows red, not purple), --theme gruvbox-dark-medium (added rows green, not beige), --theme tokyo-night, --theme slack-dark (generic fallback accents).

bun run src/main.tsx -- diff --theme rose-pine
Theme 0.19.0 Feature
rose-pine image image
everforest-dark image image
everforest-light image image
gruvbox-dark-medium image image
tokyo-night image image
slack-dark image image
slack-ochin image image

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

@masonmcelvain is attempting to deploy a commit to the Modem Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@benvinegar

Copy link
Copy Markdown
Member

@masonmcelvain Thank you for submitting 🙏

Okay this is good to go but I want to merge #825 first, I have some questions there to address.

masonmcelvain and others added 4 commits August 28, 2026 22:14
Replace the hand-collected BUNDLED_SHIKI_THEME_DIFF_COLORS table with
one generated by a script

Mechanics: per-slot token priority (editorGutter -> diffEditor ->
terminal.ansi -> gitDecoration), alpha stripped instead of composited,
and hue/saturation/contrast validation with fall-through to the next
source or the generic fallback palette.

The old table stored mis-sourced VS Code tokens for ~25 themes:
gitDecoration file-label colors, alpha tokens flattened onto the editor
background at harvest time, and unrelated tokens (slack's white
"removed", min-light's badge-grey "modified"). buildShikiTheme then
composited those pre-blended values onto the background again,
producing washed-out or wrong-hue diff rows, signs, and badges.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Lock the generated table two ways: policy unit tests plus a drift test
that re-harvests the installed @shikijs/themes and compares it to the
checked-in table, and independent table-driven checks in catalog.test.ts
(6-digit hex, red-family removed, green/teal-family added, no greys)
that deliberately re-derive hue locally so a harvester bug cannot
certify its own output.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Declare @shikijs/themes as an exact-version devDependency matching the
shiki version @pierre/diffs resolves, so the harvest and the runtime
highlighter see the same theme data and future bumps are a deliberate,
visible diff line.

A conformance test fails if the pin and Pierre's resolved shiki drift
apart.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The harvested everforest-light removed accent rescues to a pale red whose
readable tint band is narrow. At 0.02 steps the word-emphasis tint rounds
down to 0.12 even though a 0.13 blend is still readable, and accumulated
float drift skips the final 0.02 row step, so the pair collapses and the
renderer guard rewrites it at the cost of the 4.5:1 text guarantee.

Search tint amounts at 0.01 granularity with integral step counts so the
emphasis tint stops at its full readable strength and the row search never
skips its last step.
@benvinegar
benvinegar force-pushed the fix/theme-diff-color-harvest branch from 811f977 to 1e21550 Compare August 29, 2026 02:27
@benvinegar

Copy link
Copy Markdown
Member

Rebased onto main (post-#825) and force-pushed — the branch conflicted in themes.test.ts, package.json, bun.lock, and AGENTS.md.

One real interaction surfaced beyond textual conflicts: the harvested everforest-light removed accent (#f1706f, rescued to #e36968) has a tint band too narrow for #825's separation policy. At 0.02 steps the word-emphasis tint rounded down to 0.12 even though 0.13 is still readable (4.52:1), and float drift (0.12 - 0.02×5 = 0.0199…) skipped the final row step — so the pair collapsed and the renderer guard rewrote it at 4.13:1 text contrast. Added a follow-up commit that searches tint amounts at 0.01 granularity with integral step counts; everforest-light now derives content #fae4d3 / row #fcf2df at exactly 28 separation. All other bundled themes are unaffected.

Also updated the github-dark-default addedBg expectation (#2ea043 steps to 0.14, not 0.18) and regenerated bun.lock minimally (only the @shikijs/themes entry — it was already in the graph via shiki).

@benvinegar
benvinegar merged commit f0fc408 into modem-dev:main Aug 29, 2026
11 of 12 checks passed
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.

Bundled diff-color catalog stores mis-sourced VS Code theme tokens

2 participants