Skip to main content

SessionContext

Struct SessionContext 

Source
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: PathBuf

Implementations§

Source§

impl SessionContext

Source

pub fn new(cwd: PathBuf) -> Self

Source

pub fn set_session_id(&mut self, session_id: SessionId)

Set the session ID (typically after creating or loading a session).

Source

pub fn available_modes(&self) -> &[AvailableMode]

The available agent modes advertised by the session.

Source

pub fn current_mode_id(&self) -> Option<&str>

The current mode ID, if any.

Source

pub fn set_current_mode_id(&mut self, mode_id: String)

Set the current mode ID (from a ModeChanged notification).

Source

pub fn context_usage_pct(&self) -> Option<f64>

The current context usage percentage, if reported.

Source

pub fn set_context_usage_pct(&mut self, pct: f64)

Set the context usage percentage (from Kiro metadata notifications).

Source

pub fn set_modes(&mut self, modes: &SessionModeState)

Store mode info from a NewSessionResponse.

Source

pub fn set_config_options(&mut self, options: Vec<SessionConfigOption>)

Store config options (model, etc.) from a session response or update notification.

Source

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.

Source

pub fn current_model(&self) -> Option<&str>

Return the cached model value (O(1) per frame).

Trait Implementations§

Source§

impl Debug for SessionContext

Source§

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

Formats the value using the given formatter. 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> IntoMaybeUndefined<T> for T

Source§

impl<T> IntoOption<T> for T

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<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