--- # claudbg-nq36 title: 'TUI: app state model and screen enum' status: completed type: task priority: normal created_at: 2026-03-30T04:45:19Z updated_at: 2026-03-30T16:40:31Z parent: claudbg-i6l2 blocked_by: - claudbg-78xt --- Define the central `AppState` struct and `Screen` enum that drive the entire TUI. ## Types to define (`src/tui/state.rs` or `src/commands/tui/state.rs`) ```rust pub enum Screen { SessionList, Transcript { session_id: String }, SubagentTranscript { parent_session_id: String, agent_id: String }, } pub enum Focus { ChatLog, SubagentsPanel, } pub struct AppState { pub screen: Screen, // Session list pub sessions: Vec, // loaded once pub list_selected: usize, // Transcript pub transcript_entries: Vec, pub transcript_scroll: usize, // vertical scroll offset pub transcript_h_scroll: usize, // horizontal scroll offset pub subagents: Vec, pub subagent_selected: usize, pub focus: Focus, // Modals pub show_quit_dialog: bool, pub show_help: bool, } ``` ## Notes - `SessionListItem` is a lightweight struct with the display fields (short_id, date, project, model, msg_count, agent_count). - State transitions: `AppState::enter_transcript(session_id)` loads entries + subagents. `AppState::go_back()` pops the screen stack (or just switches back to `SessionList`). - Keep all data loading in state transitions so the render function is pure. ## Blocked by - ratatui dependency task (claudbg-78xt) ## Summary of Changes\n\nCreated src/tui/mod.rs and src/tui/state.rs with Screen enum, Focus enum, AppState struct, SessionListItem, and AgentRef types. Added state transition methods: new(), enter_transcript(), enter_subagent_transcript(), go_back(). Reuses existing RawEntry and AgentRef types. 11 unit tests all pass. Wired into lib.rs via pub mod tui.