Implement per-host widget cache for instant host switching

Resolves widget data persistence issue where switching hosts left stale data
from the previous host displayed in widgets.

Key improvements:
- Add Clone derives to all widget structs (CpuWidget, MemoryWidget,
  ServicesWidget, BackupWidget)
- Create HostWidgets struct to cache widget states per hostname
- Update TuiApp with HashMap<String, HostWidgets> for per-host storage
- Fix borrowing issues by cloning hostname before mutable self borrow
- Implement instant widget state restoration when switching hosts

Tab key host switching now displays cached widget data for each host
without stale information persistence between switches.
This commit is contained in:
2025-10-18 19:54:08 +02:00
parent 46cc813a68
commit 4b7d08153c
5 changed files with 72 additions and 35 deletions

View File

@@ -10,6 +10,7 @@ use super::Widget;
use crate::ui::theme::{Theme, Typography, Components, StatusIcons};
/// Backup widget displaying backup status, services, and repository information
#[derive(Clone)]
pub struct BackupWidget {
/// Overall backup status
overall_status: Status,

View File

@@ -10,6 +10,7 @@ use super::Widget;
use crate::ui::theme::{Theme, Typography, Components, StatusIcons};
/// CPU widget displaying load, temperature, and frequency
#[derive(Clone)]
pub struct CpuWidget {
/// CPU load averages (1, 5, 15 minutes)
load_1min: Option<f32>,

View File

@@ -10,6 +10,7 @@ use super::Widget;
use crate::ui::theme::{Theme, Typography, Components, StatusIcons};
/// Memory widget displaying usage, totals, and swap information
#[derive(Clone)]
pub struct MemoryWidget {
/// Memory usage percentage
usage_percent: Option<f32>,

View File

@@ -12,6 +12,7 @@ use crate::ui::theme::{Theme, Typography, Components, StatusIcons};
use ratatui::style::Style;
/// Services widget displaying hierarchical systemd service statuses
#[derive(Clone)]
pub struct ServicesWidget {
/// Parent services (nginx, docker, etc.)
parent_services: HashMap<String, ServiceInfo>,