mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:23:33 +00:00
fix(theme/persist): apply custom colors only when theme == Custom; clear [tui.theme].colors/label when switching to built-in themes so startup doesn’t force Custom palette
This commit is contained in:
@@ -386,6 +386,14 @@ pub fn set_tui_theme_name(codex_home: &Path, theme: ThemeName) -> anyhow::Result
|
||||
|
||||
// Write `[tui.theme].name = "…"`
|
||||
doc["tui"]["theme"]["name"] = toml_edit::value(theme_str);
|
||||
// When switching away from the Custom theme, clear any lingering custom
|
||||
// overrides so built-in themes render true to spec on next startup.
|
||||
if theme != ThemeName::Custom {
|
||||
if let Some(tbl) = doc["tui"]["theme"].as_table_mut() {
|
||||
tbl.remove("label");
|
||||
tbl.remove("colors");
|
||||
}
|
||||
}
|
||||
|
||||
// ensure codex_home exists
|
||||
std::fs::create_dir_all(codex_home)?;
|
||||
|
||||
@@ -57,7 +57,12 @@ impl Default for Theme {
|
||||
/// Initialize the global theme from configuration
|
||||
pub fn init_theme(config: &ThemeConfig) {
|
||||
let mut theme = get_predefined_theme(config.name);
|
||||
apply_custom_colors(&mut theme, &config.colors);
|
||||
// Important: Only apply color overrides for the Custom theme.
|
||||
// Built-in themes should render exactly as defined so that switching away
|
||||
// from Custom does not keep stale custom overrides from config.
|
||||
if matches!(config.name, ThemeName::Custom) {
|
||||
apply_custom_colors(&mut theme, &config.colors);
|
||||
}
|
||||
|
||||
// On some terminals (notably macOS Terminal.app with certain profiles),
|
||||
// truecolor escape sequences may render incorrectly. Detect such cases
|
||||
|
||||
Reference in New Issue
Block a user