Fix storage display and improve UI formatting

- 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
This commit is contained in:
Christoffer Martinsson 2025-10-22 23:02:16 +02:00
parent 52d630a2e5
commit 14aae90954
3 changed files with 23 additions and 9 deletions

View File

@ -19,8 +19,8 @@ impl SimpleCache {
persist_path: config.persist_path, persist_path: config.persist_path,
}; };
// Load from disk on startup // Clear cache file on startup to ensure fresh data
cache.load_from_disk(); cache.clear_cache_file();
cache 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),
}
}
}
} }

View File

@ -578,7 +578,7 @@ impl TuiApp {
), ),
ratatui::text::Span::styled( ratatui::text::Span::styled(
pool_header_text, 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)); let pool_header_para = Paragraph::new(ratatui::text::Line::from(pool_header_spans));

View File

@ -129,6 +129,7 @@ impl ServicesWidget {
&self, &self,
name: &str, name: &str,
info: &ServiceInfo, info: &ServiceInfo,
is_last: bool,
) -> Vec<ratatui::text::Span<'static>> { ) -> Vec<ratatui::text::Span<'static>> {
// Truncate long sub-service names to fit layout (accounting for indentation) // Truncate long sub-service names to fit layout (accounting for indentation)
let short_name = if name.len() > 18 { let short_name = if name.len() > 18 {
@ -163,11 +164,12 @@ impl ServicesWidget {
}; };
let icon = StatusIcons::get_icon(info.widget_status); let icon = StatusIcons::get_icon(info.widget_status);
let tree_symbol = if is_last { "└─" } else { "├─" };
vec![ vec![
// Indentation and tree prefix // Indentation and tree prefix
ratatui::text::Span::styled( ratatui::text::Span::styled(
" ├─ ".to_string(), format!(" {} ", tree_symbol),
Style::default() Style::default()
.fg(Theme::secondary_text()) .fg(Theme::secondary_text())
.bg(Theme::background()), .bg(Theme::background()),
@ -333,7 +335,7 @@ impl Widget for ServicesWidget {
} }
// Build hierarchical service list for display // 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 // Sort parent services alphabetically for consistent order
let mut parent_services: Vec<_> = self.parent_services.iter().collect(); 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(); let mut sorted_subs = sub_list.clone();
sorted_subs.sort_by(|(a, _), (b, _)| a.cmp(b)); 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 // Store sub-service info for custom span rendering
display_lines.push(( display_lines.push((
sub_name.clone(), sub_name.clone(),
sub_info.widget_status, sub_info.widget_status,
true, true,
Some(sub_info.clone()), Some((sub_info.clone(), is_last_sub)),
)); // true = sub-service )); // true = sub-service, with is_last info
} }
} }
} }
@ -377,7 +380,8 @@ impl Widget for ServicesWidget {
{ {
let spans = if *is_sub && sub_info.is_some() { let spans = if *is_sub && sub_info.is_some() {
// Use custom sub-service span creation // 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 { } else {
// Use regular status spans for parent services // Use regular status spans for parent services
StatusIcons::create_status_spans(*line_status, line_text) StatusIcons::create_status_spans(*line_status, line_text)