Skip to main content

limit_cli/tui/
state.rs

1//! TUI state types and constants
2//!
3//! This module contains the core state types used by the TUI system.
4
5/// Maximum paste size to prevent memory issues (100KB)
6pub const MAX_PASTE_SIZE: usize = 100 * 1024;
7
8/// TUI state for displaying agent events
9#[derive(Debug, Clone, PartialEq, Default)]
10pub enum TuiState {
11    #[default]
12    Idle,
13    Thinking,
14}
15
16/// State for file autocomplete popup
17#[derive(Debug, Clone, Default)]
18pub struct FileAutocompleteState {
19    /// Whether autocomplete popup is visible
20    pub is_active: bool,
21    /// Query typed after @ (e.g., "Cargo" in "@Cargo")
22    pub query: String,
23    /// Start position of @ in input_text
24    pub trigger_pos: usize,
25    /// List of matching files
26    pub matches: Vec<limit_tui::components::FileMatchData>,
27    /// Currently selected index in matches
28    pub selected_index: usize,
29}
30
31#[cfg(test)]
32mod tests {
33    use super::*;
34
35    #[test]
36    fn test_tui_state_default() {
37        let state = TuiState::default();
38        assert_eq!(state, TuiState::Idle);
39    }
40
41    #[test]
42    fn test_file_autocomplete_default() {
43        let state = FileAutocompleteState::default();
44        assert!(!state.is_active);
45        assert_eq!(state.query, "");
46        assert_eq!(state.trigger_pos, 0);
47        assert_eq!(state.matches.len(), 0);
48        assert_eq!(state.selected_index, 0);
49    }
50
51    #[test]
52    fn test_max_paste_size() {
53        assert_eq!(MAX_PASTE_SIZE, 100 * 1024);
54    }
55}