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<Self>
pub fn new(sessions_dir: PathBuf) -> Result<Self>
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<Self>
pub fn default_location() -> Result<Self>
Create a SessionManager using the default location (~/.deepseek/sessions)
Sourcepub fn save_session(&self, session: &SavedSession) -> Result<PathBuf>
pub fn save_session(&self, session: &SavedSession) -> Result<PathBuf>
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>>
pub fn load_compaction_artifacts( &self, session_id: &str, ) -> Result<Vec<CompactionArtifact>>
Load compaction artifacts for a session from SQLite (empty when JSON-only mode).
Sourcepub fn save_checkpoint(&self, session: &SavedSession) -> Result<PathBuf>
pub fn save_checkpoint(&self, session: &SavedSession) -> Result<PathBuf>
Save a crash-recovery checkpoint for in-flight turns.
Sourcepub fn load_checkpoint(&self) -> Result<Option<SavedSession>>
pub fn load_checkpoint(&self) -> Result<Option<SavedSession>>
Load the most recent crash-recovery checkpoint if present.
Sourcepub fn clear_checkpoint(&self) -> Result<()>
pub fn clear_checkpoint(&self) -> Result<()>
Clear any crash-recovery checkpoint.
Sourcepub fn save_offline_queue_state(
&self,
state: &OfflineQueueState,
session_id: Option<&str>,
) -> Result<PathBuf>
pub fn save_offline_queue_state( &self, state: &OfflineQueueState, session_id: Option<&str>, ) -> Result<PathBuf>
Save offline queue state (queued + draft messages).
Sourcepub fn load_offline_queue_state(&self) -> Result<Option<OfflineQueueState>>
pub fn load_offline_queue_state(&self) -> Result<Option<OfflineQueueState>>
Load offline queue state if present.
Sourcepub fn clear_offline_queue_state(&self) -> Result<()>
pub fn clear_offline_queue_state(&self) -> Result<()>
Remove persisted offline queue state.
Sourcepub fn find_session_id_by_runtime_thread_id(
&self,
runtime_thread_id: &str,
) -> Result<Option<String>>
pub fn find_session_id_by_runtime_thread_id( &self, runtime_thread_id: &str, ) -> Result<Option<String>>
Find a persisted session id linked to a runtime thread (most recent first).
Sourcepub fn load_session(&self, id: &str) -> Result<SavedSession>
pub fn load_session(&self, id: &str) -> Result<SavedSession>
Load a session by ID (SQLite first, then JSON fallback)
Sourcepub fn load_session_by_prefix(&self, prefix: &str) -> Result<SavedSession>
pub fn load_session_by_prefix(&self, prefix: &str) -> Result<SavedSession>
Load a session by partial ID prefix
Sourcepub fn list_sessions(&self) -> Result<Vec<SessionMetadata>>
pub fn list_sessions(&self) -> Result<Vec<SessionMetadata>>
List all saved sessions (SQLite indexed, then JSON fallback)
Sourcepub fn delete_session(&self, id: &str) -> Result<()>
pub fn delete_session(&self, id: &str) -> Result<()>
Delete a session by ID
Sourcepub fn prune_sessions_older_than(&self, max_age: Duration) -> Result<usize>
pub fn prune_sessions_older_than(&self, max_age: Duration) -> Result<usize>
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>>
pub fn get_latest_session_for_workspace( &self, workspace: &Path, ) -> Result<Option<SessionMetadata>>
Get the most recent session scoped to the current workspace.
Sourcepub fn search_sessions(&self, query: &str) -> Result<Vec<SessionMetadata>>
pub fn search_sessions(&self, query: &str) -> Result<Vec<SessionMetadata>>
Search sessions by title