pub struct SessionManager { /* private fields */ }Expand description
Manager for session persistence operations
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(sessions_dir: PathBuf) -> Result<SessionManager, Error>
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.
Sourcepub fn default_location() -> Result<SessionManager, Error>
pub fn default_location() -> Result<SessionManager, Error>
Create a SessionManager using the default location (~/.deepseek/sessions)
Sourcepub fn save_session(&self, session: &SavedSession) -> Result<PathBuf, Error>
pub fn save_session(&self, session: &SavedSession) -> Result<PathBuf, Error>
Save a session to disk using SQLite (or atomic write JSON if no DB).
Sourcepub fn load_compaction_artifacts(
&self,
session_id: &str,
) -> Result<Vec<CompactionArtifact>, Error>
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).
Sourcepub fn save_checkpoint(&self, session: &SavedSession) -> Result<PathBuf, Error>
pub fn save_checkpoint(&self, session: &SavedSession) -> Result<PathBuf, Error>
Save a crash-recovery checkpoint for in-flight turns.
Sourcepub fn load_checkpoint(&self) -> Result<Option<SavedSession>, Error>
pub fn load_checkpoint(&self) -> Result<Option<SavedSession>, Error>
Load the most recent crash-recovery checkpoint if present.
Sourcepub fn clear_checkpoint(&self) -> Result<(), Error>
pub fn clear_checkpoint(&self) -> Result<(), Error>
Clear any crash-recovery checkpoint.
Sourcepub fn save_offline_queue_state(
&self,
state: &OfflineQueueState,
session_id: Option<&str>,
) -> Result<PathBuf, Error>
pub fn save_offline_queue_state( &self, state: &OfflineQueueState, session_id: Option<&str>, ) -> Result<PathBuf, Error>
Save offline queue state (queued + draft messages).
Sourcepub fn load_offline_queue_state(
&self,
) -> Result<Option<OfflineQueueState>, Error>
pub fn load_offline_queue_state( &self, ) -> Result<Option<OfflineQueueState>, Error>
Load offline queue state if present.
Sourcepub fn clear_offline_queue_state(&self) -> Result<(), Error>
pub fn clear_offline_queue_state(&self) -> Result<(), Error>
Remove persisted offline queue state.
Sourcepub fn find_session_id_by_runtime_thread_id(
&self,
runtime_thread_id: &str,
) -> Result<Option<String>, Error>
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).
Sourcepub fn load_session(&self, id: &str) -> Result<SavedSession, Error>
pub fn load_session(&self, id: &str) -> Result<SavedSession, Error>
Load a session by ID (SQLite first, then JSON fallback)
Sourcepub fn load_session_by_prefix(
&self,
prefix: &str,
) -> Result<SavedSession, Error>
pub fn load_session_by_prefix( &self, prefix: &str, ) -> Result<SavedSession, Error>
Load a session by partial ID prefix
Sourcepub fn list_sessions(&self) -> Result<Vec<SessionMetadata>, Error>
pub fn list_sessions(&self) -> Result<Vec<SessionMetadata>, Error>
List all saved sessions (SQLite indexed, then JSON fallback)
Sourcepub fn prune_sessions_older_than(
&self,
max_age: Duration,
) -> Result<usize, Error>
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.
Sourcepub fn get_latest_session_for_workspace(
&self,
workspace: &Path,
) -> Result<Option<SessionMetadata>, Error>
pub fn get_latest_session_for_workspace( &self, workspace: &Path, ) -> Result<Option<SessionMetadata>, Error>
Get the most recent session scoped to the current workspace.
Sourcepub fn search_sessions(
&self,
query: &str,
) -> Result<Vec<SessionMetadata>, Error>
pub fn search_sessions( &self, query: &str, ) -> Result<Vec<SessionMetadata>, Error>
Search sessions by title
Auto Trait Implementations§
impl !Freeze for SessionManager
impl RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
impl UnwindSafe for SessionManager
Blanket Implementations§
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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