//! # Zesdex TUI (Terminal User Interface) //! //! This crate provides the terminal UI interface for the Zesdex application, //! built on `ratatui` with `crossterm` for terminal interaction. //! //! It is one of MANY possible user interfaces — others include the HTTP API //! gateway, CLI batch commands, and daemon-mode background processing. //! //! ## Architecture //! //! ```text //! apps/interfaces/tui/src/ //! ├── lib.rs — Crate root: module declarations + re-exports //! ├── state.rs — AppStateRest + all TUI-perspective state types //! ├── action.rs — Action enum + apply_action dispatcher //! ├── view/ — TUI rendering (ratatui widgets) //! │ ├── mod.rs — Main draw function (layered layout) //! │ ├── chat.rs — Chat transcript panel //! │ ├── markdown.rs — Markdown-to-styled-spans renderer //! │ ├── sidebar.rs — Right-hand dashboard sidebar //! │ ├── status.rs — Bottom status bar //! │ ├── theme.rs — Tokyo Night colour palette //! │ ├── workflow.rs — Workflow agent status panel //! │ └── overlays/ — 15 modal overlay panels //! ├── controller/ — Input handling + command parsing //! │ ├── mod.rs //! │ ├── command.rs — /slash command parser //! │ └── input.rs — Key event → Action dispatch //! ├── model/ — Data persistence layer //! │ ├── store.rs — Store path configuration (re-export) //! │ ├── msglog/ — SQLite message-log (schema, insert, blobs) //! │ └── agent_def/ — Agent definitions (builtin/global/session) //! └── components/ — Reusable UI widgets (extensible) //! ``` //! //! ## Dependencies //! //! - `zesdex-domain` — Domain entities (Role, ChatMessage, Settings, AppConfig) //! - `zesdex-application` — Application port traits and use-cases //! - `zesdex-infrastructure` — Shared concrete infrastructure types //! (SessionRuntime, Toast, DirCache, TurnEvent, etc.) //! - `ratatui` / `crossterm` — Terminal rendering and raw-key input //! - `pulldown-cmark` — Markdown parsing for message rendering //! //! ## State Flow //! //! 1. `state::AppStateRest` is constructed in the application's main/entry point //! 2. The TUI event loop calls `controller::input::handle_key` on each key press //! 3. `handle_key` returns `Vec` which the loop applies via //! `action::apply_action` //! 4. After each action batch, `view::draw` re-renders the terminal //! //! The state types defined here (`AppStateRest`, `InputState`, `MiscState`, //! `Overlay`, etc.) are TUI-perspective — they represent what the interface //! needs to render, not the full application state. // Module declarations pub mod action; pub mod components; pub mod controller; pub mod model; pub mod run; pub mod state; pub mod turn; pub mod view; // --------------------------------------------------------------------------- // Re-exports for convenient access by consumers (main.rs / bin entry points) // --------------------------------------------------------------------------- pub use action::{Action, apply_action}; pub use run::run_single_process; pub use state::{ AgentState, AppStateRest, AutocompleteKind, ChatMessageDisplay, InputState, MiscState, Overlay, ScrollState, SimpleAgent, SimpleWorkflowEngine, TranscriptCache, EditorState, }; /// Convenience: initialise a `Store` for data directory resolution. pub use zesdex_domain::core::Store;