Skip to content

feat: add per-mode theme overrides - #2324

Open
aneym wants to merge 1 commit into
herdrdev:masterfrom
aneym:pr/theme-custom-modes
Open

feat: add per-mode theme overrides#2324
aneym wants to merge 1 commit into
herdrdev:masterfrom
aneym:pr/theme-custom-modes

Conversation

@aneym

@aneym aneym commented Aug 4, 2026

Copy link
Copy Markdown

Summary

[theme.custom] applies one set of overrides in both modes, so with auto_switch a value tuned for the dark theme washes out when the light theme activates. #837 proposed per-mode blocks and @ogulcancelik approved a PR there.

This adds [theme.custom.light] and [theme.custom.dark]. Resolution order: theme defaults, then [theme.custom], then the block matching the resolved appearance. Configs that do not use the new blocks resolve exactly as they do today.

[theme]
auto_switch = true

[theme.custom]
accent = "#fe640b"

[theme.custom.light]
text = "#2e3145"
subtext0 = "#494c66"

before and after: sidebar rows in the light theme, with and without a light-mode override

Both panes are the same seeded layout rendered with catppuccin-latte active; the only difference is the [theme.custom.light] block.

Refs #837. #2032 asks for the same capability from a full-theme-pair angle; this shape covers it through [theme.custom.light]/[theme.custom.dark] alone.

Test plan

  • Branch rebased onto current master (93e0086). just check steps all pass: fmt, clippy, windows-lint, config-reference parity, integration assets, plugin marketplace, script unittests
  • nextest: 3046 tests, 3043 passed. The 3 failures (live_handoff x2, api_ping pane-info) are pty-timing timeouts that fail identically on unmodified master in the same environment
  • New tests in src/config/theme.rs cover parsing both blocks, per-mode resolution precedence, and that configs without the new blocks resolve unchanged
  • Ran it locally for several days with auto_switch flipping between catppuccin-mocha and catppuccin-latte

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8442d6bf-16b8-4c05-9f7e-ef9ffb63a136

📥 Commits

Reviewing files that changed from the base of the PR and between bd6babf and 1c53cf1.

📒 Files selected for processing (5)
  • docs/next/website/src/content/docs/configuration.mdx
  • docs/next/website/src/data/config-reference.json
  • src/app/mod.rs
  • src/config.rs
  • src/main.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • docs/next/website/src/data/config-reference.json
  • src/main.rs
  • docs/next/website/src/content/docs/configuration.mdx
  • src/config.rs
  • src/app/mod.rs

📝 Walkthrough

Walkthrough

The theme configuration now supports light- and dark-appearance custom color overrides. Automatic theme switching applies active mode overrides after shared custom and legacy accent colors. Tests and documentation cover the new behavior.

Changes

Theme appearance overrides

Layer / File(s) Summary
Theme configuration contract
src/config/theme.rs, src/config.rs
CustomThemeColors defines optional light and dark ModeThemeColors tables. Deserialization tests cover their color values. The type is publicly re-exported.
Mode-aware palette resolution
src/app/state.rs, src/app/mod.rs
Automatic theme selection passes active mode overrides to palette resolution. Palette::with_mode_overrides applies token values after shared custom and legacy accent colors. Tests verify precedence and fallback behavior.
Configuration documentation and examples
docs/next/website/src/content/docs/configuration.mdx, docs/next/website/src/data/config-reference.json, src/main.rs
Documentation, reference data, and default examples describe light and dark appearance-specific color settings.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HostAppearance
  participant resolve_effective_theme
  participant resolve_palette_for_theme_name
  participant Palette
  HostAppearance->>resolve_effective_theme: select light or dark appearance
  resolve_effective_theme->>resolve_palette_for_theme_name: pass active mode overrides
  resolve_palette_for_theme_name->>Palette: apply shared custom colors
  Palette->>Palette: apply active mode-specific colors
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the addition of per-mode theme overrides.
Description check ✅ Passed The description explains the new configuration blocks, resolution order, compatibility, tests, and validation results.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@kangal-bot

Copy link
Copy Markdown
Collaborator

Hi @aneym, thanks for your interest in contributing!

Herdr automatically admits focused bug fixes from contributors who are not maintainers when the title uses fix: ... or fix(scope): ... and the patch changes no more than 20 files and 1,000 total added or deleted lines.

Contributors who are not maintainers may submit only focused bug fixes. If this pull request fixes a bug, rename it to use a conventional fix: ... or fix(scope): ... title, then tag a maintainer to review and reopen it.

Feature requests, behavior changes, and other proposals belong in GitHub Discussions and require maintainer approval before a pull request.

If this gate classified the pull request incorrectly, reply and tag a maintainer listed in .github/MAINTAINERS. A verified maintainer can reopen it; reopening by anyone else will be closed again automatically.

Patch size: 7 changed files, 391 changed lines.

See https://github.com/herdrdev/herdr/blob/master/CONTRIBUTING.md for the contribution policy.

