pub struct SessionDomain {Show 21 fields
pub id: SessionId,
pub agent_type: AgentType,
pub model: Model,
pub model_display_override: Option<String>,
pub status: SessionStatus,
pub current_activity: Option<ActivityDetail>,
pub context: ContextUsage,
pub cost: Money,
pub duration: SessionDuration,
pub lines_changed: LinesChanged,
pub started_at: DateTime<Utc>,
pub last_activity: DateTime<Utc>,
pub working_directory: Option<String>,
pub claude_code_version: Option<String>,
pub tmux_pane: Option<String>,
pub project_root: Option<String>,
pub worktree_path: Option<String>,
pub worktree_branch: Option<String>,
pub parent_session_id: Option<SessionId>,
pub child_session_ids: Vec<SessionId>,
pub first_prompt: Option<String>,
}Expand description
Core domain model for a Claude Code session.
Contains pure business logic and state. Does NOT include infrastructure concerns (PIDs, sockets, file paths).
Consistent with CONCURRENCY_MODEL.md RegistryActor ownership.
Fields§
§id: SessionIdUnique session identifier
agent_type: AgentTypeType of agent (main, subagent, etc.)
model: ModelClaude model being used
model_display_override: Option<String>Display name override for unknown/non-Anthropic models.
When model is Unknown, this holds the raw model ID or
the provider-supplied display name for UI rendering.
status: SessionStatusCurrent session status (3-state model)
current_activity: Option<ActivityDetail>Current activity details (tool name, context, timing)
context: ContextUsageContext window usage
cost: MoneyAccumulated cost
duration: SessionDurationSession duration tracking
lines_changed: LinesChangedLines of code changed
started_at: DateTime<Utc>When the session started
last_activity: DateTime<Utc>Last activity timestamp
working_directory: Option<String>Working directory (project root)
claude_code_version: Option<String>Claude Code version
tmux_pane: Option<String>Tmux pane ID (e.g., “%5”) if session is running in tmux
project_root: Option<String>Git project root (resolved from working_directory). Shared across all worktrees of the same repo.
worktree_path: Option<String>Git worktree path (specific checkout directory). For the main checkout, this equals project_root.
worktree_branch: Option<String>Git branch name for this worktree.
parent_session_id: Option<SessionId>Parent session ID (set when this session is a subagent).
child_session_ids: Vec<SessionId>Child subagent session IDs spawned by this session.
first_prompt: Option<String>First user prompt (captured from the first UserPromptSubmit hook event).
Implementations§
Source§impl SessionDomain
impl SessionDomain
Sourcepub fn new(id: SessionId, agent_type: AgentType, model: Model) -> Self
pub fn new(id: SessionId, agent_type: AgentType, model: Model) -> Self
Creates a new SessionDomain with required fields.
Sourcepub fn from_status_line(data: &StatusLineData) -> Self
pub fn from_status_line(data: &StatusLineData) -> Self
Creates a SessionDomain from Claude Code status line data.
Sourcepub fn update_from_status_line(&mut self, data: &StatusLineData) -> bool
pub fn update_from_status_line(&mut self, data: &StatusLineData) -> bool
Updates the session with new status line data.
When current_usage is null in Claude’s status line, all current_* values
will be 0, which correctly resets context percentage to 0%.
Returns true if the working directory changed (caller should re-resolve git info).
Sourcepub fn apply_hook_event(
&mut self,
event_type: HookEventType,
tool_name: Option<&str>,
)
pub fn apply_hook_event( &mut self, event_type: HookEventType, tool_name: Option<&str>, )
Updates status based on a hook event.
Sourcepub fn set_first_prompt(&mut self, prompt: &str)
pub fn set_first_prompt(&mut self, prompt: &str)
Stores the first user prompt if not already set.
Sourcepub fn apply_notification(&mut self, notification_type: Option<&str>)
pub fn apply_notification(&mut self, notification_type: Option<&str>)
Updates status based on a notification event.
Sourcepub fn time_since_activity(&self) -> Duration
pub fn time_since_activity(&self) -> Duration
Returns time since last activity.
Sourcepub fn needs_context_attention(&self) -> bool
pub fn needs_context_attention(&self) -> bool
Returns true if context usage needs attention.
Trait Implementations§
Source§impl Clone for SessionDomain
impl Clone for SessionDomain
Source§fn clone(&self) -> SessionDomain
fn clone(&self) -> SessionDomain
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more