Feat: CPU meter in top bar
This commit is contained in:
@@ -407,28 +407,36 @@ fn render_header(
|
||||
pattern_area,
|
||||
);
|
||||
|
||||
// Stats block
|
||||
// Stats block — CPU bar filling the area, text overlaid
|
||||
let cpu_pct = (app.metrics.cpu_load * 100.0).min(100.0);
|
||||
let peers = link.peers();
|
||||
let voices = app.metrics.active_voices;
|
||||
let cpu_color = if cpu_pct >= 80.0 {
|
||||
let cpu_bar_color = if cpu_pct >= 80.0 {
|
||||
theme.flash.error_fg
|
||||
} else if cpu_pct >= 50.0 {
|
||||
theme.ui.accent
|
||||
} else {
|
||||
theme.header.stats_fg
|
||||
theme.meter.low
|
||||
};
|
||||
let dim = Style::new()
|
||||
.bg(theme.header.stats_bg)
|
||||
.fg(theme.header.stats_fg);
|
||||
let stats_line = Line::from(vec![
|
||||
Span::styled(format!(" CPU {cpu_pct:.0}%"), dim.fg(cpu_color)),
|
||||
Span::styled(format!(" V:{voices} L:{peers} "), dim),
|
||||
]);
|
||||
let block_style = Style::new().bg(theme.header.stats_bg);
|
||||
|
||||
frame.render_widget(
|
||||
Paragraph::new(stats_line)
|
||||
.block(Block::default().padding(pad).style(block_style))
|
||||
Block::default().style(Style::new().bg(theme.header.stats_bg)),
|
||||
stats_area,
|
||||
);
|
||||
let filled_w = (cpu_pct / 100.0 * stats_area.width as f32).round() as u16;
|
||||
if filled_w > 0 {
|
||||
frame.render_widget(
|
||||
Block::default().style(Style::new().bg(cpu_bar_color)),
|
||||
Rect {
|
||||
width: filled_w.min(stats_area.width),
|
||||
..stats_area
|
||||
},
|
||||
);
|
||||
}
|
||||
let stats_text = format!("CPU {cpu_pct:.0}% V:{voices}");
|
||||
frame.render_widget(
|
||||
Paragraph::new(stats_text)
|
||||
.block(Block::default().padding(pad))
|
||||
.style(Style::new().fg(theme.ui.text_primary))
|
||||
.alignment(Alignment::Center),
|
||||
stats_area,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user