diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-08-04 17:26:30 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-04 17:26:30 +0300 |
| commit | cc9fa47540d8525f24fe46a10f759ca40090a6e0 (patch) | |
| tree | ef6979a7d5168952dc2de8d7a68e42b3ad69c45b /src/ui/status.rs | |
| parent | 4473e391962c68d59bd980fa98a44f3397d9931d (diff) | |
feat(ui): add distinct status indicators (#2282)
refs #2260
Diffstat (limited to 'src/ui/status.rs')
| -rw-r--r-- | src/ui/status.rs | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/src/ui/status.rs b/src/ui/status.rs index a7399285..62646482 100644 --- a/src/ui/status.rs +++ b/src/ui/status.rs @@ -10,7 +10,7 @@ use super::text::display_width_u16; use super::widgets::panel_contrast_fg; use crate::{ app::state::{CopyFeedback, Palette, ToastKind, ToastNotification}, - config::{ToastClipboardPosition, ToastHerdrPosition}, + config::{StatusIndicatorStyle, ToastClipboardPosition, ToastHerdrPosition}, detect::AgentState, }; @@ -193,16 +193,37 @@ pub(super) fn render_config_diagnostic(frame: &mut Frame, area: Rect, message: & } } -pub(super) fn state_dot(state: AgentState, seen: bool, p: &Palette) -> (&'static str, Style) { - match (state, seen) { - (AgentState::Blocked, _) => ("●", Style::default().fg(p.red)), - (AgentState::Working, _) => ("●", Style::default().fg(p.yellow)), - (AgentState::Idle, false) => ("●", Style::default().fg(p.teal)), - (AgentState::Idle, true) => ("○", Style::default().fg(p.green)), - (AgentState::Unknown, _) => ("·", Style::default().fg(p.overlay0)), +pub(super) fn state_icon_symbol( + state: AgentState, + seen: bool, + indicator_style: StatusIndicatorStyle, +) -> &'static str { + match (indicator_style, state, seen) { + (StatusIndicatorStyle::Dots, AgentState::Blocked, _) => "●", + (StatusIndicatorStyle::Dots, AgentState::Working, _) => "●", + (StatusIndicatorStyle::Dots, AgentState::Idle, false) => "●", + (StatusIndicatorStyle::Dots, AgentState::Idle, true) => "○", + (StatusIndicatorStyle::Dots, AgentState::Unknown, _) => "·", + (StatusIndicatorStyle::Symbols, AgentState::Blocked, _) => "×", + (StatusIndicatorStyle::Symbols, AgentState::Working, _) => "◐", + (StatusIndicatorStyle::Symbols, AgentState::Idle, false) => "✓", + (StatusIndicatorStyle::Symbols, AgentState::Idle, true) => "○", + (StatusIndicatorStyle::Symbols, AgentState::Unknown, _) => "·", } } +pub(super) fn state_icon( + state: AgentState, + seen: bool, + indicator_style: StatusIndicatorStyle, + p: &Palette, +) -> (&'static str, Style) { + ( + state_icon_symbol(state, seen, indicator_style), + Style::default().fg(state_label_color(state, seen, p)), + ) +} + pub(super) fn state_label(state: AgentState, seen: bool) -> &'static str { match (state, seen) { (AgentState::Blocked, _) => "blocked", @@ -245,18 +266,27 @@ mod tests { } #[test] - fn state_dots_use_aligned_static_workspace_marks() { + fn state_icons_support_dot_and_distinct_symbol_styles() { let palette = Palette::catppuccin(); - for (state, seen, symbol, color) in [ - (AgentState::Blocked, true, "●", palette.red), - (AgentState::Working, true, "●", palette.yellow), - (AgentState::Idle, false, "●", palette.teal), - (AgentState::Idle, true, "○", palette.green), - (AgentState::Unknown, true, "·", palette.overlay0), + for (indicator_style, expected_symbols) in [ + (StatusIndicatorStyle::Dots, ["●", "●", "●", "○", "·"]), + (StatusIndicatorStyle::Symbols, ["×", "◐", "✓", "○", "·"]), ] { - let (actual_symbol, style) = state_dot(state, seen, &palette); - assert_eq!(actual_symbol, symbol); - assert_eq!(style.fg, Some(color)); + for ((state, seen, color), expected_symbol) in [ + (AgentState::Blocked, true, palette.red), + (AgentState::Working, true, palette.yellow), + (AgentState::Idle, false, palette.teal), + (AgentState::Idle, true, palette.green), + (AgentState::Unknown, true, palette.overlay0), + ] + .into_iter() + .zip(expected_symbols) + { + let (actual_symbol, style) = state_icon(state, seen, indicator_style, &palette); + assert_eq!(actual_symbol, expected_symbol); + assert_eq!(display_width_u16(actual_symbol), 1); + assert_eq!(style.fg, Some(color)); + } } } |
