Skip to content

feat(theme): prioritize user themes over embedded themes and add white theme - #47

Merged
Blankeos merged 2 commits into
Blankeos:mainfrom
felipecm-br:feat/user-theme-priority-and-white-theme
Nov 5, 2026
Merged

Blankeos merged 2 commits into
Blankeos:mainfrom
felipecm-br:feat/user-theme-priority-and-white-theme

Conversation

@felipecm-br

Copy link
Copy Markdown
Contributor

Summary

  • User Theme Override Priority: Prioritizes user themes loaded at runtime from ~/.config/lazygitrs/themes/*.json (and ~/.config/lazygit/themes/*.json) over compile-time embedded themes. Previously, embedded themes were checked first in both load_color_themes() and ColorTheme::to_theme(), preventing users from overriding existing themes with custom palettes.
  • High-Contrast White Theme: Adds src/themes/white.json, providing a clean, pure black-on-white high-contrast theme suited for bright daylight and e-ink displays.
  • Unit Tests: Added test coverage verifying that the white theme is discovered, resolves with ThemeAppearance::Light, and initializes expected color properties.

Verification

  • cargo fmt checked.
  • cargo test --bin lazygitrs (373 passed).

@Blankeos

Blankeos commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

feat/user-theme-priority-and-white-theme → main
Model: claude-sonnet-5-5, effort unknown

Confidence: 5/5

Checks run: cargo test on the branch with my follow-up: 372 passed, 0 failed. Built the PR for Linux and ran it in a temp repo: the White theme is legible on a light terminal, and a user white.json with the same id overrides the built-in (verified with a magenta accent).
Confidence bumps: none left. Note: no theme paints a background, so White (like github-light and the other light themes) is unreadable on a dark terminal; not specific to this PR.

Summary

Update: I pushed 3b1748c to this branch (maintainer edit): the test now parses the embedded white.json directly instead of reading the real user themes dir, separator (#e8e8e8 -> #b2b2b2) and diff_line_number (#c0c0c0 -> #8c8c8c) are darker so they are visible on white, a comment named the wrong dir, and the README says a custom theme with a built-in's id replaces it. Reviewed with Opus.

Thanks Felipe, nice and tight. This moves user themes (~/.config/lazygitrs/themes/*.json and the lazygit dir) ahead of the embedded ones in both load_color_themes() and ColorTheme::to_theme(), so a user file with the same id now overrides a built-in. It also adds a high-contrast white theme and a test. The ordering is consistent in both places (list entry and resolved colors both come from the user file), which is the part that could easily have drifted. Two small notes: to_theme() now scans the themes dir on disk for every non-default theme before checking embedded ones (it is only called from src/gui/mod.rs, so no hot loop, fine). And the test calls load_color_themes(), which reads the real user config dir, so a developer who has their own white.json locally could get a different result. Optional: mention the override behavior in the docs/README.

Map

flowchart LR
  W[src/themes/white.json] -->|include_dir CUSTOM_THEMES_DIR| L[load_color_themes]
  U[user themes dir] --> D[discover_user_themes]
  D --> L
  U --> LU[load_user_theme]
  LU --> T[ColorTheme::to_theme]
  W --> T
  L --> G[gui/mod.rs theme picker]
  T --> G
Loading

Regressions

  • Behavior change by design: a user theme file whose id matches a built-in now silently replaces it. Anyone with an old copy of a built-in theme in their themes dir will start seeing that copy instead of the updated embedded one.
  • to_theme() does a disk read of the themes dirs for every non-default theme switch (was only a fallback before). Negligible, single caller in src/gui/mod.rs:1220.
  • Test depends on the real user config dir (a local white.json could break it).
  • Otherwise none found; no other open PR (42-50) touches theme files.

Migrations

None. No config keys or formats change. New white id is additive; users already having their own white.json will keep theirs (now with priority).

Before merging

  • cargo test passes (PR says 373 passed)
  • Select White in the theme picker and check selected row, diff add/remove, borders, and popups are readable
  • Decide whether the override-built-ins behavior should be noted in docs
  • Optional: make the test not depend on the user config dir

@Blankeos Blankeos left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after review and checks (see the pr-review comment).

@Blankeos
Blankeos merged commit 2a7a13d into Blankeos:main Nov 5, 2026
6 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.

2 participants