From 14aae90954ebec2f0fe7dc170950a49311e0381a Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Wed, 22 Oct 2025 23:02:16 +0200 Subject: [PATCH] Fix storage display and improve UI formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix duplicate storage pool issue by clearing cache on agent startup - Change storage pool header text to normal color for better readability - Improve services panel tree icons with proper └─ symbols for last items - Ensure fresh metrics data on each agent restart --- agent/src/cache/mod.rs | 14 ++++++++++++-- dashboard/src/ui/mod.rs | 2 +- dashboard/src/ui/widgets/services.rs | 16 ++++++++++------ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/agent/src/cache/mod.rs b/agent/src/cache/mod.rs index affcd18..44b6f19 100644 --- a/agent/src/cache/mod.rs +++ b/agent/src/cache/mod.rs @@ -19,8 +19,8 @@ impl SimpleCache { persist_path: config.persist_path, }; - // Load from disk on startup - cache.load_from_disk(); + // Clear cache file on startup to ensure fresh data + cache.clear_cache_file(); cache } @@ -82,6 +82,16 @@ impl SimpleCache { } } } + + /// Clear cache file on startup to ensure fresh data + fn clear_cache_file(&self) { + if Path::new(&self.persist_path).exists() { + match fs::remove_file(&self.persist_path) { + Ok(_) => info!("Cleared cache file {} on startup", self.persist_path), + Err(e) => warn!("Failed to clear cache file {}: {}", self.persist_path, e), + } + } + } } diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index 2b2412b..35c62f4 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -578,7 +578,7 @@ impl TuiApp { ), ratatui::text::Span::styled( pool_header_text, - Typography::widget_title(), + Style::default().fg(Theme::primary_text()), ), ]; let pool_header_para = Paragraph::new(ratatui::text::Line::from(pool_header_spans)); diff --git a/dashboard/src/ui/widgets/services.rs b/dashboard/src/ui/widgets/services.rs index 441ba91..f2f56f7 100644 --- a/dashboard/src/ui/widgets/services.rs +++ b/dashboard/src/ui/widgets/services.rs @@ -129,6 +129,7 @@ impl ServicesWidget { &self, name: &str, info: &ServiceInfo, + is_last: bool, ) -> Vec> { // Truncate long sub-service names to fit layout (accounting for indentation) let short_name = if name.len() > 18 { @@ -163,11 +164,12 @@ impl ServicesWidget { }; let icon = StatusIcons::get_icon(info.widget_status); + let tree_symbol = if is_last { "└─" } else { "├─" }; vec![ // Indentation and tree prefix ratatui::text::Span::styled( - " ├─ ".to_string(), + format!(" {} ", tree_symbol), Style::default() .fg(Theme::secondary_text()) .bg(Theme::background()), @@ -333,7 +335,7 @@ impl Widget for ServicesWidget { } // Build hierarchical service list for display - let mut display_lines = Vec::new(); + let mut display_lines: Vec<(String, Status, bool, Option<(ServiceInfo, bool)>)> = Vec::new(); // Sort parent services alphabetically for consistent order let mut parent_services: Vec<_> = self.parent_services.iter().collect(); @@ -350,14 +352,15 @@ impl Widget for ServicesWidget { let mut sorted_subs = sub_list.clone(); sorted_subs.sort_by(|(a, _), (b, _)| a.cmp(b)); - for (sub_name, sub_info) in sorted_subs { + for (i, (sub_name, sub_info)) in sorted_subs.iter().enumerate() { + let is_last_sub = i == sorted_subs.len() - 1; // Store sub-service info for custom span rendering display_lines.push(( sub_name.clone(), sub_info.widget_status, true, - Some(sub_info.clone()), - )); // true = sub-service + Some((sub_info.clone(), is_last_sub)), + )); // true = sub-service, with is_last info } } } @@ -377,7 +380,8 @@ impl Widget for ServicesWidget { { let spans = if *is_sub && sub_info.is_some() { // Use custom sub-service span creation - self.create_sub_service_spans(line_text, sub_info.as_ref().unwrap()) + let (service_info, is_last) = sub_info.as_ref().unwrap(); + self.create_sub_service_spans(line_text, service_info, *is_last) } else { // Use regular status spans for parent services StatusIcons::create_status_spans(*line_status, line_text)