@kangal-bot kangal-bot closed this Aug 4, 2026
@ogulcancelik ogulcancelik reopened this Aug 4, 2026
@kangal-bot kangal-bot added ai-review Trigger automated AI reviews for pull requests admitted by the PR gate maintainer-approved PR scope explicitly approved by a maintainer labels Aug 4, 2026
@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds light- and dark-specific custom color overrides that apply when automatic theme switching resolves the corresponding appearance.

  • Adds [theme.custom.light] and [theme.custom.dark] configuration models and documentation.
  • Layers mode-specific colors after the selected built-in palette and shared custom overrides.
  • Preserves manual theme selection behavior by leaving mode-specific overrides inactive when auto-switching is disabled.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the prior Settings-preview concern is invalid because previewing and applying both target manual mode, while cancellation restores the exact palette captured before Settings opened.

Important Files Changed

Filename Overview
src/config/theme.rs Adds deserializable light and dark custom color blocks while retaining the existing shared override fields.
src/app/mod.rs Selects the override block matching the resolved host appearance and applies it after shared colors.
src/app/state.rs Adds palette application support for all mode-specific color tokens.
docs/next/website/src/data/config-reference.json Documents every supported light- and dark-mode custom color key.
docs/next/website/src/content/docs/configuration.mdx Explains mode-specific theme configuration and override precedence.
src/main.rs Extends the generated default configuration example with light and dark override blocks.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Resolve host appearance] --> B{auto_switch enabled?}
  B -->|No| C[Manual theme]
  B -->|Yes: light| D[Light theme]
  B -->|Yes: dark| E[Dark theme]
  C --> F[Apply shared overrides]
  D --> F
  E --> F
  F --> G{Resolved mode}
  G -->|Manual| H[Final palette]
  G -->|Light| I[Apply custom.light]
  G -->|Dark| J[Apply custom.dark]
  I --> H
  J --> H
Loading

Reviews (5): Last reviewed commit: "feat: add per-mode theme overrides" | Re-trigger Greptile

Comment thread src/app/mod.rs
@aneym
aneym force-pushed the pr/theme-custom-modes branch from 66ee3b8 to d1a4e65 Compare August 8, 2026 02:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/config/theme.rs (1)

126-146: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Add sidebar_bg to mode-specific overrides.

ModeThemeColors omits sidebar_bg, although CustomThemeColors and Palette support it. A user cannot set a light-only or dark-only sidebar background.

Add sidebar_bg to ModeThemeColors. Apply it in Palette::with_mode_overrides. Add parsing and palette-resolution coverage.

Proposed fix
--- a/src/config/theme.rs
+++ b/src/config/theme.rs
 pub struct ModeThemeColors {
     pub accent: Option<String>,
     pub panel_bg: Option<String>,
+    pub sidebar_bg: Option<String>,
     pub surface0: Option<String>,
--- a/src/app/state.rs
+++ b/src/app/state.rs
         if let Some(c) = &custom.panel_bg {
             self.panel_bg = parse_color(c);
         }
+        if let Some(c) = &custom.sidebar_bg {
+            self.sidebar_bg = parse_color(c);
+        }

Based on supplied downstream context, src/app/state.rs:641-692 has the same omission.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1cefb19c-6dd0-416f-9a93-164b72966a75

📥 Commits

Reviewing files that changed from the base of the PR and between 66ee3b8 and d1a4e65.

📒 Files selected for processing (7)
  • docs/next/website/src/content/docs/configuration.mdx
  • docs/next/website/src/data/config-reference.json
  • src/app/mod.rs
  • src/app/state.rs
  • src/config.rs
  • src/config/theme.rs
  • src/main.rs
🚧 Files skipped from review as they are similar to previous changes (6)
  • docs/next/website/src/content/docs/configuration.mdx
  • docs/next/website/src/data/config-reference.json
  • src/main.rs
  • src/app/state.rs
  • src/app/mod.rs
  • src/config.rs

@aneym
aneym force-pushed the pr/theme-custom-modes branch from d1a4e65 to baff68f Compare August 8, 2026 08:57
@aneym

aneym commented Aug 8, 2026

Copy link
Copy Markdown
Author

Added sidebar_bg to the per-mode overrides in baff68f: field on ModeThemeColors, applied in with_mode_overrides, covered in the parse and palette-resolution tests, and documented under theme.custom.light/theme.custom.dark in the config reference.

@aneym
aneym force-pushed the pr/theme-custom-modes branch from baff68f to bd6babf Compare August 10, 2026 08:59
allow [theme.custom.light] and [theme.custom.dark] blocks so custom
overrides can differ per resolved appearance when auto_switch flips.
precedence: theme defaults, then [theme.custom], then the block for
the active mode. configs without the new blocks resolve unchanged.

refs herdrdev#837
@aneym
aneym force-pushed the pr/theme-custom-modes branch from bd6babf to 1c53cf1 Compare August 11, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Trigger automated AI reviews for pull requests admitted by the PR gate maintainer-approved PR scope explicitly approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants