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)
Progress: ~82,200 (51%)Assistant: ~49,426 (31%)User: ~29,913 (19%)FileSnapshot: ~65 (<0.1%)QueueOperation: ~58 (<0.1%)System: ~6 (<0.1%)Summary: ~1 (<0.1%)
§Links and Relationships
Events form a conversation graph via:
uuid: Unique identifier for this eventparent_uuid: Links to previous message in conversation chaintool_use_id: Links progress to tool invocationsource_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)
§Links
parent_uuid→ previous messagesource_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
§Links
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[].
§Links
tool_use_id→ tool invocation that triggered thisparent_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
§Links
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.
§Links
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)
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
impl SessionEvent
Sourcepub fn metadata(&self) -> Option<EventMetadata>
pub fn metadata(&self) -> Option<EventMetadata>
Extract common metadata present in most events
Sourcepub fn parent_uuid(&self) -> Option<&str>
pub fn parent_uuid(&self) -> Option<&str>
Get parent UUID for conversation graph traversal
Sourcepub fn timestamp(&self) -> DateTime<Utc>
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.
Sourcepub fn extract_text_content(&self) -> Option<String>
pub fn extract_text_content(&self) -> Option<String>
Extract all text content from this event (for FTS indexing)
Sourcepub fn extract_file_paths(&self) -> Vec<String>
pub fn extract_file_paths(&self) -> Vec<String>
Extract file paths mentioned in this event
Sourcepub fn extract_tool_names(&self) -> Vec<String>
pub fn extract_tool_names(&self) -> Vec<String>
Extract tool names used in this event
Source§impl SessionEvent
impl SessionEvent
Extract tags for indexing (legacy method)
Tags enable fast filtering of events without parsing full content.
Sourcepub fn is_context_relevant(&self) -> bool
pub fn is_context_relevant(&self) -> bool
Check if this event is important for context extraction