pub struct SessionContext {
pub id: Option<SessionId>,
pub cwd: PathBuf,
/* private fields */
}Expand description
Owns all session-level state: IDs, modes, config options, and working directory.
This is the single source of truth for session data. The toolbar borrows from this struct at render time.
Fields§
§id: Option<SessionId>§cwd: PathBufImplementations§
Source§impl SessionContext
impl SessionContext
pub fn new(cwd: PathBuf) -> Self
Sourcepub fn set_session_id(&mut self, session_id: SessionId)
pub fn set_session_id(&mut self, session_id: SessionId)
Set the session ID (typically after creating or loading a session).
Sourcepub fn available_modes(&self) -> &[AvailableMode]
pub fn available_modes(&self) -> &[AvailableMode]
The available agent modes advertised by the session.
Sourcepub fn current_mode_id(&self) -> Option<&str>
pub fn current_mode_id(&self) -> Option<&str>
The current mode ID, if any.
Sourcepub fn set_current_mode_id(&mut self, mode_id: String)
pub fn set_current_mode_id(&mut self, mode_id: String)
Set the current mode ID (from a ModeChanged notification).
Sourcepub fn context_usage_pct(&self) -> Option<f64>
pub fn context_usage_pct(&self) -> Option<f64>
The current context usage percentage, if reported.
Sourcepub fn set_context_usage_pct(&mut self, pct: f64)
pub fn set_context_usage_pct(&mut self, pct: f64)
Set the context usage percentage (from Kiro metadata notifications).
Sourcepub fn set_modes(&mut self, modes: &SessionModeState)
pub fn set_modes(&mut self, modes: &SessionModeState)
Store mode info from a NewSessionResponse.
Sourcepub fn set_config_options(&mut self, options: Vec<SessionConfigOption>)
pub fn set_config_options(&mut self, options: Vec<SessionConfigOption>)
Store config options (model, etc.) from a session response or update notification.
Sourcepub fn set_optimistic_model(&mut self, model: String)
pub fn set_optimistic_model(&mut self, model: String)
Optimistically update the cached model for immediate UI feedback.
The server’s ConfigOptionsUpdated event will confirm or overwrite this.
Sourcepub fn current_model(&self) -> Option<&str>
pub fn current_model(&self) -> Option<&str>
Return the cached model value (O(1) per frame).