Skip to main content

Module repl_state

Module repl_state 

Source
Expand description

REPL visibility state machine.

The interactive REPL — the command prompt at the bottom of the terminal that accepts set, controls, metrics …, and other inspector commands — has three visibility states:

  • Hidden (default): no prompt rendered, no input accepted, the status block fills the bottom region. This is the baseline for non-interactive runs.
  • Bar: a single-row prompt at the bottom of the terminal, accepting commands. The status block remains visible above it.
  • Window: a full-screen REPL — most of the terminal is turned over to the command interface with command history visible. The status block is suppressed in this mode.

§Keys

  • ~: cycle Hidden ↔ Bar. From Window, returns to Hidden. Tilde is the universal “toggle off” key — pressing it from any visible state collapses to Hidden.
  • ` (backtick): open or close Window. From Hidden or Bar, opens to Window; from Window, returns to Hidden. Picked over the originally-spec’d Ctrl-~ because terminals deliver the bare chord more reliably than the Ctrl-modified one.

§Coordination

State lives in a process-global atomic (AtomicU8). The key watcher (which sees ~ presses) stamps the state; the LogOnlySink reads it on every render tick to decide whether to draw the prompt. No locks — every reader picks up the latest write within one render frame.

Enums§

ReplVisibility

Functions§

current
Current REPL visibility. Read on every render tick by the LogOnlySink to decide whether to draw the prompt and how to lay out the bottom region.
push_transcript
Push the operator’s command echo + the dispatcher’s response onto the transcript ring. Each line lands as its own entry so the renderer’s “last N rows” slice maps directly to display rows. Older entries fall off the front when the ring is full.
push_transcript_line
Push a single pre-rendered line to the transcript ring — e.g. a completion-suggestion row — with no > command echo. Same ring and capacity discipline as push_transcript. Used to keep ephemeral console output inside the frame instead of scrolling it through the terminal.
toggle_bar
Apply the ~ keystroke transition:
toggle_window
Apply the Ctrl-~ keystroke transition:
transcript_len
Current number of lines in the transcript ring. Cheap change detector for the console renderer — when it differs from the last paint, the console (on the alternate screen) repaints to show new output, regardless of which source pushed it.
transcript_tail
Snapshot the most recent n transcript lines in display order (oldest first). Returns <= n strings — fewer when the transcript is shorter than n.