Skip to main content

SessionManager

Struct SessionManager 

Source
pub struct SessionManager { /* private fields */ }
Expand description

Manager for session persistence operations

Implementations§

Source§

impl SessionManager

Source

pub fn new(sessions_dir: PathBuf) -> Result<SessionManager, Error>

Create a new SessionManager with the specified sessions directory. Tries to open SQLite DB at sessions_dir/sessions.db with auto-migration from JSON files if present.

Source

pub fn default_location() -> Result<SessionManager, Error>

Create a SessionManager using the default location (~/.deepseek/sessions)

Source

pub fn save_session(&self, session: &SavedSession) -> Result<PathBuf, Error>

Save a session to disk using SQLite (or atomic write JSON if no DB).

Source

pub fn load_compaction_artifacts( &self, session_id: &str, ) -> Result<Vec<CompactionArtifact>, Error>

Load compaction artifacts for a session from SQLite (empty when JSON-only mode).

Source

pub fn save_checkpoint(&self, session: &SavedSession) -> Result<PathBuf, Error>

Save a crash-recovery checkpoint for in-flight turns.

Source

pub fn load_checkpoint(&self) -> Result<Option<SavedSession>, Error>

Load the most recent crash-recovery checkpoint if present.

Source

pub fn clear_checkpoint(&self) -> Result<(), Error>

Clear any crash-recovery checkpoint.

Source

pub fn save_offline_queue_state( &self, state: &OfflineQueueState, session_id: Option<&str>, ) -> Result<PathBuf, Error>

Save offline queue state (queued + draft messages).

Source

pub fn load_offline_queue_state( &self, ) -> Result<Option<OfflineQueueState>, Error>

Load offline queue state if present.

Source

pub fn clear_offline_queue_state(&self) -> Result<(), Error>

Remove persisted offline queue state.

Source

pub fn find_session_id_by_runtime_thread_id( &self, runtime_thread_id: &str, ) -> Result<Option<String>, Error>

Find a persisted session id linked to a runtime thread (most recent first).

Source

pub fn load_session(&self, id: &str) -> Result<SavedSession, Error>

Load a session by ID (SQLite first, then JSON fallback)

Source

pub fn load_session_by_prefix( &self, prefix: &str, ) -> Result<SavedSession, Error>

Load a session by partial ID prefix

Source

pub fn list_sessions(&self) -> Result<Vec<SessionMetadata>, Error>

List all saved sessions (SQLite indexed, then JSON fallback)

Source

pub fn delete_session(&self, id: &str) -> Result<(), Error>

Delete a session by ID

Source

pub fn prune_sessions_older_than( &self, max_age: Duration, ) -> Result<usize, Error>

Remove session files whose updated_at is older than max_age from the persisted-sessions directory. Returns the number of records pruned. Building block for #406’s phase-2 auto-archive on boot; today the user-facing entry point is the /sessions prune <days> slash command.

Crash-recovery safety: skips the running checkpoint (checkpoints/latest.json) and any file under checkpoints/ — those are owned by the checkpoint subsystem and live with stricter durability rules. Only top-level <session_id>.json files are candidates.

max_age is checked against the metadata’s updated_at timestamp embedded in the JSON, not the filesystem mtime — the user may have rsynced their ~/.deepseek between machines and fs mtimes can lie.

Source

pub fn get_latest_session_for_workspace( &self, workspace: &Path, ) -> Result<Option<SessionMetadata>, Error>

Get the most recent session scoped to the current workspace.

Source

pub fn search_sessions( &self, query: &str, ) -> Result<Vec<SessionMetadata>, Error>

Search sessions by title

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToAst for T

Source§

fn ast(self, begin: usize, end: usize) -> Spanned<Self>

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