Expand description
Centralized colour palette. Set once at startup from
crate::config::UiConfig::theme; read by screens via
active.
Themes are deliberately slot-based: each slot is a semantic
intent (Pass / Warn / Fail / Header / etc.), not a literal colour.
Components ask the active theme “what colour for Warn?” rather
than hard-coding Color::Yellow — that’s what makes a mono
variant possible without rewriting every component.
The migration is incremental: components flip from hard-coded
Color literals to [active().pass] etc. as their commits
land. The first migrated component (S1 Health) ships in the same
commit as the theme module.
Structs§
- Glyphs
- Slot-based glyph set, sibling of
Theme. Components asktheme::active().glyphs.passfor the “Pass” glyph rather than hardcoding"✓"— that’s what makes--asciiwork without touching every screen. - Theme
- Slot-based colour palette. New slots get added as components are migrated; never break a slot’s meaning between releases.
Functions§
- active
- Read the active theme. Returns the default palette if
installwas never called (e.g. in unit tests that don’t go throughApp::new). - advance_
spinner - Bump the spinner counter — called from the central Tick handler so every screen sees the same frame at the same time.
- classify_
header_ error - Classify a header-line error message into a render colour + a
friendlier prefix. Bee returns
HTTP 503: Node is syncing. This endpoint is unavailable. Try again later.for almost every endpoint during the first few minutes after startup; rendering that in red as a hard error gives a terrible first impression. We detect the syncing case and render it inwarncolour with a one-sentence explanation. - from_
name - Resolve a theme name to a
Theme. Unknown names fall back to the default palette with a single tracing warning so the operator notices the typo without the binary refusing to start. - install
- Set the active theme from the
[ui]config section. Called once duringcrate::app::App::new. Re-calling silently no-ops; full runtime theme switching is a v0.6 feature. - install_
with_ overrides - Resolution rules for
--ascii/--no-color/NO_COLOR, applied on top of the[ui]config section. CLI flags win over env, env wins over config — the operator who typed--asciigets ASCII, and aNO_COLOR=1runtime override on a coloured[ui].theme = "default"config still demotes to mono. - no_
color_ env - Detect whether the host terminal asked us to suppress colour.
Honours the no-color.org convention —
any non-empty
NO_COLORenv var means “no colour”. - spinner_
glyph - Current spinner glyph. Resolves against the active glyph set
(Unicode or ASCII) so cold-start polish honours
--ascii. Detection is by content equality against the canonical pass glyph (✓vsOK) — pointer comparison is unreliable across builds because the compiler may or may not dedup the string literal.