pub enum SessionState {
Starting,
Working,
Idle,
WaitingForInput,
WaitingForPermission,
Ended,
}Expand description
The coarse, inferred lifecycle state of a Claude Code session.
Serialized snake_case (waiting_for_permission, …) into list/status
payloads. waiting_for_* are reliable (a Notification hook fires them
directly); working/idle are best-effort inference from PreToolUse /
Stop plus the transcript-growth backstop (Claude Code ships no dedicated
state event — ADR-0052).
Variants§
Starting
Session just started (SessionStart), before any turn.
Working
Actively processing a turn — a tool call (PreToolUse/PostToolUse), a
submitted prompt (UserPromptSubmit), or observed transcript growth.
Idle
Finished a turn and waiting at the prompt (Stop).
WaitingForInput
Blocked on the user for a plain input/idle notification.
WaitingForPermission
Blocked on the user to approve a tool/permission prompt.
Ended
The session ended (SessionEnd); reaped shortly after via
[ENDED_SESSION_TTL].
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn for_event(event: &SessionEvent, current: Option<Self>) -> Self
pub fn for_event(event: &SessionEvent, current: Option<Self>) -> Self
The state a sighting of event implies, given the session’s current
state (None for a brand-new session). This is the whole inference
machine, kept in one testable place:
SessionStart→StartingUserPromptSubmit/PreToolUse/PostToolUse→WorkingTranscriptGrew→Working, except whileWaitingForInput/WaitingForPermission/Ended, which it leaves unchanged — growth is expected in those states without the session doing anything, so it is not evidence the turn resumed (#1418)Stop→IdleNotification(PermissionPrompt)→WaitingForPermissionNotification(IdlePrompt | AgentNeedsInput)→WaitingForInputNotification(Other)→ unchanged (an unclassified notification is not evidence of a state change)TranscriptDiscovered→ the current state if known, elseIdle(a passively-discovered session’s activity is unknown; a later hook or growth upgrades it)StreamState(s)→sverbatim (an authoritative stream-json report; the only non-inferred variant — see ADR-0057)
Trait Implementations§
Source§impl Clone for SessionState
impl Clone for SessionState
Source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SessionState
Source§impl Debug for SessionState
impl Debug for SessionState
Source§impl<'de> Deserialize<'de> for SessionState
impl<'de> Deserialize<'de> for SessionState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for SessionState
Source§impl PartialEq for SessionState
impl PartialEq for SessionState
Source§impl Serialize for SessionState
impl Serialize for SessionState
impl StructuralPartialEq for SessionState
Auto Trait Implementations§
impl Freeze for SessionState
impl RefUnwindSafe for SessionState
impl Send for SessionState
impl Sync for SessionState
impl Unpin for SessionState
impl UnsafeUnpin for SessionState
impl UnwindSafe for SessionState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.