Skip to content

feat: add automatic dark/light theme switching based on system preference#397

Merged
simonrw merged 4 commits into
mainfrom
feat/auto-theme-switching
Apr 7, 2026
Merged

feat: add automatic dark/light theme switching based on system preference#397
simonrw merged 4 commits into
mainfrom
feat/auto-theme-switching

Conversation

@simonrw
Copy link
Copy Markdown
Owner

@simonrw simonrw commented Apr 7, 2026

Summary

  • Add a Theme struct with 19 semantic color fields and dark/light palettes, replacing ~90 hardcoded Color:: references across all 13 TUI UI modules
  • Detect system color scheme at startup using dark-light crate (freedesktop portal on Linux) and re-check every 2s in a background thread
  • Add theme = "auto" | "dark" | "light" config option in config.toml to override detection
  • Parameterise syntax highlighting to switch between base16-ocean.dark and base16-ocean.light

Test plan

  • cargo check --all-targets --all-features passes
  • All 389 tests pass (cargo xtask test)
  • All doctests pass (cargo xtask doctest)
  • Visual check: run with system in dark mode, confirm dark palette
  • Visual check: set theme = "light" in config, confirm light palette
  • Toggle system dark mode, confirm TUI switches within ~2 seconds

🤖 Generated with Claude Code

@simonrw simonrw force-pushed the feat/auto-theme-switching branch from db71be8 to de5e440 Compare April 7, 2026 12:15
simonrw and others added 3 commits April 7, 2026 13:41
…ence

Detect the system color scheme using the dark-light crate and
automatically switch the TUI between dark and light palettes. The theme
is re-checked every ~5 seconds so toggling the desktop dark mode is
reflected without restarting.

- Add Theme struct with 19 semantic color fields and dark/light palettes
- Add ThemePreference config option (auto/dark/light) in config.toml
- Replace ~90 hardcoded Color:: references across all 13 UI modules
- Parameterise syntax highlighting to switch between base16-ocean themes
- Invalidate syntax cache on theme change via extended thread-local key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous implementation called dark_light::detect() on the main
thread every ~5 seconds, which blocked the UI during the synchronous
D-Bus call. Move detection to a dedicated background thread
(tui-theme-watcher) that sleeps independently and sends ThemeChanged
events through the existing event channel when the system color
scheme changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@simonrw simonrw force-pushed the feat/auto-theme-switching branch from de5e440 to 278ab73 Compare April 7, 2026 12:41
@simonrw simonrw enabled auto-merge (squash) April 7, 2026 13:00
@simonrw simonrw merged commit 6b66e6a into main Apr 7, 2026
14 checks passed
@simonrw simonrw deleted the feat/auto-theme-switching branch April 7, 2026 13:02
@github-actions github-actions Bot mentioned this pull request Apr 7, 2026
simonrw pushed a commit that referenced this pull request Apr 7, 2026
## 🤖 New release

* `dap-gui-config`: 0.1.0 -> 0.2.0 (⚠ API breaking changes)
* `dap-gui-ui-core`: 0.1.0 -> 0.1.1 (✓ API compatible changes)
* `dap-gui-egui`: 0.1.0 -> 0.1.1
* `dap-tui`: 0.1.0 -> 0.1.1

### ⚠ `dap-gui-config` breaking changes

```text
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field Config.theme in /tmp/.tmppHoepB/dap-gui/crates/config/src/lib.rs:26
```

<details><summary><i><b>Changelog</b></i></summary><p>

## `dap-gui-config`

<blockquote>

##
[0.2.0](dap-gui-config-v0.1.0...dap-gui-config-v0.2.0)
- 2026-04-07

### Added

- add automatic dark/light theme switching based on system preference
([#397](#397))

### Other

- release v0.1.0 ([#394](#394))
</blockquote>

## `dap-gui-ui-core`

<blockquote>

##
[0.1.1](dap-gui-ui-core-v0.1.0...dap-gui-ui-core-v0.1.1)
- 2026-04-07

### Added

- add automatic dark/light theme switching based on system preference
([#397](#397))
- add log rotation, non-blocking writes, and CLI log flags
([#398](#398))
- use launch config cwd and show file browser overflow
([#396](#396))
- add configurable keybindings with TOML config file
([#393](#393))
</blockquote>

## `dap-gui-egui`

<blockquote>

##
[0.1.1](dap-gui-egui-v0.1.0...dap-gui-egui-v0.1.1)
- 2026-04-07

### Added

- add automatic dark/light theme switching based on system preference
([#397](#397))
- use launch config cwd and show file browser overflow
([#396](#396))
- add configurable keybindings with TOML config file
([#393](#393))
</blockquote>

## `dap-tui`

<blockquote>

##
[0.1.1](dap-tui-v0.1.0...dap-tui-v0.1.1)
- 2026-04-07

### Added

- add automatic dark/light theme switching based on system preference
([#397](#397))
- add log rotation, non-blocking writes, and CLI log flags
([#398](#398))
- use launch config cwd and show file browser overflow
([#396](#396))
- add readline keybindings and input history to all text input fields
- add configurable keybindings with TOML config file
([#393](#393))
- default to file picker panel on startup without target
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant