Update system widget layout to new specification

- Remove Active users line from NixOS section
- Add status icons to CPU and RAM sections
- Restructure layout with proper tree symbols and spacing
- Add empty lines between sections for better readability
- Remove Storage header, show each filesystem as top-level item
- Fix tree indentation to match specification
- CPU shows load averages with frequency as sub-item
- RAM shows usage with /tmp as sub-item with status icon
This commit is contained in:
Christoffer Martinsson 2025-10-23 18:35:17 +02:00
parent 473f89fb57
commit 7f5949b818

View File

@ -244,10 +244,6 @@ impl SystemWidget {
/// Render storage section with tree structure
fn render_storage(&self) -> Vec<Line> {
let mut lines = Vec::new();
lines.push(Line::from(vec![
Span::styled("Storage:", Typography::widget_title())
]));
for pool in &self.storage_pools {
// Pool header line
@ -265,8 +261,10 @@ impl SystemWidget {
lines.push(Line::from(pool_spans));
// Drive lines with tree structure
let has_usage_line = pool.usage_percent.is_some();
for (i, drive) in pool.drives.iter().enumerate() {
let tree_symbol = if i == pool.drives.len() - 1 { "└─" } else { "├─" };
let is_last_drive = i == pool.drives.len() - 1;
let tree_symbol = if is_last_drive && !has_usage_line { "└─" } else { "├─" };
let mut drive_info = Vec::new();
if let Some(temp) = drive.temperature {
@ -282,7 +280,7 @@ impl SystemWidget {
};
let mut drive_spans = vec![
Span::raw(" "),
Span::raw(" "),
Span::raw(tree_symbol),
Span::raw(" "),
];
@ -294,7 +292,7 @@ impl SystemWidget {
if pool.usage_percent.is_some() {
let tree_symbol = "└─";
let mut usage_spans = vec![
Span::raw(" "),
Span::raw(" "),
Span::raw(tree_symbol),
Span::raw(" "),
];
@ -408,11 +406,6 @@ impl Widget for SystemWidget {
Span::styled(format!("Build: {}", build_text), Typography::secondary())
]));
let users_text = self.active_users.as_deref().unwrap_or("unknown");
lines.push(Line::from(vec![
Span::styled(format!("Active users: {}", users_text), Typography::secondary())
]));
let agent_hash_text = self.agent_hash.as_deref().unwrap_or("unknown");
let short_hash = if agent_hash_text.len() > 8 && agent_hash_text != "unknown" {
&agent_hash_text[..8]
@ -423,38 +416,44 @@ impl Widget for SystemWidget {
Span::styled(format!("Agent: {}", short_hash), Typography::secondary())
]));
// Empty line
lines.push(Line::from(vec![Span::raw("")]));
// CPU section
lines.push(Line::from(vec![
Span::styled("CPU:", Typography::widget_title())
]));
let load_text = self.format_cpu_load();
let freq_text = self.format_cpu_frequency();
let cpu_spans = StatusIcons::create_status_spans(
self.cpu_status.clone(),
&format!("Load: {} {}", load_text, freq_text)
&format!("CPU: {}", load_text)
);
lines.push(Line::from(cpu_spans));
let freq_text = self.format_cpu_frequency();
lines.push(Line::from(vec![
Span::raw("└─ "),
Span::styled(format!("Freq: {}", freq_text), Typography::secondary())
]));
// RAM section
lines.push(Line::from(vec![
Span::styled("RAM:", Typography::widget_title())
]));
let memory_text = self.format_memory_usage();
let memory_spans = StatusIcons::create_status_spans(
self.memory_status.clone(),
&format!("Usage: {}", memory_text)
&format!("RAM: {}", memory_text)
);
lines.push(Line::from(memory_spans));
let tmp_text = self.format_tmp_usage();
let tmp_spans = StatusIcons::create_status_spans(
let mut tmp_spans = vec![
Span::raw(" └─ "),
];
tmp_spans.extend(StatusIcons::create_status_spans(
self.memory_status.clone(),
&format!("/tmp: {}", tmp_text)
);
));
lines.push(Line::from(tmp_spans));
// Empty line before storage
lines.push(Line::from(vec![Span::raw("")]));
// Storage section with tree structure
lines.extend(self.render_storage());