redbear-power: show load average in header

Add a "Load: 0.42 0.55 0.61" line to render_header, color-coded by load versus core count (green <= 50% capacity, yellow <= 100%, red overcommitted). Bump HEADER_LINES from 7 to 8. Build, 224 tests, clippy, and fmt clean.
This commit is contained in:
Sisyphus Agent
2026-07-07 14:54:41 +03:00
parent eb7b88548b
commit bec5262019
@@ -30,7 +30,7 @@ use crate::cpuid;
use crate::graph::BrailleGraph;
use crate::theme::{self, Theme};
pub const HEADER_LINES: u16 = 7;
pub const HEADER_LINES: u16 = 8;
pub const KEYBAR_LINES: u16 = 1;
pub const TAB_BAR_LINES: u16 = 1;
pub const GRAPH_HEIGHT: u16 = 6;
@@ -268,6 +268,24 @@ pub fn render_header<'a>(app: &'a App, focused: bool) -> Paragraph<'a> {
app.hybrid_summary.as_str().set_style(theme.value_hot)
},
]),
Line::from(vec![
"Load: ".set_style(theme.label),
match app.load_avg {
Some((a, b, c)) => {
let cores = app.cpus.len().max(1) as f64;
let one_minute = a.max(b).max(c);
let style = if one_minute >= cores {
theme.value_hot
} else if one_minute >= cores * 0.5 {
theme.value_warm
} else {
theme.value_ok
};
format!("{a:.2} {b:.2} {c:.2}").set_style(style)
}
None => "n/a".set_style(theme.value_off),
},
]),
Line::from(vec![
"Daemons: ".set_style(theme.label),
"cpufreqd=".set_style(theme.value_off),