pub struct State {Show 14 fields
pub seq: Seq,
pub sessions: BTreeMap<SessionId, Session>,
pub archived_sessions: BTreeMap<SessionId, Session>,
pub tasks: BTreeMap<TaskId, Task>,
pub messages: Vec<BusMessage>,
pub artifacts: Vec<Artifact>,
pub reviews: Vec<ReviewComment>,
pub pending_permissions: BTreeMap<String, PermissionRequest>,
pub pending_questions: BTreeMap<String, UserQuestion>,
pub transcripts: HashMap<SessionId, VecDeque<String>>,
pub log_ok: bool,
pub quotas: BTreeMap<String, Quota>,
pub queues: BTreeMap<SessionId, Vec<String>>,
pub inbox_cursors: BTreeMap<SessionId, String>,
}Fields§
§seq: Seq§sessions: BTreeMap<SessionId, Session>§archived_sessions: BTreeMap<SessionId, Session>Historical sessions removed from active list with native_id (for resuming original conversation).
tasks: BTreeMap<TaskId, Task>§messages: Vec<BusMessage>§artifacts: Vec<Artifact>§reviews: Vec<ReviewComment>§pending_permissions: BTreeMap<String, PermissionRequest>Pending approval requests.
pending_questions: BTreeMap<String, UserQuestion>Pending interactive user questions.
transcripts: HashMap<SessionId, VecDeque<String>>Session ID -> output text lines.
log_ok: boolEvent log write health status (defaults to normal).
quotas: BTreeMap<String, Quota>Latest quota reported by each agent (agent ID -> quota).
queues: BTreeMap<SessionId, Vec<String>>Queued raw prompt text list per session (session ID -> items).
inbox_cursors: BTreeMap<SessionId, String>Last bus message id already delivered to each session (session ID -> message ID).
Implementations§
Source§impl State
impl State
pub fn new() -> Self
Sourcepub fn archive_session(&mut self, session: &str)
pub fn archive_session(&mut self, session: &str)
Moves terminated session from active list; archives to archived_sessions if possessing native_id for future resumption.
Sourcepub fn archived_to_prune(
&self,
now_ms: u64,
max_count: usize,
max_days: u64,
) -> Vec<SessionId>
pub fn archived_to_prune( &self, now_ms: u64, max_count: usize, max_days: u64, ) -> Vec<SessionId>
Archived session ids that exceed the retention limits: older than max_days
(counted from when they ended) or beyond the newest max_count entries.
Sourcepub fn session_depth(&self, sid: &str) -> usize
pub fn session_depth(&self, sid: &str) -> usize
Calculates depth of sid (human-created sessions are level 0, child agents increment sequentially).
Sourcepub fn tree_root(&self, sid: &str) -> SessionId
pub fn tree_root(&self, sid: &str) -> SessionId
Traverses upward along parent to find the root session ID of the tree.
Sourcepub fn tree_sessions(&self, sid: &str) -> Vec<SessionId>
pub fn tree_sessions(&self, sid: &str) -> Vec<SessionId>
Returns all session IDs in the same tree as sid (root and all descendants).
Sourcepub fn tree_cost_usd(&self, sid: &str) -> f64
pub fn tree_cost_usd(&self, sid: &str) -> f64
Calculates total USD cost for the same tree as sid (root and all descendants).
Sourcepub fn live_children_count(&self, parent_id: &str) -> usize
pub fn live_children_count(&self, parent_id: &str) -> usize
Counts live direct child sessions currently running under parent_id.
Sourcepub fn sessions_sorted(&self) -> Vec<&Session>
pub fn sessions_sorted(&self) -> Vec<&Session>
Helper for TUI to retrieve sessions sorted by creation time.
pub fn live_sessions(&self) -> impl Iterator<Item = &Session>
Sourcepub fn total_cost(&self) -> Cost
pub fn total_cost(&self) -> Cost
Calculates cumulative cost and token usage across all sessions.
Sourcepub fn unfinished_deps(&self, task: &Task) -> Vec<&Task>
pub fn unfinished_deps(&self, task: &Task) -> Vec<&Task>
Incomplete prerequisite tasks (present in depends_on with status other than done).
Missing IDs do not count: they will never complete, and counting them would deadlock the task.
Sourcepub fn resolve_session_id(&self, id_or_label: &str) -> Option<SessionId>
pub fn resolve_session_id(&self, id_or_label: &str) -> Option<SessionId>
Resolves session ID by id or label (prefers exact ID match, then live session with matching label).
Sourcepub fn resolve_resumable_session(
&self,
id_or_label: &str,
) -> Option<(Session, bool)>
pub fn resolve_resumable_session( &self, id_or_label: &str, ) -> Option<(Session, bool)>
Finds target session for :resume by id, label, or native_id; returns (Session, is_archived).
Sourcepub fn successor_of(&self, id: &str) -> SessionId
pub fn successor_of(&self, id: &str) -> SessionId
Follows handed_off_to chain to final successor; stops at current node on cycles or exceeding 16 levels.
Sourcepub fn inbox_for(
&self,
session_id: &str,
after_msg_id: Option<&str>,
) -> Vec<BusMessage>
pub fn inbox_for( &self, session_id: &str, after_msg_id: Option<&str>, ) -> Vec<BusMessage>
Retrieves messages received by a session after after_msg_id.
Sourcepub fn export_markdown(
&self,
root_id: &str,
include_tree: bool,
diff: Option<&str>,
) -> Result<String, String>
pub fn export_markdown( &self, root_id: &str, include_tree: bool, diff: Option<&str>, ) -> Result<String, String>
Exports a session (and optionally entire child session tree) into a Markdown report suitable for PR / Issue description.
Includes metadata, child session hierarchy, associated tasks, transcript, and optional git diff;
entire output is masked with redact_secrets to prevent leaking keys to external services.