Support the terminal color palette update notifications protocol (terminal dark/light mode detection)#6151
Open
yorickvP wants to merge 3 commits into
Open
Support the terminal color palette update notifications protocol (terminal dark/light mode detection)#6151yorickvP wants to merge 3 commits into
yorickvP wants to merge 3 commits into
Conversation
Author
|
I'm using this in my own app with class TApp(App):
def on_terminal_color_theme(self, message: TerminalColorTheme):
match message.theme:
case "light":
self.theme = "catppuccin-latte" # "textual-light"
case "dark":
self.theme = "catppuccin-mocha" # "textual-dark" |
Author
|
@willmcgugan I'm getting a lot of mileage out of this, could you share some thoughts on it? |
yorickvP
force-pushed
the
color-palette-updates
branch
from
January 1, 2026 10:25
1b6b427 to
1d8f7b7
Compare
yorickvP
force-pushed
the
color-palette-updates
branch
from
March 20, 2026 08:24
1d8f7b7 to
67b0855
Compare
4 tasks
This was referenced May 8, 2026
Closed
|
Would love to see this landed! |
mdrxy
added a commit
to langchain-ai/deepagents
that referenced
this pull request
May 10, 2026
Fixes part 1 of #2146 --- Add per-terminal theme mapping so users switching between terminals (e.g. dark iTerm vs. light Apple Terminal) get the right theme automatically without re-picking each time. ## Changes - Add `[ui.terminal_themes]` config table keyed on `TERM_PROGRAM` — looked up before the saved global preference in `_load_theme_preference`, after the `DEEPAGENTS_CLI_THEME` env var override - Introduce `_resolve_theme_name` to canonicalize theme values (registry key, human label, case-insensitive, whitespace-tolerant, plus `textual-ansi` → `ansi-light` legacy migration) shared across env var, terminal mapping, and saved-preference resolution paths - Add `save_terminal_theme_mapping` for atomic TOML writes to `[ui.terminal_themes]`; preserves existing table entries and repairs malformed scalar values with a warning - Extend `ThemeSelectorScreen` with `n` to toggle between human-readable labels and canonical registry keys, and `t` to persist the highlighted theme for the current `TERM_PROGRAM` without touching `[ui].theme` — the picker stays open and the `(default)` badge updates in place, so users can keep browsing - Badge the option list with `(default)` when a theme matches the current terminal's saved mapping; combine with `(current)` as `(current, default)` when both apply - Serialize `config.toml` writes with a process-local lock so a quick `t`-then-Enter sequence can't clobber either mutation PR 1 of 2 — system dark/light auto-detection will follow once Textualize/textual#6151 lands upstream. --------- Co-authored-by: Mason Daugherty <github@mdrxy.com> Co-authored-by: Mason Daugherty <mason@langchain.dev>
yorickvP
force-pushed
the
color-palette-updates
branch
from
July 23, 2026 08:00
67b0855 to
79d44ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for the color palette update notifications protocol. Changing the terminal color theme will generate a
Messages.TerminalColorTheme, and one will be generated at the start.This can be used to implement auto light/dark theme switching.
In the future, this could be extended to the web and to implement automatic theme switching inside textual (maybe using
TEXTUAL_THEME=dark=textual-dark,light=textual-lightor something similar).Please review the following checklist.