From 156d707377ea770e0240e889ab429963c812ea4a Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Fri, 21 Nov 2025 16:19:45 +0100 Subject: [PATCH] Add version display and fix status aggregation priorities - Add dynamic version display in top bar using CARGO_PKG_VERSION - Rewrite status aggregation to only show Critical/Warning/OK in top bar - Fix Status enum ordering to prioritize OK over transitional states - Remove blue/gray colors from top bar background --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/ui/mod.rs | 24 ++++++++++-------------- shared/Cargo.toml | 2 +- shared/src/metrics.rs | 14 +++++++------- 6 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64d7d1a..fbae8f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.96" +version = "0.1.97" dependencies = [ "anyhow", "chrono", @@ -301,7 +301,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.96" +version = "0.1.97" dependencies = [ "anyhow", "async-trait", @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.96" +version = "0.1.97" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 33128d5..b2bfdf1 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.97" +version = "0.1.98" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 689f51b..43e7709 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.97" +version = "0.1.98" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index c7b3b21..9a4df62 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -589,12 +589,13 @@ impl TuiApp { // Split the title bar into left and right sections let chunks = Layout::default() .direction(Direction::Horizontal) - .constraints([Constraint::Length(15), Constraint::Min(0)]) + .constraints([Constraint::Length(22), Constraint::Min(0)]) .split(area); - // Left side: "cm-dashboard" text + // Left side: "cm-dashboard" text with version + let title_text = format!(" cm-dashboard v{}", env!("CARGO_PKG_VERSION")); let left_span = Span::styled( - " cm-dashboard", + &title_text, Style::default().fg(Theme::background()).bg(background_color).add_modifier(Modifier::BOLD) ); let left_title = Paragraph::new(Line::from(vec![left_span])) @@ -666,32 +667,27 @@ impl TuiApp { return host_summary_metric.status; } - // Fallback to old aggregation logic with proper Pending handling + // Rewritten status aggregation - only Critical, Warning, or OK for top bar let mut has_critical = false; let mut has_warning = false; - let mut ok_count = 0; for metric in &metrics { match metric.status { Status::Critical => has_critical = true, Status::Warning => has_warning = true, - Status::Pending => ok_count += 1, // Treat pending as OK for aggregation - Status::Ok => ok_count += 1, - Status::Inactive => ok_count += 1, // Treat inactive as OK for aggregation - Status::Unknown => ok_count += 1, // Treat unknown as OK for aggregation - Status::Offline => {}, // Ignore offline for aggregation + // Treat all other statuses as OK for top bar aggregation + Status::Ok | Status::Pending | Status::Inactive | Status::Unknown => {}, + Status::Offline => {}, // Ignore offline } } - // Priority order: Critical > Warning > Ok > Unknown (no Pending) + // Only return Critical, Warning, or OK - no other statuses if has_critical { Status::Critical } else if has_warning { Status::Warning - } else if ok_count > 0 { - Status::Ok } else { - Status::Unknown + Status::Ok } } diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 062283f..006d560 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.97" +version = "0.1.98" edition = "2021" [dependencies] diff --git a/shared/src/metrics.rs b/shared/src/metrics.rs index e4cd409..1df9bce 100644 --- a/shared/src/metrics.rs +++ b/shared/src/metrics.rs @@ -82,13 +82,13 @@ impl MetricValue { /// Health status for metrics #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] pub enum Status { - Inactive, // Lowest priority - treated as good - Ok, // Second lowest - also good - Unknown, - Offline, - Pending, - Warning, - Critical, + Inactive, // Lowest priority + Unknown, // + Offline, // + Pending, // + Ok, // 5th place - good status has higher priority than unknown states + Warning, // + Critical, // Highest priority } impl Status {