feat(tui): add auto theme mode that follows system/terminal theme#21611
feat(tui): add auto theme mode that follows system/terminal theme#21611ZhangWillThink wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate PRs FoundBased on the search results, there are potentially related PRs addressing similar theme functionality:
These PRs all touch on TUI theme handling and automatic theme detection. You may want to review them to ensure PR #21611 doesn't duplicate efforts or conflicts with existing work. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Replace the binary dark/light toggle with a three-state scheme (auto | dark | light). In auto mode the TUI follows the terminal's reported background color via OSC 11 and renderer events. Users can still force dark or light through the command palette, which now cycles: auto → dark → light → auto. Backward compatible: legacy theme_mode_lock KV entries are migrated on read, and the existing locked()/lock()/unlock()/setMode() API surface is preserved as thin wrappers.
082f8e9 to
adbe48a
Compare
Issue for this PR
Related: #9697, #4464
Type of change
What does this PR do?
Replaces the two separate theme commands ("Toggle theme mode" + "Lock/Unlock theme mode") with a single cycling command that introduces a three-state scheme: auto → dark → light → auto.
In auto mode (the new default), the TUI follows the terminal's reported background color via the existing OSC 11 detection and renderer theme-change events. This infrastructure was already in place but wasn't exposed to users in a clean way — the previous UX required toggling + locking separately, which was confusing.
Key design decisions:
store.scheme("auto" | "dark" | "light") = user preference.store.mode("dark" | "light") = resolved actual mode. These are intentionally separate.theme_schemestores the preference. On init, legacytheme_mode_lockentries are read as fallback for backward compat.locked()/lock()/unlock()/setMode()API preserved as thin wrappers so nothing breaks downstream.TuiTheme.mode()still returns the resolved"dark" | "light", unchanged.Difference from related PRs:
theme_modeconfig override intui.json— this PR exposes the control through the command palette at runtime, no config editing needed. These approaches are complementary.How did you verify your code works?
bun run typecheckpasses across all 13 packages (via turbo)bun test test/cli/tui/theme-store.test.ts(5/5)Screenshots / recordings
Command palette cycling: The "Theme mode" command now shows the current scheme and cycles through auto → dark → light → auto on each selection.
Checklist