Skip to main content

SessionManager

Struct SessionManager 

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

Manages sessions on disk.

Implementations§

Source§

impl SessionManager

Source

pub fn new() -> Result<Self, SessionError>

Create a new SessionManager with the default sessions directory (~/.talos/sessions/).

Source

pub fn with_dir(sessions_dir: PathBuf) -> Self

Create a new SessionManager with a custom sessions directory.

Source

pub fn sessions_dir(&self) -> &Path

Return the root directory used for session JSONL files and the colocated index.

Source

pub fn create_session( &self, project: &str, workspace_root: &str, ) -> Result<Session, SessionError>

Create a new session for the given project and workspace.

The session file is created at ~/.talos/sessions/<workspace_dir>/<uuid>.jsonl, where workspace_dir is a hash of the workspace root path.

Source

pub fn defer_create_session( &self, project: &str, workspace_root: &str, ) -> Result<Session, SessionError>

Prepare a new session without creating the file on disk.

Returns a Session with persisted = false. The JSONL file is not created until Session::ensure_persisted is called (triggered automatically on the first message append).

Source

pub fn get_session(&self, id: &Uuid) -> Result<Session, SessionError>

Load an existing session by ID.

Scans all workspace directories (both old basename and new hashed layouts) for a file matching <id>.jsonl.

Source

pub fn list_sessions(&self) -> Result<Vec<SessionInfo>, SessionError>

List all sessions across all workspace directories.

Source

pub fn list_workspace_sessions( &self, workspace_root: &str, ) -> Result<Vec<SessionInfo>, SessionError>

List sessions for one workspace directory.

Source

pub fn latest_workspace_session( &self, workspace_root: &str, ) -> Result<Option<SessionInfo>, SessionError>

Return the most recently modified session for one workspace directory.

Source

pub fn resume_session(&self, session_id: &str) -> Result<Session, SessionError>

Resume a session by ID, loading all entries from the JSONL file.

This is equivalent to SessionManager::get_session but with a clearer name for the “resume” use case.

Source

pub fn search( &self, query: &str, limit: usize, ) -> Result<Vec<SearchResult>, IndexError>

Perform a full-text search across all indexed session messages.

Returns results ranked by relevance. The index is created lazily if it does not exist.

Source

pub fn list_recent(&self, limit: usize) -> Result<Vec<SessionInfo>, IndexError>

List the most recently updated sessions from the index.

Returns sessions ordered by last update time, descending.

Source

pub fn update_index(&self, session: &Session) -> Result<(), IndexError>

Update the search index for a session.

If the index has not been initialized, this is a no-op.

Source

pub fn checkpoint_index(&self) -> Result<(), IndexError>

Checkpoint the session index WAL and truncate it where possible.

Source

pub fn vacuum_index(&self) -> Result<(), IndexError>

Vacuum the session index database.

Source

pub fn get_forks(&self, session_id: &str) -> Result<Vec<ForkInfo>, IndexError>

Return forks originating from the given session ID.

Source

pub fn reconcile_index(&self) -> Result<usize, IndexError>

Source

pub fn delete_session(&self, id: &Uuid) -> Result<(), SessionError>

Source

pub fn cleanup_candidates( &self, policy: &SessionCleanupPolicy, ) -> Result<Vec<SessionCleanupCandidate>, SessionError>

Return sessions that would be removed by policy without deleting files.

Source

pub fn apply_cleanup( &self, policy: &SessionCleanupPolicy, ) -> Result<SessionCleanupReport, SessionError>

Apply a cleanup policy by deleting selected sessions and index rows.

This is an explicit maintenance operation. It never removes IDs listed in protected_session_ids, even if callers accidentally include an active session in an otherwise matching policy.

Trait Implementations§

Source§

impl Clone for SessionManager

Source§

fn clone(&self) -> SessionManager

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 SessionManager

Source§

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

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

impl Default for SessionManager

Source§

fn default() -> Self

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
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.

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> 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.