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<SharedMessage>,
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<SharedMessage>§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>, ) -> Self
Sourcepub fn from_compaction_record(
parent: &Session,
summary_text: &str,
record: CompactionRecord,
) -> Self
pub fn from_compaction_record( parent: &Session, summary_text: &str, record: CompactionRecord, ) -> Self
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<()>
pub async fn save(&self) -> Result<()>
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<Self>
Sourcepub fn load_from_dir(dir: &Path, id: &str) -> Result<Self>
pub fn load_from_dir(dir: &Path, id: &str) -> Result<Self>
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<()>
pub fn set_name(&mut self, name: &str) -> Result<()>
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.