fix(ui): honor color settings in interactive prompt themes (#9999)#10151
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces automatic terminal background color detection to dynamically select an appropriate theme (using a light-friendly theme like base16 on light terminals, and charm on dark terminals) based on the COLORFGBG environment variable. It updates the JSON schema, settings documentation, and theme selection logic in Rust, and adds comprehensive unit tests for the new behavior. There are no review comments, and I have no feedback to provide.
Greptile SummaryThis PR fixes interactive prompts ignoring color settings by making
Confidence Score: 5/5Safe to merge — changes are isolated to theme selection logic with no effect on correctness of any other subsystem. The fix is a small, well-contained change to a UI helper: the disabled-colors short-circuit is straightforward and matches demand's own behavior, the COLORFGBG detection is best-effort with a safe false default, and the pure-helper refactor makes the branches directly testable. All changed paths are covered by the five new unit tests. The behavior delta for existing users (default theme) is zero unless COLORFGBG is set to a light-background value. No files require special attention. Important Files Changed
Reviews (5): Last reviewed commit: "fix(ui): honor color settings in interac..." | Re-trigger Greptile |
2f19f7e to
8e84d46
Compare
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
3d192cd to
986b09d
Compare
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
986b09d to
497c547
Compare
Problem
Reported in discussion #9999: the interactive
mise usetool picker (and otherdemand-based prompts) ignores color settings. On light terminals the default theme is unreadable, andcolor=false/NO_COLORhave no effect on the prompt styling.Root cause
Interactive prompts use the
demandcrate. Its ownTheme::default()already checksconsole::colors_enabled_stderr()and returns an unstyledTheme::new()when colors are disabled:But mise's
src/ui/theme.rs::get_theme()skipped that check and constructed a colored theme (charm()/base16()/ …) directly, so the rawColorSpecvalues were always emitted regardless ofcolor=false/NO_COLOR/CLICOLOR=0(all of which already setcolors_enabled_stderr(false)insrc/config/settings.rs).Changes
get_theme()now returnsTheme::new()(the same unstyled theme demand uses for its default) whencolors_enabled_stderr()is false. This fixes everyget_theme()call site (mise use,mise runtask selection,mise search,mise set,mise upgrade, prompts) at once.color_theme = "auto"option, which is also the new behavior of the default"default". It detects a light background via theCOLORFGBGenv var and picksbase16for readability, otherwisecharm. Explicitcharmkeeps the previous fixed dark theme (no auto-detection). OSC 11 terminal queries are intentionally not used (they can hang / corrupt output).select_theme,colorfgbg_is_light) so both the colored and unstyled branches can be unit-tested without depending on the global color state (the test harness forces colors off globally).settings.toml(enum + docs) and regeneratedschema/mise.jsonviamise run render:schema.Behavior change note
When
color_themeis left at its default, mise now auto-detects a light terminal viaCOLORFGBGand switches tobase16. Terminals withoutCOLORFGBG, and any explicit theme value, behave as before.defaultis documented as an alias forauto; setcharmto force the previous dark theme.Testing
cargo test --bin mise ui::theme::→ 5 passed.cargo build→ clean (pre-existing warnings only).MISE_COLOR=0 mise use/NO_COLOR=1 mise useproduce no ANSI styling;COLORFGBG="0;15" MISE_COLOR_THEME=auto mise userenders the readable light theme.Relates to the earlier abandoned draft #10009 (closed by its author without landing); this takes a simpler approach by reusing demand's own
Theme::new()instead of manually clearing fields.🤖 Generated with Claude Code