use gpui_kit::assets::IconName;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ComponentKind {
Chat,
Embedder,
Store,
Parser,
Chunker,
Retriever,
Vision,
References,
Other,
}
impl ComponentKind {
pub fn label(self) -> &'static str {
match self {
Self::Chat => "Chat model",
Self::Embedder => "Embedder",
Self::Store => "Store",
Self::Parser => "Parser",
Self::Chunker => "Chunker",
Self::Retriever => "Retriever",
Self::Vision => "Vision",
Self::References => "References",
Self::Other => "Component",
}
}
pub fn icon(self) -> IconName {
match self {
Self::Chat => IconName::Bot,
Self::Embedder => IconName::Cpu,
Self::Store => IconName::Database,
Self::Parser => IconName::FileText,
Self::Chunker => IconName::Scissors,
Self::Retriever => IconName::Search,
Self::Vision => IconName::Eye,
Self::References => IconName::BookOpen,
Self::Other => IconName::Settings,
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum ComponentStatus {
#[default]
Inactive,
Ready,
Busy,
Error,
}
impl ComponentStatus {
pub fn label(self) -> &'static str {
match self {
Self::Inactive => "inactive",
Self::Ready => "ready",
Self::Busy => "busy",
Self::Error => "error",
}
}
pub fn is_busy(self) -> bool {
matches!(self, Self::Busy)
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct AgentComponent {
pub id: String,
pub kind: ComponentKind,
pub label: String,
pub status: ComponentStatus,
pub detail: Option<String>,
}
impl AgentComponent {
pub fn new(id: impl Into<String>, kind: ComponentKind, label: impl Into<String>) -> Self {
Self {
id: id.into(),
kind,
label: label.into(),
status: ComponentStatus::default(),
detail: None,
}
}
pub fn status(mut self, status: ComponentStatus) -> Self {
self.status = status;
self
}
pub fn detail(mut self, detail: impl Into<String>) -> Self {
self.detail = Some(detail.into());
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn kinds_have_labels_and_icons() {
assert_eq!(ComponentKind::Chat.label(), "Chat model");
assert_eq!(ComponentKind::Store.icon(), IconName::Database);
assert_eq!(ComponentKind::References.label(), "References");
assert_eq!(ComponentKind::References.icon(), IconName::BookOpen);
}
#[test]
fn components_default_to_inactive() {
let component = AgentComponent::new("chat", ComponentKind::Chat, "DeepSeek");
assert_eq!(component.status, ComponentStatus::Inactive);
assert!(!component.status.is_busy());
}
}