use ratatui::style::Color;
#[derive(Debug, Clone, PartialEq, Default)]
pub enum Activity {
#[default]
Idle,
Thinking,
Reading,
Writing,
Editing,
Searching,
Running,
WebSearch,
WebFetch,
Tool(String),
Asking, }
impl Activity {
pub fn label(&self) -> String {
match self {
Activity::Idle => "Ready".into(),
Activity::Thinking => "Thinking".into(),
Activity::Reading => "📖 Reading".into(),
Activity::Writing => "📝 Writing".into(),
Activity::Editing => "✏️ Editing".into(),
Activity::Searching => "🔍 Searching".into(),
Activity::Running => "⚡ Running".into(),
Activity::WebSearch => "🌐 WebSearch".into(),
Activity::WebFetch => "🔗 Fetching".into(),
Activity::Tool(name) => format!("🔧 {}", name),
Activity::Asking => "❓ Waiting input".into(),
}
}
pub fn color(&self) -> Color {
match self {
Activity::Idle => Color::Green,
Activity::Thinking => Color::Magenta,
Activity::Reading | Activity::Searching => Color::Cyan,
Activity::Writing | Activity::Editing => Color::Yellow,
Activity::Running => Color::Red,
Activity::WebSearch | Activity::WebFetch => Color::Blue,
Activity::Tool(_) => Color::Cyan,
Activity::Asking => Color::Yellow,
}
}
pub fn from_tool(name: &str) -> Self {
match name.to_lowercase().as_str() {
"read" => Activity::Reading,
"write" => Activity::Writing,
"edit" | "multi_edit" => Activity::Editing,
"search" | "glob" | "ls" => Activity::Searching,
"bash" => Activity::Running,
"websearch" => Activity::WebSearch,
"webfetch" => Activity::WebFetch,
other => Activity::Tool(other.to_string()),
}
}
}
#[derive(PartialEq)]
pub enum Role {
User,
Assistant,
Thinking,
Tool { name: String, is_error: bool },
System,
}
impl Role {
pub fn icon(&self) -> &'static str {
match self {
Role::User => "👤",
Role::Assistant => "🤖",
Role::Thinking => "💭",
Role::Tool { is_error, .. } => if *is_error { "❌" } else { "✅" },
Role::System => "⚠️",
}
}
pub fn label(&self) -> String {
match self {
Role::User => "You".into(),
Role::Assistant => "Assistant".into(),
Role::Thinking => "Thinking".into(),
Role::Tool { name, .. } => name.clone(),
Role::System => "System".into(),
}
}
pub fn color(&self) -> Color {
match self {
Role::User => Color::Green,
Role::Assistant => Color::Blue,
Role::Thinking => Color::Magenta,
Role::Tool { is_error, .. } => if *is_error { Color::Red } else { Color::Cyan },
Role::System => Color::Yellow,
}
}
}
pub struct Message {
pub role: Role,
pub content: String,
}
#[derive(Debug, Clone, PartialEq, Default)]
pub enum ApproveMode {
#[default]
Ask,
Auto,
Strict,
}
impl ApproveMode {
pub fn label(&self) -> &'static str {
match self {
ApproveMode::Ask => "ask",
ApproveMode::Auto => "auto",
ApproveMode::Strict => "strict",
}
}
pub fn next(&self) -> Self {
match self {
ApproveMode::Ask => ApproveMode::Auto,
ApproveMode::Auto => ApproveMode::Strict,
ApproveMode::Strict => ApproveMode::Ask,
}
}
}