pub struct UserEvent {
pub metadata: EventMetadata,
pub message: MessageContent,
pub permission_mode: Option<String>,
pub is_meta: Option<bool>,
pub is_compact_summary: Option<bool>,
pub origin: Option<OriginInfo>,
pub tool_use_result: Option<ToolUseResult>,
pub source_tool_assistant_uuid: Option<String>,
}Expand description
User message event
Represents messages from:
- Human users (userType = “external”)
- Tool results (has tool_use_result field)
Fields§
§metadata: EventMetadataCommon event metadata
message: MessageContentMessage content
permission_mode: Option<String>Permission mode (for file operations)
is_meta: Option<bool>Marks injected/synthetic turns: local-command caveats and similar harness-generated notices rather than something the human actually typed.
is_compact_summary: Option<bool>Marks a synthesized conversation-compaction summary turn (the text
Claude Code writes back as a user turn to replay a compacted
conversation) rather than something the human actually typed.
origin: Option<OriginInfo>Where this turn came from. Present on newer transcripts; absent on
older ones and on several harness-injected shapes that predate this
field, so its absence does not by itself mean “human” — only specific
present values ("task-notification", "peer") are used, as an
exclusion signal.
tool_use_result: Option<ToolUseResult>Tool result (if this is a tool result message)
Deserialized leniently — see
crate::events::tool_result::deserialize_tool_use_result_lenient.
source_tool_assistant_uuid: Option<String>Links result back to assistant message that invoked tool
Implementations§
Source§impl UserEvent
impl UserEvent
Sourcepub fn parent_uuid(&self) -> Option<&str>
pub fn parent_uuid(&self) -> Option<&str>
Get parent UUID
Sourcepub fn extract_text_content(&self) -> Option<String>
pub fn extract_text_content(&self) -> Option<String>
Extract text content for FTS indexing
Sourcepub fn extract_file_paths(&self) -> Vec<String>
pub fn extract_file_paths(&self) -> Vec<String>
Extract file paths mentioned
Sourcepub fn extract_tool_names(&self) -> Vec<String>
pub fn extract_tool_names(&self) -> Vec<String>
Extract tool names
Sourcepub fn classify_turn(&self) -> UserTurnKind<'_>
pub fn classify_turn(&self) -> UserTurnKind<'_>
Classify this turn’s content for a restore digest.
Excludes, as UserTurnKind::HarnessNotification:
- non-external turns (tool results routed back as
userevents withuserTypeunset or"internal") isMetaturns (harness-injected notices)isCompactSummaryturns (the synthesized replay of a compacted conversation, written back as auserturn — not human-authored)- turns whose
origin.kindis"task-notification"(a delegated agent’s completion notice) or"peer"(a cross-session message) - turns whose content is only tool results (no text block at all —
handled implicitly, since
ContentBlock::as_textonly matches text blocks) - local-command echoes (
<local-command-caveat>,<local-command-stdout>,<local-command-stderr>), stray<task-notification>/<system-reminder>text blocks not caught by the structural checks above
Recognizes, as UserTurnKind::SlashCommand: a <command-name>
invocation — a real user action, not free text, but not a harness
notification either. The caller decides how to render it.
Everything else is UserTurnKind::HumanPrompt — including
system-generated notices of a genuine user action, e.g.
[Request interrupted by user], which reflect something the human
actually did even though the string wasn’t typed character-by-character.