feat(tui): add theme config setting, suppress underline from themes

Add `[tui] theme = "..."` config option that lets users override the
auto-detected syntax highlighting theme with any of the 32 bundled
two-face themes by kebab-case name. Invalid names log a warning and
fall back to adaptive detection.

Also suppress FontStyle::UNDERLINE in convert_style — themes like
Dracula mark type scopes with underline which produces distracting
underlines on type/module names in terminal output.
This commit is contained in:
Felipe Coury
2026-02-21 19:20:47 -03:00
parent 9878b734a0
commit 82fc47e317
5 changed files with 251 additions and 4 deletions
+33
View File
@@ -278,6 +278,9 @@ pub struct Config {
/// `current-dir`.
pub tui_status_line: Option<Vec<String>>,
/// Syntax highlighting theme override (kebab-case name).
pub tui_theme: Option<String>,
/// The directory that should be treated as the current working directory
/// for the session. All relative paths inside the business-logic layer are
/// resolved against this path.
@@ -2120,6 +2123,7 @@ impl Config {
.map(|t| t.alternate_screen)
.unwrap_or_default(),
tui_status_line: cfg.tui.as_ref().and_then(|t| t.status_line.clone()),
tui_theme: cfg.tui.as_ref().and_then(|t| t.theme.clone()),
otel: {
let t: OtelConfigToml = cfg.otel.unwrap_or_default();
let log_user_prompt = t.log_user_prompt.unwrap_or(false);
@@ -2518,6 +2522,30 @@ allowed_domains = ["openai.com"]
Ok(())
}
#[test]
fn tui_theme_deserializes_from_toml() {
let cfg = r#"
[tui]
theme = "dracula"
"#;
let parsed =
toml::from_str::<ConfigToml>(cfg).expect("TOML deserialization should succeed");
assert_eq!(
parsed.tui.as_ref().and_then(|t| t.theme.as_deref()),
Some("dracula"),
);
}
#[test]
fn tui_theme_defaults_to_none() {
let cfg = r#"
[tui]
"#;
let parsed =
toml::from_str::<ConfigToml>(cfg).expect("TOML deserialization should succeed");
assert_eq!(parsed.tui.as_ref().and_then(|t| t.theme.as_deref()), None);
}
#[test]
fn tui_config_missing_notifications_field_defaults_to_enabled() {
let cfg = r#"
@@ -2537,6 +2565,7 @@ allowed_domains = ["openai.com"]
show_tooltips: true,
alternate_screen: AltScreenMode::Auto,
status_line: None,
theme: None,
}
);
}
@@ -4646,6 +4675,7 @@ model_verbosity = "high"
feedback_enabled: true,
tui_alternate_screen: AltScreenMode::Auto,
tui_status_line: None,
tui_theme: None,
otel: OtelConfig::default(),
},
o3_profile_config
@@ -4768,6 +4798,7 @@ model_verbosity = "high"
feedback_enabled: true,
tui_alternate_screen: AltScreenMode::Auto,
tui_status_line: None,
tui_theme: None,
otel: OtelConfig::default(),
};
@@ -4888,6 +4919,7 @@ model_verbosity = "high"
feedback_enabled: true,
tui_alternate_screen: AltScreenMode::Auto,
tui_status_line: None,
tui_theme: None,
otel: OtelConfig::default(),
};
@@ -4994,6 +5026,7 @@ model_verbosity = "high"
feedback_enabled: true,
tui_alternate_screen: AltScreenMode::Auto,
tui_status_line: None,
tui_theme: None,
otel: OtelConfig::default(),
};
+7
View File
@@ -681,6 +681,13 @@ pub struct Tui {
/// `current-dir`.
#[serde(default)]
pub status_line: Option<Vec<String>>,
/// Syntax highlighting theme name (kebab-case).
///
/// When set, overrides automatic light/dark theme detection.
/// Run with `--list-themes` or see docs for available names.
#[serde(default)]
pub theme: Option<String>,
}
const fn default_true() -> bool {