use crate::colors::SectionColors;
use crate::utils::visible_len;
use serde::Deserialize;
#[derive(Clone, PartialEq, Debug)]
pub enum SectionKind {
Generic,
QuotaCompact(String),
QuotaDetailed(String),
ContextCompact,
ContextDetailed,
}
#[derive(Clone)]
pub struct Section {
pub kind: SectionKind,
pub content: String,
pub priority: u16, pub colors: SectionColors, pub width: usize, }
impl Section {
pub fn with_kind(
kind: SectionKind,
content: String,
priority: u16,
colors: SectionColors,
) -> Self {
let width = visible_len(&content);
Section {
kind,
content,
priority,
colors,
width,
}
}
pub fn new(content: String, priority: u16, colors: SectionColors) -> Self {
Self::with_kind(SectionKind::Generic, content, priority, colors)
}
pub fn new_quota_compact(
label: &str,
content: String,
priority: u16,
colors: SectionColors,
) -> Self {
Self::with_kind(
SectionKind::QuotaCompact(label.to_string()),
content,
priority,
colors,
)
}
pub fn new_quota_detailed(
label: &str,
content: String,
priority: u16,
colors: SectionColors,
) -> Self {
Self::with_kind(
SectionKind::QuotaDetailed(label.to_string()),
content,
priority,
colors,
)
}
pub fn new_context_compact(content: String, priority: u16, colors: SectionColors) -> Self {
Self::with_kind(SectionKind::ContextCompact, content, priority, colors)
}
pub fn new_context_detailed(content: String, priority: u16, colors: SectionColors) -> Self {
Self::with_kind(SectionKind::ContextDetailed, content, priority, colors)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ContextAccuracy {
Exact,
Estimated,
}
pub struct ContextUsageInfo {
pub percentage: f64,
pub current_usage_tokens: u64,
pub context_window_size: Option<u64>,
pub accuracy: ContextAccuracy,
}
#[derive(Debug, Deserialize, Clone)]
pub struct ClaudeInput {
pub cwd: Option<String>,
pub workspace: Option<Workspace>,
pub model: Option<Model>,
pub context_window: Option<ContextWindow>,
pub cost: Option<Cost>,
pub output_style: Option<OutputStyle>,
pub worktree: Option<Worktree>,
pub rate_limits: Option<RateLimits>,
pub effort: Option<Effort>,
pub thinking: Option<Thinking>,
pub version: Option<String>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct RateLimits {
pub five_hour: Option<RateLimit>,
pub seven_day: Option<RateLimit>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct RateLimit {
pub used_percentage: Option<f64>,
pub resets_at: Option<u64>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Effort {
pub level: Option<String>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Thinking {
pub enabled: Option<bool>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Workspace {
pub current_dir: Option<String>,
pub project_dir: Option<String>,
pub added_dirs: Option<Vec<String>>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Model {
pub id: Option<String>,
pub display_name: Option<String>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct OutputStyle {
pub name: Option<String>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct ContextWindow {
pub context_window_size: Option<u64>,
pub total_input_tokens: Option<u64>,
pub total_output_tokens: Option<u64>,
pub current_usage: Option<CurrentUsage>,
pub used_percentage: Option<f64>,
pub remaining_percentage: Option<f64>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct CurrentUsage {
pub input_tokens: Option<u64>,
#[serde(alias = "_output_tokens")]
pub output_tokens: Option<u64>,
pub cache_creation_input_tokens: Option<u64>,
pub cache_read_input_tokens: Option<u64>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Cost {
pub total_cost_usd: Option<f64>,
pub total_duration_ms: Option<u64>,
pub total_api_duration_ms: Option<u64>,
pub total_lines_added: Option<u64>,
pub total_lines_removed: Option<u64>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Worktree {
pub name: Option<String>,
pub path: Option<String>,
pub branch: Option<String>,
pub original_cwd: Option<String>,
pub original_branch: Option<String>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct QuotaData {
pub five_hour_pct: Option<f64>,
pub five_hour_resets_at: Option<String>,
pub seven_day_pct: Option<f64>,
pub seven_day_resets_at: Option<String>,
}
#[derive(Debug, PartialEq)]
pub struct GitInfo {
pub branch: String,
pub is_dirty: bool,
pub repo_name: Option<String>,
pub lines_added: usize,
pub lines_removed: usize,
}