Struct SessionStore
pub struct SessionStore {
pub session_queue: Arc<SessionActorQueue>,
/* private fields */
}Fields§
§session_queue: Arc<SessionActorQueue>Implementations§
Source§impl SessionStore
impl SessionStore
pub fn new(max_sessions: usize, session_queue: Arc<SessionActorQueue>) -> Self
pub async fn insert( &self, id: String, session: RpcSession, ) -> Result<(), &'static str>
pub async fn get_agent(&self, id: &str) -> Option<Arc<Mutex<Agent>>>
Sourcepub async fn get_generation(&self, id: &str) -> Option<u64>
pub async fn get_generation(&self, id: &str) -> Option<u64>
Return the current generation for the session with id, or None if
the session is absent. Provider-refresh callers capture this value
before building a provider box and thread it through
apply_model_provider so stale work targeting a replaced session
becomes a no-op.
pub async fn touch(&self, id: &str)
pub async fn set_overrides( &self, id: &str, patch: SessionOverrides, ) -> Option<SessionOverrides>
Sourcepub async fn set_overrides_gated(
&self,
id: &str,
generation: u64,
patch: SessionOverrides,
) -> Option<SessionOverrides>
pub async fn set_overrides_gated( &self, id: &str, generation: u64, patch: SessionOverrides, ) -> Option<SessionOverrides>
Like set_overrides, but validates generation before mutating the
session entry or its agent. Returns None if the session is absent
or if it was replaced under the same ID — both cases mean the caller
captured a stale generation and the work must be discarded.
pub async fn preview_overrides( &self, id: &str, patch: &SessionOverrides, ) -> Option<SessionOverrides>
Sourcepub async fn apply_model_provider(
&self,
id: &str,
generation: u64,
model_provider: Box<dyn ModelProvider>,
model_provider_name: String,
model_name: String,
tool_dispatcher: Box<dyn ToolDispatcher>,
temperature: Option<Option<f64>>,
) -> bool
pub async fn apply_model_provider( &self, id: &str, generation: u64, model_provider: Box<dyn ModelProvider>, model_provider_name: String, model_name: String, tool_dispatcher: Box<dyn ToolDispatcher>, temperature: Option<Option<f64>>, ) -> bool
Swap a freshly built ModelProvider box (and its name) onto the
session’s agent. Called by the dispatcher after it constructs the
box from config, keeping model_provider-build logic out of the store.
generation must match the session’s current generation (captured
before the caller built the provider box). If the session was replaced
under the same ID — e.g. by session/new or ACP rehydration — while
the provider was being built, the generations won’t match and this
call becomes a no-op (returns false).
When temperature is Some(v), the captured agent’s temperature is
set to v (which may be None, clearing a prior profile temperature).
When temperature is None, the agent’s temperature is left unchanged
— used by session/configure where temperature is already committed
via set_overrides_gated.
pub async fn get_overrides(&self, id: &str) -> Option<SessionOverrides>
Sourcepub async fn get_upload(
&self,
session_id: &str,
ref_id: &str,
) -> Option<UploadEntry>
pub async fn get_upload( &self, session_id: &str, ref_id: &str, ) -> Option<UploadEntry>
Look up an existing upload by ref_id. Returns None if the session
or entry doesn’t exist.
Sourcepub async fn insert_upload(&self, session_id: &str, entry: UploadEntry)
pub async fn insert_upload(&self, session_id: &str, entry: UploadEntry)
Insert (or overwrite) an upload entry in the session’s index.
Sourcepub async fn get_workspace_dir(&self, session_id: &str) -> Option<String>
pub async fn get_workspace_dir(&self, session_id: &str) -> Option<String>
Get the workspace directory for a session.
Sourcepub async fn get_agent_alias(&self, session_id: &str) -> Option<String>
pub async fn get_agent_alias(&self, session_id: &str) -> Option<String>
Get the agent alias bound to a session, if known. Used by the dispatcher to route uploads to the agent’s own workspace dir rather than to the user’s session cwd (which is often a git repo we shouldn’t be writing into).
pub async fn seed_history(&self, id: &str, msgs: &[ChatMessage])
pub async fn seed_history_with_event( &self, id: &str, msgs: &[ChatMessage], ) -> Option<TurnEvent>
Sourcepub async fn set_plan(&self, id: &str, entries: Vec<PlanEntry>)
pub async fn set_plan(&self, id: &str, entries: Vec<PlanEntry>)
Replace the session’s execution plan wholesale (TodoWrite whole-list semantics). No-op if the session is unknown.
Sourcepub async fn get_plan(&self, id: &str) -> Option<Vec<PlanEntry>>
pub async fn get_plan(&self, id: &str) -> Option<Vec<PlanEntry>>
Current stored plan for a session. None if the session is
unknown; Some(empty) if the session exists with no/cleared plan.
pub async fn seed_conversation_history( &self, id: &str, msgs: Vec<ConversationMessage>, )
pub async fn seed_conversation_history_with_event( &self, id: &str, msgs: Vec<ConversationMessage>, ) -> Option<TurnEvent>
pub async fn chat_mode(&self, id: &str) -> Option<ChatMode>
pub async fn history_len(&self, id: &str) -> Option<usize>
pub async fn history_slice_from( &self, id: &str, from: usize, ) -> Option<Vec<ConversationMessage>>
pub async fn remove(&self, id: &str) -> bool
pub async fn evict_same_mode_sibling( &self, tui_id: &str, chat_mode: &ChatMode, except_id: &str, ) -> Vec<(String, String)>
Sourcepub async fn session_owner_tui_id(
&self,
session_id: &str,
) -> Option<Option<String>>
pub async fn session_owner_tui_id( &self, session_id: &str, ) -> Option<Option<String>>
Read the owner_tui_id stamp from a session. Returns None if the
session doesn’t exist, Some(None) if it exists but is unowned (e.g.
created by an anonymous connection), Some(Some(id)) if owned by id.
pub async fn list_ids(&self) -> Vec<String>
pub fn register_cancel_token(&self, id: &str, token: CancellationToken) -> u64
pub fn remove_cancel_token(&self, id: &str, generation: u64)
pub fn cancel_session(&self, id: &str) -> bool
Sourcepub fn signal_session_removal(&self, id: &str) -> bool
pub fn signal_session_removal(&self, id: &str) -> bool
Signal an in-flight turn before a close/delete handler waits for the session admission permit. The handler removes the session only after the admitted prompt has finalized under its original incarnation.
Sourcepub fn signal_session_kill(&self, id: &str) -> bool
pub fn signal_session_kill(&self, id: &str) -> bool
Signal an in-flight turn before an administrative kill waits for the session admission permit.
Sourcepub fn has_inflight_turn(&self, id: &str) -> bool
pub fn has_inflight_turn(&self, id: &str) -> bool
Returns true if a cancel token is registered — i.e. a turn is in flight.
pub async fn kill_session(&self, id: &str) -> bool
Sourcepub fn record_cancel_cause(&self, id: &str, cause: CancelCause)
pub fn record_cancel_cause(&self, id: &str, cause: CancelCause)
Record the cause for an imminent cancel-token fire. Call immediately before firing so the verdict site can attribute the cancel.
Sourcepub fn take_cancel_cause(&self, id: &str) -> Option<CancelCause>
pub fn take_cancel_cause(&self, id: &str) -> Option<CancelCause>
Drain the recorded cancel cause for a session. Returns None only
when no cancel actually fired (clean completion); every firing path
records before token.cancel(), so Some(_) after a fired token is
the invariant the verdict audit relies on.
pub async fn count(&self) -> usize
Sourcepub async fn count_by_agent(&self) -> HashMap<String, usize>
pub async fn count_by_agent(&self) -> HashMap<String, usize>
Count active sessions grouped by agent alias.
Auto Trait Implementations§
impl !Freeze for SessionStore
impl !RefUnwindSafe for SessionStore
impl !UnwindSafe for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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