pub struct ClaudeSession {Show 67 fields
pub pid: u32,
pub session_id: String,
pub cwd: String,
pub project_name: String,
pub started_at: u64,
pub elapsed: Duration,
pub tty: String,
pub status: SessionStatus,
pub cpu_percent: f32,
pub cpu_history: Vec<f32>,
pub mem_mb: f64,
pub own_input_tokens: u64,
pub own_output_tokens: u64,
pub own_cache_read_tokens: u64,
pub own_cache_write_tokens: u64,
pub subagent_input_tokens: u64,
pub subagent_output_tokens: u64,
pub subagent_cache_read_tokens: u64,
pub subagent_cache_write_tokens: u64,
pub total_input_tokens: u64,
pub total_output_tokens: u64,
pub model: String,
pub command_args: String,
pub session_name: String,
pub jsonl_path: Option<PathBuf>,
pub jsonl_offset: u64,
pub last_message_ts: u64,
pub cache_read_tokens: u64,
pub cache_write_tokens: u64,
pub cost_usd: f64,
pub context_tokens: u64,
pub context_max: u64,
pub prev_cost_usd: f64,
pub burn_rate_per_hr: f64,
pub subagent_count: usize,
pub active_subagent_count: usize,
pub active_subagent_jsonl_paths: Vec<PathBuf>,
pub subagent_rollups: HashMap<PathBuf, SubagentRollup>,
pub activity_history: Vec<u8>,
pub files_modified: HashMap<String, u32>,
pub tool_usage: HashMap<String, ToolStats>,
pub worktree_id: Option<String>,
pub telemetry_status: TelemetryStatus,
pub usage_metrics_available: bool,
pub cost_estimate_unverified: bool,
pub model_profile_source: String,
pub last_msg_type: String,
pub last_stop_reason: String,
pub is_waiting_for_task: bool,
pub pending_tool_name: Option<String>,
pub pending_tool_input: Option<String>,
pub pending_file_path: Option<String>,
pub has_file_conflict: bool,
pub last_tool_error: bool,
pub last_error_message: Option<String>,
pub recent_errors: Vec<ErrorEntry>,
pub total_tokens_at_edit_count: u64,
pub edit_event_count: u32,
pub baseline_tokens_per_edit: Option<f64>,
pub error_counts_per_window: Vec<u32>,
pub current_window_errors: u32,
pub window_tick_counter: u32,
pub baseline_error_rate: Option<f64>,
pub file_reads_since_edit: HashMap<String, u32>,
pub total_error_count: u32,
pub decay_score: u32,
pub worker_origin: Option<String>,
}Fields§
§pid: u32§session_id: String§cwd: String§project_name: String§started_at: u64§elapsed: Duration§tty: String§status: SessionStatus§cpu_percent: f32§cpu_history: Vec<f32>§mem_mb: f64§own_input_tokens: u64§own_output_tokens: u64§own_cache_read_tokens: u64§own_cache_write_tokens: u64§subagent_input_tokens: u64§subagent_output_tokens: u64§subagent_cache_read_tokens: u64§subagent_cache_write_tokens: u64§total_input_tokens: u64§total_output_tokens: u64§model: String§command_args: String§session_name: String§jsonl_path: Option<PathBuf>§jsonl_offset: u64§last_message_ts: u64§cache_read_tokens: u64§cache_write_tokens: u64§cost_usd: f64§context_tokens: u64§context_max: u64§prev_cost_usd: f64§burn_rate_per_hr: f64§subagent_count: usize§active_subagent_count: usize§active_subagent_jsonl_paths: Vec<PathBuf>§subagent_rollups: HashMap<PathBuf, SubagentRollup>§activity_history: Vec<u8>§files_modified: HashMap<String, u32>§tool_usage: HashMap<String, ToolStats>§worktree_id: Option<String>§telemetry_status: TelemetryStatus§usage_metrics_available: bool§cost_estimate_unverified: bool§model_profile_source: String§last_msg_type: StringPersisted across ticks so status inference works when no new JSONL arrives.
last_stop_reason: String§is_waiting_for_task: bool§pending_tool_name: Option<String>Pending tool call details for rule-based auto-actions.
pending_tool_input: Option<String>§pending_file_path: Option<String>§has_file_conflict: bool§last_tool_error: bool§last_error_message: Option<String>§recent_errors: Vec<ErrorEntry>§total_tokens_at_edit_count: u64Cumulative tokens at each Edit/Write event (for efficiency trending).
edit_event_count: u32Number of Edit/Write events (for averaging tokens-per-edit).
baseline_tokens_per_edit: Option<f64>Baseline tokens-per-edit, frozen after first 5 edits.
error_counts_per_window: Vec<u32>Error count ring buffer: one entry per window (~10s each).
current_window_errors: u32Accumulator for current error window.
window_tick_counter: u32Ticks since last window flush.
baseline_error_rate: Option<f64>Baseline error rate (errors per window), frozen after 3 windows.
file_reads_since_edit: HashMap<String, u32>File reads since last edit: path -> read count. Reset when file is edited.
total_error_count: u32All-time error count.
decay_score: u32Cached composite decay score (0-100), recomputed each tick.
worker_origin: Option<String>If set, this session is from a remote worker (not local). Terminal actions (approve, kill, etc.) are disabled for remote sessions.
Implementations§
Source§impl ClaudeSession
impl ClaudeSession
pub fn from_raw(raw: RawSession) -> Self
Sourcepub fn record_activity(&mut self)
pub fn record_activity(&mut self)
Record current status into the activity sparkline ring buffer. Max 15 entries (one per tick, at 2s default = 30s of history).
Sourcepub fn format_sparkline(&self) -> String
pub fn format_sparkline(&self) -> String
Render the sparkline as unicode block characters.
pub fn display_name(&self) -> &str
Sourcepub fn from_remote_json(worker_id: &str, json: &Value) -> Option<Self>
pub fn from_remote_json(worker_id: &str, json: &Value) -> Option<Self>
Build a ClaudeSession from remote JSON (as received via heartbeat/HTTP).
pub fn format_subagent_summary(&self) -> String
pub fn subagent_breakdown(&self) -> Vec<SubagentBreakdown>
pub fn format_elapsed(&self) -> String
pub fn format_tokens(&self) -> String
pub fn format_mem(&self) -> String
pub fn format_cost(&self) -> String
pub fn context_percent(&self) -> f64
Sourcepub fn format_context(&self) -> String
pub fn format_context(&self) -> String
Format context as “450k/1M 45%” or a visual bar
Sourcepub fn format_context_bar(&self, width: usize) -> String
pub fn format_context_bar(&self, width: usize) -> String
Visual bar for context usage: ████░░ 62%
Sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
Produce a JSON-serializable value for –json export.
pub fn format_burn_rate(&self) -> String
pub fn telemetry_label(&self) -> &'static str
pub fn has_usage_metrics(&self) -> bool
Trait Implementations§
Source§impl Clone for ClaudeSession
impl Clone for ClaudeSession
Source§fn clone(&self) -> ClaudeSession
fn clone(&self) -> ClaudeSession
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ClaudeSession
impl RefUnwindSafe for ClaudeSession
impl Send for ClaudeSession
impl Sync for ClaudeSession
impl Unpin for ClaudeSession
impl UnsafeUnpin for ClaudeSession
impl UnwindSafe for ClaudeSession
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more