OXYGENHUB
# 8cfb9269bb14 spectra / src / cli / marks.rs
989 B · Rust · last changed Projects with relations from .oxymodules, presence and sessions; projections skip malformed payloads (#5) 2 days ago source blame history raw
1
//! Spectra's own marks, in the style of `oxy`'s (`ui.rs` stays exactly
2
//! `oxy`'s, so the two tools look the same): presence and agent health.
3
4
use super::ui::{dim, glyph, ok, warn};
5
use console::style;
6
7
/// An agent's presence (spec §8.1) as a coloured glyph and word.
8
pub fn presence(state: &str) -> String {
9
    let (g, a) = match state {
10
        "online" => ("●", "*"),
11
        "busy" => ("◆", "+"),
12
        "idle" => ("◌", "o"),
13
        "blocked" => ("‼", "!"),
14
        "paused" => ("⏸", "="),
15
        _ => ("○", "-"),
16
    };
17
    let text = format!("{} {state:<7}", glyph(g, a));
18
    match state {
19
        "online" => ok(text),
20
        "busy" => style(text).cyan().to_string(),
21
        "blocked" | "paused" => warn(text),
22
        _ => dim(text),
23
    }
24
}
25
26
/// Whether an agent may act: a tick, or a warning with the reason.
27
pub fn health(state: &str) -> String {
28
    if state == "ok" {
29
        ok(glyph("✔", "ok"))
30
    } else {
31
        warn(glyph("⚠", "!"))
32
    }
33
}