pub struct Session {Show 17 fields
pub id: String,
pub title: String,
pub name: Option<String>,
pub model: String,
pub thinking_level: String,
pub system_prompt: Option<String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub total_input_tokens: u64,
pub total_output_tokens: u64,
pub session_cost: f64,
pub api_messages: Vec<Arc<Value>>,
pub abort_context: Option<String>,
pub parent_session: Option<String>,
pub compacted_into: Option<String>,
pub prompt_provenance: Option<PromptProvenance>,
pub compaction: Option<CompactionRecord>,
}Fields§
§id: String§title: String§name: Option<String>§model: String§thinking_level: String§system_prompt: Option<String>§created_at: DateTime<Utc>§updated_at: DateTime<Utc>§total_input_tokens: u64§total_output_tokens: u64§session_cost: f64§api_messages: Vec<Arc<Value>>§abort_context: Option<String>Saved abort context — injected into the next user message on /continue
parent_session: Option<String>ID of the session this was compacted from (backward link)
compacted_into: Option<String>ID of the session created by compacting this one (forward link)
prompt_provenance: Option<PromptProvenance>§compaction: Option<CompactionRecord>Typed compaction summary provenance (spec §9.3). Present on sessions produced by (or updated in place by) a compaction transition.
Implementations§
Source§impl Session
impl Session
pub fn new( model: &str, thinking_level: &str, system_prompt: Option<&str>, ) -> Session
Sourcepub fn from_compaction_record(
parent: &Session,
summary_text: &str,
record: CompactionRecord,
) -> Session
pub fn from_compaction_record( parent: &Session, summary_text: &str, record: CompactionRecord, ) -> Session
Create a successor session from a compaction transition (spec §9.3).
The summary enters context through the canonical sanitized rendering
(crate::compaction::compaction_context_messages); the parent’s
system prompt stays TYPED metadata — the successor’s system_prompt
field and the provenance record — never plain user text.
Sourcepub fn auto_title(&mut self)
pub fn auto_title(&mut self)
Set title from the first user message if not already set
Sourcepub async fn save(&self) -> Result<(), Error>
pub async fn save(&self) -> Result<(), Error>
Persist this session under the configured persistence mode
(session_persistence config key; default is the unchanged legacy
JSON path — see Task 35 / crate::core::session_journal).
pub fn load(id: &str) -> Result<Session, Error>
Sourcepub fn load_from_dir(dir: &Path, id: &str) -> Result<Session, Error>
pub fn load_from_dir(dir: &Path, id: &str) -> Result<Session, Error>
Canonical backward-compatible host load for a caller-selected sessions directory. Both legacy snapshots and journal-backed sessions resolve through the same journal overlay implementation.
pub fn info(&self) -> SessionInfo
Sourcepub fn set_name(&mut self, name: &str) -> Result<(), Error>
pub fn set_name(&mut self, name: &str) -> Result<(), Error>
Assign a name to this session. Validates name, enforces uniqueness across sessions, and rejects collisions with existing chain names. Idempotent: re-applying the current name is a no-op.
pub fn clear_name(&mut self)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Session
impl<'de> Deserialize<'de> for Session
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Session, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Session, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Session
impl Serialize for Session
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.