Skip to main content

SessionState

Struct SessionState 

Source
pub struct SessionState {
Show 19 fields pub version: u64, pub generation: u64, pub last_seq: u64, pub active_run: Option<RunId>, pub cwd_identity: Option<CwdIdentity>, pub context_tokens: Option<u64>, pub estimated_cost_usd: Option<f64>, pub run_agent: Option<AgentId>, pub creation_agent: Option<Box<AgentSnapshot>>, pub run_snapshot: Option<Box<AgentSnapshot>>, pub run_selected_suffix: Option<Vec<FrozenModelBinding>>, pub model_selection: SessionModelState, pub goal: Option<GoalState>, pub transcript: Vec<TranscriptItem>, pub pending_inputs: VecDeque<PendingInput>, pub voided_inputs: Vec<String>, pub thinking_durations: HashMap<(u64, u64), Duration>, pub tools: HashMap<ToolCallId, ToolCallState>, pub approvals: Vec<ApprovalState>, /* private fields */
}
Expand description

Per-session projection of persisted events and live output.

Fields§

§version: u64

Changes whenever the visible projection mutates, for UI cache invalidation.

§generation: u64§last_seq: u64§active_run: Option<RunId>§cwd_identity: Option<CwdIdentity>§context_tokens: Option<u64>

Total context occupied at the end of the latest committed turn (input_tokens + output_tokens); None when the turn reported no usage, so the bottom bar hides its context segment.

§estimated_cost_usd: Option<f64>

Latest authoritative session usage cost fetched from the engine. None covers both not-yet-fetched and unpriced usage; both hide the bottom-bar segment.

§run_agent: Option<AgentId>

Frozen producing agent of the latest accepted RunStarted.

§creation_agent: Option<Box<AgentSnapshot>>

The complete frozen creation snapshot from SessionCreated, including the exact frozen fallback chain. Delegated draft projections derive only from this, never from live descriptors.

§run_snapshot: Option<Box<AgentSnapshot>>

The complete frozen snapshot of the latest accepted RunStarted.

§run_selected_suffix: Option<Vec<FrozenModelBinding>>

The authoritative exact suffix from the latest accepted RunStarted: after any run-selection variant override, this vector — never a reconstruction from the agent fallback chain — is what attempts and delegated pickers use.

§model_selection: SessionModelState§goal: Option<GoalState>§transcript: Vec<TranscriptItem>§pending_inputs: VecDeque<PendingInput>

The engine’s pending-input lane for this session, reduced purely from admission/promotion/recall events: steered messages the model has not seen yet. Source of the queue strip between the conversation pane and the composer.

§voided_inputs: Vec<String>

Pending inputs the engine voided at run end (no per-entry events), parked here until the UI restores their text into the composer — user text is never silently lost. Drained by the UI on sight.

§thinking_durations: HashMap<(u64, u64), Duration>

Elapsed thinking time per sealed thinking part, keyed by (item_id, part_id) and derived from durable event timestamps.

§tools: HashMap<ToolCallId, ToolCallState>§approvals: Vec<ApprovalState>

Implementations§

Source§

impl SessionState

Source

pub fn is_open_assistant_part(&self, item_id: u64, part_id: u64) -> bool

Source

pub fn is_open_thinking(&self, item_id: u64, part_id: u64) -> bool

Source

pub fn has_open_thinking(&self) -> bool

Whether any assistant part is still streaming thinking content.

Source

pub fn has_running_tool(&self) -> bool

Whether any tool call in this session is still running.

Source

pub fn has_pending_producers(&self) -> bool

Whether any producer message is waiting for a model run to claim it.

Source

pub fn thinking_duration(&self, item_id: u64, part_id: u64) -> Option<Duration>

The sealed elapsed thinking duration for one part, when known.

Trait Implementations§

Source§

impl Clone for SessionState

Source§

fn clone(&self) -> SessionState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionState

Source§

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

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

impl Default for SessionState

Source§

fn default() -> SessionState

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

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

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

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
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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