Skip to main content

Crate nmbrs_tui

Crate nmbrs_tui 

Source
Expand description

§nmbrs-tui

Contract & axioms: SRD 59.

Terminal UI for nmbrs, built on ratatui. Provides a live dashboard showing the scenario tree, per-phase progress and detail blocks, throughput sparklines, latency percentile histograms, an optional log panel, and a help overlay.

§Architecture

  • state::RunState — shared state between the executor thread and the render thread. Holds the canonical SceneTree (parent / children / status), the side-mapped PhaseSummary per node, active-phase live counters, log ring buffer, ops-history sparkline data, etc.
  • app::App — owns the render loop. Reads RunState at the tick rate (default 4 Hz) and produces a frame. Handles keyboard input (LOD cycle, log toggle, pause, help, control-edit prompt).
  • reporter — a nmbrs_metrics::scheduler::Reporter implementation that observers register so per-tick MetricSet snapshots flow into RunState’s sparkline / percentile histories.
  • [widgets] — small custom widgets where ratatui’s built-ins fall short.

Lifecycle: nmbrs builds a run_state_actor::RunStateHandle (the actor owns a private RunState and publishes immutable Arc<RunState> snapshots via arc_swap::ArcSwap), hands the handle to the runner-side executor via observer::TuiObserver and to the TUI thread, and spawns the TUI on a dedicated std::thread (not tokio — the TUI never blocks the async runtime). Observers and the TUI both mutate state by sending typed run_state_actor::RunStateCmd messages into the actor’s inbox; nothing ever takes a write lock on shared state. See SRD-02 §“Display and Diagnostic Decoupling”.

§See also

  • SRD 62 (docs/SRD/62_tui_layout.md) — layout, LOD cycle, phase status glyphs, spinner cadence, “scenario done?” semantics.
  • SRD 18b — scene tree (the canonical structure RunState.tree mirrors).

Modules§

app
TUI application: event loop, terminal setup, frame rendering.
display_sink
DisplaySink — uniform consumer interface for the run-state snapshot stream.
formatted_line_sink
FormattedLineSink — non-interactive, non-positioning display sink for log-archive / piped-stderr runs.
inspector_repl
nmbrs --inspector — interactive REPL TUI for the OOB introspection endpoint (see crate::inspector_server).
inspector_server
Out-of-band introspection endpoint.
key_watcher
Stdin keystroke watcher for terminal-mode display.
log_only_observer
LogOnlyObserver — RunObserver impl for tui=off mode.
log_only_sink
LogOnlySink — DisplaySink impl that renders every log entry to stderr.
observer
TUI-driving [RunObserver] implementation.
repl_state
REPL visibility state machine.
reporter
TUI reporter: receives base-cadence metrics snapshots and forwards them to the TUI render thread via an mpsc channel. Used for sparkline feeds, history rings, and the live percentile display.
run_state_actor
Display-side actor that owns RunState and publishes immutable snapshots.
sink_supervisor
SinkSupervisor — coordinates the active crate::display_sink::DisplaySink and the crate::key_watcher::KeyWatcher across a tui=terminal run.
state
Shared state between the executor and the TUI display.
status_fold
SRD-100 P2 — consumer-side per-phase status renderer.