87 lines
2.9 KiB
Rust
87 lines
2.9 KiB
Rust
use ratatui::layout::Rect;
|
|||
|
|
use ratatui::style::{Style, Modifier};
|
||
|
|
use ratatui::text::{Line, Span};
|
||
|
|
use ratatui::widgets::{Block, Borders, List, ListItem};
|
||
|
|
use ratatui::Frame;
|
||
|
|
use super::theme::Theme;
|
||
|
|
|
||
|
|
pub fn draw_workflow_panel(frame: &mut Frame, area: Rect, state: &crate::app::state::rest::AppStateRest) {
|
||
|
|
let block = Block::default()
|
||
|
|
.borders(Borders::ALL)
|
||
|
|
.border_style(Style::default().fg(Theme::BORDER))
|
||
|
|
.title(" Workflow ");
|
||
|
|
|
||
|
|
let session_runtime = match &state.session_runtime {
|
||
|
|
Some(r) => r,
|
||
|
|
None => {
|
||
|
|
let empty = Block::default().borders(Borders::ALL).title(" Workflow ");
|
||
|
|
let paragraph = ratatui::widgets::Paragraph::new(Line::from(Span::raw("No active session")))
|
||
|
|
.block(empty);
|
||
|
|
frame.render_widget(paragraph, area);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
let tool_count = session_runtime.tool_call_results.len();
|
||
|
|
let pending_count = session_runtime.pending_tool_queue.len();
|
||
|
|
let bash_count = session_runtime.bash_jobs.len();
|
||
|
|
let subagent_queue = session_runtime.subagent_queue;
|
||
|
|
let edit_count = session_runtime.edit_count;
|
||
|
|
|
||
|
|
let mut items = Vec::new();
|
||
|
|
|
||
|
|
items.push(ListItem::new(Line::from(Span::styled(
|
||
|
|
format!(" Messages: {}", session_runtime.messages.len()),
|
||
|
|
Style::default().fg(Theme::TEXT),
|
||
|
|
))));
|
||
|
|
|
||
|
|
items.push(ListItem::new(Line::from(Span::styled(
|
||
|
|
format!(" Tool calls completed: {}", tool_count),
|
||
|
|
Style::default().fg(Theme::SUCCESS),
|
||
|
|
))));
|
||
|
|
|
||
|
|
if pending_count > 0 {
|
||
|
|
items.push(ListItem::new(Line::from(Span::styled(
|
||
|
|
format!(" Pending tool queue: {}", pending_count),
|
||
|
|
Style::default().fg(Theme::WARNING),
|
||
|
|
))));
|
||
|
|
}
|
||
|
|
|
||
|
|
if bash_count > 0 {
|
||
|
|
items.push(ListItem::new(Line::from(Span::styled(
|
||
|
|
format!(" Active bash jobs: {}", bash_count),
|
||
|
|
Style::default().fg(Theme::WARNING),
|
||
|
|
))));
|
||
|
|
}
|
||
|
|
|
||
|
|
if subagent_queue > 0 {
|
||
|
|
items.push(ListItem::new(Line::from(Span::styled(
|
||
|
|
format!(" Subagent queue: {}", subagent_queue),
|
||
|
|
Style::default().fg(Theme::INFO),
|
||
|
|
))));
|
||
|
|
}
|
||
|
|
|
||
|
|
items.push(ListItem::new(Line::from(Span::styled(
|
||
|
|
format!(" Edits: {}", edit_count),
|
||
|
|
Style::default().fg(Theme::INFO),
|
||
|
|
))));
|
||
|
|
|
||
|
|
let phase_status = match state.mode {
|
||
|
|
crate::app::state::types::AgentMode::Auto => "Auto-running",
|
||
|
|
crate::app::state::types::AgentMode::Normal => "Awaiting input",
|
||
|
|
crate::app::state::types::AgentMode::Plan => "Planning",
|
||
|
|
crate::app::state::types::AgentMode::Yolo => "Full autonomy",
|
||
|
|
};
|
||
|
|
|
||
|
|
items.push(ListItem::new(Line::from(Span::styled(
|
||
|
|
format!(" Phase: {}", phase_status),
|
||
|
|
Style::default().fg(Theme::PRIMARY),
|
||
|
|
))));
|
||
|
|
|
||
|
|
let list = List::new(items)
|
||
|
|
.block(block)
|
||
|
|
.highlight_style(Style::default().add_modifier(Modifier::BOLD));
|
||
|
|
|
||
|
|
frame.render_widget(list, area);
|
||
|
|
}
|