From 1086f7534b00135bd8e6d76e24134e72261a4e52 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Thu, 21 May 2026 07:13:24 +1000 Subject: [PATCH 1/2] fix(ui): honor color settings in prompt themes --- src/ui/theme.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/ui/theme.rs b/src/ui/theme.rs index 0391acbe94..18ac834d5c 100644 --- a/src/ui/theme.rs +++ b/src/ui/theme.rs @@ -11,6 +11,9 @@ use crate::config::Settings; /// - "dracula" - Dracula theme pub fn get_theme() -> Theme { let settings = Settings::get(); + if !console::colors_enabled_stderr() { + return no_color_theme(); + } match settings.color_theme.to_lowercase().as_str() { "base16" => Theme::base16(), "catppuccin" => Theme::catppuccin(), @@ -22,3 +25,46 @@ pub fn get_theme() -> Theme { } } } + +fn no_color_theme() -> Theme { + let mut theme = Theme::new(); + theme.input_placeholder = Default::default(); + theme.focused_button = Default::default(); + theme.blurred_button = Default::default(); + theme.cursor_style = Default::default(); + theme.force_style = false; + theme.breadcrumb_active = Default::default(); + theme.breadcrumb_clickable = Default::default(); + theme.breadcrumb_future = Default::default(); + theme +} + +#[cfg(test)] +mod tests { + use confique::Layer; + + use crate::config::Settings; + use crate::config::settings::SettingsPartial; + + use super::*; + + #[test] + fn get_theme_returns_no_color_theme_when_color_is_disabled() { + let mut partial = SettingsPartial::empty(); + partial.color = Some(false); + partial.color_theme = Some("base16".to_string()); + Settings::reset(Some(partial)); + + let theme = get_theme(); + let cursor_color = theme.real_cursor_color(None); + + assert!(theme.title.fg().is_none()); + assert!(theme.description.fg().is_none()); + assert!(theme.selected_option.fg().is_none()); + assert!(theme.unselected_option.fg().is_none()); + assert!(cursor_color.fg().is_none()); + assert!(cursor_color.bg().is_none()); + + Settings::reset(None); + } +} From 3318f2a469d3e7d40a9ad18e97701a85a005af29 Mon Sep 17 00:00:00 2001 From: Taku Kodma <79110363+risu729@users.noreply.github.com> Date: Thu, 21 May 2026 07:29:48 +1000 Subject: [PATCH 2/2] test(ui): cover unstyled prompt theme fields --- src/ui/theme.rs | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/ui/theme.rs b/src/ui/theme.rs index 18ac834d5c..0d4f51f73b 100644 --- a/src/ui/theme.rs +++ b/src/ui/theme.rs @@ -28,7 +28,20 @@ pub fn get_theme() -> Theme { fn no_color_theme() -> Theme { let mut theme = Theme::new(); + theme.title = Default::default(); + theme.description = Default::default(); + theme.cursor = Default::default(); + theme.selected_option = Default::default(); + theme.selected_prefix_fg = Default::default(); + theme.unselected_option = Default::default(); + theme.unselected_prefix_fg = Default::default(); + theme.error_indicator = Default::default(); + theme.input_cursor = Default::default(); theme.input_placeholder = Default::default(); + theme.input_prompt = Default::default(); + theme.help_key = Default::default(); + theme.help_desc = Default::default(); + theme.help_sep = Default::default(); theme.focused_button = Default::default(); theme.blurred_button = Default::default(); theme.cursor_style = Default::default(); @@ -49,7 +62,7 @@ mod tests { use super::*; #[test] - fn get_theme_returns_no_color_theme_when_color_is_disabled() { + fn get_theme_returns_no_color_theme_when_stderr_colors_are_disabled() { let mut partial = SettingsPartial::empty(); partial.color = Some(false); partial.color_theme = Some("base16".to_string()); @@ -58,10 +71,31 @@ mod tests { let theme = get_theme(); let cursor_color = theme.real_cursor_color(None); - assert!(theme.title.fg().is_none()); - assert!(theme.description.fg().is_none()); - assert!(theme.selected_option.fg().is_none()); - assert!(theme.unselected_option.fg().is_none()); + for color in [ + &theme.title, + &theme.description, + &theme.cursor, + &theme.selected_option, + &theme.selected_prefix_fg, + &theme.unselected_option, + &theme.unselected_prefix_fg, + &theme.error_indicator, + &theme.input_cursor, + &theme.input_placeholder, + &theme.input_prompt, + &theme.help_key, + &theme.help_desc, + &theme.help_sep, + &theme.focused_button, + &theme.blurred_button, + &theme.cursor_style, + &theme.breadcrumb_active, + &theme.breadcrumb_clickable, + &theme.breadcrumb_future, + ] { + assert!(color.fg().is_none()); + assert!(color.bg().is_none()); + } assert!(cursor_color.fg().is_none()); assert!(cursor_color.bg().is_none());