This commit is contained in:
2025-10-12 16:01:56 +02:00
parent c3dbaeead2
commit bd6c14c8c1
9 changed files with 216 additions and 116 deletions

View File

@@ -35,6 +35,7 @@ struct HostRuntimeState {
smart: Option<SmartMetrics>,
services: Option<ServiceMetrics>,
backup: Option<BackupMetrics>,
service_description_cache: HashMap<String, Vec<String>>, // service_name -> last_known_descriptions
}
/// Top-level application state container.
@@ -259,7 +260,25 @@ impl App {
if service_metrics.timestamp != timestamp {
service_metrics.timestamp = timestamp;
}
let snapshot = service_metrics.clone();
let mut snapshot = service_metrics.clone();
// Update description cache and fill in missing descriptions
for service in &mut snapshot.services {
// If service has a new description, cache it
if let Some(ref description) = service.description {
if !description.is_empty() {
state.service_description_cache.insert(service.name.clone(), description.clone());
}
}
// If service has no description but we have a cached one, use it
if service.description.is_none() || service.description.as_ref().map_or(true, |d| d.is_empty()) {
if let Some(cached_description) = state.service_description_cache.get(&service.name) {
service.description = Some(cached_description.clone());
}
}
}
self.history.record_services(service_metrics);
state.services = Some(snapshot);
}