corelens 0.1.0

Linux TUI for CPU topology, local AI workloads, and GPU metrics
Documentation
use crate::{
    app::{App, Focus},
    ui::cpu_status::core_type_status,
};
use ratatui::{prelude::*, widgets::Paragraph};

pub fn render(frame: &mut Frame<'_>, area: Rect, app: &App) {
    let diagnostics = if app.diagnostics {
        format!(" · {}", diagnostics(app))
    } else {
        String::new()
    };
    let focus = match app.focus {
        Focus::Cpu => "CPU",
        Focus::Workload => "WORKLOAD",
        Focus::Gpu => "GPU",
        Focus::Ollama => "OLLAMA",
        Focus::ProcessBrowser => "PROCESSES",
    };
    let errors = if app.status.is_empty() {
        "Live".to_owned()
    } else {
        app.status.join(" | ")
    };
    let topology_warning = if app.cpu.diagnostics.has_mismatch() {
        " · ⚠ topology mismatch"
    } else {
        ""
    };
    frame.render_widget(Paragraph::new(format!(" corelens · {errors} · {}{topology_warning} · focus {focus}{diagnostics}   c view · p processes · d details · ? help · q quit", core_type_status(app))), area);
}

fn diagnostics(app: &App) -> String {
    let mut sources = app
        .cpu
        .cpus
        .iter()
        .map(|cpu| {
            format!(
                "{} {}%",
                cpu.detection.source.label(),
                cpu.detection.confidence_percent
            )
        })
        .collect::<Vec<_>>();
    sources.sort();
    sources.dedup();
    if sources.is_empty() {
        "no CPU metadata".into()
    } else {
        sources.join(", ")
    }
}