1.7 KiB
| title | status | type | priority | created_at | updated_at | parent | blocked_by | |
|---|---|---|---|---|---|---|---|---|
| TUI: terminal setup, event loop, and teardown | completed | task | normal | 2026-03-30T04:45:32Z | 2026-03-30T16:47:13Z | claudbg-i6l2 |
|
Implement terminal initialization, the main event loop, and graceful teardown.
Responsibilities
-
Setup: enable raw mode (
crossterm::terminal::enable_raw_mode), switch to alternate screen (EnterAlternateScreen), createCrosstermBackend, instantiateratatui::Terminal. -
Panic hook: install a panic hook that restores the terminal before printing the panic message (prevents garbled terminal on crash).
-
Event loop:
loop { terminal.draw(|f| render(f, &state)); if event::poll(Duration::from_millis(50))? { handle_event(event::read()?, &mut state); } if state.should_quit { break; } } -
Teardown: disable raw mode, leave alternate screen.
Entry point
Replaces the stub in src/commands/stubs.rs (the Tui command handler). The tui() async function should call into a synchronous run_tui() function since ratatui is sync.
Notes
- Use
crossterm::event::Eventfor keyboard input — no mouse needed for this milestone. - The 50 ms poll timeout gives ~20 fps without busy-spinning.
- Teardown must run even on error: use a RAII guard or wrap in a closure.
Blocked by
- ratatui deps (claudbg-78xt), app state (claudbg-nq36)