Interactive terminal UI
The interactive terminal UI is the local control surface for a running Simnet. It gives an engineer a live view of chain progress, logs, transactions, and startup work while sending a small set of control commands back to the local environment.
Simnet session
The Simnet session is a local Solana environment that can use a remote RPC source or run offline. The terminal UI starts only for an interactive surfpool start run; --no-tui, daemon mode, and CI use log output instead. The same session can also expose RPC and Surfpool Studio links for tools that need a browser or API view. See CLI and server and User interfaces.
flowchart LR
Start["surfpool start"] --> Session["Local Simnet session"]
Session --> RPC["RPC and WebSocket services"]
Session --> Studio["Surfpool Studio"]
Session --> Events["Simnet events"]
Events --> TUI["Interactive terminal UI"]
TUI --> Commands["Clock, slot, block mode, and stop commands"]
Commands --> Session
The session first starts its core services. The CLI then plans startup work such as account loading and runbook execution, and seals that plan before the environment can report readiness. The UI receives the resulting event stream and keeps the display useful during both startup and normal transaction processing.
References: crates/…/mod.rs• L63-101 crates/…/mod.rs• L188-243 crates/…/mod.rs• L248-288 crates/…/mod.rs• L951-998
Terminal display
The display is organized around the state an engineer needs while testing a local environment. A header shows the current slot and epoch progress plus the service URL. The main area switches between logs and transactions, while the footer shows help or a temporary status message.
| Area | Purpose |
|---|---|
| Slot and epoch | Shows simulated chain progress and whether the clock is paused. |
| Service link | Shows the active Studio URL or the RPC URL when Studio is disabled. |
| Logs | Shows time-stamped information, warning, error, success, and optional debug events. |
| Transactions | Shows processed transaction signatures and whether each one succeeded. Studio-backed sessions make signatures into transaction links. |
| Footer | Shows the active runbook status when work is pending. Otherwise it shows the basic key hints. |
The UI keeps a local view of events as they arrive. It updates chain counters from clock and epoch events, records processed transactions, and scrolls to new messages. Debug output is included only when the configured log level is debug. Terminal capability checks select a safe color set for older terminals or terminals with limited color support.
References: crates/…/simnet.rs• L44-69 crates/…/simnet.rs• L84-188 crates/…/simnet.rs• L190-242 crates/…/simnet.rs• L252-339 crates/…/simnet.rs• L784-1170
Startup interaction
Startup interaction connects project preparation to the same event view used for live operation. The CLI inspects the project, loads declared remote accounts when needed, and runs the selected startup runbooks. Runbook progress appears as logs or a temporary status message, so the engineer can see work in progress without a second console.
When startup work completes, the UI marks the runbook as complete and resumes normal transaction reporting. A startup failure remains visible in the interactive session instead of being hidden by a background shutdown watchdog. In headless modes, the watchdog instead terminates a failed session so readiness clients do not wait for an environment that cannot become ready. See Runbook automation.
sequenceDiagram
participant CLI
participant Simnet
participant Startup
participant UI
CLI->>Simnet: Start local services
Simnet-->>CLI: Core started
CLI->>Startup: Inspect project and build startup plan
CLI->>Simnet: Seal startup tasks
CLI->>Startup: Load accounts and run runbooks
Startup-->>UI: Progress and log events
Simnet-->>UI: Lifecycle and chain events
Startup-->>Simnet: Task completion
Simnet-->>UI: Runbook completion or failure
The event channel separates lifecycle events from ordinary log traffic. Lifecycle events must reach the UI, while log-class events can be dropped when a bounded channel is under pressure. This keeps a busy session from blocking the Simnet on display-only output.
References: crates/…/startup.rs• L84-135 crates/…/startup.rs• L334-452 crates/…/types.rs• L434-479 crates/…/types.rs• L572-647
Keyboard controls
Keyboard controls let the engineer inspect the event history and change the local chain state without leaving the session. The controls act through Simnet commands, so the UI does not directly own the chain state.
| Key | Action |
|---|---|
q or Esc | Request a graceful session stop. |
Ctrl-C | Request a graceful session stop. |
Up / Down | Move through the selected log or transaction list. |
Left / Right | Select the Logs or Transactions tab. |
Space | Toggle the simulated clock between running and paused. |
Tab | Advance the simulated slot once. |
t | Use transaction-driven block production. |
c | Use clock-driven block production. |
f or j | Send a small transaction to the local RPC endpoint to break or wake the chain. |
Clock toggles and slot advances change simulated time through the command channel. Block production mode changes decide whether new blocks follow clock movement or transaction activity. The f and j action uses the configured breaker keypair to send a small transfer, so it is a diagnostic action rather than a normal user transaction flow.
References: crates/…/simnet.rs• L437-455 crates/…/simnet.rs• L718-781 crates/…/types.rs• L741-786
Transaction monitoring
Transaction monitoring turns Simnet processing events into a short local history. Each processed transaction is shown with a success or failure marker and its signature. Successful transaction logs are added to the log view after startup runbooks finish, while failures remain visible when they occur.
The UI can show a Studio transaction link when Studio is enabled. When Studio is disabled, it shows the raw signature instead. This makes the terminal useful as a fast monitor while preserving a path to richer transaction inspection in the related Studio UI.
References: crates/…/simnet.rs• L536-567 crates/…/simnet.rs• L1087-1135 crates/…/mod.rs• L148-186
Shutdown behavior
Shutdown is a command-driven handoff from the UI to the Simnet. The UI sends a terminate command for q, Esc, or Ctrl-C, exits its event loop, restores the terminal, and lets the service coordinator stop the Studio server and wait for the Simnet thread to clean up.
The UI also exits when it receives a Simnet shutdown event. An aborted session stops the display loop, while the surrounding CLI returns the failure to the process caller. This distinction lets a user stop a healthy session cleanly and still see startup or runtime failures as errors.
References: crates/…/simnet.rs• L395-434 crates/…/simnet.rs• L458-575 crates/…/mod.rs• L358-405
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the keyboard table aligned with the
SimnetCommandvariants and the command-loop behavior. A key can appear to work while no service state changes if either side changes alone. - Keep startup event handling aligned with startup planning and the readiness contract. The UI must not treat a planning, task, or shutdown event as the same state.
- Keep transaction display links aligned with the sanitized service URLs. Studio-disabled sessions must continue to show usable raw RPC context.
- Keep the event delivery policy aligned with the event consumers. Lifecycle events must remain lossless even when log traffic is high.
- Keep terminal color choices compatible with the capabilities reported by the terminal. A richer palette must not make the display unreadable in a limited terminal.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Startup plan is not sealed | The Simnet cannot become ready. | The CLI seals the plan before dispatching startup tasks, or seals an empty plan when deployment is disabled. |
| Startup task fails in headless mode | A readiness client could otherwise wait on a dead session. | The startup watchdog emits an abort and sends a terminate command. |
| Log traffic fills the event channel | Display-only messages may be lost. | Log events use lossy delivery; lifecycle events use lossless delivery. |
| Terminal exits without cleanup | Raw mode or the alternate screen can remain active. | The UI disables raw mode, leaves the alternate screen, and restores the cursor after the run loop. |
| Studio is disabled | Transaction entries cannot link to Studio. | The transaction tab falls back to the transaction signature. |
Key files
| File | Why to read it |
|---|---|
| crates/…/simnet.rs | Defines the interactive display, event model, keyboard controls, and terminal cleanup. |
| crates/…/mod.rs | Connects local Simnet startup to the UI or to headless log output. |
| crates/…/startup.rs | Explains how startup work is planned, dispatched, watched, and reported. |
| crates/…/types.rs | Defines the event and command vocabulary shared by the Simnet and its frontends. |
| crates/…/mod.rs | Defines the start runtime choices that select the interactive UI, headless output, or daemon behavior. |
| crates/…/mod.rs | Shows how runbook progress reaches the Simnet frontends. |