From 0a13cab897f989a380cf2e453d8d3dd98b0bd68b Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 13 Nov 2025 11:26:58 +0100 Subject: [PATCH] Add detected IP display in dashboard Agent row Display the connection IP address that the dashboard is configured to use for each host below the Agent version information. Shows which network path (local/Tailscale) is being used for connections based on host configuration. Features: - Display detected IP below Agent row in system widget - Uses existing host configuration connection logic - Shows actual IP being used for dashboard connections --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/ui/mod.rs | 4 +++- dashboard/src/ui/widgets/system.rs | 12 +++++++++++- shared/Cargo.toml | 2 +- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6334380..e7e640d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.66" +version = "0.1.67" dependencies = [ "anyhow", "chrono", @@ -292,7 +292,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.66" +version = "0.1.67" dependencies = [ "anyhow", "async-trait", @@ -315,7 +315,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.66" +version = "0.1.67" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 41d7383..5cd0dbd 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.67" +version = "0.1.68" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 6d74406..99d4726 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.67" +version = "0.1.68" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index c3f9489..fbee6f3 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -829,8 +829,10 @@ impl TuiApp { let host_widgets = self.get_or_create_host_widgets(&hostname); host_widgets.system_scroll_offset }; + // Clone the config to avoid borrowing issues + let config = self.config.clone(); let host_widgets = self.get_or_create_host_widgets(&hostname); - host_widgets.system_widget.render_with_scroll(frame, inner_area, scroll_offset, &hostname); + host_widgets.system_widget.render_with_scroll(frame, inner_area, scroll_offset, &hostname, Some(&config)); } } diff --git a/dashboard/src/ui/widgets/system.rs b/dashboard/src/ui/widgets/system.rs index 2c956a8..a10bf8d 100644 --- a/dashboard/src/ui/widgets/system.rs +++ b/dashboard/src/ui/widgets/system.rs @@ -439,7 +439,7 @@ impl Widget for SystemWidget { impl SystemWidget { /// Render with scroll offset support - pub fn render_with_scroll(&mut self, frame: &mut Frame, area: Rect, scroll_offset: usize, hostname: &str) { + pub fn render_with_scroll(&mut self, frame: &mut Frame, area: Rect, scroll_offset: usize, hostname: &str, config: Option<&crate::config::DashboardConfig>) { let mut lines = Vec::new(); // NixOS section @@ -457,6 +457,16 @@ impl SystemWidget { Span::styled(format!("Agent: {}", agent_version_text), Typography::secondary()) ])); + // Display detected connection IP + if let Some(config) = config { + if let Some(host_details) = config.hosts.get(hostname) { + let detected_ip = host_details.get_connection_ip(hostname); + lines.push(Line::from(vec![ + Span::styled(format!("IP: {}", detected_ip), Typography::secondary()) + ])); + } + } + // CPU section lines.push(Line::from(vec![ diff --git a/shared/Cargo.toml b/shared/Cargo.toml index a3590bc..fb461ed 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.67" +version = "0.1.68" edition = "2021" [dependencies]