Implement chat and markdown views, enhance status bar, and add workflow panel
- Added `chat.rs` for rendering chat messages with timestamps and roles. - Introduced `markdown.rs` for rendering markdown content with styling. - Created `status.rs` to display the application status bar with session and message counts. - Developed `workflow.rs` to show the current workflow status, including tool calls and active jobs. - Established a `theme.rs` for centralized color management across the UI. - Updated `mod.rs` to include new modules and manage rendering logic.
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user