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,
};
// 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),
}
}
}
}

View File

@ -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));

View File

@ -129,6 +129,7 @@ impl ServicesWidget {
&self,
name: &str,
info: &ServiceInfo,
is_last: bool,
) -> Vec<ratatui::text::Span<'static>> {
// 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)