pub struct SessionManager {
pub current_session_id: Option<String>,
pub messages: Vec<SessionMessage>,
pub context_checkpoint: Option<Value>,
/* private fields */
}Fields§
§current_session_id: Option<String>§messages: Vec<SessionMessage>§context_checkpoint: Option<Value>Retrieval cutoff for the model view (optional; persisted per session).
Implementations§
Source§impl SessionManager
impl SessionManager
pub fn new(project_path: &Path) -> Self
Sourcepub fn project_path(&self) -> PathBuf
pub fn project_path(&self) -> PathBuf
Project root this session store belongs to (<project>/.aacode/sessions).
Sourcepub fn create_session(
&mut self,
task: &str,
title: Option<&str>,
) -> Result<String>
pub fn create_session( &mut self, task: &str, title: Option<&str>, ) -> Result<String>
Create a new session and make it current. Returns the session id.
Sourcepub fn add_message(&mut self, msg: SessionMessage) -> Result<()>
pub fn add_message(&mut self, msg: SessionMessage) -> Result<()>
Append a message to the current session. Writes are batched via
a cooldown (every N messages or every flush_interval_secs) to avoid
full-file serialize + disk write on every single message.
Sourcepub fn add_messages(
&mut self,
msgs: impl IntoIterator<Item = SessionMessage>,
) -> Result<()>
pub fn add_messages( &mut self, msgs: impl IntoIterator<Item = SessionMessage>, ) -> Result<()>
Append several messages (batch) then persist once.
Sourcepub fn flush(&mut self) -> Result<()>
pub fn flush(&mut self) -> Result<()>
Force a write of the current session to disk (messages + index).
Sourcepub fn switch_session(&mut self, id: &str) -> Result<bool>
pub fn switch_session(&mut self, id: &str) -> Result<bool>
Load an existing session as current.
Sourcepub fn context_checkpoint(&self) -> Option<Value>
pub fn context_checkpoint(&self) -> Option<Value>
Persisted retrieval checkpoint (model-view cutoff only).
Sourcepub fn set_context_checkpoint(
&mut self,
checkpoint: Option<Value>,
) -> Result<()>
pub fn set_context_checkpoint( &mut self, checkpoint: Option<Value>, ) -> Result<()>
Persist a retrieval checkpoint. Messages themselves are never modified.
Sourcepub fn export_jsonl(&self, id: &str) -> Result<String>
pub fn export_jsonl(&self, id: &str) -> Result<String>
Export one session as JSONL (user-triggered, read-only).
Format: a header line, one message line per persisted message, and a
footer line. Stable IDs/fields; no execution replay. Tool output text
is exported verbatim — callers are responsible for not exporting
sessions that contain secrets.
Sourcepub fn fork_session(
&mut self,
source_id: &str,
upto: Option<usize>,
) -> Result<String>
pub fn fork_session( &mut self, source_id: &str, upto: Option<usize>, ) -> Result<String>
Fork a session from a message prefix into a new session.
The prefix is copied by value; the source session is untouched and the
new session is not made current. A boundary that would split an
assistant(tool_calls) from its tool results is moved back to before
the assistant so tool pairing is always intact. The retrieval checkpoint
is reset (it is recomputed safely for the new session).
Sourcepub fn list_sessions(&self) -> Vec<SessionSummary>
pub fn list_sessions(&self) -> Vec<SessionSummary>
List all sessions, newest activity first. Falls back to scanning disk files when the index is empty.
Sourcepub fn delete_session(&mut self, id: &str) -> Result<bool>
pub fn delete_session(&mut self, id: &str) -> Result<bool>
Delete a session file + index entry.
Sourcepub fn read_session_messages(&self, id: &str) -> Vec<SessionMessage>
pub fn read_session_messages(&self, id: &str) -> Vec<SessionMessage>
Read messages of a session file directly (without switching).
Sourcepub fn ensure_session(&mut self, sid: &str, title: &str) -> Result<()>
pub fn ensure_session(&mut self, sid: &str, title: &str) -> Result<()>
Ensure a session with the given id exists (idempotent create-or-touch).
If it exists, its last_activity is bumped (and a non-empty title
updates the stored title); otherwise an empty session file + index entry
are created.
Sourcepub fn rename_session(&mut self, sid: &str, title: &str) -> Result<()>
pub fn rename_session(&mut self, sid: &str, title: &str) -> Result<()>
Set an explicit title on an existing session (no-op if missing).
Sourcepub fn touch_session(&mut self, sid: &str) -> Result<()>
pub fn touch_session(&mut self, sid: &str) -> Result<()>
Bump last_activity of an existing session (no-op if missing).
Sourcepub fn append_session_messages(
&mut self,
sid: &str,
msgs: Vec<SessionMessage>,
) -> Result<()>
pub fn append_session_messages( &mut self, sid: &str, msgs: Vec<SessionMessage>, ) -> Result<()>
Append messages to a session file (creating the session if missing), then refresh the index entry (counts + last_activity + title fallback).
Sourcepub fn history_chat(&self) -> Vec<ChatMessage>
pub fn history_chat(&self) -> Vec<ChatMessage>
Get the current session’s messages as ChatMessages (for LLM history). System messages are included so that dynamically-appended context (project analysis, init instructions, compaction summaries, etc.) are preserved in the prefix for provider KV-cache stability across calls.
Sourcepub fn ended_mid_tool(&self) -> bool
pub fn ended_mid_tool(&self) -> bool
Whether the last message is a tool result (interrupted mid-execution).
Auto Trait Implementations§
impl Freeze for SessionManager
impl RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
impl UnwindSafe for SessionManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more