pub struct SessionStore { /* private fields */ }Expand description
Handles persistence of sessions as JSONL files in a directory.
By default, uses ~/.local/share/tinyharness/sessions/. This can be
overridden with SessionStore::new for testing or alternative paths.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn default_path() -> Self
pub fn default_path() -> Self
Create a store that uses the default session directory
(~/.local/share/tinyharness/sessions/).
Prefer SessionStore::from_paths when the caller has a
Paths instance — this form resolves from the
ambient process environment.
Sourcepub fn from_paths(paths: &Paths) -> Self
pub fn from_paths(paths: &Paths) -> Self
Create a store that uses paths.sessions_dir().
Sourcepub fn ensure_dir(&self) -> Result<(), SessionError>
pub fn ensure_dir(&self) -> Result<(), SessionError>
Ensure the session directory exists.
Sourcepub fn create(
&self,
working_dir: &str,
mode: AgentMode,
provider: &str,
model: Option<String>,
) -> Session
pub fn create( &self, working_dir: &str, mode: AgentMode, provider: &str, model: Option<String>, ) -> Session
Create a brand-new session and write its initial metadata to disk.
Returns the new Session handle.
Sourcepub fn load(
&self,
session_id: &str,
) -> Result<(Session, Vec<Message>), SessionError>
pub fn load( &self, session_id: &str, ) -> Result<(Session, Vec<Message>), SessionError>
Load an existing session by its full ID. Returns the session handle and the conversation messages.
Sourcepub fn find_latest_for_dir(&self, working_dir: &str) -> Option<String>
pub fn find_latest_for_dir(&self, working_dir: &str) -> Option<String>
Find the most recent session for a given working directory.
Sourcepub fn find_by_prefix(&self, prefix: &str) -> Result<String, SessionError>
pub fn find_by_prefix(&self, prefix: &str) -> Result<String, SessionError>
Find a session by an ID prefix.
Sourcepub fn list_all(&self) -> Vec<SessionMeta>
pub fn list_all(&self) -> Vec<SessionMeta>
List all sessions, most recently updated first.