//! Application actions, effects, and task results. //! //! This module defines the three enums that form the backbone of the //! event→dispatch→effect pipeline: //! //! - [`Action`] — produced by input handling, consumed by dispatch (sync). //! - [`Effect`] — produced by dispatch, consumed by the event loop (async). //! - [`TaskResult`] — produced by spawned tasks, fed back into dispatch. use super::agent::AgentId; use crate::scrollback::entry::EntryId; use agent_client_protocol as acp; use kigi_shell::sampling::types::ReasoningEffort; /// Typed error for model switch failures. Replaces the raw `String` in /// `TaskResult::SwitchModelComplete` so dispatch can match on the variant /// instead of parsing strings. #[derive(Debug, Clone)] pub enum SwitchModelError { /// The target model requires a different agent harness than the /// active session. The pager should offer to start a new session. /// Deserialized from `ModelSwitchIncompatibleAgentError` in /// `acp::Error.data`. IncompatibleAgent { error: kigi_shell::agent::config::ModelSwitchIncompatibleAgentError, /// The model that was active before the optimistic UI update /// (if any). Used to roll back `models.current` when the user /// declines to start a new session. prev_model_id: Option, }, /// Any other failure (network, auth, server error, etc.). Other(String), } /// Synchronous, side-effect-free user intent. /// /// Produced by [`super::input`] from key/mouse events. /// Consumed by [`super::dispatch::dispatch`] to mutate state and return effects. #[derive(Debug)] #[allow(clippy::large_enum_variant)] pub enum Action { /// Quit the application. Quit, /// Restart the binary to pick up a downloaded update. QuitForUpdate, /// Resume the recent foreign session offered on the launch welcome screen. ResumeForeignSession, /// Re-exec into the other screen mode (`true` = minimal). RelaunchInScreenMode { minimal: bool, }, /// Quit without double-press confirmation (e.g., from command palette or pre-login screens). QuitConfirmed, /// Create a new session from the welcome screen. NewSession, /// Ask whether the new session should use a git worktree. ChooseNewSessionMode, /// Exit the current session and return to the welcome screen. ExitSession, /// Exit session without double-press confirmation (e.g., from command palette). ExitSessionConfirmed, /// Open an arbitrary URL in the system browser (with scheme validation). OpenUrl(String), /// Cycle to the next visible link (or highlight the first if none selected). OpenNextLink, /// Cycle to the previous visible link. OpenPrevLink, /// Fetch the session list for the session picker on the welcome screen. FetchSessionList, /// Cycle the active session picker's source filter. CycleSessionSourceFilter, /// Load a selected session from the session picker. PickSession(usize), /// Load a selected session from the session picker into a new worktree. PickSessionInWorktree(usize), /// Copy the selected session's ID to the clipboard. CopySessionId(usize), /// Toggle expanded card view for a session in the picker. ExpandSessionCard { source: String, session_id: String, }, /// Open the session picker overlay (from within an active session via /resume). ShowSessionPicker, /// The session picker overlay was dismissed without a pick: invalidate any /// in-flight list/search/foreign scan so a late response can't fall /// through to the welcome picker fields. SessionPickerClosed, /// Create a new session in a git worktree from the welcome screen. /// `load_session_id`: when `Some`, loads that session in the new worktree /// instead of creating a fresh one (`--resume` + `--worktree`). /// `label`: optional human-readable label from CLI `-w