Skip to main content

AppState

Struct AppState 

Source
pub struct AppState {
Show 79 fields pub running: bool, pub mode: OperationMode, pub autonomy: AutonomyLevel, pub reasoning_level: ReasoningLevel, pub model: String, pub working_dir: String, pub path_shortener: PathShortener, pub git_branch: Option<String>, pub tokens_used: u64, pub tokens_limit: u64, pub context_usage_pct: f64, pub session_cost: f64, pub mcp_status: Option<(usize, usize)>, pub mcp_has_errors: bool, pub agent_active: bool, pub messages: Vec<DisplayMessage>, pub task_progress: Option<TaskProgress>, pub spinner: SpinnerState, pub input_buffer: String, pub input_cursor: usize, pub active_tools: Vec<ToolExecution>, pub scroll_offset: u32, pub user_scrolled: bool, pub autocomplete: AutocompleteEngine, pub background_task_count: usize, pub backgrounded_task_info: Option<(String, Instant)>, pub active_subagents: Vec<SubagentDisplayState>, pub todo_manager: Option<Arc<Mutex<TodoManager>>>, pub todo_items: Vec<TodoDisplayItem>, pub todo_expanded: bool, pub thinking_expanded: bool, pub todo_spinner_tick: usize, pub plan_name: Option<String>, pub file_changes: Option<(usize, u64, u64)>, pub version: String, pub welcome_panel: WelcomePanelState, pub terminal_width: u16, pub terminal_height: u16, pub pending_queue: VecDeque<PendingItem>, pub dirty: bool, pub message_generation: u64, pub cached_lines: Vec<Line<'static>>, pub lines_generation: u64, pub per_message_hashes: Vec<u64>, pub per_message_line_counts: Vec<usize>, pub markdown_cache: HashMap<u64, Vec<Line<'static>>>, pub cached_width: u16, pub per_message_culled: Vec<bool>, pub cached_scroll_offset: u32, pub scroll_last_direction: Option<bool>, pub scroll_last_time: Option<Instant>, pub scroll_accel_level: u8, pub theme: Theme, pub theme_name: ThemeName, pub command_history: CommandHistory, pub compact_requested: bool, pub compaction_active: bool, pub pending_plan_request: bool, pub plan_content_display: Option<String>, pub backgrounding_pending: bool, pub bg_agent_manager: BackgroundAgentManager, pub task_watcher_open: bool, pub task_watcher_focus: usize, pub task_watcher_cell_scrolls: Vec<usize>, pub task_watcher_page: usize, pub task_watcher_all_done_at: Option<Instant>, pub last_task_completion: Option<(String, Instant)>, pub toasts: Vec<Toast>, pub leader_pending: bool, pub leader_timestamp: Option<Instant>, pub undo_stack: Vec<String>, pub redo_stack: Vec<String>, pub debug_panel_open: bool, pub session_title: Option<String>, pub bg_subagent_map: HashMap<String, String>, pub subagent_cancel_tokens: HashMap<String, CancellationToken>, pub selection: SelectionState, pub force_clear: bool, pub last_event_time: Option<Instant>,
}
Expand description

Persistent application state shared across renders.

Fields§

§running: bool

Whether the app is running.

§mode: OperationMode

Current operation mode.

§autonomy: AutonomyLevel

Autonomy level (Manual / Semi-Auto / Auto).

§reasoning_level: ReasoningLevel

Reasoning effort level (Off / Low / Medium / High).

§model: String

Active model name.

§working_dir: String

Current working directory.

§path_shortener: PathShortener

Cached path shortener for display (avoids repeated syscalls).

§git_branch: Option<String>

Git branch name (if in a repo).

§tokens_used: u64

Tokens used in current session.

§tokens_limit: u64

Token limit for the session.

§context_usage_pct: f64

Context window usage percentage (0.0 - 100.0+).

§session_cost: f64

Session cost in USD.

§mcp_status: Option<(usize, usize)>

MCP server status: (connected, total).

§mcp_has_errors: bool

Whether any MCP server has errors.

§agent_active: bool

Whether the agent is currently processing.

§messages: Vec<DisplayMessage>

Conversation messages for display.

§task_progress: Option<TaskProgress>

Current task progress (while agent is working).

§spinner: SpinnerState

Spinner state for animation.

§input_buffer: String

Current user input buffer.

§input_cursor: usize

Cursor position within the input buffer.

§active_tools: Vec<ToolExecution>

Active tool executions.

§scroll_offset: u32

Scroll offset for the conversation view (lines from bottom).

§user_scrolled: bool

Whether the user has scrolled up (disables auto-scroll).

§autocomplete: AutocompleteEngine

Autocomplete engine for / commands and @ file mentions.

§background_task_count: usize

Number of running background tasks.

§backgrounded_task_info: Option<(String, Instant)>

