Skip to main content

SessionEvent

Enum SessionEvent 

Source
pub enum SessionEvent {
Show 18 variants User(UserEvent), Assistant(AssistantEvent), Progress(ProgressEvent), System(SystemEvent), FileSnapshot(FileHistorySnapshot), QueueOperation(QueueOperation), Summary(SessionSummary), Attachment(RootAttachmentEvent), CustomTitle(CustomTitleEvent), AiTitle(AiTitleEvent), LastPrompt(LastPromptEvent), BridgeSession(BridgeSessionEvent), AtisLatch(AtisLatchEvent), Mode(ModeEvent), PermissionMode(PermissionModeEvent), AgentName(AgentNameEvent), FileHistoryDelta(FileHistoryDeltaEvent), Unknown,
}
Expand description

Top-level session event discriminator

All events in a Claude Code session JSONL file parse into one of these variants. Uses serde’s tagged enum feature to automatically select variant based on type field.

§Frequency Distribution (per large session)

  1. Progress: ~82,200 (51%)
  2. Assistant: ~49,426 (31%)
  3. User: ~29,913 (19%)
  4. FileSnapshot: ~65 (<0.1%)
  5. QueueOperation: ~58 (<0.1%)
  6. System: ~6 (<0.1%)
  7. Summary: ~1 (<0.1%)

Events form a conversation graph via:

  • uuid: Unique identifier for this event
  • parent_uuid: Links to previous message in conversation chain
  • tool_use_id: Links progress to tool invocation
  • source_tool_assistant_uuid: Links tool result back to assistant

Variants§

§

User(UserEvent)

User message event

Represents messages from:

  • Human users (userType = “external”)
  • Tool results (has tool_use_result field)
  • parent_uuid → previous message
  • source_tool_assistant_uuid → assistant that invoked tool
  • Contains .message.content[] with text/tool_result types

§Frequency

~29,913 events per large session (~19%)

§

Assistant(AssistantEvent)

Assistant message event

Represents responses from Claude, including:

  • Text responses
  • Tool use invocations
  • Token usage statistics
  • parent_uuid → user message being responded to
  • Contains .message.content[] with text/tool_use types
  • Tool uses link to user tool results via id

§Frequency

~49,426 events per large session (~31%)

§

Progress(ProgressEvent)

Progress event

Real-time updates during tool execution. Contains full conversation context in .data.normalizedMessages[].

  • tool_use_id → tool invocation that triggered this
  • parent_uuid → parent message
  • Contains full conversation history (HUGE!)

§Frequency

~82,200 events per large session (~51% - MOST FREQUENT!)

§

System(SystemEvent)

System event

System-level events:

  • Compact boundaries (conversation compaction)
  • API errors
  • System reminders
  • logical_parent_uuid → last message before compaction

§Frequency

~6 events per large session (rare but important!)

§

FileSnapshot(FileHistorySnapshot)

File history snapshot

Tracks file state at message boundaries for undo/redo.

  • message_id → message where snapshot was taken

§Frequency

~65 events per large session

§

QueueOperation(QueueOperation)

Queue operation event

Tracks session queue management (enqueue/dequeue).

§Frequency

~58 events per large session

§

Summary(SessionSummary)

Session summary

Summary of entire session (typically at end).

§Frequency

~1 event per session

§

Attachment(RootAttachmentEvent)

Root-level attachment event

A hook result, todo reminder, or similar side-channel notice — the same payload shape as the nested attachment field found inside progress normalizedMessages, but emitted directly at the root. The dominant root event type on real transcripts (v2.1.2xx): dwarfs every other type combined in raw line count, though it carries no conversational text relevant to a restore digest.

§

CustomTitle(CustomTitleEvent)

Custom session title

The session title Claude Code’s own UI shows, set by the user or the model. Repeats verbatim through the file as it is re-affirmed; the last occurrence is authoritative. This is the provider’s own title/topic — prefer it over any inferred label.

§

AiTitle(AiTitleEvent)

Model-generated session title

A model-authored title, distinct from custom-title (which reflects an explicit/user-affirmed title). Used as the topic fallback when no custom-title is present.

§

LastPrompt(LastPromptEvent)

Latest verbatim user prompt

Tracks the most recent human prompt text as the session progresses; updates repeatedly. Falls back to this for the topic when neither title event is present.

§

BridgeSession(BridgeSessionEvent)

Bridge session correlation (cloud sync identity) — not conversational content, tracked only so it does not fall into the generic unknown bucket.

§

AtisLatch(AtisLatchEvent)

ATIS latch state — harness-internal signal, not conversational content.

§

Mode(ModeEvent)

Conversation mode marker (e.g. “normal”) — harness-internal signal.

§

PermissionMode(PermissionModeEvent)

Permission-mode marker (e.g. “auto”) — harness-internal signal.

§

AgentName(AgentNameEvent)

Agent/session display-name marker — harness-internal signal.

§

FileHistoryDelta(FileHistoryDeltaEvent)

Incremental file-history delta (undo/redo tracking), the incremental counterpart to file-history-snapshot.

§

Unknown

Unknown event type (forward compatibility)

Anything not matched above lands here. This is normal on a continuously-evolving transcript format and must never be treated as a parse failure — the whole point of tolerant parsing is that one unrecognized root type never drops the rest of the line’s siblings.

Implementations§

Source§

impl SessionEvent

Source

pub fn metadata(&self) -> Option<EventMetadata>

Extract common metadata present in most events

Source

pub fn uuid(&self) -> Option<&str>

Get UUID of this event

Source

pub fn parent_uuid(&self) -> Option<&str>

Get parent UUID for conversation graph traversal

Source

pub fn timestamp(&self) -> DateTime<Utc>

Get event timestamp

Several harness-internal marker events (custom-title, ai-title, last-prompt, bridge-session, atis-latch, mode, permission-mode, agent-name) carry no timestamp field on disk; these fall back to the current time, matching the existing Unknown fallback, since ordering by them is never meaningful.

Source

pub fn extract_text_content(&self) -> Option<String>

Extract all text content from this event (for FTS indexing)

Source

pub fn extract_file_paths(&self) -> Vec<String>

Extract file paths mentioned in this event

Source

pub fn extract_tool_names(&self) -> Vec<String>

Extract tool names used in this event

Source§

impl SessionEvent

Source

pub fn extract_tags(&self) -> Vec<String>

Extract tags for indexing (legacy method)

Tags enable fast filtering of events without parsing full content.

Source

pub fn is_context_relevant(&self) -> bool

Check if this event is important for context extraction

Trait Implementations§

Source§

impl Clone for SessionEvent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SessionEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SessionEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for SessionEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for SessionEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.