#[derive(Debug, Clone, PartialEq, Default)]
pub enum ViewMode {
#[default]
Main,
WorkerAttached { agent_id: String },
}
const MAX_WORKER_STREAM_BYTES: usize = 64 * 1024; const MAX_WORKER_TOOL_EVENTS: usize = 200;
#[derive(Debug, Clone, Default)]
pub struct WorkerDetailState {
pub full_stream: String,
pub tool_events: Vec<WorkerToolEvent>,
pub scroll_offset: u16,
pub auto_scroll: bool,
}
impl WorkerDetailState {
pub fn push_stream(&mut self, text: &str) {
self.full_stream.push_str(text);
if self.full_stream.len() > MAX_WORKER_STREAM_BYTES {
let trim = self.full_stream.len() - MAX_WORKER_STREAM_BYTES;
let boundary = self.full_stream.ceil_char_boundary(trim);
self.full_stream.drain(..boundary);
}
}
pub fn push_tool_event(&mut self, event: WorkerToolEvent) {
if self.tool_events.len() >= MAX_WORKER_TOOL_EVENTS {
self.tool_events
.drain(..self.tool_events.len() - MAX_WORKER_TOOL_EVENTS + 1);
}
self.tool_events.push(event);
}
}
#[derive(Debug, Clone)]
pub struct WorkerToolEvent {
pub name: String,
pub args_preview: String,
pub result_preview: String,
pub success: bool,
}
#[derive(Debug, Clone)]
pub struct SwarmUiStatus {
pub mode_label: String,
pub agents: Vec<SwarmAgentUiEntry>,
pub phase: SwarmPhase,
pub pending_conflicts: Vec<(String, Vec<String>)>,
}
#[derive(Debug, Clone)]
pub struct SwarmAgentUiEntry {
pub agent_id: String,
pub name: String,
pub task_preview: String,
pub status: SwarmAgentStatus,
pub iteration: u32,
pub modified_files: Vec<String>,
pub tool_calls: u32,
pub input_tokens: u64,
pub output_tokens: u64,
pub output: String,
pub current_tool: Option<String>,
pub streaming_preview: String,
pub last_activity: Option<std::time::Instant>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum SwarmAgentStatus {
Pending,
Running,
Paused,
Completed { success: bool },
}
#[derive(Debug, Clone, PartialEq)]
pub enum SwarmPhase {
Analyzing,
PlanReview,
Executing,
MergingResults,
ResolvingConflicts,
Done,
}
#[derive(Debug, Clone)]
pub struct PendingPlan {
pub plan: String,
pub user_msg: String,
pub system_prompt: String,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ToolLogEntry {
pub name: String,
pub args_preview: String,
pub args_full: Option<String>,
pub result_preview: String,
pub success: bool,
pub call_id: Option<String>,
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ChangedFileEntry {
pub path: String,
pub additions: usize,
pub deletions: usize,
}
#[derive(Debug, Clone, Default)]
pub struct DebugMonitor {
pub memory_bytes: u64,
pub cpu_percent: f32,
pub input_tokens: u64,
pub output_tokens: u64,
pub total_tool_calls: u32,
pub total_api_calls: u32,
pub active_agents: usize,
pub tool_latency_avg_ms: f64,
pub tool_latency_max_ms: u64,
pub api_latency_avg_ms: f64,
pub api_latency_max_ms: u64,
pub tool_success_rate: f32,
pub tokens_per_iteration: f64,
pub tools_per_iteration: f64,
pub top_tools: Vec<(String, u32)>,
pub mcp_memory_bytes: u64,
pub lsp_memory_bytes: u64,
}