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:
@@ -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,
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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>,
|
||||
|
||||
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user