Ratatui TUI Cockpit
Architectural Layer: L9 TUI Cockpit
Source Directory:src/tui
File Count: 62 source files
62-file terminal cockpit, read-only projection over SQLite, streaming, and screens.
Module Files & Detailed Reference
| Source File | Lines | Key Types | Responsibility |
|---|---|---|---|
| app.rs | 3552 | TuiApplication | The one TUI application root (L9 projection owner). TuiApplication ... |
| approval.rs | 218 | ApprovalModal, ApprovalDecision | Interactive policy approval modal. High importance — clearly elevated... |
| binding.rs | 144 | TuiRuntimeBinding, RuntimeAssemblyOutcome | One TUI composition boundary (Principle 2): TuiRuntimeBinding. ```t... |
| channel.rs | 365 | OutboxState, ActionSendError, TuiActionSender | Bounded channel abstractions and backpressure support for TUI (Problem... |
| badge.rs | 72 | Functions/Traits | Quiet semantic status badges. Color supports meaning; symbol + text c... |
| code.rs | 113 | Functions/Traits | Bounded Code Block and Tool Output Viewer (TUI-01, TDS-02). Enforces ... |
| diff.rs | 232 | DiffParser, DiffStats, ParsedDiffLine | Production-Grade Unified Diff Presentation Component (TUI-01, TDS-03, ... |
| key_hint.rs | 63 | KeyHint | Dynamic Keyboard Hint Presentation Primitives (TUI-01, TDS-01). Provi... |
| mod.rs | 13 | Functions/Traits | Reusable TUI Visual Component Primitives (TUI-01, TDS-01–04). |
| progress.rs | 73 | Functions/Traits | Progress Bar and Visual Progress Primitives (TUI-01, TDS-02). Provide... |
| composer.rs | 1965 | AutocompleteSuggestion, FileDiscoveryReceiver, TuiComposer | Interactive Prompt Composer Component (COP-01, CLI-01, CLI-04, D-04). ... |
| conversation.rs | 1047 | TuiConversationItem | TUI Conversation Timeline Presentation Models (PRD §01, CLI-02, CLI-04... |
| errors.rs | 113 | TuiError, TuiErrorKind | Explicit TUI error states (Principles 10–11). Every major runtime fai... |
| focus.rs | 168 | FocusManager, FocusTarget | Explicit Focus Management Model for TUI 2.0 (TUI-01, TDS-01). Provide... |
| guard.rs | 101 | TerminalGuard | Terminal Guard & Panic Safety Subsystem (TDS-01, TDS-02, D-10). P... |
| icons.rs | 457 | IconRegistry, Spinner, IconKey | Semantic Nerd Font Icon System with Safe Fallback (TUI-03, D-15). Pro... |
| mod.rs | 5 | Functions/Traits | Reusable text input widget (shared by composer, palette, wizard). |
| text_input.rs | 581 | TextInput, InputMasking, InputMode | Zero-Dependency Reusable Text Input Component (COP-01, CFX-03, D-04, D... |
| keymap.rs | 229 | KeyContext, KeyAction | The single input-priority authority. Keyboard ownership is explicit a... |
| compact.rs | 39 | Functions/Traits | Compact Layout (<100w, 80x24 minimum). Single column: quiet header... |
| mod.rs | 379 | LayoutAreas, ResponsiveLayout, WorkspaceLayoutGeometry | Responsive Layout Classification & Breakdown (TUI-02). Classifies... |
| wide.rs | 46 | Functions/Traits | Multi-Column Wide Layouts (Standard, Large, Ultra-wide). Conversation... |
| lifecycle.rs | 455 | TuiLifecycleProjection, TuiLifecycleStage | Governed lifecycle projection for the conversation-first TUI. Pure pr... |
| mod.rs | 61 | Functions/Traits | Terminal TUI Cockpit & Projection Subsystem. Delivers the operati... |
| model.rs | 4964 | ExecutionHeartbeat, LiveToolOperation, TuiAgentSnapshot | In-Memory TUI Projection ViewModel (TUI-03, D-15). Pure in-memory pro... |
| navigation.rs | 403 | NavigationRouter, NavigationAction, RouteResolution | Canonical Navigation & Shortcut Router (TUI-01, D-16). Maps globa... |
| help.rs | 69 | Functions/Traits | Quiet contextual help overlay. |
| manager.rs | 51 | OverlayManager, OverlayKind, OverlayPriority | Priority-Aware Overlay System Manager (Section 11, TUI-01). Enforces ... |
| mod.rs | 7 | Functions/Traits | Centralized Modal & Overlay System (Section 11, TUI-01). |
| palette_v2.rs | 679 | PaletteItemV2, UniversalCommandPalette, PaletteActionV2 | Universal Fuzzy Command Palette V2 (COP-03, D-05, T-13-12). Provides ... |
| registry.rs | 602 | ViewMetadata, ViewRegistry, ViewId | 40 Canonical Views Typed Registry (COP-03, D-05, UI_UX_SPEC §113). St... |
| replay.rs | 266 | ReplayController, ReplaySpeed | Post-Mortem & Checkpoint Replay Subsystem (TUI-01, D-19). Provide... |
| routes.rs | 737 | RouteContext | Modular route composition (Principles 7–8). Each route composes M31A'... |
| runtime_bridge.rs | 2244 | TuiRuntimeBridge | Asynchronous Runtime Bridge for TUI Cockpit (COP-04, CLI-01, CLI-04, D... |
| sanitizer.rs | 184 | Functions/Traits | Terminal Text Sanitization & ANSI Escape Stripping (TUI-06, THREAT... |
| mod.rs | 13 | Functions/Traits | TUI dialog screens. Route composition lives in [crate::tui::routes]... |
| wizard.rs | 3437 | DiscoveryReceiver, SetupWizardScreen, ProviderVerificationState | 7-Step Guided Onboarding Setup Wizard Screen (FRX-02, FRX-03, D-02). ... |
| workspace_setup.rs | 1043 | DetectedRepoContext, WorkspaceSetupScreen, GitIsolationChoice | Focused Workspace Configuration Screen (Section 4). Provides the cano... |
| context_rail.rs | 364 | Functions/Traits | Contextual Right Rail for Active Session Workspace (MODE B). Compact,... |
| footer.rs | 135 | Functions/Traits | Quiet context-sensitive shell footer. A single muted hint line. Focus... |
| header.rs | 200 | Functions/Traits | Quiet application shell header (conversation-first). Shows only high-... |
| mod.rs | 11 | Functions/Traits | Persistent Application Shell (Section 5, TUI-01). |
| workspace.rs | 1624 | Functions/Traits | Unified Workspace Orchestration & Composition Surface (Section 5, ... |
| state.rs | 159 | TuiEvent | TUI typed event flow: runtime outcomes enter presentation state throug... |
| status.rs | 127 | StatusPresentation, StatusKind | 12-Status Presentation Taxonomy (TDS-04, D-03). Provides the canonica... |
| agents.rs | 289 | AgentStateDisplay | Agent Swarm & Autonomous Roles Surface (Section 14, TUI-01). Visu... |
| artifacts.rs | 266 | Functions/Traits | Artifact Explorer & Output Management Surface (Section 28, TUI-01)... |
| conversation.rs | 239 | Functions/Traits | Primary conversational execution surface (conversation-first). Quiet,... |
| decision.rs | 177 | Functions/Traits | Native interactive decision prompt surface. Renders pending decisions... |
| doctor.rs | 137 | Functions/Traits | Doctor Diagnostics Surface (TUI-01, CLI-04). Visualizes 6-category sy... |
| git.rs | 208 | Functions/Traits | Git Timeline & Unstaged Diff Surface (Section 24, TUI-01). Provid... |
| jobs.rs | 199 | Functions/Traits | Process Sandboxing & Background Jobs Surface (TUI-01). Visualizes... |
| mod.rs | 78 | Functions/Traits | Contextual Application Surfaces (Section 5, 6, 12–29). Replaces disco... |
| model_selector.rs | 601 | ModelInfo, ModelSelectorState, ProviderInfo | Models Surface. Renders live model provider state and allows switchin... |
| replay.rs | 129 | Functions/Traits | Post-Mortem Event Replay Surface (Section 27, TUI-01, T-11-20). Visua... |
| settings.rs | 1506 | SettingsRow, SettingsState, SettingsAction | Settings surface — projection/editor of the canonical configuration sy... |
| tasks.rs | 334 | Functions/Traits | Task DAG & Master-Detail Inspection Surface (Section 13, TUI-01). ... |
| telemetry.rs | 162 | Functions/Traits | Telemetry & Model Usage Surface (Section 23, TUI-01). Provides co... |
| tools.rs | 280 | DisplayToolItem | Tool & Capability Telemetry Surface (Section 8, TUI-01). Visualiz... |
| verification.rs | 337 | Functions/Traits | Verification Gates & Proof Evidence Surface (Section 25, TUI-01). ... |
| workflow.rs | 907 | WorkflowDashboardState, WorkflowAction, WorkflowViewMode | Workflow Visual Dashboard Surface. Renders live workflow execution st... |
| theme.rs | 431 | ThemeTokens, ThemeMode | Centralized Theme & Design Token System (TDS-03, D-03). Provides ... |
src/tui/app.rs
- Source Link:
src/tui/app.rson GitHub - Lines of Code: 3552 (160531 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate | 🛑 Supports Cancellation Tokens
Primary Responsibility
The one TUI application root (L9 projection owner). TuiApplication owns every presentation responsibility: UI state, runtime binding, routing, input, transient UI, and rendering. Enforces Law 9: "The TUI is a projection, never authoritative state." Features dirty-state frame scheduling (30–60 FPS), sub-5ms render budget, bounded update consumption, and zero database queries during draw. Construction is synchronous and runtime-free: new() builds a valid engine, with_runtime_startup() arms the production startup state, the first frame draws before any runtime await, and the canonical AppRuntime (assembled by the real composition root in main.rs) attaches later via the binding. Events flow runtime → bridge → TuiEvent → apply_tui_event → render; render performs zero I/O and never touches the runtime.
Types & Trait Declarations
- Structs (1):
TuiApplication
Key Functions & Signatures (15 shown)
// private
fn default() -> Self;
// pub
fn new() -> Self;
// pub
fn with_runtime_startup(self,
workspace_root: PathBuf,
config: &crate::config::ResolvedConfiguration,) -;
// pub
fn with_interaction_rx(mut self, rx: impl Into<TuiInteractionReceiver>) -> Self;
// pub
fn with_bridge_tx(mut self, tx: impl Into<TuiActionSender>) -> Self;
// private
fn send_or_fail(&mut self, op: &str, action: ApplicationAction) -> bool;
// pub
fn retry_quarantine_refresh(&mut self) -> bool;
// pub
fn retry_catalog_refresh(&mut self) -> bool;
// private
fn handle_quarantine_key(&mut self, key: KeyEvent, is_modal: bool) -> Option<RuntimeCommand>;
// pub
fn has_context_panel(&self) -> bool;
// pub
fn normalize_focus(&mut self);
// pub
fn normalize_context_rail_state(&mut self);
// pub
fn set_terminal_size(&mut self, width: u16, height: u16);
// pub
fn handle_resize(&mut self, width: u16, height: u16);
// pub
fn handle_mouse_scroll(&mut self, up: bool);
src/tui/approval.rs
- Source Link:
src/tui/approval.rson GitHub - Lines of Code: 218 (7364 bytes)
Primary Responsibility
Interactive policy approval modal. High importance — clearly elevated — but professional, not cyberpunk. Keys: y/Enter approve once, a approve always, n reject, Esc dismiss. Behavior preserved; only presentation rebuilt.
Types & Trait Declarations
- Structs (1):
ApprovalModal - Enums (1):
ApprovalDecision
Key Functions & Signatures (8 shown)
// pub
fn new() -> Self;
// pub
fn open(&mut self, request: TuiApprovalRequest);
// pub
fn close(&mut self);
// pub
fn handle_key(&mut self, key: KeyEvent) -> Option<ApprovalDecision>;
// pub
fn render(&self, f: &mut Frame, area: Rect);
// pub
fn render_with_theme(&self, f: &mut Frame, area: Rect, tokens: &ThemeTokens);
// private
fn truncate(s: &str, max: usize) -> String;
// private
fn centered_approval_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect;
src/tui/binding.rs
- Source Link:
src/tui/binding.rson GitHub - Lines of Code: 144 (4764 bytes)
Primary Responsibility
One TUI composition boundary (Principle 2): TuiRuntimeBinding. text AppRuntime → TuiRuntimeBinding → TuiApplication → state/routing/input/render The binding consumes the canonical AppRuntime (built once by the real composition root). It never constructs a production runtime or any production authority (capability/tool registries, pipeline, policy, approvals, artifacts, model caller, context compiler, auth, git, jobs). It owns only channels and task handles: the bridge sender, the interaction receiver, and the bridge supervisor handle.
Types & Trait Declarations
- Structs (1):
TuiRuntimeBinding - Enums (1):
RuntimeAssemblyOutcome
Key Functions & Signatures (12 shown)
// private
fn default() -> Self;
// pub
fn new() -> Self;
// pub
fn has_runtime(&self) -> bool;
// pub
fn has_bridge(&self) -> bool;
// pub
fn runtime(&self) -> Option<Arc<AppRuntime>>;
// pub
fn last_error(&self) -> Option<&TuiError>;
// pub
fn bridge_sender(&self) -> Option<TuiActionSender>;
// pub
fn take_interaction_receiver(&mut self) -> Option<TuiInteractionReceiver>;
// pub
async fn attach_runtime(&mut self,
runtime: Arc<AppRuntime>,
resume_session_id: Option<SessionId>,) -> R;
// pub
fn record_failure(&mut self, error: TuiError);
// pub
fn poll_bridge_supervision(&mut self) -> Option<TuiError>;
// private
fn binding_starts_empty_and_records_failures_visibly();
Unit Verification (1 inline tests)
Tests defined within module:
binding_starts_empty_and_records_failures_visibly
src/tui/channel.rs
- Source Link:
src/tui/channel.rson GitHub - Lines of Code: 365 (13728 bytes)
Primary Responsibility
Bounded channel abstractions and backpressure support for TUI (Problem 7). Provides TuiActionSender and TuiInteractionReceiver supporting both bounded channels (production default) and unbounded channels (for test compatibility).
Types & Trait Declarations
- Structs (1):
OutboxState - Enums (4):
ActionSendError,TuiActionSender,TuiInteractionReceiver,TuiInteractionSender
Key Functions & Signatures (15 shown)
// private
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;
// pub
fn try_send(&self, action: ApplicationAction) -> Result<(), ActionSendError>;
// pub
fn send(&self, action: ApplicationAction) -> Result<(), ActionSendError>;
// pub
fn is_closed(&self) -> bool;
// private
fn from(s: mpsc::Sender<ApplicationAction>) -> Self;
// private
fn from(s: mpsc::UnboundedSender<ApplicationAction>) -> Self;
// pub
fn try_recv(&mut self) -> Result<InteractionEvent, TryRecvError>;
// pub
async fn recv(&mut self) -> Option<InteractionEvent>;
// private
fn from(r: mpsc::Receiver<InteractionEvent>) -> Self;
// private
fn from(r: mpsc::UnboundedReceiver<InteractionEvent>) -> Self;
// private
fn is_terminal_or_approval(event: &InteractionEvent) -> bool;
// pub
fn push_critical(&mut self, event: InteractionEvent) -> Result<(), ActionSendError>;
// private
fn log_saturation_warning(&mut self);
// pub
fn try_send(&self, event: InteractionEvent) -> Result<(), ActionSendError>;
// pub
fn flush_outbox(&self);
src/tui/component/badge.rs
- Source Link:
src/tui/component/badge.rson GitHub - Lines of Code: 72 (2566 bytes)
Primary Responsibility
Quiet semantic status badges. Color supports meaning; symbol + text carries it. No emoji blocks.
Key Functions & Signatures (5 shown)
// pub
fn render_status_badge(status: StatusKind, tokens: &ThemeTokens) -> Vec<Span<'a>>;
// pub
fn render_risk_badge(risk: &str, tokens: &ThemeTokens) -> Span<'a>;
// pub
fn render_agent_tag(role: &str, tokens: &ThemeTokens) -> Span<'a>;
// pub
fn render_key_chip(key: &str, tokens: &ThemeTokens) -> Span<'a>;
// pub
fn format_key_hints_placeholder() -> Style;
src/tui/component/code.rs
- Source Link:
src/tui/component/code.rson GitHub - Lines of Code: 113 (4146 bytes)
Primary Responsibility
Bounded Code Block and Tool Output Viewer (TUI-01, TDS-02). Enforces Law 5 and Section 8/28: Large outputs (up to 500MB) must never flood the framebuffer or block the render path. Provides clean truncation, artifact locator citations, and structured terminal styling.
Key Functions & Signatures (1 shown)
// pub
fn render_bounded_output(content: &str,
max_lines: usize,
width: u16,
artifact_id: Option<&str>,
tokens:;
src/tui/component/diff.rs
- Source Link:
src/tui/component/diff.rson GitHub - Lines of Code: 232 (8452 bytes)
Primary Responsibility
Production-Grade Unified Diff Presentation Component (TUI-01, TDS-03, Section 24). Parses and renders unified diffs with syntax coloring, line numbers, hunk headers, file attribution, and addition/deletion telemetry.
Types & Trait Declarations
- Structs (3):
DiffParser,DiffStats,ParsedDiffLine - Enums (1):
DiffLineType
Key Functions & Signatures (4 shown)
// pub
fn parse(diff_text: &str) -> (Vec<ParsedDiffLine>, DiffStats);
// private
fn parse_hunk_indices(header: &str) -> (usize, usize);
// pub
fn render_diff_lines(parsed_lines: &[ParsedDiffLine],
width: u16,
tokens: &ThemeTokens,) -> Vec<Line<'a>>;
// private
fn truncate_str(s: &str, max: u16) -> String;
src/tui/component/key_hint.rs
- Source Link:
src/tui/component/key_hint.rson GitHub - Lines of Code: 63 (1900 bytes)
Primary Responsibility
Dynamic Keyboard Hint Presentation Primitives (TUI-01, TDS-01). Provides responsive footer keybindings and contextual command hints.
Types & Trait Declarations
- Structs (1):
KeyHint
Key Functions & Signatures (1 shown)
// pub
fn format_key_hints(hints: &[KeyHint], max_width: u16, tokens: &ThemeTokens) -> Line<'a>;
src/tui/component/mod.rs
- Source Link:
src/tui/component/mod.rson GitHub - Lines of Code: 13 (462 bytes)
Primary Responsibility
Reusable TUI Visual Component Primitives (TUI-01, TDS-01–04).
src/tui/component/progress.rs
- Source Link:
src/tui/component/progress.rson GitHub - Lines of Code: 73 (2136 bytes)
Primary Responsibility
Progress Bar and Visual Progress Primitives (TUI-01, TDS-02). Provides dense, high-clarity progress bars and metrics for task DAG, verification pipelines, and job execution.
Key Functions & Signatures (2 shown)
// pub
fn format_progress_bar(percentage: u8, width: usize) -> String;
// pub
fn render_progress_line(label: &str,
percentage: u8,
width: u16,
tokens: &ThemeTokens,) -> Line<'a>;
src/tui/composer.rs
- Source Link:
src/tui/composer.rson GitHub - Lines of Code: 1965 (75527 bytes)
Primary Responsibility
Interactive Prompt Composer Component (COP-01, CLI-01, CLI-04, D-04). Provides the primary operator input surface for the M31A Cockpit: - Natural language prompt composition with full Unicode support - Multiline editing with block quotes (""") and line continuation (\) - Centralized slash command autocomplete popup (sourced from SlashCommandRegistry) - Real-time @file and @directory mention autocompletion - Input history navigation (Up/Down traversal) - Clean rendering with zero DB/filesystem I/O during draw
Types & Trait Declarations
- Structs (3):
AutocompleteSuggestion,FileDiscoveryReceiver,TuiComposer - Enums (3):
AutocompleteKind,ComposerAction,FileDiscoveryState
Key Functions & Signatures (15 shown)
// pub
fn is_loading(&self) -> bool;
// pub
fn is_ready(&self) -> bool;
// pub
fn is_failed(&self) -> bool;
// private
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;
// private
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;
// private
fn default() -> Self;
// pub
fn new(workspace_root: PathBuf) -> Self;
// pub
fn with_cached_models(mut self, models: Vec<(String, String);
// pub
fn with_cached_files(mut self, files: Vec<String>) -> Self;
// pub
fn set_workspace_root(&mut self, root: PathBuf);
// pub
fn file_discovery_state(&self) -> &FileDiscoveryState;
// pub
fn spawn_file_discovery(&mut self);
// pub
fn poll_file_discovery(&mut self) -> bool;
// pub
fn apply_file_discovery_result(&mut self,
scan_id: u64,
result: Result<Vec<String>, String>,) -> bool;
// pub
fn cancel_file_discovery(&mut self);
Unit Verification (10 inline tests)
Tests defined within module:
test_composer_basic_input_and_submit, test_composer_slash_autocomplete_trigger, test_composer_history_navigation, test_composer_model_autocomplete_empty_catalog_has_no_synthetic_fallback, test_composer_model_autocomplete_populates_from_catalog, test_composer_file_autocomplete_first_use_is_non_blocking_and_async, test_composer_file_autocomplete_empty_workspace, test_composer_file_autocomplete_failed_worker_reports_diagnostic, test_composer_file_autocomplete_workspace_switch_cancels_and_resets, test_composer_file_autocomplete_stale_scan_result_discarded
src/tui/conversation.rs
- Source Link:
src/tui/conversation.rson GitHub - Lines of Code: 1047 (39187 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
TUI Conversation Timeline Presentation Models (PRD §01, CLI-02, CLI-04). Provides strongly typed, human-readable presentation models for the live interactive conversation stream: - User prompts with @mention badges - Assistant reasoning and model responses - Real-time tool invocations and structured results - Verification gate proofs and summaries - Policy approval escalation prompts and resolutions - System lifecycle events and error reporting Enforces: - Semantic badges ([USER], [ASST], [TOOL], [VERIFY], [ASK], [ERR], [SYS]) - Secret scrubbing and terminal escape sanitization - Theme-aware rendering honoring NO_COLOR - Non-color semantic status encoding
Types & Trait Declarations
- Enums (1):
TuiConversationItem
Key Functions & Signatures (11 shown)
// pub
fn badge(&self) -> &'static str;
// pub
fn icon_key(&self) -> IconKey;
// pub
fn render_lines_with_icons(&'a self,
max_width: u16,
tokens: &ThemeTokens,
_icons: &IconRegistry;
// pub
fn timestamp(&self) -> DateTime<Utc>;
// pub
fn from_turn(turn: &ConversationTurn) -> Self;
// pub
fn content_width(area_width: u16) -> usize;
// pub
fn render_lines(&self, width: u16, tokens: &ThemeTokens) -> Vec<Line<'static>>;
// private
fn truncate_to_width(s: &str, width: usize) -> String;
// private
fn wrap_conversation_text(text: &str,
width: usize,
style: ratatui::style::Style,) -> Vec<Line<'static>>;
// private
fn wrap_prefixed(prefix: &str,
text: &str,
width: usize,
style: ratatui::style::Style,) -> Vec<Line<'static>;
// private
fn render_command_output_text(text: &str,
width: usize,
tokens: &ThemeTokens,) -> Vec<Line<'static>>;
src/tui/errors.rs
- Source Link:
src/tui/errors.rson GitHub - Lines of Code: 113 (3395 bytes)
Primary Responsibility
Explicit TUI error states (Principles 10–11). Every major runtime failure becomes visible TUI state. The renderer never silently returns an empty frame: failures are typed, carry a human-readable message, and render through the normal shell (header / startup panel / composer / footer). M31A visual identity is unchanged; this module only classifies failures so the startup panel and notifications can explain what failed.
Types & Trait Declarations
- Structs (1):
TuiError - Enums (1):
TuiErrorKind
Key Functions & Signatures (12 shown)
// pub
fn as_str(&self) -> &'static str;
// pub
fn title(&self) -> &'static str;
// pub
fn new(kind: TuiErrorKind, message: impl Into<String>) -> Self;
// pub
fn runtime(message: impl Into<String>) -> Self;
// pub
fn bridge(message: impl Into<String>) -> Self;
// pub
fn hydration(message: impl Into<String>) -> Self;
// pub
fn model(message: impl Into<String>) -> Self;
// pub
fn workspace(message: impl Into<String>) -> Self;
// pub
fn display(&self) -> String;
// private
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;
// private
fn error_display_prefixes_kind_title();
// private
fn kinds_have_stable_ids();
Unit Verification (2 inline tests)
Tests defined within module:
error_display_prefixes_kind_title, kinds_have_stable_ids
src/tui/focus.rs
- Source Link:
src/tui/focus.rson GitHub - Lines of Code: 168 (5154 bytes)
Primary Responsibility
Explicit Focus Management Model for TUI 2.0 (TUI-01, TDS-01). Provides single-source-of-truth focus ownership across: - Composer: Input editor for natural language and slash commands - Conversation: Main execution stream (scrollable, interactive items) - ContextPanel: Master/detail side surface (tasks, agents, tools, diff, etc.) - Overlay: Modals, Command Palette, Help, Approval dialogs
Types & Trait Declarations
- Structs (1):
FocusManager - Enums (1):
FocusTarget
Key Functions & Signatures (15 shown)
// pub
fn as_str(&self) -> &'static str;
// pub
fn is_composer(&self) -> bool;
// pub
fn is_conversation(&self) -> bool;
// pub
fn is_context_panel(&self) -> bool;
// pub
fn is_settings(&self) -> bool;
// pub
fn is_overlay(&self) -> bool;
// pub
fn new(initial: FocusTarget) -> Self;
// pub
fn current(&self) -> FocusTarget;
// pub
fn set_focus(&mut self, target: FocusTarget);
// pub
fn focus_composer(&mut self);
// pub
fn unfocus_composer(&mut self);
// pub
fn enter_overlay(&mut self);
// pub
fn exit_overlay(&mut self);
// pub
fn enter_settings(&mut self);
// pub
fn exit_settings(&mut self);
src/tui/guard.rs
- Source Link:
src/tui/guard.rson GitHub - Lines of Code: 101 (3159 bytes)
Primary Responsibility
Terminal Guard & Panic Safety Subsystem (TDS-01, TDS-02, D-10). Provides RAII-based terminal mode management and global panic restoration hooks. Ensures that regardless of exit status (normal exit, error, panic, or signal), the terminal's raw mode, alternate screen buffer, mouse capture, and cursor visibility are completely and idempotently restored.
Types & Trait Declarations
- Structs (1):
TerminalGuard
Key Functions & Signatures (8 shown)
// pub
fn acquire() -> io::Result<Self>;
// pub
fn restore(&mut self) -> io::Result<()>;
// pub
fn emergency_restore() -> io::Result<()>;
// pub
fn is_active(&self) -> bool;
// private
fn drop(&mut self);
// pub
fn install_panic_hook();
// private
fn test_panic_hook_installation_is_idempotent();
// private
fn test_guard_emergency_restore_idempotency();
Unit Verification (2 inline tests)
Tests defined within module:
test_panic_hook_installation_is_idempotent, test_guard_emergency_restore_idempotency
src/tui/icons.rs
- Source Link:
src/tui/icons.rson GitHub - Lines of Code: 457 (15312 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
Semantic Nerd Font Icon System with Safe Fallback (TUI-03, D-15). Provides a single canonical icon registry used by all TUI rendering. Never scatters raw icon literals throughout the code. Supports Nerd Font mode and a safe ASCII/Unicode fallback so the TUI remains readable on: - Nerd Font terminal - normal Unicode terminal - restricted ANSI terminal
Types & Trait Declarations
- Structs (2):
IconRegistry,Spinner - Enums (2):
IconKey,IconMode
Key Functions & Signatures (15 shown)
// pub
fn detect(theme_mode: ThemeMode) -> Self;
// pub
fn new(mode: IconMode) -> Self;
// pub
fn from_theme(theme_mode: ThemeMode) -> Self;
// pub
fn mode(&self) -> IconMode;
// pub
fn get(&self, key: IconKey) -> &'static str;
// pub
fn new() -> Self;
// pub
fn nerd_font() -> Self;
// pub
fn ascii() -> Self;
// pub
fn for_mode(mode: IconMode) -> Self;
// pub
fn tick(&mut self) -> &'static str;
// pub
fn current(&self) -> &'static str;
// pub
fn reset(&mut self);
// private
fn default() -> Self;
// private
fn test_icon_modes_produce_output();
// private
fn test_spinner_cycles();
Unit Verification (2 inline tests)
Tests defined within module:
test_icon_modes_produce_output, test_spinner_cycles
src/tui/input/mod.rs
- Source Link:
src/tui/input/mod.rson GitHub - Lines of Code: 5 (150 bytes)
Primary Responsibility
Reusable text input widget (shared by composer, palette, wizard).
src/tui/input/text_input.rs
- Source Link:
src/tui/input/text_input.rson GitHub - Lines of Code: 581 (17969 bytes)
Primary Responsibility
Zero-Dependency Reusable Text Input Component (COP-01, CFX-03, D-04, D-08). Provides Unicode-safe cursor navigation, single-line and multiline editing, history navigation, word boundary traversal, and secret masking.
Types & Trait Declarations
- Structs (1):
TextInput - Enums (2):
InputMasking,InputMode
Key Functions & Signatures (15 shown)
// private
fn default() -> Self;
// pub
fn new(mode: InputMode) -> Self;
// pub
fn single_line() -> Self;
// pub
fn multi_line() -> Self;
// pub
fn set_mode(&mut self, mode: InputMode);
// pub
fn with_placeholder(mut self, placeholder: impl Into<String>) -> Self;
// pub
fn with_masking(mut self, masking: InputMasking) -> Self;
// pub
fn with_max_length(mut self, max: usize) -> Self;
// pub
fn value(&self) -> &str;
// pub
fn text(&self) -> &str;
// pub
fn set_value(&mut self, val: &str);
// pub
fn set_text(&mut self, val: &str);
// pub
fn handle_key(&mut self, key: crossterm::event::KeyEvent) -> bool;
// pub
fn clear(&mut self);
// pub
fn char_count(&self) -> usize;
Unit Verification (2 inline tests)
Tests defined within module:
test_text_input_unicode_and_editing, test_text_input_secret_masking
src/tui/keymap.rs
- Source Link:
src/tui/keymap.rson GitHub - Lines of Code: 229 (7271 bytes)
Primary Responsibility
The single input-priority authority. Keyboard ownership is explicit and tested here: text replay → dialog → palette → help → wizard → palette-chord → interrupt → composer → route → global This module classifies keys; it never executes domain actions. Execution lives in TuiApplication::handle_*_key, which consumes every classification — no result is discarded and no second matcher exists.
Types & Trait Declarations
- Structs (1):
KeyContext - Enums (1):
KeyAction
Key Functions & Signatures (13 shown)
// pub
fn new(replay_active: bool,
dialog_open: bool,
palette_open: bool,
help_open: bool,
wiza;
// pub
fn with_decision(mut self, decision_pending: bool) -> Self;
// pub
fn resolve_key(key: KeyEvent, ctx: KeyContext) -> KeyAction;
// private
fn is_palette_chord(key: KeyEvent, composer_focused: bool) -> bool;
// private
fn is_exit_chord(key: KeyEvent) -> bool;
// private
fn key(code: KeyCode) -> KeyEvent;
// private
fn ctrl(code: KeyCode) -> KeyEvent;
// private
fn priority_dialog_over_everything();
// private
fn transient_owners_beat_composer_and_route();
// private
fn ctrl_p_opens_palette_from_composer_and_route();
// private
fn colon_types_in_composer_but_opens_palette_on_route();
// private
fn ctrl_c_is_exit_chord_before_composer();
// private
fn replay_locks_all_keys();
Unit Verification (6 inline tests)
Tests defined within module:
priority_dialog_over_everything, transient_owners_beat_composer_and_route, ctrl_p_opens_palette_from_composer_and_route, colon_types_in_composer_but_opens_palette_on_route, ctrl_c_is_exit_chord_before_composer, replay_locks_all_keys
src/tui/layout/compact.rs
- Source Link:
src/tui/layout/compact.rson GitHub - Lines of Code: 39 (1165 bytes)
Primary Responsibility
Compact Layout (<100w, 80x24 minimum). Single column: quiet header, conversation, composer, minimal footer. No sidebar, no telemetry, no dashboard.
Key Functions & Signatures (1 shown)
// pub
fn compute_compact_layout(area: Rect) -> LayoutAreas;
src/tui/layout/mod.rs
- Source Link:
src/tui/layout/mod.rson GitHub - Lines of Code: 379 (13049 bytes)
Primary Responsibility
Responsive Layout Classification & Breakdown (TUI-02). Classifies terminal dimensions into 4 tiers: - Compact (<100w): Single-column stacked layout with tabbed pane switching; optimized for 80x24. - Standard (100–159w): Dual-column layout (sidebar + main cockpit). - Large (160–219w): Three-column layout (nav sidebar + cockpit + telemetry). - UltraWide (>=220w): Full wide-screen layout with expanded inspector panes.
Types & Trait Declarations
- Structs (3):
LayoutAreas,ResponsiveLayout,WorkspaceLayoutGeometry - Enums (2):
LayoutTier,ScrollTargetPane
Key Functions & Signatures (10 shown)
// pub
fn from_dimensions(width: u16, height: u16) -> Self;
// pub
fn is_below_minimum(width: u16, height: u16) -> bool;
// pub
fn as_str(&self) -> &'static str;
// pub
fn classify_terminal_size(width: u16, height: u16) -> LayoutTier;
// pub
fn partition(area: Rect) -> (LayoutTier, LayoutAreas);
// pub
fn split_vertical_chrome(area: Rect) -> (Rect, Rect, Rect);
// pub
fn compute_layout(area: Rect) -> (LayoutTier, LayoutAreas);
// pub
fn target_pane_at(&self, col: u16, row: u16) -> Option<ScrollTargetPane>;
// pub
fn rect_contains(rect: Rect, col: u16, row: u16) -> bool;
// pub
fn compute_workspace_layout_geometry(terminal: Rect,
screen: crate::tui::navigation::ScreenId,
has_modal_or_over;
src/tui/layout/wide.rs
- Source Link:
src/tui/layout/wide.rson GitHub - Lines of Code: 46 (1549 bytes)
Primary Responsibility
Multi-Column Wide Layouts (Standard, Large, Ultra-wide). Conversation-first: the conversation always dominates. Wide viewports add a modest contextual inspector only when explicitly requested via navigation detail — never a permanent telemetry sidebar by default. sidebar/telemetry rects are therefore None unless the caller opens a detail; the workspace renders conversation full-width.
Key Functions & Signatures (4 shown)
// private
fn compute_wide_layout(area: Rect) -> LayoutAreas;
// pub
fn compute_standard_layout(area: Rect) -> LayoutAreas;
// pub
fn compute_large_layout(area: Rect) -> LayoutAreas;
// pub
fn compute_ultrawide_layout(area: Rect) -> LayoutAreas;
src/tui/lifecycle.rs
- Source Link:
src/tui/lifecycle.rson GitHub - Lines of Code: 455 (18183 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
Governed lifecycle projection for the conversation-first TUI. Pure presentation projection over the canonical M31A runtime lifecycle. This module never executes tools, never mutates workspace state, never authorizes execution, and never writes to the database. It only derives renderable lifecycle state from trusted runtime events. Authority order: persisted LifecycleStage > runtime EventType > InteractionEvent summaries. UI-only guesses are never invented here.
Types & Trait Declarations
- Structs (1):
TuiLifecycleProjection - Enums (1):
TuiLifecycleStage
Key Functions & Signatures (14 shown)
// pub
fn label(&self) -> &'static str;
// pub
fn bracket_label(&self) -> String;
// pub
fn is_terminal(&self) -> bool;
// pub
fn is_governance_gate(&self) -> bool;
// private
fn default() -> Self;
// pub
fn new() -> Self;
// pub
fn select_next_option(&mut self);
// pub
fn select_prev_option(&mut self);
// pub
fn selected_option(&self) -> Option<&str>;
// pub
fn short_hash(hash: &str) -> String;
// private
fn touch(&mut self);
// private
fn sealed(&self) -> bool;
// pub
fn apply_lifecycle_stage(&mut self,
state: &crate::persistence::sqlite::repositories::lifecycle::PersistedLifecy;
// pub
fn apply_event(&mut self, event: &EventEnvelope);
src/tui/mod.rs
- Source Link:
src/tui/mod.rson GitHub - Lines of Code: 61 (1862 bytes)
Primary Responsibility
Terminal TUI Cockpit & Projection Subsystem. Delivers the operational cockpit. Enforces Law 9: "The TUI is a projection, never authoritative state." Public surface is deliberately small: the application root, the runtime binding, the event reducer, the navigation authority, and the primitives the binary and integration tests drive directly. Everything else is reached through its module path (tui::model::TuiViewModel, …).
src/tui/model.rs
- Source Link:
src/tui/model.rson GitHub - Lines of Code: 4964 (200157 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
In-Memory TUI Projection ViewModel (TUI-03, D-15). Pure in-memory projection of runtime state. Never executes SQLite queries or synchronous I/O during rendering.
Types & Trait Declarations
- Structs (22):
ExecutionHeartbeat,LiveToolOperation,TuiAgentSnapshot,TuiApprovalRequest,TuiArtifactSnapshot,TuiDoctorCheck,TuiJobSnapshot,TuiLogLine,TuiModelUsage,TuiQuarantineItem,TuiRecoverySnapshot,TuiSandboxStatus,TuiSkillSnapshot,TuiSystemStats,TuiTaskSnapshot,TuiTimelineEntry,TuiToolDefinitionSnapshot,TuiToolSnapshot,TuiTraceabilityChain,TuiVerificationCheck,TuiVerificationSummary,TuiViewModel - Enums (10):
ActivityKind,DoctorStatus,LiveToolState,QuarantineProjectionState,RuntimeStartupState,SectionProjectionState,SessionViewMode,TaskGraphProjectionState,TuiCredentialStatus,UiOperationState
Key Functions & Signatures (15 shown)
// pub
fn is_ready(&self) -> bool;
// pub
fn is_failed(&self) -> bool;
// pub
fn is_startup(&self) -> bool;
// pub
fn label(&self) -> String;
// pub
fn failure_reason(&self) -> Option<&str>;
// pub
fn is_welcome(&self) -> bool;
// pub
fn is_active(&self) -> bool;
// pub
fn is_closed(&self) -> bool;
// pub
fn is_working(&self) -> bool;
// pub
fn is_waiting(&self) -> bool;
// pub
fn icon_key(&self) -> crate::tui::icons::IconKey;
// private
fn default() -> Self;
// pub
fn new(id: impl Into<String>,
title: impl Into<String>,
status: impl Into<String>,
agent_role: O;
// pub
fn effective_prompt_tokens(&self) -> u64;
// pub
fn effective_completion_tokens(&self) -> u64;
src/tui/navigation.rs
- Source Link:
src/tui/navigation.rson GitHub - Lines of Code: 403 (14254 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
Canonical Navigation & Shortcut Router (TUI-01, D-16). Maps global canonical keyboard shortcuts: - 1–0: Primary operational screens (Dashboard, Mission, Task Graph, Agents, Tools, Jobs, Verification, Git, Approvals, Doctor) - l, m, a, r, ?: Auxiliary screens (Logs, Model, Artifacts, Replay, Help) - Ctrl+P or :: Open universal fuzzy Command Palette - Esc: Pop navigation history stack or close overlay
Types & Trait Declarations
- Structs (1):
NavigationRouter - Enums (3):
NavigationAction,RouteResolution,ScreenId
Key Functions & Signatures (15 shown)
// pub
fn title(&self) -> &'static str;
// pub
fn title_with_shortcut(&self) -> &'static str;
// pub
fn shortcut(&self) -> &'static str;
// pub
fn canonical_screen(view: ViewId) -> ScreenId;
// pub
fn resolve_view(view: ViewId) -> RouteResolution;
// private
fn default() -> Self;
// pub
fn new() -> Self;
// pub
fn navigate_to_view(&mut self, view: ViewId);
// pub
fn open_modal(&mut self, modal: ViewId);
// pub
fn close_modal(&mut self);
// pub
fn open_detail(&mut self, detail: ViewId);
// pub
fn close_detail(&mut self);
// pub
fn open_overlay(&mut self, overlay: ViewId);
// pub
fn close_overlay(&mut self);
// pub
fn navigate_to(&mut self, target: ScreenId);
src/tui/overlay/help.rs
- Source Link:
src/tui/overlay/help.rson GitHub - Lines of Code: 69 (2290 bytes)
Primary Responsibility
Quiet contextual help overlay.
Key Functions & Signatures (1 shown)
// pub
fn render_help_overlay(f: &mut Frame, area: Rect, tokens: &ThemeTokens);
src/tui/overlay/manager.rs
- Source Link:
src/tui/overlay/manager.rson GitHub - Lines of Code: 51 (1277 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
Priority-Aware Overlay System Manager (Section 11, TUI-01). Enforces centralized modal and overlay priority: 1. Critical Policy Approval (highest priority - owns input until resolved) 2. Universal Command Palette (Ctrl+P / :) 3. Contextual Help Dialog (?)
Types & Trait Declarations
- Structs (1):
OverlayManager - Enums (2):
OverlayKind,OverlayPriority
Key Functions & Signatures (4 shown)
// pub
fn new() -> Self;
// pub
fn open_help(&mut self);
// pub
fn close_help(&mut self);
// pub
fn toggle_help(&mut self);
src/tui/overlay/mod.rs
- Source Link:
src/tui/overlay/mod.rson GitHub - Lines of Code: 7 (194 bytes)
Primary Responsibility
Centralized Modal & Overlay System (Section 11, TUI-01).
src/tui/palette_v2.rs
- Source Link:
src/tui/palette_v2.rson GitHub - Lines of Code: 679 (23168 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
Universal Fuzzy Command Palette V2 (COP-03, D-05, T-13-12). Provides instant navigation across all 40 canonical views, active mission entities, and runtime commands via fuzzy search (SkimMatcherV2) with credential masking.
Types & Trait Declarations
- Structs (2):
PaletteItemV2,UniversalCommandPalette - Enums (1):
PaletteActionV2
Key Functions & Signatures (15 shown)
// private
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;
// private
fn default() -> Self;
// pub
fn new() -> Self;
// pub
fn register_all_commands(&mut self);
// pub
fn register_slash_commands(&mut self,
slash_registry: &crate::interaction::commands::SlashCommandRegistry,);
// pub
fn with_slash_registry(mut self,
slash_registry: &crate::interaction::commands::SlashCommandRegistry,) -> Self;
// pub
fn items(&self) -> &[PaletteItemV2];
// pub
fn is_open(&self) -> bool;
// pub
fn open(&mut self);
// pub
fn close(&mut self);
// pub
fn query(&self) -> &str;
// pub
fn set_query(&mut self, query: &str);
// pub
fn selected_item(&self) -> Option<&PaletteItemV2>;
// pub
fn select_next(&mut self);
// pub
fn select_prev(&mut self);
src/tui/registry.rs
- Source Link:
src/tui/registry.rson GitHub - Lines of Code: 602 (17132 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
40 Canonical Views Typed Registry (COP-03, D-05, UI_UX_SPEC §113). Strongly typed registry cataloging all 40 canonical operational views with identity, numeric code (1–40), classification kind, shortcut hotkey, and URL/route path.
Types & Trait Declarations
- Structs (2):
ViewMetadata,ViewRegistry - Enums (2):
ViewId,ViewKind
Key Functions & Signatures (12 shown)
// pub
fn number(&self) -> u8;
// pub
fn all() -> &'static [ViewId];
// private
fn default() -> Self;
// pub
fn new() -> Self;
// pub
fn len(&self) -> usize;
// pub
fn is_empty(&self) -> bool;
// pub
fn get(&self, id: ViewId) -> Option<&ViewMetadata>;
// pub
fn get_by_number(&self, number: u8) -> Option<&ViewMetadata>;
// pub
fn get_by_route(&self, route: &str) -> Option<&ViewMetadata>;
// pub
fn get_by_hotkey(&self, hotkey: char) -> Option<&ViewMetadata>;
// pub
fn find_by_name(&self, query: &str) -> Vec<&ViewMetadata>;
// pub
fn all(&self) -> Vec<&ViewMetadata>;
src/tui/replay.rs
- Source Link:
src/tui/replay.rson GitHub - Lines of Code: 266 (8472 bytes)
Primary Responsibility
Post-Mortem & Checkpoint Replay Subsystem (TUI-01, D-19). Provides read-only historical execution scrub through event and checkpoint timelines: - [: Step backward 1 event - ]: Step forward 1 event - Space: Play / Pause timeline playback - 1 / 2 / 4: Select scrub playback speed (1x, 2x, 4x) - Esc: Exit Replay mode Strictly enforces D-19 and T-11-20: Replay mode is 100% read-only, displays a high-visibility amber banner [REPLAY MODE - READ ONLY], and completely blocks/strips all mutating operator actions to ensure zero side effects.
Types & Trait Declarations
- Structs (1):
ReplayController - Enums (1):
ReplaySpeed
Key Functions & Signatures (15 shown)
// pub
fn as_str(&self) -> &'static str;
// pub
fn step_interval(&self) -> std::time::Duration;
// private
fn default() -> Self;
// pub
fn new() -> Self;
// pub
fn load_history(&mut self, history: Vec<EventEnvelope>);
// pub
fn exit(&mut self);
// pub
fn step_backward(&mut self) -> bool;
// pub
fn step_forward(&mut self) -> bool;
// pub
fn jump_to(&mut self, target: usize);
// pub
fn seek_to_start(&mut self) -> bool;
// pub
fn seek_to_end(&mut self) -> bool;
// pub
fn toggle_playback(&mut self);
// pub
fn advance_elapsed(&mut self, elapsed: std::time::Duration) -> bool;
// pub
fn tick_playback(&mut self) -> bool;
// pub
fn reconstruct_current_view(&self) -> TuiViewModel;
src/tui/routes.rs
- Source Link:
src/tui/routes.rson GitHub - Lines of Code: 737 (24270 bytes)
Primary Responsibility
Modular route composition (Principles 7–8). Each route composes M31A's existing surfaces — no business logic, no I/O, no policy, no runtime calls. The previous giant render_workspace() match is preserved pixel-for-pixel here as small per-route functions so screens own their composition: text Session = header + conversation + execution/tool activity + contextual inspector + composer + footer Other routes keep M31A's visual design and responsive behavior unchanged (conversation + inspector split on wide terminals, single surface on narrow ones). render_workspace() in shell/workspace.rs remains the thin orchestrator (startup → welcome → route → composer → rail → detail → overlay) and delegates upper-area composition here.
Types & Trait Declarations
- Structs (1):
RouteContext
Key Functions & Signatures (15 shown)
// pub
fn new(screen: ScreenId,
focus: FocusTarget,
context_selected_idx: usize,
replay: &'a ReplayCont;
// pub
fn render_route_upper(f: &mut Frame,
upper_area: Rect,
model: &mut TuiViewModel,
_composer: &TuiComposer,
;
// private
fn wide_split(area: Rect, left_pct: u16, right_pct: u16) -> (Rect, Rect);
// private
fn conversation_focused(ctx: &RouteContext<'_>) -> bool;
// private
fn panel_focused(ctx: &RouteContext<'_>) -> bool;
// pub
fn render_session(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
tokens: &;
// private
fn render_split_with_selected(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
;
// pub
fn render_tasks(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
tokens: &Th;
// pub
fn render_agents(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
tokens: &T;
// pub
fn render_tools(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
tokens: &Th;
// pub
fn render_git(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
tokens: &Them;
// pub
fn render_verification(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
toke;
// pub
fn render_jobs(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
tokens: &The;
// pub
fn render_doctor(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
tokens: &T;
// pub
fn render_models(f: &mut Frame,
area: Rect,
model: &mut TuiViewModel,
ctx: &RouteContext<'_>,
tokens: &T;
Unit Verification (1 inline tests)
Tests defined within module:
every_route_composes_without_blank
src/tui/runtime_bridge.rs
- Source Link:
src/tui/runtime_bridge.rson GitHub - Lines of Code: 2244 (94883 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate | 🛑 Supports Cancellation Tokens
Primary Responsibility
Asynchronous Runtime Bridge for TUI Cockpit (COP-04, CLI-01, CLI-04, D-15). Connects the synchronous 60 FPS TUI projection layer to the asynchronous AppRuntime core without violating Law 9 ("The model proposes. The runtime decides") or Law 15 (Zero database I/O during frame rendering). Responsibilities: - Receives typed ApplicationAction from the composer/palette - Dispatches actions to AppRuntime, SqliteSessionRepository, and SlashCommandRegistry - Subscribes to BroadcastEventBus and transforms kernel events into InteractionEvents - Streams InteractionEvents back to the TUI update channel
Types & Trait Declarations
- Structs (1):
TuiRuntimeBridge
Key Functions & Signatures (10 shown)
// pub
fn send_action(&self, action: ApplicationAction) -> bool;
// pub
fn take_event_receiver(&mut self) -> Option<TuiInteractionReceiver>;
// pub
fn sender(&self) -> TuiActionSender;
// pub
async fn spawn(runtime: Arc<AppRuntime>,
resume_session_id: Option<SessionId>,) -> Result<(Self, tokio::task::Jo;
// private
async fn hydrate_session_state(runtime: &Arc<AppRuntime>,
session_repo: &SqliteSessionRepository,
session: &Sess;
// private
fn response_to_hydration_events(resp: PreExecutionResponse, out: &mut Vec<InteractionEvent>);
// private
async fn run_bridge_worker(mut runtime: Arc<AppRuntime>,
workspace_root: PathBuf,
session_repo: SqliteSessionRep;
// private
async fn ensure_bridge_session(session: &'a mut Option<Session>,
session_repo: &SqliteSessionRepository,
workspa;
// private
async fn dispatch_bridge_action(action: ApplicationAction,
runtime: &mut Arc<AppRuntime>,
workspace_root: &Path,;
// private
async fn emit_workflow_snapshot_if_known(runtime: &AppRuntime,
run_id_str: &str,
event_tx: &TuiInteractionSender;
src/tui/sanitizer.rs
- Source Link:
src/tui/sanitizer.rson GitHub - Lines of Code: 184 (6803 bytes)
Primary Responsibility
Terminal Text Sanitization & ANSI Escape Stripping (TUI-06, THREAT-01). Mitigates T-11-18 (terminal control injection) by stripping dangerous ANSI sequences, OSC title overrides, and cursor repositioning commands before rendering untrusted repository, tool, web, or MCP content.
Key Functions & Signatures (15 shown)
// pub
fn sanitize_terminal_text(input: &str) -> String;
// pub
fn sanitize_diff(diff: &str) -> String;
// pub
fn sanitize_tool_spool(spool: &str) -> String;
// pub
fn truncate_to_width(s: &str, max_width: usize) -> std::borrow::Cow<'_, str>;
// pub
fn truncate_str_safe(s: &str, max_width: usize) -> String;
// pub
fn format_display_model(raw: &str) -> String;
// private
fn test_format_display_model();
// private
fn test_sanitizer_strips_color_and_formatting();
// private
fn test_sanitizer_strips_cursor_repositioning_and_clearing();
// private
fn test_sanitizer_strips_osc_terminal_title_injection();
// private
fn test_unicode_safe_truncation_ascii();
// private
fn test_unicode_safe_truncation_limits_zero_and_one();
// private
fn test_unicode_safe_truncation_multibyte_and_emoji();
// private
fn test_unicode_safe_truncation_wide_and_combining();
// private
fn test_unicode_safe_truncation_no_allocation_when_fits();
Unit Verification (9 inline tests)
Tests defined within module:
test_format_display_model, test_sanitizer_strips_color_and_formatting, test_sanitizer_strips_cursor_repositioning_and_clearing, test_sanitizer_strips_osc_terminal_title_injection, test_unicode_safe_truncation_ascii, test_unicode_safe_truncation_limits_zero_and_one, test_unicode_safe_truncation_multibyte_and_emoji, test_unicode_safe_truncation_wide_and_combining, test_unicode_safe_truncation_no_allocation_when_fits
src/tui/screens/mod.rs
- Source Link:
src/tui/screens/mod.rson GitHub - Lines of Code: 13 (484 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
TUI dialog screens. Route composition lives in [crate::tui::routes]; this module hosts only the setup wizard dialog state machine. It owns no routing authority.
src/tui/screens/wizard.rs
- Source Link:
src/tui/screens/wizard.rson GitHub - Lines of Code: 3437 (143105 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
7-Step Guided Onboarding Setup Wizard Screen (FRX-02, FRX-03, D-02). Interactive terminal wizard walking the operator through Workspace Trust, Doctor Diagnostics, Provider Selection, Model Selection, Profile Selection, Autonomy/Safety constraints, and Final Verification.
Types & Trait Declarations
- Structs (2):
DiscoveryReceiver,SetupWizardScreen - Enums (4):
ProviderVerificationState,WizardDiscoveryState,WizardOutcome,WizardProfile
Key Functions & Signatures (15 shown)
// pub
fn all() -> &'static [Self];
// pub
fn canonical_id(&self) -> &'static str;
// pub
fn from_canonical_id(id: &str) -> Option<Self>;
// pub
fn name(&self) -> &'static str;
// pub
fn description(&self) -> &'static str;
// pub
fn recommendation(&self) -> &'static str;
// pub
fn autonomy_mode(&self) -> &'static str;
// pub
fn is_success(&self) -> bool;
// pub
fn badge(&self) -> &'static str;
// pub
fn is_loading(&self) -> bool;
// pub
fn is_ready(&self) -> bool;
// private
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;
// pub
fn new(workspace_path: PathBuf) -> Self;
// pub
fn with_config_scope(mut self, scope: crate::storage::ConfigScope) -> Self;
// pub
fn config_scope_label(&self) -> String;
src/tui/screens/workspace_setup.rs
- Source Link:
src/tui/screens/workspace_setup.rson GitHub - Lines of Code: 1043 (39798 bytes)
- Runtime Properties: 🛡️ Enforces Policy Gate
Primary Responsibility
Focused Workspace Configuration Screen (Section 4). Provides the canonical workspace configuration experience: - Focused, reliable, keyboard-driven interface. - Captures essential project facts without an artificial 7-step wizard. - Pre-fills sensible defaults via repository inspection (Cargo.toml, package.json, etc.). - Allows single-confirmation acceptance of detected defaults. - Atomically persists canonical configuration to <workspace>/.m31a/M31A.toml. - Never writes credentials or secrets to workspace files. - Preserves existing configuration sections during reconfiguration.
Types & Trait Declarations
- Structs (2):
DetectedRepoContext,WorkspaceSetupScreen - Enums (5):
GitIsolationChoice,PolicyPostureChoice,ProjectTypeChoice,SetupField,WorkspaceSetupOutcome
Key Functions & Signatures (15 shown)
// pub
fn as_str(&self) -> &'static str;
// pub
fn display_label(&self) -> &'static str;
// pub
fn from_str_loose(s: &str) -> Self;
// pub
fn as_str(&self) -> &'static str;
// pub
fn display_label(&self) -> &'static str;
// pub
fn from_str_loose(s: &str) -> Self;
// pub
fn as_str(&self) -> &'static str;
// pub
fn display_label(&self) -> &'static str;
// pub
fn from_str_loose(s: &str) -> Self;
// pub
fn inspect(root: &Path) -> Self;
// pub
fn title(&self) -> &'static str;
// pub
fn new(workspace_root: PathBuf) -> Self;
// private
fn load_from_existing(&mut self, path: &Path);
// pub
fn active_field(&self) -> SetupField;
// pub
fn active_field_idx(&self) -> usize;
src/tui/shell/context_rail.rs
- Source Link:
src/tui/shell/context_rail.rson GitHub - Lines of Code: 364 (13186 bytes)
Primary Responsibility
Contextual Right Rail for Active Session Workspace (MODE B). Compact, secondary status information displayed alongside the primary conversation: - SESSION: active/working/waiting/ready state & duration - ACTION: pending approval prompt if any - CURRENT: live working activity - CONTEXT: token count & cost - TODO: task progress checklist - AGENTS: active agents & roles - TOOLS: current or recent tool execution - GIT: branch & working copy status - VERIFICATION: test/check summary
Key Functions & Signatures (4 shown)
// pub
fn render_context_rail(f: &mut Frame,
area: Rect,
model: &TuiViewModel,
tokens: &ThemeTokens,
is_focused;
// pub
fn calculate_total_rail_lines(model: &TuiViewModel) -> usize;
// private
fn section_header(title: impl Into<String>, tokens: &ThemeTokens) -> Line<'static>;
// private
fn truncate_str(s: &str, max: usize) -> String;
src/tui/shell/footer.rs
- Source Link:
src/tui/shell/footer.rson GitHub - Lines of Code: 135 (4460 bytes)