Skip to content

armgit / herdr

Public Imported from GitHub
0

the runtime your coding agents live on

fix: keep the terminal theme readable on light terminals (#6092)

Can Celik8734523b92de
diff --git a/src/app/mod.rs b/src/app/mod.rs
index 32f6e6d55..0dfab8641 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -297,6 +297,7 @@ fn resolve_palette_for_theme_name(
fallback_name: &str,
runtime: &state::ThemeRuntimeConfig,
mode_custom: Option<&crate::config::ModeThemeColors>,
+ host: Option<&crate::terminal_theme::TerminalTheme>,
) -> state::Palette {
let mut palette = state::Palette::from_name(name).unwrap_or_else(|| {
tracing::warn!(
@@ -307,11 +308,17 @@ fn resolve_palette_for_theme_name(
state::Palette::from_name(fallback_name).unwrap_or_else(state::Palette::catppuccin)
});
+ if crate::config::canonical_theme_name(name) == Some("terminal") {
+ if let Some(host) = host {
+ palette = state::Palette::terminal_for_host(host);
+ }
+ }
if let Some(custom) = &runtime.custom {
palette = palette.with_overrides(custom);
}
if let Some(accent) = &runtime.legacy_accent {
palette.accent = crate::config::parse_color(accent);
+ palette.accent_fg = None;
}
if let Some(custom) = mode_custom {
palette = palette.with_mode_overrides(custom);
@@ -323,6 +330,7 @@ fn resolve_palette_for_theme_name(
fn resolve_effective_theme(
runtime: &state::ThemeRuntimeConfig,
appearance: Option<crate::terminal_theme::HostAppearance>,
+ host: Option<&crate::terminal_theme::TerminalTheme>,
) -> (state::Palette, String) {
let (name, fallback, mode_custom) = if runtime.auto_switch {
match appearance.unwrap_or(crate::terminal_theme::HostAppearance::Dark) {
@@ -347,7 +355,7 @@ fn resolve_effective_theme(
(&runtime.manual_name, "catppuccin", None)
};
(
- resolve_palette_for_theme_name(name, fallback, runtime, mode_custom),
+ resolve_palette_for_theme_name(name, fallback, runtime, mode_custom, host),
name.clone(),
)
}
@@ -359,20 +367,22 @@ pub(crate) fn client_theme_runtime_from_config(config: &Config) -> state::ThemeR
pub(crate) fn client_palette_for_theme(
runtime: &state::ThemeRuntimeConfig,
name: &str,
+ host: &crate::terminal_theme::TerminalTheme,
) -> state::Palette {
- resolve_palette_for_theme_name(name, "catppuccin", runtime, None)
+ resolve_palette_for_theme_name(name, "catppuccin", runtime, None, Some(host))
}
pub(crate) fn client_palette_from_config(config: &Config) -> state::Palette {
let runtime = client_theme_runtime_from_config(config);
- resolve_effective_theme(&runtime, None).0
+ resolve_effective_theme(&runtime, None, None).0
}
pub(crate) fn client_palette_for_appearance(
runtime: &state::ThemeRuntimeConfig,
- appearance: crate::terminal_theme::HostAppearance,
+ appearance: Option<crate::terminal_theme::HostAppearance>,
+ host: &crate::terminal_theme::TerminalTheme,
) -> state::Palette {
- resolve_effective_theme(runtime, Some(appearance)).0
+ resolve_effective_theme(runtime, appearance, Some(host)).0
}
impl App {
@@ -492,7 +502,7 @@ impl App {
#[cfg(test)]
let agent_manifest_summaries = Vec::new();
let theme_runtime = theme_runtime_config(config, true);
- let (theme_palette, theme_name) = resolve_effective_theme(&theme_runtime, None);
+ let (theme_palette, theme_name) = resolve_effective_theme(&theme_runtime, None, None);
let mut state = AppState {
terminals: std::collections::HashMap::new(),
diff --git a/src/app/state.rs b/src/app/state.rs
index f30279d6c..0e2129a51 100644
--- a/src/app/state.rs
+++ b/src/app/state.rs
@@ -35,6 +35,8 @@ use crate::workspace::Workspace;
pub struct Palette {
/// Primary accent (highlight, active borders).
pub accent: Color,
+ /// Host-derived text color for accent fills, independent of borders and separators.
+ pub(crate) accent_fg: Option<Color>,
/// Background for the tab bar, floating panels, overlays, and modals.
pub panel_bg: Color,
/// Optional desktop sidebar background. Reset preserves the terminal background.
@@ -74,9 +76,24 @@ pub struct Palette {
}
impl Palette {
+ pub(crate) fn accent_foreground(&self) -> Color {
+ self.accent_fg.unwrap_or(match self.panel_bg {
+ Color::Reset => self.surface_dim,
+ color => color,
+ })
+ }
+
+ pub(crate) fn fill_foreground(&self) -> Color {
+ match self.panel_bg {
+ Color::Reset => self.surface_dim,
+ color => color,
+ }
+ }
+
/// Catppuccin Mocha — the default.
pub fn catppuccin() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(137, 180, 250), // blue
panel_bg: Color::Rgb(24, 24, 37),
sidebar_bg: Color::Reset,
@@ -102,6 +119,7 @@ impl Palette {
/// Catppuccin Latte — the light Catppuccin flavor.
pub fn catppuccin_latte() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(30, 102, 245),
panel_bg: Color::Rgb(239, 241, 245),
sidebar_bg: Color::Reset,
@@ -127,6 +145,7 @@ impl Palette {
/// Terminal 16-color theme.
pub fn terminal() -> Self {
Self {
+ accent_fg: None,
accent: Color::Blue,
panel_bg: Color::Reset,
sidebar_bg: Color::Reset,
@@ -149,9 +168,79 @@ impl Palette {
}
}
+ pub(crate) fn terminal_for_host(host: &crate::terminal_theme::TerminalTheme) -> Self {
+ use crate::terminal_theme::RgbColor;
+
+ let mut palette = Self::terminal();
+ let (Some(foreground), Some(background)) = (host.foreground, host.background) else {
+ return palette;
+ };
+ let rgb = |color: RgbColor| Color::Rgb(color.r, color.g, color.b);
+
+ if let Some(surface) = host.palette[8] {
+ if foreground.contrast_ratio(surface) < 3.0 {
+ // Keep the host background's hue while making the active row visible.
+ let visible_tint = |text_floor| {
+ for weight in (10u16..=95).step_by(5) {
+ let blend = |bg: u8, fg: u8| {
+ ((u16::from(bg) * (100 - weight) + u16::from(fg) * weight) / 100) as u8
+ };
+ let candidate = RgbColor {
+ r: blend(background.r, foreground.r),
+ g: blend(background.g, foreground.g),
+ b: blend(background.b, foreground.b),
+ };
+ if foreground.contrast_ratio(candidate) < text_floor {
+ break;
+ }
+ if background.contrast_ratio(candidate) >= 1.3 {
+ return Some(candidate);
+ }
+ }
+ None
+ };
+ if let Some(row) = visible_tint(4.5).or_else(|| visible_tint(3.0)) {
+ palette.active_row_bg = rgb(row);
+ palette.surface1 = rgb(row);
+ }
+ }
+ if let Some(accent) = host.palette[4] {
+ if surface.contrast_ratio(accent) < 4.5 {
+ let black = RgbColor { r: 0, g: 0, b: 0 };
+ let white = RgbColor {
+ r: 255,
+ g: 255,
+ b: 255,
+ };
+ let contrast = if background.contrast_ratio(accent) >= 4.5 {
+ background
+ } else if black.contrast_ratio(accent) >= white.contrast_ratio(accent) {
+ black
+ } else {
+ white
+ };
+ palette.accent_fg = Some(rgb(contrast));
+ }
+ }
+ }
+
+ for (color, index) in [
+ (&mut palette.overlay0, 7),
+ (&mut palette.subtext0, 7),
+ (&mut palette.mauve, 7),
+ (&mut palette.overlay1, 15),
+ ] {
+ if host.palette[index].is_some_and(|color| color.contrast_ratio(background) < 3.0) {
+ *color = Color::Reset;
+ }
+ }
+ palette
+ }
+
/// Tokyo Night — blue-purple aesthetic.
pub fn tokyo_night() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(122, 162, 247), // blue
panel_bg: Color::Rgb(26, 27, 38),
sidebar_bg: Color::Reset,
@@ -177,6 +266,7 @@ impl Palette {
/// Tokyo Night Day — the light Tokyo Night style.
pub fn tokyo_night_day() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(46, 125, 233),
panel_bg: Color::Rgb(225, 226, 231),
sidebar_bg: Color::Reset,
@@ -202,6 +292,7 @@ impl Palette {
/// Dracula — purple/pink/green.
pub fn dracula() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(189, 147, 249), // purple
panel_bg: Color::Rgb(40, 42, 54),
sidebar_bg: Color::Reset,
@@ -227,6 +318,7 @@ impl Palette {
/// Nord — frosty blue palette.
pub fn nord() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(136, 192, 208), // frost
panel_bg: Color::Rgb(46, 52, 64),
sidebar_bg: Color::Reset,
@@ -252,6 +344,7 @@ impl Palette {
/// Gruvbox Dark — warm retro palette.
pub fn gruvbox() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(215, 153, 33), // yellow
panel_bg: Color::Rgb(40, 40, 40),
sidebar_bg: Color::Reset,
@@ -277,6 +370,7 @@ impl Palette {
/// Gruvbox Light — the light retro palette.
pub fn gruvbox_light() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(7, 102, 120),
panel_bg: Color::Rgb(251, 241, 199),
sidebar_bg: Color::Reset,
@@ -302,6 +396,7 @@ impl Palette {
/// One Dark — Atom's classic dark theme.
pub fn one_dark() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(97, 175, 239), // blue
panel_bg: Color::Rgb(40, 44, 52),
sidebar_bg: Color::Reset,
@@ -327,6 +422,7 @@ impl Palette {
/// One Light — Atom's classic light theme.
pub fn one_light() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(64, 120, 242),
panel_bg: Color::Rgb(250, 250, 250),
sidebar_bg: Color::Reset,
@@ -352,6 +448,7 @@ impl Palette {
/// Solarized Dark — Ethan Schoonover's classic.
pub fn solarized() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(38, 139, 210), // blue
panel_bg: Color::Rgb(0, 43, 54),
sidebar_bg: Color::Reset,
@@ -377,6 +474,7 @@ impl Palette {
/// Solarized Light — Ethan Schoonover's light variant.
pub fn solarized_light() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(38, 139, 210),
panel_bg: Color::Rgb(253, 246, 227),
sidebar_bg: Color::Reset,
@@ -402,6 +500,7 @@ impl Palette {
/// Kanagawa — inspired by Katsushika Hokusai.
pub fn kanagawa() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(126, 156, 216), // blue
panel_bg: Color::Rgb(31, 31, 40),
sidebar_bg: Color::Reset,
@@ -427,6 +526,7 @@ impl Palette {
/// Kanagawa Lotus — the light Kanagawa variant.
pub fn kanagawa_lotus() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(77, 105, 155),
panel_bg: Color::Rgb(242, 236, 188),
sidebar_bg: Color::Reset,
@@ -452,6 +552,7 @@ impl Palette {
/// Rosé Pine — muted, elegant.
pub fn rose_pine() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(196, 167, 231), // iris
panel_bg: Color::Rgb(25, 23, 36),
sidebar_bg: Color::Reset,
@@ -477,6 +578,7 @@ impl Palette {
/// Rosé Pine Dawn — the light Rosé Pine variant.
pub fn rose_pine_dawn() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(144, 122, 169),
panel_bg: Color::Rgb(250, 244, 237),
sidebar_bg: Color::Reset,
@@ -502,6 +604,7 @@ impl Palette {
/// Vesper — minimal high-contrast monochrome with peach and mint accents.
pub fn vesper() -> Self {
Self {
+ accent_fg: None,
accent: Color::Rgb(255, 199, 153),
panel_bg: Color::Rgb(26, 26, 26),
sidebar_bg: Color::Reset,
@@ -552,6 +655,9 @@ impl Palette {
/// Apply custom color overrides on top of this palette.
pub fn with_overrides(mut self, custom: &crate::config::CustomThemeColors) -> Self {
use crate::config::parse_color;
+ if custom.accent.is_some() || custom.panel_bg.is_some() || custom.surface_dim.is_some() {
+ self.accent_fg = None;
+ }
if let Some(c) = &custom.accent {
self.accent = parse_color(c);
}
@@ -614,6 +720,9 @@ impl Palette {
pub fn with_mode_overrides(mut self, custom: &crate::config::ModeThemeColors) -> Self {
use crate::config::parse_color;
+ if custom.accent.is_some() || custom.panel_bg.is_some() || custom.surface_dim.is_some() {
+ self.accent_fg = None;
+ }
if let Some(c) = &custom.accent {
self.accent = parse_color(c);
}
@@ -1374,28 +1483,12 @@ mod tests {
state.assert_invariants_for_test();
}
- fn rgb_luminance(color: Color) -> f64 {
- let Color::Rgb(r, g, b) = color else {
- panic!("expected RGB color, got {color:?}");
- };
- let channel = |value: u8| {
- let value = f64::from(value) / 255.0;
- if value <= 0.04045 {
- value / 12.92
- } else {
- ((value + 0.055) / 1.055).powf(2.4)
- }
- };
- 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b)
- }
-
fn contrast_ratio(a: Color, b: Color) -> f64 {
- let (lighter, darker) = {
- let a = rgb_luminance(a);
- let b = rgb_luminance(b);
- (a.max(b), a.min(b))
+ let rgb = |color| match color {
+ Color::Rgb(r, g, b) => crate::terminal_theme::RgbColor { r, g, b },
+ other => panic!("expected RGB color, got {other:?}"),
};
- (lighter + 0.05) / (darker + 0.05)
+ rgb(a).contrast_ratio(rgb(b))
}
#[test]
@@ -1408,6 +1501,87 @@ mod tests {
}
}
+ #[test]
+ fn terminal_host_palette_preserves_readable_pairs_and_repairs_low_contrast_pairs() {
+ use crate::terminal_theme::{RgbColor, TerminalTheme};
+
+ let rgb = |r, g, b| RgbColor { r, g, b };
+ let light = rgb(238, 238, 238);
+ let dark = rgb(16, 16, 16);
+ let accent = rgb(137, 180, 250);
+ let mut host = TerminalTheme {
+ foreground: Some(light),
+ background: Some(dark),
+ ..TerminalTheme::default()
+ };
+ host.palette[4] = Some(accent);
+ host.palette[8] = Some(dark);
+ assert_eq!(Palette::terminal_for_host(&host), Palette::terminal());
+
+ // A light host may use dark colors for every ANSI slot.
+ host.foreground = Some(dark);
+ host.background = Some(light);
+ host.palette[4] = Some(rgb(23, 77, 166));
+ host.palette[8] = Some(rgb(83, 96, 113));
+ for (index, color) in [
+ (2, rgb(17, 102, 17)),
+ (3, rgb(102, 85, 0)),
+ (9, rgb(153, 17, 17)),
+ (6, rgb(0, 102, 119)),
+ ] {
+ host.palette[index] = Some(color);
+ }
+ let palette = Palette::terminal_for_host(&host);
+ let to_color = |color: RgbColor| Color::Rgb(color.r, color.g, color.b);
+ assert!(contrast_ratio(to_color(dark), palette.active_row_bg) >= 4.5);
+ assert!(contrast_ratio(to_color(light), palette.active_row_bg) >= 1.3);
+ assert!(contrast_ratio(to_color(light), palette.active_row_bg) < 1.5);
+ for index in [2, 3, 9, 6] {
+ assert!(
+ contrast_ratio(
+ to_color(host.palette[index].unwrap()),
+ palette.active_row_bg
+ ) >= 3.0
+ );
+ }
+ assert_eq!(palette.surface_dim, Palette::terminal().surface_dim);
+ assert!(
+ contrast_ratio(
+ to_color(host.palette[4].unwrap()),
+ palette.accent_foreground()
+ ) >= 4.5
+ );
+ assert_eq!(palette.panel_bg, Color::Reset);
+ assert_eq!(palette.sidebar_bg, Color::Reset);
+ let custom = palette.with_overrides(&crate::config::CustomThemeColors {
+ surface_dim: Some("#123456".into()),
+ ..Default::default()
+ });
+ assert_eq!(custom.accent_foreground(), Color::Rgb(0x12, 0x34, 0x56));
+
+ // A lower-contrast host needs the 3:1 fallback to keep the row visible.
+ host.foreground = Some(rgb(104, 104, 104));
+ let low_contrast = Palette::terminal_for_host(&host);
+ assert!(contrast_ratio(to_color(light), low_contrast.active_row_bg) >= 1.3);
+ let text_contrast = contrast_ratio(
+ to_color(host.foreground.unwrap()),
+ low_contrast.active_row_bg,
+ );
+ assert!(text_contrast >= 3.0);
+ assert!(text_contrast < 4.5);
+
+ // If no legible tint is visible, keep the existing ANSI row instead of hiding it.
+ host.foreground = Some(rgb(150, 150, 150));
+ let dim = Palette::terminal_for_host(&host);
+ assert_eq!(dim.active_row_bg, Palette::terminal().active_row_bg);
+ assert!(contrast_ratio(to_color(light), to_color(host.palette[8].unwrap())) >= 1.3);
+
+ assert_eq!(
+ Palette::terminal_for_host(&TerminalTheme::default()),
+ Palette::terminal()
+ );
+ }
+
#[test]
fn built_in_active_rows_remain_visible_with_matching_terminal_backgrounds() {
for name in crate::config::THEME_NAMES
diff --git a/src/app/theme_sync.rs b/src/app/theme_sync.rs
index b11072cde..042adecdd 100644
--- a/src/app/theme_sync.rs
+++ b/src/app/theme_sync.rs
@@ -100,6 +100,7 @@ impl App {
let (palette, theme_name) = super::resolve_effective_theme(
&self.state.theme_runtime,
self.state.host_terminal_appearance,
+ None,
);
if self.state.theme_name == theme_name && self.state.palette == palette {
return false;
diff --git a/src/client/shell.rs b/src/client/shell.rs
index 2d180443b..e74163858 100644
--- a/src/client/shell.rs
+++ b/src/client/shell.rs
@@ -236,13 +236,6 @@ fn status_color(
}
}
-fn panel_contrast_fg(palette: &Palette) -> ratatui::style::Color {
- match palette.panel_bg {
- ratatui::style::Color::Reset => palette.surface_dim,
- color => color,
- }
-}
-
fn blit_pane_surface(target: &mut FrameData, source: &FrameData, area: Rect) {
let copy_width = source.width.min(area.width);
let copy_height = source.height.min(area.height);
diff --git a/src/client/shell/composition.rs b/src/client/shell/composition.rs
index b7ab4a967..5dfb8bd14 100644
--- a/src/client/shell/composition.rs
+++ b/src/client/shell/composition.rs
@@ -394,7 +394,7 @@ impl ClientShellState {
hit.scroll,
&self.config.palette,
crate::terminal_theme::TerminalTheme {
- background: self.host_background,
+ background: self.host_theme.background,
..Default::default()
},
);
@@ -758,7 +758,7 @@ fn render_client_copy_search_highlights(
let bottom = top.saturating_add(u32::from(hit.inner_rect.height.saturating_sub(1)));
let style = if current_only {
Style::default()
- .fg(panel_contrast_fg(palette))
+ .fg(palette.accent_foreground())
.bg(palette.accent)
.add_modifier(Modifier::BOLD)
} else {
diff --git a/src/client/shell/config.rs b/src/client/shell/config.rs
index 04a3ddb56..80b87fd60 100644
--- a/src/client/shell/config.rs
+++ b/src/client/shell/config.rs
@@ -16,6 +16,34 @@ pub(super) fn merged_config_diagnostic(
}
impl ClientShellState {
+ pub(super) fn refresh_host_palette(&mut self) -> bool {
+ let effective = crate::app::client_palette_for_appearance(
+ &self.config.theme_runtime,
+ self.host_appearance,
+ &self.host_theme,
+ );
+ let preview = if let Some(ClientShellOverlay::Settings(settings)) = self.overlay.as_mut() {
+ settings
+ .original_theme_name
+ .clone_from(&self.config.theme_runtime.manual_name);
+ settings.original_palette = effective.clone();
+ settings.theme_preview.as_deref()
+ } else {
+ None
+ };
+ let palette = if let Some(name) = preview {
+ self.config.theme_name = name.to_owned();
+ crate::app::client_palette_for_theme(&self.config.theme_runtime, name, &self.host_theme)
+ } else {
+ effective
+ };
+ if self.config.palette == palette {
+ return false;
+ }
+ self.config.palette = palette;
+ true
+ }
+
pub(super) fn set_local_config_diagnostic(&mut self, diagnostic: Option<String>) {
self.local_config_diagnostic = diagnostic;
self.config_diagnostic = merged_config_diagnostic(
@@ -77,12 +105,7 @@ impl ClientShellState {
&loaded.diagnostics,
&loaded.invalid_sections,
);
- if let Some(appearance) = self.host_appearance {
- self.config.palette = crate::app::client_palette_for_appearance(
- &self.config.theme_runtime,
- appearance,
- );
- }
+ self.refresh_host_palette();
if !self.sidebar_width_manual {
self.sidebar_width = self.config.sidebar_width;
}
diff --git a/src/client/shell/input.rs b/src/client/shell/input.rs
index ee92d5909..330a00872 100644
--- a/src/client/shell/input.rs
+++ b/src/client/shell/input.rs
@@ -222,6 +222,7 @@ impl ClientShellState {
pub(crate) fn handle_raw_events(&mut self, events: Vec<RawInputEvent>) -> ClientShellInput {
let mut outcome = ClientShellInput::default();
+ let mut host_palette_changed = false;
if !events.is_empty() && self.endpoint_error.take().is_some() {
self.endpoint_error_deadline = None;
outcome.repaint = true;
@@ -336,41 +337,35 @@ impl ClientShellState {
self.host_appearance = Some(appearance);
self.host_appearance_explicit = true;
outcome.query_host_theme = true;
- if self.config.theme_runtime.auto_switch {
- self.config.palette = crate::app::client_palette_for_appearance(
- &self.config.theme_runtime,
- appearance,
- );
- outcome.repaint = true;
- }
+ host_palette_changed = true;
}
- RawInputEvent::HostDefaultColor {
- kind: crate::terminal_theme::DefaultColorKind::Background,
- color,
- } => {
- if self.host_background != Some(color) {
- self.host_background = Some(color);
+ RawInputEvent::HostDefaultColor { kind, color } => {
+ if kind == crate::terminal_theme::DefaultColorKind::Background
+ && self.host_theme.background != Some(color)
+ {
outcome.repaint = true;
}
- if !self.host_appearance_explicit {
- let appearance = color.inferred_appearance();
- self.host_appearance = Some(appearance);
- if self.config.theme_runtime.auto_switch {
- self.config.palette = crate::app::client_palette_for_appearance(
- &self.config.theme_runtime,
- appearance,
- );
- outcome.repaint = true;
- }
+ self.host_theme = self.host_theme.with_color(kind, color);
+ host_palette_changed = true;
+ if kind == crate::terminal_theme::DefaultColorKind::Background
+ && !self.host_appearance_explicit
+ {
+ self.host_appearance = Some(color.inferred_appearance());
+ }
+ }
+ RawInputEvent::HostPaletteColors { colors } => {
+ for (index, color) in colors {
+ self.host_theme = self.host_theme.with_palette_color(index, color);
}
+ host_palette_changed = true;
}
- RawInputEvent::HostDefaultColor { .. }
- | RawInputEvent::HostPaletteColors { .. }
- | RawInputEvent::HostCellSizeReport { .. }
- | RawInputEvent::Unsupported => {}
+ RawInputEvent::HostCellSizeReport { .. } | RawInputEvent::Unsupported => {}
}
self.reconcile_input_source();
}
+ if host_palette_changed {
+ outcome.repaint |= self.refresh_host_palette();
+ }
outcome.repaint |= self.resume_mobile_switcher_if_ready();
outcome
}
diff --git a/src/client/shell/overlays.rs b/src/client/shell/overlays.rs
index f26cc6e4e..7c826d8b8 100644
--- a/src/client/shell/overlays.rs
+++ b/src/client/shell/overlays.rs
@@ -124,7 +124,7 @@ pub(crate) fn render_global_menu(
let highlighted = index == menu.highlighted;
let style = if highlighted {
Style::default()
- .fg(panel_contrast_fg(palette))
+ .fg(palette.accent_foreground())
.bg(palette.accent)
.add_modifier(Modifier::BOLD)
} else {
@@ -201,7 +201,7 @@ pub(crate) fn render_context_menu(
let highlighted = index == menu.highlighted;
let style = if highlighted {
Style::default()
- .fg(panel_contrast_fg(palette))
+ .fg(palette.accent_foreground())
.bg(palette.accent)
.add_modifier(Modifier::BOLD)
} else {
@@ -299,12 +299,6 @@ fn row(i: Rect, ws: &[u16], gap: u16, off: u16) -> Vec<Rect> {
})
.collect()
}
-fn contrast(p: &Palette) -> ratatui::style::Color {
- match p.panel_bg {
- ratatui::style::Color::Reset => p.surface_dim,
- c => c,
- }
-}
fn render_release_notes_overlay(
b: &mut Buffer,
notes: &crate::app::state::ReleaseNotesState,
@@ -371,7 +365,7 @@ fn render_release_notes_overlay(
close,
" esc close ",
Style::default()
- .fg(contrast(p))
+ .fg(p.accent_foreground())
.bg(p.accent)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM),
@@ -487,7 +481,7 @@ fn render_product_announcement_overlay(
close,
" esc close ",
Style::default()
- .fg(contrast(p))
+ .fg(p.accent_foreground())
.bg(p.accent)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM),
@@ -629,7 +623,7 @@ fn render_onboarding_overlay(
primary,
" ↵ continue ",
Style::default()
- .fg(contrast(p))
+ .fg(p.accent_foreground())
.bg(p.accent)
.add_modifier(Modifier::BOLD)
.remove_modifier(Modifier::DIM),
@@ -676,7 +670,7 @@ fn render_rename_overlay(
*save,
" ↵ save ",
Style::default()
- .fg(contrast(p))
+ .fg(p.accent_foreground())
.bg(p.accent)
.add_modifier(Modifier::BOLD),
);
@@ -846,7 +840,7 @@ fn render_navigator_overlay(
.add_modifier(Modifier::DIM)
} else if ix == selected {
Style::default()
- .fg(contrast(p))
+ .fg(p.accent_foreground())
.bg(p.accent)
.add_modifier(Modifier::BOLD)
} else {
@@ -1148,7 +1142,7 @@ fn render_help_overlay(
" esc close "
},
Style::default()
- .fg(contrast(p))
+ .fg(p.accent_foreground())
.bg(p.accent)
.add_modifier(Modifier::BOLD),
);
@@ -1288,7 +1282,7 @@ fn render_confirm_close_overlay(
*ok,
" ↵ confirm ",
Style::default()
- .fg(contrast(p))
+ .fg(p.fill_foreground())
.bg(p.red)
.add_modifier(Modifier::BOLD),
);
diff --git a/src/client/shell/settings.rs b/src/client/shell/settings.rs
index b4474bc79..82beb23fe 100644
--- a/src/client/shell/settings.rs
+++ b/src/client/shell/settings.rs
@@ -38,6 +38,7 @@ impl ClientShellState {
selected: theme_index(&self.config.theme_name),
original_theme_name: self.config.theme_name.clone(),
original_palette: self.config.palette.clone(),
+ theme_preview: None,
integrations: Vec::new(),
integration_messages: Vec::new(),
loading_integrations: false,
@@ -140,15 +141,19 @@ impl ClientShellState {
}
fn preview_selected_theme(&mut self) {
- let Some(ClientShellOverlay::Settings(settings)) = self.overlay.as_ref() else {
+ let Some(ClientShellOverlay::Settings(settings)) = self.overlay.as_mut() else {
return;
};
let Some(name) = crate::config::THEME_NAMES.get(settings.selected) else {
return;
};
+ settings.theme_preview = Some((*name).to_owned());
self.config.theme_name = (*name).to_owned();
- self.config.palette =
- crate::app::client_palette_for_theme(&self.config.theme_runtime, name);
+ self.config.palette = crate::app::client_palette_for_theme(
+ &self.config.theme_runtime,
+ name,
+ &self.host_theme,
+ );
}
pub(super) fn cancel_settings_overlay(&mut self) {
diff --git a/src/client/shell/settings_overlay.rs b/src/client/shell/settings_overlay.rs
index 25f37b2a0..db02b5eec 100644
--- a/src/client/shell/settings_overlay.rs
+++ b/src/client/shell/settings_overlay.rs
@@ -3,7 +3,7 @@ use super::*;
fn choice_style(selected: bool, palette: &Palette) -> Style {
if selected {
Style::default()
- .fg(contrast(palette))
+ .fg(palette.accent_foreground())
.bg(palette.accent)
.add_modifier(Modifier::BOLD)
} else {
@@ -84,7 +84,7 @@ pub(super) fn render_settings_overlay(
let active = *section == settings.section;
let style = if active {
Style::default()
- .fg(contrast(palette))
+ .fg(palette.accent_foreground())
.bg(palette.accent)
.add_modifier(Modifier::BOLD)
} else {
@@ -217,7 +217,7 @@ pub(super) fn render_settings_overlay(
" ↵ apply "
},
Style::default()
- .fg(contrast(palette))
+ .fg(palette.accent_foreground())
.bg(palette.accent)
.add_modifier(Modifier::BOLD),
);
diff --git a/src/client/shell/state.rs b/src/client/shell/state.rs
index 5a732920c..6a69035c1 100644
--- a/src/client/shell/state.rs
+++ b/src/client/shell/state.rs
@@ -416,6 +416,7 @@ pub(super) struct ClientSettingsOverlay {
pub(super) selected: usize,
pub(super) original_theme_name: String,
pub(super) original_palette: Palette,
+ pub(super) theme_preview: Option<String>,
pub(super) integrations: Vec<crate::api::schema::IntegrationInfo>,
pub(super) integration_messages: Vec<String>,
pub(super) loading_integrations: bool,
@@ -953,7 +954,7 @@ pub(crate) struct ClientShellState {
pub(super) pending_input_source_changes: Vec<bool>,
pub(super) host_appearance: Option<crate::terminal_theme::HostAppearance>,
pub(super) host_appearance_explicit: bool,
- pub(super) host_background: Option<crate::terminal_theme::RgbColor>,
+ pub(super) host_theme: crate::terminal_theme::TerminalTheme,
pub(super) local_config_diagnostic: Option<String>,
pub(super) config_diagnostic: Option<String>,
pub(super) endpoint_error: Option<String>,
@@ -1121,7 +1122,7 @@ impl ClientShellState {
pending_input_source_changes: Vec::new(),
host_appearance: None,
host_appearance_explicit: false,
- host_background: None,
+ host_theme: crate::terminal_theme::TerminalTheme::default(),
config_diagnostic: local_config_diagnostic.clone(),
local_config_diagnostic,
endpoint_error: None,
diff --git a/src/client/shell/tabs.rs b/src/client/shell/tabs.rs
index 3fdcf7dcf..6d4bf723d 100644
--- a/src/client/shell/tabs.rs
+++ b/src/client/shell/tabs.rs
@@ -102,7 +102,7 @@ pub(crate) fn render_tab_bar(
let rect = Rect::new(x, area.y, width, 1);
let style = if tab.focused {
let base = Style::default()
- .fg(panel_contrast_fg(palette))
+ .fg(palette.accent_foreground())
.bg(palette.accent);
if tab.custom_label {
base.add_modifier(Modifier::BOLD)
@@ -280,7 +280,7 @@ fn render_tab_bar_status(
let width = display_width(&segment.text);
let style = if segment.accent {
Style::default()
- .fg(panel_contrast_fg(palette))
+ .fg(palette.accent_foreground())
.bg(palette.accent)
.add_modifier(Modifier::BOLD)
} else {
diff --git a/src/client/shell/tests/close_tab.rs b/src/client/shell/tests/close_tab.rs
index d5e897a3e..131d08a3b 100644
--- a/src/client/shell/tests/close_tab.rs
+++ b/src/client/shell/tests/close_tab.rs
@@ -65,6 +65,70 @@ fn assert_tab_close(outcome: &ClientShellInput) {
assert!(matches!(methods.as_slice(), [Method::TabClose(target)] if target.tab_id == "tab_1"));
}
+#[test]
+fn destructive_buttons_keep_their_own_foreground_when_accent_text_changes() {
+ use crate::terminal_theme::{RgbColor, TerminalTheme};
+ let mut host = TerminalTheme {
+ foreground: Some(RgbColor {
+ r: 238,
+ g: 238,
+ b: 238,
+ }),
+ background: Some(RgbColor {
+ r: 16,
+ g: 16,
+ b: 16,
+ }),
+ ..Default::default()
+ };
+ host.palette[4] = Some(RgbColor {
+ r: 20,
+ g: 20,
+ b: 245,
+ });
+ host.palette[8] = Some(RgbColor {
+ r: 24,
+ g: 24,
+ b: 24,
+ });
+ host.palette[9] = Some(RgbColor {
+ r: 255,
+ g: 200,
+ b: 200,
+ });
+ let palette = Palette::terminal_for_host(&host);
+ let danger = crate::protocol::color_to_u32(palette.fill_foreground());
+ let accent = crate::protocol::color_to_u32(palette.accent_foreground());
+ assert_ne!(danger, accent);
+
+ for overlay in [
+ ClientShellOverlay::ConfirmClose(ClientConfirmCloseOverlay {
+ workspace_id: "ws_1".into(),
+ close_group: false,
+ tab_target: None,
+ title: "close".into(),
+ detail: "confirm".into(),
+ }),
+ ClientShellOverlay::WorktreeRemove(ClientWorktreeRemoveOverlay {
+ workspace_id: "ws_1".into(),
+ path: "path".into(),
+ error: None,
+ removing: false,
+ force_confirmation: false,
+ }),
+ ] {
+ let mut state = close_state(true, 1);
+ state.config.palette = palette.clone();
+ state.overlay = Some(overlay);
+ let frame = state.compose(106, 24).unwrap();
+ let primary = state.hits.overlay_primary;
+ assert!(primary.width > 3);
+ let cell = &frame.cells[usize::from(primary.y) * 106 + usize::from(primary.x + 3)];
+ assert_eq!(cell.bg, crate::protocol::color_to_u32(palette.red));
+ assert_eq!(cell.fg, danger);
+ }
+}
+
#[test]
fn last_tab_close_waits_for_keyboard_or_mouse_confirmation() {
for menu in [false, true] {
diff --git a/src/client/shell/tests/graphics.rs b/src/client/shell/tests/graphics.rs
index 6622e3d8b..8ed8c513d 100644
--- a/src/client/shell/tests/graphics.rs
+++ b/src/client/shell/tests/graphics.rs
@@ -313,6 +313,7 @@ fn every_dialog_and_menu_occludes_its_panel_not_the_whole_screen() {
section: ClientSettingsSection::Theme,
selected: 0,
original_theme_name: String::new(),
+ theme_preview: None,
original_palette: palette,
integrations: Vec::new(),
integration_messages: Vec::new(),
diff --git a/src/client/shell/tests/input.rs b/src/client/shell/tests/input.rs
index 8b817d0ae..abba68c91 100644
--- a/src/client/shell/tests/input.rs
+++ b/src/client/shell/tests/input.rs
@@ -7,11 +7,13 @@ fn host_appearance_prefers_explicit_reports_over_background_inference() {
let light = crate::app::client_palette_for_appearance(
&state.config.theme_runtime,
- crate::terminal_theme::HostAppearance::Light,
+ Some(crate::terminal_theme::HostAppearance::Light),
+ &crate::terminal_theme::TerminalTheme::default(),
);
let dark = crate::app::client_palette_for_appearance(
&state.config.theme_runtime,
- crate::terminal_theme::HostAppearance::Dark,
+ Some(crate::terminal_theme::HostAppearance::Dark),
+ &crate::terminal_theme::TerminalTheme::default(),
);
let inferred = state.handle_raw_events(vec![RawInputEvent::HostDefaultColor {
@@ -76,6 +78,169 @@ fn host_appearance_prefers_explicit_reports_over_background_inference() {
assert_eq!(state.config.palette, dark);
}
+#[test]
+fn terminal_theme_refreshes_from_host_reports_without_auto_switch_and_keeps_overrides() {
+ use crate::terminal_theme::{DefaultColorKind, RgbColor};
+ use ratatui::style::Color;
+
+ let config: Config = toml::from_str(
+ r##"
+[theme]
+name = "terminal"
+[theme.custom]
+overlay0 = "#123456"
+"##,
+ )
+ .unwrap();
+ let mut state = ClientShellState::new(ClientShellConfig::from_config(&config));
+ let background = RgbColor {
+ r: 255,
+ g: 249,
+ b: 232,
+ };
+ let foreground = RgbColor {
+ r: 69,
+ g: 55,
+ b: 60,
+ };
+ let surface = RgbColor {
+ r: 94,
+ g: 82,
+ b: 82,
+ };
+ let accent = RgbColor {
+ r: 66,
+ g: 106,
+ b: 121,
+ };
+ let initial = state.config.palette.clone();
+ state.handle_raw_events(vec![RawInputEvent::HostPaletteColors {
+ colors: vec![(4, accent), (8, surface), (7, background)],
+ }]);
+ assert_eq!(state.config.palette, initial);
+
+ let outcome = state.handle_raw_events(vec![
+ RawInputEvent::HostDefaultColor {
+ kind: DefaultColorKind::Background,
+ color: background,
+ },
+ RawInputEvent::HostDefaultColor {
+ kind: DefaultColorKind::Foreground,
+ color: foreground,
+ },
+ ]);
+ assert!(outcome.repaint);
+ assert_eq!(state.config.palette.overlay0, Color::Rgb(0x12, 0x34, 0x56));
+ assert_ne!(state.config.palette, initial);
+ let resolved = state.config.palette.clone();
+
+ let updated = state.handle_raw_events(vec![RawInputEvent::HostPaletteColors {
+ colors: vec![(4, background), (8, foreground)],
+ }]);
+ assert!(updated.repaint);
+ assert_ne!(state.config.palette, resolved);
+ assert_eq!(state.config.palette.overlay0, Color::Rgb(0x12, 0x34, 0x56));
+}
+
+#[test]
+fn settings_theme_only_previews_user_choices_and_cancel_follows_current_appearance() {
+ use crate::terminal_theme::HostAppearance;
+
+ let config: Config = toml::from_str(
+ r#"
+[theme]
+name = "catppuccin"
+auto_switch = true
+light_name = "catppuccin-latte"
+dark_name = "catppuccin"
+"#,
+ )
+ .unwrap();
+ let mut state = ClientShellState::new(ClientShellConfig::from_config(&config));
+ let appearance = |value| vec![RawInputEvent::HostColorSchemeChanged(value)];
+ state.handle_raw_events(appearance(HostAppearance::Light));
+ let light = state.config.palette.clone();
+ state.open_settings_overlay();
+ state.handle_raw_events(appearance(HostAppearance::Light));
+ assert_eq!(state.config.palette, light);
+
+ let select = |name| {
+ crate::config::THEME_NAMES
+ .iter()
+ .position(|candidate| *candidate == name)
+ .unwrap()
+ };
+ // Selecting the original manual name is still a deliberate preview under auto-switch.
+ state.select_settings_choice(select("catppuccin"));
+ let manual = state.config.palette.clone();
+ assert_ne!(manual, light);
+ state.handle_raw_events(appearance(HostAppearance::Light));
+ assert_eq!(state.config.palette, manual);
+
+ state.select_settings_choice(select("dracula"));
+ let preview = state.config.palette.clone();
+ state.select_settings_section(
+ ClientSettingsSection::Sound,
+ &mut ClientShellInput::default(),
+ );
+ let mut config = config;
+ config.ui.sound.enabled = false;
+ state.config.apply_live_config(&config, &[], &[]);
+ state.refresh_host_palette();
+ assert_eq!(state.config.palette, preview);
+ assert_eq!(state.config.theme_name, "dracula");
+ assert!(!state.config.sound_enabled);
+ state.handle_raw_events(appearance(HostAppearance::Dark));
+ assert_eq!(state.config.palette, preview);
+ state.cancel_settings_overlay();
+ assert_eq!(state.config.palette, manual);
+}
+
+#[test]
+fn settings_cancel_after_config_reload_keeps_rollback_name_and_palette_together() {
+ use crate::terminal_theme::HostAppearance;
+
+ for auto_switch in [false, true] {
+ let mut config = Config::default();
+ config.theme.name = Some("catppuccin".into());
+ config.theme.auto_switch = auto_switch;
+ config.theme.light_name = Some("catppuccin-latte".into());
+ let mut state = ClientShellState::new(ClientShellConfig::from_config(&config));
+ state.handle_raw_events(vec![RawInputEvent::HostColorSchemeChanged(
+ HostAppearance::Light,
+ )]);
+ state.open_settings_overlay();
+ let preview_index = crate::config::THEME_NAMES
+ .iter()
+ .position(|name| *name == "dracula")
+ .unwrap();
+ state.select_settings_choice(preview_index);
+ let preview = state.config.palette.clone();
+
+ config.theme.name = Some("nord".into());
+ config.theme.light_name = Some("one-light".into());
+ state.config.apply_live_config(&config, &[], &[]);
+ state.refresh_host_palette();
+ assert_eq!(state.config.theme_name, "dracula");
+ assert_eq!(state.config.palette, preview);
+
+ state.cancel_settings_overlay();
+ assert_eq!(state.config.theme_name, "nord");
+ let expected = crate::app::client_palette_for_appearance(
+ &state.config.theme_runtime,
+ Some(HostAppearance::Light),
+ &state.host_theme,
+ );
+ assert_eq!(state.config.palette, expected);
+
+ state.open_settings_overlay();
+ let Some(ClientShellOverlay::Settings(settings)) = state.overlay.as_ref() else {
+ panic!("expected Settings to reopen");
+ };
+ assert_eq!(crate::config::THEME_NAMES[settings.selected], "nord");
+ }
+}
+
#[test]
fn full_host_palette_response_is_sent_as_one_theme_update() {
use std::fmt::Write as _;
diff --git a/src/client/shell/worktree_overlays.rs b/src/client/shell/worktree_overlays.rs
index 318c40190..59c27b016 100644
--- a/src/client/shell/worktree_overlays.rs
+++ b/src/client/shell/worktree_overlays.rs
@@ -78,7 +78,7 @@ pub(super) fn render_worktree_create_overlay(
*primary,
" ↵ create and open ",
Style::default()
- .fg(contrast(p))
+ .fg(p.accent_foreground())
.bg(p.accent)
.add_modifier(Modifier::BOLD),
);
@@ -209,7 +209,7 @@ pub(super) fn render_worktree_open_overlay(
row_hits.push((rect, entry_index));
let selected = entry_index == open.selected;
let style = if selected {
- Style::default().fg(contrast(p)).bg(p.accent)
+ Style::default().fg(p.accent_foreground()).bg(p.accent)
} else {
Style::default().fg(p.text).bg(p.panel_bg)
};
@@ -277,7 +277,7 @@ pub(super) fn render_worktree_open_overlay(
*primary,
" ↵ open ",
Style::default()
- .fg(contrast(p))
+ .fg(p.accent_foreground())
.bg(p.accent)
.add_modifier(Modifier::BOLD),
);
@@ -389,7 +389,7 @@ pub(super) fn render_worktree_remove_overlay(
" ↵ remove "
},
Style::default()
- .fg(contrast(p))
+ .fg(p.fill_foreground())
.bg(p.red)
.add_modifier(Modifier::BOLD),
);
diff --git a/src/terminal_theme.rs b/src/terminal_theme.rs
index 2460731e2..80ac26522 100644
--- a/src/terminal_theme.rs
+++ b/src/terminal_theme.rs
@@ -21,6 +21,23 @@ impl HostAppearance {
}
impl RgbColor {
+ pub(crate) fn contrast_ratio(self, other: Self) -> f64 {
+ fn luminance(color: RgbColor) -> f64 {
+ let channel = |value: u8| {
+ let value = f64::from(value) / 255.0;
+ if value <= 0.04045 {
+ value / 12.92
+ } else {
+ ((value + 0.055) / 1.055).powf(2.4)
+ }
+ };
+ 0.2126 * channel(color.r) + 0.7152 * channel(color.g) + 0.0722 * channel(color.b)
+ }
+ let a = luminance(self);
+ let b = luminance(other);
+ (a.max(b) + 0.05) / (a.min(b) + 0.05)
+ }
+
pub fn inferred_appearance(self) -> HostAppearance {
let luminance = u32::from(self.r) * 299 + u32::from(self.g) * 587 + u32::from(self.b) * 114;
if luminance >= 128_000 {
diff --git a/src/ui/panes.rs b/src/ui/panes.rs
index 6a91f18ac..fad2099e2 100644
--- a/src/ui/panes.rs
+++ b/src/ui/panes.rs
@@ -10,7 +10,6 @@ use super::scrollbar::{render_pane_scrollbar, should_show_scrollbar};
#[cfg(test)]
use super::text::display_width;
use super::text::truncate_end;
-use super::widgets::panel_contrast_fg;
use crate::app::state::Palette;
use crate::app::AppState;
use crate::layout::{PaneId, PaneInfo};
@@ -887,7 +886,7 @@ fn selection_fg_for_bg(bg: Color, p: &Palette) -> Color {
Color::Black
}
})
- .unwrap_or_else(|| panel_contrast_fg(p))
+ .unwrap_or_else(|| p.accent_foreground())
}
fn mix_rgb(base: Rgb, target: Rgb, amount: f32) -> Rgb {
diff --git a/src/ui/status.rs b/src/ui/status.rs
index d8371cdb5..8c75aa1a5 100644
--- a/src/ui/status.rs
+++ b/src/ui/status.rs
@@ -6,7 +6,6 @@ use ratatui::{
widgets::{Block, Borders, Clear, Paragraph, Widget},
};
-use super::widgets::panel_contrast_fg;
use crate::{
app::state::{CopyFeedback, Palette},
config::ToastClipboardPosition,
@@ -95,7 +94,7 @@ pub(crate) fn render_config_diagnostic_buffer(
mut covered: impl FnMut(Rect),
) -> u16 {
let style = Style::default()
- .fg(panel_contrast_fg(palette))
+ .fg(palette.fill_foreground())
.bg(palette.yellow)
.add_modifier(Modifier::BOLD);
let mut rendered_rows = 0u16;
@@ -128,6 +127,45 @@ pub(crate) fn render_config_diagnostic_buffer(
mod tests {
use super::*;
+ #[test]
+ fn config_diagnostic_uses_non_accent_fill_foreground() {
+ use crate::terminal_theme::{RgbColor, TerminalTheme};
+ let mut host = TerminalTheme {
+ foreground: Some(RgbColor {
+ r: 238,
+ g: 238,
+ b: 238,
+ }),
+ background: Some(RgbColor {
+ r: 16,
+ g: 16,
+ b: 16,
+ }),
+ ..Default::default()
+ };
+ host.palette[4] = Some(RgbColor {
+ r: 20,
+ g: 20,
+ b: 245,
+ });
+ host.palette[8] = Some(RgbColor {
+ r: 24,
+ g: 24,
+ b: 24,
+ });
+ let palette = Palette::terminal_for_host(&host);
+ assert_ne!(palette.accent_foreground(), palette.fill_foreground());
+ let area = Rect::new(0, 0, 40, 1);
+ let mut buffer = Buffer::empty(area);
+ let mut diagnostic = Rect::default();
+ render_config_diagnostic_buffer(&mut buffer, area, "invalid config", &palette, |rect| {
+ diagnostic = rect;
+ });
+ let cell = &buffer[(diagnostic.x + 2, diagnostic.y)];
+ assert_eq!(cell.bg, palette.yellow);
+ assert_eq!(cell.fg, palette.fill_foreground());
+ }
+
#[test]
fn copy_feedback_rect_uses_configured_position() {
let area = Rect::new(10, 20, 100, 40);
diff --git a/src/ui/widgets.rs b/src/ui/widgets.rs
index 33fcc9a05..c589ddc48 100644
--- a/src/ui/widgets.rs
+++ b/src/ui/widgets.rs
@@ -1,16 +1,4 @@
-use ratatui::{
- layout::{Constraint, Layout, Rect},
- style::Color,
-};
-
-use crate::app::state::Palette;
-
-pub(super) fn panel_contrast_fg(palette: &Palette) -> Color {
- match palette.panel_bg {
- Color::Reset => palette.surface_dim,
- color => color,
- }
-}
+use ratatui::layout::{Constraint, Layout, Rect};
pub(crate) fn centered_popup_rect(area: Rect, popup_width: u16, popup_height: u16) -> Option<Rect> {
let popup_width = popup_width.min(area.width.saturating_sub(4));