use crate::{layout::Rect, PaneId, Rgba};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PaneChrome {
pub id: PaneId,
pub title: String,
pub subtitle: String,
pub rect: Rect,
pub focused: bool,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct TranscriptItem {
pub role: String,
pub content: String,
pub detail: String,
}
impl TranscriptItem {
pub fn system(content: impl Into<String>) -> Self {
Self {
role: "system".to_string(),
content: content.into(),
detail: String::new(),
}
}
pub fn user(content: impl Into<String>) -> Self {
Self {
role: "user".to_string(),
content: content.into(),
detail: "local prompt".to_string(),
}
}
pub fn assistant(content: impl Into<String>, detail: impl Into<String>) -> Self {
Self {
role: "assistant".to_string(),
content: content.into(),
detail: detail.into(),
}
}
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PromptModel {
pub label: String,
pub input: String,
pub cursor: usize,
pub placeholder: String,
}
impl PromptModel {
pub fn label(&self) -> &str {
if self.label.is_empty() {
"prompt"
} else {
&self.label
}
}
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct StatusChip {
pub label: String,
pub value: String,
pub color: Rgba,
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct WidgetSection {
pub title: String,
pub lines: Vec<String>,
pub accent: Rgba,
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct WidgetFrame {
pub panes: Vec<PaneChrome>,
pub prompt: PromptModel,
pub transcript: Vec<TranscriptItem>,
pub chips: Vec<StatusChip>,
pub sections: Vec<WidgetSection>,
}