pub struct Conversation {
pub session_id: String,
pub project_path: Option<String>,
pub entries: Vec<ConversationEntry>,
pub started_at: Option<DateTime<Utc>>,
pub last_activity: Option<DateTime<Utc>>,
pub segment_ids: Vec<String>,
pub preamble: Vec<Value>,
}Fields§
§session_id: String§project_path: Option<String>§entries: Vec<ConversationEntry>§started_at: Option<DateTime<Utc>>§last_activity: Option<DateTime<Utc>>§segment_ids: Vec<String>Segment IDs when this conversation spans multiple files. Empty for single-segment conversations.
preamble: Vec<Value>Raw preamble entries (e.g., permission-mode) that precede
conversation entries in the JSONL file. These are not
ConversationEntry objects — they have different shapes.
Implementations§
Source§impl Conversation
impl Conversation
pub fn new(session_id: String) -> Self
pub fn add_entry(&mut self, entry: ConversationEntry)
Sourcepub fn rename_session(&mut self, id: &str)
pub fn rename_session(&mut self, id: &str)
Sets the session ID everywhere the format carries it:
session_id, every entry’s top-level sessionId that is
present, and every string-valued sessionId key in preamble
lines at any depth. Claude Code copies the ID into
worktreeSession.sessionId on worktree-state lines. A
sessionId nested inside an entry (a tool result, a snapshot,
an extra key) is content that names another session, such as a
sub-agent’s, and stays as it is.
Sourcepub fn reroot(&mut self, dir: &str)
pub fn reroot(&mut self, dir: &str)
Sets the directory everywhere the format carries it:
project_path, every entry’s cwd that is present, and a
top-level cwd on a preamble line.
pub fn user_messages(&self) -> Vec<&ConversationEntry>
pub fn assistant_messages(&self) -> Vec<&ConversationEntry>
pub fn tool_uses(&self) -> Vec<(&ConversationEntry, &ContentPart)>
pub fn message_count(&self) -> usize
pub fn duration(&self) -> Option<Duration>
Sourcepub fn entries_since(&self, since_uuid: &str) -> Vec<ConversationEntry>
pub fn entries_since(&self, since_uuid: &str) -> Vec<ConversationEntry>
Returns entries after the given UUID. If the UUID is not found, returns all entries (for full sync). If the UUID is the last entry, returns an empty vec.
Sourcepub fn title(&self, max_len: usize) -> Option<String>
pub fn title(&self, max_len: usize) -> Option<String>
Text of the first user message, truncated to max_len characters.
Sourcepub fn first_user_text(&self) -> Option<String>
pub fn first_user_text(&self) -> Option<String>
Full text of the first user message, untruncated.
Trait Implementations§
Source§impl Clone for Conversation
impl Clone for Conversation
Source§fn clone(&self) -> Conversation
fn clone(&self) -> Conversation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more