Terminal UI
Status: In implementation for Epic I (CLI/TUI). This document captures the canonical UX/telemetry contract so
agtopand the daemon evolve in lock-step.
Overview
agtop is a ratatui-based monitor that subscribes to the Runloop bus for live
openings (or replays NDJSON from stdin/files). It presents four panes plus a
status bar:
- Log – streaming log lines (from unified
CT_RUN_EVENTstream). - Plan – DAG state (node status, attempts) derived from
RunEventnodes in the unified stream. - agtop Metrics – per-agent CPU/RSS/tokens and bus health aggregated from
rlp/sys/metrics+rlp/agents/<agent_id>/metrics. - Trace – ladder view of crossings (from
traceevents in the unified stream).
Artifacts remain out of scope for Epic I and will follow in the Observability epic.
Layout snapshots (ASCII)
Live run (streaming)
┌─────────────────────────────────────────────────────────────────────────────┐
│ agtop • mode:user • opening:compose_email (trace 63f1…) • pane:Log • tkns │
│ agents_running:3 • bus_queue_depth:1 • CONFIRM STATUS: clear │
├──────────────────────────────┬──────────────────────────────────────────────┤
│ LOG (rlp/runs/<id>/events) │ PLAN (DAG from run events) │
│ [12:01:03] writer ▸ draft ok │ contacts ✔ context ✔ draft ✱ review … │
│ [12:01:05] critic warn retry │ edges animate attempts / retries │
│ … │ │
├──────────────────────────────┼──────────────────────────────────────────────┤
│ agtop metrics (rlp/sys/*) │ TRACE (rlp/runs/<id>/events kind=trace) │
│ agents_running:3 rss:420MB │ [12:01:02] CLI → router → contact_resolver │
│ msgs_sent:134 drops:0 │ [12:01:04] writer → critic │
│ bus_queue_depth:1 cache:4 │ … ladder scroll │
└──────────────────────────────┴──────────────────────────────────────────────┘
Keyed areas:
- Status bar mirrors the “Status Bar” contract and surfaces confirm state.
- Log/Plan panes share the unified stream; left = textual events, right = DAG view.
- Metrics pane aggregates global/per-agent gauges; Trace pane renders the ladder.
Confirmation prompt visible
┌──────────────────────────────────────────────────────────────────────────────┐
│ … CONFIRM STATUS: PENDING (action.proposal 27ac…) │
├───────────────────────────────┬──────────────────────────────────────────────┤
│ LOG … │ PLAN … │
├───────────────────────────────┴──────────────────────────────────────────────┤
│ CONFIRMATION REQUIRED │
│ Agent mailer proposed sending draft v3 to `john@example.com` │
│ Enter=approve • Esc=reject • (.) pause stream • [?] help │
│ meta{opening_id:draft.send, ttl_ms:15000, trace_id:63f1…} │
├───────────────────────────────┬──────────────────────────────────────────────┤
│ agtop metrics … │ TRACE … │
└───────────────────────────────┴──────────────────────────────────────────────┘
When a confirmation dialog is focused the log/plan panes keep buffering events,
but input focus moves to the overlay; decisions publish action.decision via
the UI/TUI capability described in “Confirmations”.
Status Bar
Always-on, single line:
- Mode:
uservssystem(from config). - Opening: name +
trace_id. - Pane: active pane short name.
- Tokens/Health: summarized token burn, daemon pressure, and
agents_runninggauge. - Confirm Status: shows
CONFIRM REQUIREDwhen a pendingaction.proposalis awaiting a decision.
Keybinds & Controls
agtop is keyboard-only. Defaults:
Tab/Shift+Tab– cycle panes forward/backward.q– quit.?– help overlay (lists panes, keys, topic names)./– filter/search within the active pane (e.g., log substring, node id)..– pause/resume live updates (events buffer while paused and apply on resume).!– clear active pane buffer.Enter– when a confirmation prompt is focused, approve;Escrejects (mirrors CLI confirmation semantics).
Data Plane & Topics
- Run submission: CLI publishes
ControlRequest::RunSubmitonrlp/ctrl. The daemon responds withControlResponse::RunAcceptedand begins emittingCT_RUN_EVENTrecords onrlp/runs/<trace_id>/events. - Unified stream:
rlp/runs/<trace_id>/eventscarries{kind, level?, message, meta{ts_ms, run_id, node_id?, span_id?}}events. - Metrics:
rlp/sys/metrics(global) +rlp/agents/<agent_id>/metrics(per agent). Minimum gauges/counters (Epic J prerequisites):agents_running,rss_total,bus_queue_depth_max,bus_queue_capacity_max,msgs_sent,msgs_dropped,cap_denied,broker_calls,cache_hits. Status bar surfacesagents_runningandbus_queue_depthwhen present. Subscribe to per-agent metrics with--monitor-agentsuntil auto-discovery is added. Frames conform toCT_METRICS_SNAPSHOTv1:{"v":1,"scope":"system|agent","ts_ms":...,"interval_ms":...,"labels":{executor_id,node_id,agent_id?},"gauges":{...},"counters":{...}}. When token usage is unknown, token counters are omitted (rendered as N/A). - Confirmations: Agents emit
action.proposal. Only publishers with kindui|tuimay sendaction.decision. For daemon-backed runs the CLI defers to the TUI (no inline prompt);agtopsurfaces dialogs and publishes the decision. - Ladder (trace pane):
rlp trace <id>and the TUI consume ladder hops emitted on the run stream and persisted inrun.trace.ladder. Each hop captures{ts_ms, from, to, schema_id, frame_len, body_len, msg_id, kind}. Live streams are merged with the persisted ladder;--include-control/--include-dropsopt into control-plane and drop notices when debugging.
UX Principles
- Non-blocking panes: pane switches (
Tab) never pause other streams; pausing is explicit via.. - Structured layout: each pane uses consistent column widths; tables fall
back to JSON view with
--jsonflag (shared between CLI & TUI for scripts/tests). - Error surfacing: desyncs (e.g., missing metrics) render
N/Awith muted styling rather than stale values. Bus disconnects surface in the status bar with reconnect attempts. - Deterministic replay: trace pane can load historical runs via
rlp replay <trace_id>without contacting live agents (side-effect-free replayer).
Accessibility & Theme
- Default theme
mono(Config v1) uses high-contrast colors; no critical signal relies on color alone. - All panes expose textual labels (e.g.,
[WARN] critic timed out) for screen readers. - Keyboard-only interactions; focus indicators are double-underlined entries.
- Future enhancements (post-Epic I): configurable palettes and screen-reader mode.