pub struct SessionMetadata {Show 24 fields
pub id: SessionId,
pub file_path: PathBuf,
pub project_path: ProjectId,
pub first_timestamp: Option<DateTime<Utc>>,
pub last_timestamp: Option<DateTime<Utc>>,
pub message_count: u64,
pub total_tokens: u64,
pub input_tokens: u64,
pub output_tokens: u64,
pub cache_creation_tokens: u64,
pub cache_read_tokens: u64,
pub models_used: Vec<String>,
pub model_segments: Vec<(String, usize)>,
pub file_size_bytes: u64,
pub first_user_message: Option<String>,
pub has_subagents: bool,
pub parent_session_id: Option<String>,
pub duration_seconds: Option<u64>,
pub branch: Option<String>,
pub tool_usage: HashMap<String, usize>,
pub tool_token_usage: HashMap<String, u64>,
pub source_tool: SourceTool,
pub lines_added: u64,
pub lines_removed: u64,
}Expand description
Metadata extracted from a session without full parse
Created by streaming the JSONL until session_end event.
Fields§
§id: SessionIdSession ID (from filename or content)
file_path: PathBufFull path to the JSONL file
project_path: ProjectIdProject path (extracted from directory structure)
first_timestamp: Option<DateTime<Utc>>First timestamp in session
last_timestamp: Option<DateTime<Utc>>Last timestamp in session
message_count: u64Total message count (from summary or counted)
total_tokens: u64Total tokens (from summary)
input_tokens: u64Token breakdown for precise pricing
output_tokens: u64§cache_creation_tokens: u64§cache_read_tokens: u64§models_used: Vec<String>Models used in this session
model_segments: Vec<(String, usize)>Ordered model segments: (model_id, assistant_message_count). Captures mid-session model switches, e.g. Opus → Sonnet → Haiku. Empty for sessions parsed before this field was added.
file_size_bytes: u64File size in bytes
first_user_message: Option<String>Preview of first user message (truncated to 200 chars)
has_subagents: boolWhether this session spawned subagents (detected when another session references this one)
parent_session_id: Option<String>Parent session ID if this session is a subagent (derived from JSONL parentSessionId field)
duration_seconds: Option<u64>Duration in seconds (from summary)
branch: Option<String>Git branch name (normalized, extracted from first gitBranch in session)
tool_usage: HashMap<String, usize>Tool usage statistics: tool name -> call count Extracted from tool_calls in assistant messages during session scan
tool_token_usage: HashMap<String, u64>Per-tool token attribution: tool name -> tokens Proportionally distributed from message-level token counts
source_tool: SourceToolWhich AI coding tool produced this session
lines_added: u64Lines added in this session (from Edit/Write tool inputs)
lines_removed: u64Lines removed in this session (from Edit old_string)
Implementations§
Source§impl SessionMetadata
impl SessionMetadata
Sourcepub fn from_path(path: PathBuf, project_path: ProjectId) -> Self
pub fn from_path(path: PathBuf, project_path: ProjectId) -> Self
Create a minimal metadata from just file path
Sourcepub fn duration_display(&self) -> String
pub fn duration_display(&self) -> String
Human-readable duration
Sourcepub fn size_display(&self) -> String
pub fn size_display(&self) -> String
Human-readable file size
Trait Implementations§
Source§impl Clone for SessionMetadata
impl Clone for SessionMetadata
Source§fn clone(&self) -> SessionMetadata
fn clone(&self) -> SessionMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more