diff --git a/Cargo.lock b/Cargo.lock index 04d91b2..9535699 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.60" +version = "0.1.61" dependencies = [ "anyhow", "chrono", @@ -292,7 +292,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.60" +version = "0.1.61" dependencies = [ "anyhow", "async-trait", @@ -315,7 +315,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.60" +version = "0.1.61" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index c84c186..c7f4a5a 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.61" +version = "0.1.62" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 0c7d136..878f8f0 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.61" +version = "0.1.62" edition = "2021" [dependencies] diff --git a/dashboard/src/app.rs b/dashboard/src/app.rs index 7670ad5..1ae525b 100644 --- a/dashboard/src/app.rs +++ b/dashboard/src/app.rs @@ -149,6 +149,8 @@ impl Dashboard { let mut last_metrics_check = Instant::now(); let metrics_check_interval = Duration::from_millis(100); // Check for metrics every 100ms + let mut last_heartbeat_check = Instant::now(); + let heartbeat_check_interval = Duration::from_secs(1); // Check for host connectivity every 1 second loop { // Handle terminal events (keyboard input) only if not headless @@ -254,14 +256,8 @@ impl Dashboard { } } - // Update TUI with new hosts and metrics (only if not headless) + // Update TUI with new metrics (only if not headless) if let Some(ref mut tui_app) = self.tui_app { - let connected_hosts = self - .metric_store - .get_connected_hosts(Duration::from_secs(self.config.zmq.heartbeat_timeout_seconds)); - - - tui_app.update_hosts(connected_hosts); tui_app.update_metrics(&self.metric_store); } } @@ -280,6 +276,18 @@ impl Dashboard { last_metrics_check = Instant::now(); } + // Check for host connectivity changes (heartbeat timeouts) periodically + if last_heartbeat_check.elapsed() >= heartbeat_check_interval { + if let Some(ref mut tui_app) = self.tui_app { + let connected_hosts = self + .metric_store + .get_connected_hosts(Duration::from_secs(self.config.zmq.heartbeat_timeout_seconds)); + + tui_app.update_hosts(connected_hosts); + } + last_heartbeat_check = Instant::now(); + } + // Render TUI (only if not headless) if !self.headless { if let Some(ref mut terminal) = self.terminal { diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 91a8426..367c9b8 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.61" +version = "0.1.62" edition = "2021" [dependencies]