docs/theme-screenshot-diff.md
A test + CI job that renders before vs. after screenshots whenever a pull request changes a built-in theme, so reviewers can see exactly what a color tweak does instead of eyeballing RGB triples in a JSON diff (e.g. #2372, an APCA-contrast audit that touched seven themes).
cargo test and surfaced as a downloadable build artifact on the PR's
checks — no manual steps, no repo writes, no comment spam.theme_screenshot_gallery scene suite and BlogShowcase SVG renderer
rather than inventing a second capture path.#[ignore]d so it never
runs (or slows) the default cargo nextest job; it only runs in its
dedicated, path-filtered workflow.Themes ship as JSON under crates/fresh-editor/themes/*.json and are embedded
at compile time, but the editor also loads themes at runtime from a
themes_dir. The test exploits this:
git show <base-ref>:crates/fresh-editor/themes/<name>.json.Each version is written into a throw-away themes_dir under a unique name and
selected through config.theme, so one process can render both versions with
no recompile and no global state.
Base ref resolution (first that works):
FRESH_THEME_BASE_REF env → git merge-base HEAD origin/master → origin/master
→ master. If none resolve (e.g. shallow clone with no base), the test prints a
notice and renders after only.
The test is theme_diff_gallery
(crates/fresh-editor/tests/e2e/theme_screenshots.rs, #[ignore]).
FRESH_THEME_DIFF_THEMES=dark,nord restricts to a list;
FRESH_THEME_DIFF_ALL=1 forces all built-in themes.FRESH_THEME_DIFF_ALL=1).docs/blog/theme-diff/ (git-ignored):
docs/blog/theme-diff/index.html — top-level index linking every processed
theme and how many color keys changed.docs/blog/theme-diff/<theme>/index.html — a table of the changed color
keys (old → new) followed by every captured frame as a before | after pair.docs/blog/theme-diff/<theme>/{before,after}/ — the raw SVG frames +
showcase.json metadata for each side.git_explorer plugin → file_status_* colors) and an LSP status
indicator (fake LSP server → status_lsp_on_*). Best-effort scenes
(git/LSP/terminal) skip or snap-whatever-rendered on both sides identically,
so frames always stay aligned. Diagnostics/diff overlays use theme-keyed
OverlayFace::Style, so those colors come from the theme, not fixed RGB.wait_until, which returns the instant its condition holds (git status,
LSP "on" pill, and terminal pane each settle in tens of ms) — no fixed
sleeps or polling budgets. The bulk is the ~4s/side of real keystroke +
render work across the scene suite. The run scales linearly with the number
of changed themes; the CI job and render step are time-boxed so a stuck
wait_until fails fast instead of hanging.~/.config; every theme is loaded
from a per-run temp dir..github/workflows/theme-screenshots.yml:
pull_request events whose changes touch
crates/fresh-editor/themes/**.FRESH_THEME_BASE_REF, then runs the test with
--run-ignored ignored-only.docs/blog/theme-diff/ as an artifact and writes a short summary
(themes changed, link to the artifact) to the job summary.# Only the themes you changed vs. origin/master:
scripts/generate-theme-diff.sh
# A specific theme, against an explicit base:
FRESH_THEME_BASE_REF=origin/master FRESH_THEME_DIFF_THEMES=dark \
scripts/generate-theme-diff.sh
# then open docs/blog/theme-diff/index.html