Info about a recently-backgrounded task: (task_id, when).

§active_subagents: Vec<SubagentDisplayState>

Active subagent executions for nested display.

§todo_manager: Option<Arc<Mutex<TodoManager>>>

Shared todo manager for syncing panel state with tool results.

§todo_items: Vec<TodoDisplayItem>

Todo items from the current plan (for the todo progress panel).

§todo_expanded: bool

Whether the todo panel is expanded (true) or collapsed (false).

§thinking_expanded: bool

Whether thinking blocks should start expanded (toggled by Ctrl+I).

§todo_spinner_tick: usize

Spinner tick counter for todo panel animation.

§plan_name: Option<String>

Optional plan name for the todo panel title.

§file_changes: Option<(usize, u64, u64)>

File change stats for current session: (files, additions, deletions).

§version: String

Application version string.

§welcome_panel: WelcomePanelState

Animated welcome panel state.

§terminal_width: u16

Cached terminal width for tick-time access.

§terminal_height: u16

Cached terminal height for tick-time access.

§pending_queue: VecDeque<PendingItem>

Unified queue for items waiting to be processed by the foreground agent. Contains both user messages and completed background results, processed FIFO.

§dirty: bool

Dirty flag — set to true when state changes; cleared after render.

§message_generation: u64

Generation counter for message/tool state changes. Incremented whenever messages, tool results, or collapse state change.

§cached_lines: Vec<Line<'static>>

Cached conversation lines (static message portion only, excludes spinners).

§lines_generation: u64

Generation counter at which cached_lines was last built.

§per_message_hashes: Vec<u64>

Per-message content hashes for incremental cache rebuilds.

§per_message_line_counts: Vec<usize>

Per-message line counts tracking how many cached_lines each message produced.

§markdown_cache: HashMap<u64, Vec<Line<'static>>>

Per-message markdown render cache, keyed by hash of (role + content).

§cached_width: u16

Terminal width at which cached_lines were last built (for resize invalidation).

§per_message_culled: Vec<bool>

Per-message culling state from the last cache rebuild. Used to detect when scrolling changes which messages are visible vs culled.

§cached_scroll_offset: u32

Scroll offset at the time cached_lines were last built.

§scroll_last_direction: Option<bool>

Scroll acceleration: last scroll direction (true = up, false = down).

§scroll_last_time: Option<Instant>

Scroll acceleration: timestamp of the last scroll key press.

§scroll_accel_level: u8

Scroll acceleration: current acceleration level (0 = base, increases).

§theme: Theme

Active color theme for the TUI.

§theme_name: ThemeName

Name of the active theme.

§command_history: CommandHistory

Command history for Up/Down arrow navigation.

§compact_requested: bool

Flag set by /compact command; agent loop consumes and triggers compaction.

§compaction_active: bool

Whether manual compaction is currently in progress.

§pending_plan_request: bool

Plan mode flag — when true, next UserSubmit injects plan reminder.

§plan_content_display: Option<String>

Plan content to display in the conversation (consumed after first render).

§backgrounding_pending: bool

Whether we’re waiting for the current tool to finish before backgrounding.

§bg_agent_manager: BackgroundAgentManager

Background agent task manager.

§task_watcher_open: bool

Whether the task watcher panel (Alt+B) is open.

§task_watcher_focus: usize

Index of focused cell in the task watcher grid (0-based).

§task_watcher_cell_scrolls: Vec<usize>

Per-task scroll offset in the task watcher (index = task_idx, value = lines scrolled up).

§task_watcher_page: usize

Page offset when tasks exceed grid capacity.

§task_watcher_all_done_at: Option<Instant>

When all tasks finished (for auto-close after 3s grace).

§last_task_completion: Option<(String, Instant)>

Last task completion flash: (task_id, when).

§toasts: Vec<Toast>

Active toast notifications.

§leader_pending: bool

Whether leader key (Ctrl+X) is pending.

§leader_timestamp: Option<Instant>

Timestamp of leader key press (for timeout).

§undo_stack: Vec<String>

Undo stack: tree hashes from snapshot manager.

§redo_stack: Vec<String>

Redo stack: tree hashes for redo.

§debug_panel_open: bool

Whether debug panel is open.

§session_title: Option<String>

Session title (set by the agent).

§bg_subagent_map: HashMap<String, String>

Maps background subagent IDs to their parent background task IDs.

§subagent_cancel_tokens: HashMap<String, CancellationToken>

Per-subagent cancellation tokens for individual kill support.

§selection: SelectionState

Text selection state for mouse-based copy.

§force_clear: bool

Force a full terminal clear before next draw (resets ratatui’s diff buffer).

§last_event_time: Option<Instant>

Timestamp of last user-interactive event (key, mouse, scroll). Used to detect tab-switch return via timing gap.

Trait Implementations§

Source§

impl Debug for AppState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AppState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more