Skip to main content

Module interactive_tui

Module interactive_tui 

Source
Expand description

Interactive mode for pi-cli.

Full-screen terminal UI with a streaming transcript, an editor, a live status indicator, and tool-execution display. Mirrors the TypeScript packages/coding-agent/src/modes/interactive/interactive-mode.ts event→UI mapping (handleEvent), driven by the live AgentEvent stream the harness emits via the BroadcastEmitter installed in crate::session.

Key architecture facts (see docs/tui-gap-analysis.md):

  • TuiAltScreen::start() and show_overlay are stubs, so this module owns a spawn_blocking crossterm read() loop for key dispatch and a tokio::spawn task that drains broadcast::Receiver<AgentEvent> into UI mutations.
  • The layout root is built ONCE at startup (mirrors the TS fullscreenLayoutRoot); per-message we mutate only chat_container / status_container / autocomplete_container children and call request_render(false) so the differential renderer repaints just the changed rows.
  • Selectors (/model /session /theme) are implemented by swapping the editor_container child (the TS showSelector swap pattern, interactive-mode.ts:4354-4377) — the show_overlay stub is avoided entirely. An active_selector state field holds the live SelectList; while it is Some the key loop routes to it first and restores the editor on done/cancel.

Functions§

interactive_tui
TUI-based interactive mode.
is_tui_supported
Check if the terminal supports TUI mode.