pub struct SessionManager { /* private fields */ }Expand description
Manager for session storage.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn save_index(&mut self) -> Result<()>
pub fn save_index(&mut self) -> Result<()>
Save the session index to disk (public, acquires lock).
Sourcepub fn start_new(&mut self, project_path: Option<&Path>) -> Result<&Session>
pub fn start_new(&mut self, project_path: Option<&Path>) -> Result<&Session>
Start a new session.
Sourcepub fn continue_last(&mut self) -> Result<Option<&Session>>
pub fn continue_last(&mut self) -> Result<Option<&Session>>
Continue the last session (for –continue). Returns the session without modifying its project_path. The caller should use session.metadata.project_path as the effective path.
Sourcepub fn resume(&mut self, query: &str) -> Result<Option<&Session>>
pub fn resume(&mut self, query: &str) -> Result<Option<&Session>>
Resume a specific session by ID or name (for –resume). Returns the session without modifying its project_path. The caller should use session.metadata.project_path as the effective path.
Sourcepub fn save_current(&mut self) -> Result<()>
pub fn save_current(&mut self) -> Result<()>
Save the current session to disk (with file lock).
Sourcepub fn update_stats(&mut self, last_input_tokens: u32, total_output_tokens: u64)
pub fn update_stats(&mut self, last_input_tokens: u32, total_output_tokens: u64)
Update current session stats after a turn.
Sourcepub fn record_compression(&mut self, entry: CompressionHistoryEntry)
pub fn record_compression(&mut self, entry: CompressionHistoryEntry)
Record a compression event in the session history.
Sourcepub fn set_messages(&mut self, messages: Vec<Message>)
pub fn set_messages(&mut self, messages: Vec<Message>)
Set messages for the current session.
Sourcepub fn set_compressed_messages(&mut self, compressed: Vec<Message>)
pub fn set_compressed_messages(&mut self, compressed: Vec<Message>)
Set compressed messages for the current session.
Sourcepub fn api_messages(&self) -> Option<&[Message]>
pub fn api_messages(&self) -> Option<&[Message]>
Get messages for API requests (compressed if available).
Sourcepub fn display_messages(&self) -> Option<&[Message]>
pub fn display_messages(&self) -> Option<&[Message]>
Get messages for display (always full messages).
Sourcepub fn messages(&self) -> Option<&[Message]>
pub fn messages(&self) -> Option<&[Message]>
Get the current session’s messages (for API - compressed if available).
Sourcepub fn messages_mut(&mut self) -> Option<&mut Vec<Message>>
pub fn messages_mut(&mut self) -> Option<&mut Vec<Message>>
Get mutable reference to messages (returns full_messages for editing).
Sourcepub fn full_messages(&self) -> Option<&[Message]>
pub fn full_messages(&self) -> Option<&[Message]>
Get full messages for display (TUI).
Sourcepub fn current_id(&self) -> Option<&str>
pub fn current_id(&self) -> Option<&str>
Get the current session ID.
Sourcepub fn current_name(&self) -> Option<&str>
pub fn current_name(&self) -> Option<&str>
Get the current session name.
Sourcepub fn rename_current(&mut self, new_name: &str) -> Result<()>
pub fn rename_current(&mut self, new_name: &str) -> Result<()>
Rename the current session.
Sourcepub fn clear_current(&mut self) -> Result<()>
pub fn clear_current(&mut self) -> Result<()>
Clear the current session (start fresh).
Sourcepub fn list_sessions(&self) -> &[SessionMetadata]
pub fn list_sessions(&self) -> &[SessionMetadata]
List all sessions.
Sourcepub fn cleanup_old_sessions(&mut self, max_age_days: u64) -> Result<usize>
pub fn cleanup_old_sessions(&mut self, max_age_days: u64) -> Result<usize>
Clean up old sessions that haven’t been updated in N days. Returns the number of sessions removed.
Sourcepub fn prune_sessions(&mut self, max_sessions: usize) -> Result<usize>
pub fn prune_sessions(&mut self, max_sessions: usize) -> Result<usize>
Prune sessions to keep only the most recent N sessions. Returns the number of sessions removed.
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Get total session count.
Sourcepub fn has_current(&self) -> bool
pub fn has_current(&self) -> bool
Check if there’s a current session.
Sourcepub fn current_metadata(&self) -> Option<&SessionMetadata>
pub fn current_metadata(&self) -> Option<&SessionMetadata>
Get current session metadata.
Sourcepub fn history_path(&self) -> PathBuf
pub fn history_path(&self) -> PathBuf
Get the history file path (legacy compatibility).