From a86b5ba8f9a6bda334d589f715e941f03ed1f4e0 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Tue, 28 Oct 2025 18:47:02 +0100 Subject: [PATCH] Implement dynamic status-based title bar with infrastructure health indicator - Title bar background now dynamically changes based on worst-case status across all hosts - Green: all OK, Yellow: warnings present, Red: critical issues, Blue: pending, Gray: unknown - Provides immediate visual feedback of overall infrastructure health - Added 1-character padding on both sides of title bar - Maintains dark text for visibility against all status background colors - Bump version to v0.1.36 --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/ui/mod.rs | 40 ++++++++++++++++++++++++++++------------ shared/Cargo.toml | 2 +- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0aac06a..a856dd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.34" +version = "0.1.35" dependencies = [ "anyhow", "chrono", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.34" +version = "0.1.35" dependencies = [ "anyhow", "async-trait", @@ -314,7 +314,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.34" +version = "0.1.35" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index eef1edc..0d623e9 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.35" +version = "0.1.36" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 9394633..5635fdc 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.35" +version = "0.1.36" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index 5786de0..34ccc59 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -537,11 +537,21 @@ impl TuiApp { if self.available_hosts.is_empty() { let title_text = "cm-dashboard • no hosts discovered"; let title = Paragraph::new(title_text) - .style(Style::default().fg(Theme::background()).bg(Theme::highlight())); + .style(Style::default().fg(Theme::background()).bg(Theme::status_color(Status::Unknown))); frame.render_widget(title, area); return; } + // Calculate worst-case status across all hosts + let mut worst_status = Status::Ok; + for host in &self.available_hosts { + let host_status = self.calculate_host_status(host, metric_store); + worst_status = Status::aggregate(&[worst_status, host_status]); + } + + // Use the worst status color as background + let background_color = Theme::status_color(worst_status); + // Split the title bar into left and right sections let chunks = Layout::default() .direction(Direction::Horizontal) @@ -550,11 +560,11 @@ impl TuiApp { // Left side: "cm-dashboard" text let left_span = Span::styled( - "cm-dashboard", - Style::default().fg(Theme::background()).bg(Theme::highlight()) + " cm-dashboard", + Style::default().fg(Theme::background()).bg(background_color) ); let left_title = Paragraph::new(Line::from(vec![left_span])) - .style(Style::default().bg(Theme::highlight())); + .style(Style::default().bg(background_color)); frame.render_widget(left_title, chunks[0]); // Right side: hosts with status indicators @@ -564,7 +574,7 @@ impl TuiApp { if i > 0 { host_spans.push(Span::styled( " ", - Style::default().fg(Theme::background()).bg(Theme::highlight()) + Style::default().fg(Theme::background()).bg(background_color) )); } @@ -572,33 +582,39 @@ impl TuiApp { let host_status = self.calculate_host_status(host, metric_store); let status_icon = StatusIcons::get_icon(host_status); - // Add status icon with background color as foreground against blue background + // Add status icon with background color as foreground against status background host_spans.push(Span::styled( format!("{} ", status_icon), - Style::default().fg(Theme::background()).bg(Theme::highlight()), + Style::default().fg(Theme::background()).bg(background_color), )); if Some(host) == self.current_host.as_ref() { - // Selected host in bold background color against blue background + // Selected host in bold background color against status background host_spans.push(Span::styled( host.clone(), Style::default() .fg(Theme::background()) - .bg(Theme::highlight()) + .bg(background_color) .add_modifier(Modifier::BOLD), )); } else { - // Other hosts in normal background color against blue background + // Other hosts in normal background color against status background host_spans.push(Span::styled( host.clone(), - Style::default().fg(Theme::background()).bg(Theme::highlight()), + Style::default().fg(Theme::background()).bg(background_color), )); } } + // Add right padding + host_spans.push(Span::styled( + " ", + Style::default().fg(Theme::background()).bg(background_color) + )); + let host_line = Line::from(host_spans); let host_title = Paragraph::new(vec![host_line]) - .style(Style::default().bg(Theme::highlight())) + .style(Style::default().bg(background_color)) .alignment(ratatui::layout::Alignment::Right); frame.render_widget(host_title, chunks[1]); } diff --git a/shared/Cargo.toml b/shared/Cargo.toml index baeedb6..2e09343 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.35" +version = "0.1.36" edition = "2021" [dependencies]