Skip to main content

codetether_agent/tui/app/state/
default_impl.rs

1//! Default implementation for `AppState`.
2
3use std::collections::{HashMap, HashSet, VecDeque};
4use std::sync::Arc;
5
6use crate::tui::bus_log::BusLogState;
7use crate::tui::help::HelpScrollState;
8use crate::tui::models::{InputMode, ViewMode};
9use crate::tui::ralph_view::RalphViewState;
10use crate::tui::swarm_view::SwarmViewState;
11use crate::tui::symbol_search::SymbolSearchState;
12
13impl Default for super::AppState {
14    fn default() -> Self {
15        Self {
16            view_mode: ViewMode::Chat,
17            input_mode: InputMode::Normal,
18            messages: vec![],
19            input: String::new(),
20            input_cursor: 0,
21            input_scroll: 0,
22            chat_scroll: 0,
23            chat_last_max_scroll: 0,
24            tool_preview_scroll: 0,
25            tool_preview_last_max_scroll: 0,
26            status: "Ready — type a message and press Enter. Ctrl+C/Ctrl+Q quits.".to_string(),
27            processing: false,
28            session_id: None,
29            sessions: vec![],
30            selected_session: 0,
31            session_filter: String::new(),
32            cwd_display: String::new(),
33            bus_log: BusLogState::new(),
34            swarm: SwarmViewState::new(),
35            ralph: RalphViewState::new(),
36            symbol_search: SymbolSearchState::new(),
37            slash_suggestions: vec![],
38            selected_slash_suggestion: 0,
39            command_history: Vec::new(),
40            history_index: None,
41            worker_id: None,
42            worker_name: None,
43            a2a_connected: false,
44            recent_tasks: Vec::new(),
45            worker_bridge_registered_agents: HashSet::new(),
46            worker_bridge_processing_state: None,
47            worker_task_queue: VecDeque::new(),
48            help_scroll: HelpScrollState::default(),
49            show_help: false,
50            available_models: Vec::new(),
51            selected_model_index: 0,
52            model_picker_active: false,
53            model_filter: String::new(),
54            streaming_text: String::new(),
55            processing_started_at: None,
56            current_request_first_token_ms: None,
57            current_request_last_token_ms: None,
58            last_request_first_token_ms: None,
59            last_request_last_token_ms: None,
60            last_completion_model: None,
61            last_completion_latency_ms: None,
62            last_completion_prompt_tokens: None,
63            last_completion_output_tokens: None,
64            last_tool_name: None,
65            last_tool_latency_ms: None,
66            last_tool_success: None,
67            pending_images: Vec::new(),
68            queued_steering: Vec::new(),
69            current_turn_cancel: None,
70            auto_apply_edits: false,
71            allow_network: false,
72            slash_autocomplete: true,
73            use_worktree: true,
74            selected_settings_index: 0,
75            mcp_registry: Arc::new(crate::tui::app::mcp::TuiMcpRegistry::new()),
76            spawned_agents: HashMap::new(),
77            active_spawned_agent: None,
78            streaming_agent_texts: HashMap::new(),
79            cached_message_lines: Vec::new(),
80            cached_messages_len: 0,
81            cached_max_width: 0,
82            cached_streaming_snapshot: None,
83            cached_processing: false,
84            cached_frozen_len: 0,
85            watchdog_notification: None,
86            main_watchdog_root_prompt: None,
87            main_last_event_at: None,
88            main_watchdog_restart_count: 0,
89            main_inflight_prompt: None,
90            okr_repository: None,
91            pending_okr_approval: None,
92            pending_smart_switch_retry: None,
93            smart_switch_retry_count: 0,
94            smart_switch_attempted_models: Vec::new(),
95            chat_sync_rx: None,
96            chat_sync_status: None,
97            chat_sync_last_success: None,
98            chat_sync_last_error: None,
99            chat_sync_uploaded_bytes: 0,
100            chat_sync_uploaded_batches: 0,
101            autochat: super::super::autochat::state::AutochatState::default(),
102            file_picker_dir: std::path::PathBuf::new(),
103            file_picker_entries: Vec::new(),
104            file_picker_selected: 0,
105            file_picker_filter: String::new(),
106            file_picker_active: false,
107            workspace: crate::tui::models::WorkspaceSnapshot::default(),
108            chat_layout_mode: crate::tui::ui::webview::layout_mode::ChatLayoutMode::default(),
109            last_key_at: None,
110        }
111    }
112}