Skip to main content

UserEvent

Struct UserEvent 

Source
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: EventMetadata

Common event metadata

§message: MessageContent

Message 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

Source

pub fn uuid(&self) -> &str

Get UUID

Source

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

Get parent UUID

Source

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

Get timestamp

Source

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

Extract text content for FTS indexing

Source

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

Extract file paths mentioned

Source

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

Extract tool names

Source

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 user events with userType unset or "internal")
  • isMeta turns (harness-injected notices)
  • isCompactSummary turns (the synthesized replay of a compacted conversation, written back as a user turn — not human-authored)
  • turns whose origin.kind is "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_text only 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.

Trait Implementations§

Source§

impl Clone for UserEvent

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 UserEvent

Source§

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

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

impl<'de> Deserialize<'de> for UserEvent

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 Serialize for UserEvent

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, 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.