Wire everything up.

This commit is contained in:
Drew 2026-02-23 23:58:02 -08:00
parent c564f197b5
commit 05176c7742
15 changed files with 726 additions and 49 deletions

View file

@ -1,5 +1,3 @@
// Types and functions are scaffolding — wired into main.rs in Stage 1.6.
#![allow(dead_code)]
//! TUI frontend: terminal lifecycle, rendering, and input handling.
//!
@ -37,9 +35,6 @@ pub enum TuiError {
/// An underlying terminal I/O error.
#[error("terminal IO error: {0}")]
Io(#[from] std::io::Error),
/// The action channel was closed before the event loop exited cleanly.
#[error("action channel closed")]
ChannelClosed,
}
/// The UI-layer view of a conversation: rendered messages and the current input buffer.
@ -209,13 +204,13 @@ fn update_scroll(state: &mut AppState, area: Rect) {
///
/// Layout (top to bottom):
/// ```text
/// ┌──────────────────────────────┐
/// │ conversation history │ Fill(1)
/// │ │
/// ├──────────────────────────────┤
/// │ Input │ Length(3)
/// │ > _ │
/// └──────────────────────────────┘
/// +--------------------------------+
/// | conversation history | Fill(1)
/// | |
/// +--------------------------------+
/// | Input | Length(3)
/// | > _ |
/// +--------------------------------+
/// ```
///
/// Role headers are coloured: `"You:"` in cyan, `"Assistant:"` in green.
@ -255,8 +250,8 @@ fn render(frame: &mut Frame, state: &AppState) {
/// ```text
/// loop:
/// 1. drain UIEvents (non-blocking try_recv)
/// 2. poll keyboard for up to 16 ms ← spawn_blocking keeps async runtime free
/// 3. handle key event Option<LoopControl>
/// 2. poll keyboard for up to 16 ms (<- spawn_blocking keeps async runtime free)
/// 3. handle key event -> Option<LoopControl>
/// 4. render frame (scroll updated inside draw closure)
/// 5. act on LoopControl: send message or break
/// ```