OXYGENHUB

Coverage / src/cli/marks.rs 95.0%

19 of 20 lines run, 2 of 4 functions · run #28 on main · run missed

1
//! Spectra's own marks beside `ui.rs`: presence and agent health.
2
3
use super::ui::{dim, glyph, ok, warn};
4
use console::style;
5
6
/// An agent's presence (spec §8.1) as a coloured glyph and word.
71×
pub fn presence(state: &str) -> String {
81×
    let (g, a) = match state {
91×
        "online" => ("●", "*"),
101×
        "busy" => ("◆", "+"),
111×
        "idle" => ("◌", "o"),
121×
        "blocked" => ("‼", "!"),
131×
        "paused" => ("⏸", "="),
141×
        _ => ("○", "-"),
15
    };
161×
    let text = format!("{} {state:<7}", glyph(g, a));
171×
    match state {
181×
        "online" => ok(text),
191×
        "busy" => style(text).cyan().to_string(),
201×
        "blocked" | "paused" => warn(text),
211×
        _ => dim(text),
22
    }
231×
}
24
25
/// Whether an agent may act: a tick, or a warning with the reason.
261×
pub fn health(state: &str) -> String {
271×
    if state == "ok" {
280×
        ok(glyph("✔", "ok"))
29
    } else {
301×
        warn(glyph("⚠", "!"))
31
    }
321×
}