Skip to main content

SessionManager

Struct SessionManager 

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

Manager for session storage.

Implementations§

Source§

impl SessionManager

Source

pub fn new() -> Result<Self>

Create a new session manager.

Source

pub fn save_index(&mut self) -> Result<()>

Save the session index to disk (public, acquires lock).

Source

pub fn start_new(&mut self, project_path: Option<&Path>) -> Result<&Session>

Start a new session.

Source

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.

Source

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.

Source

pub fn save_current(&mut self) -> Result<()>

Save the current session to disk (with file lock).

Source

pub fn update_stats(&mut self, last_input_tokens: u32, total_output_tokens: u64)

Update current session stats after a turn.

Source

pub fn record_compression(&mut self, entry: CompressionHistoryEntry)

Record a compression event in the session history.

Source

pub fn set_messages(&mut self, messages: Vec<Message>)

Set messages for the current session.

Source

pub fn set_compressed_messages(&mut self, compressed: Vec<Message>)

Set compressed messages for the current session.

Source

pub fn api_messages(&self) -> Option<&[Message]>

Get messages for API requests (compressed if available).

Source

pub fn display_messages(&self) -> Option<&[Message]>

Get messages for display (always full messages).

Source

pub fn messages(&self) -> Option<&[Message]>

Get the current session’s messages (for API - compressed if available).

Source

pub fn messages_mut(&mut self) -> Option<&mut Vec<Message>>

Get mutable reference to messages (returns full_messages for editing).

Source

pub fn full_messages(&self) -> Option<&[Message]>

Get full messages for display (TUI).

Source

pub fn current_id(&self) -> Option<&str>

Get the current session ID.

Source

pub fn current_name(&self) -> Option<&str>

Get the current session name.

Source

pub fn rename_current(&mut self, new_name: &str) -> Result<()>

Rename the current session.

Source

pub fn clear_current(&mut self) -> Result<()>

Clear the current session (start fresh).

Source

pub fn list_sessions(&self) -> &[SessionMetadata]

List all sessions.

Source

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.

Source

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.

Source

pub fn session_count(&self) -> usize

Get total session count.

Source

pub fn has_current(&self) -> bool

Check if there’s a current session.

Source

pub fn current_metadata(&self) -> Option<&SessionMetadata>

Get current session metadata.

Source

pub fn history_path(&self) -> PathBuf

Get the history file path (legacy compatibility).

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more