1use crate::colors::SectionColors;
2use crate::utils::visible_len;
3use serde::{Deserialize, Serialize};
4
5#[derive(Clone, PartialEq, Debug)]
6pub enum SectionKind {
7 Generic,
8 QuotaCompact(String),
9 QuotaDetailed(String),
10 ContextCompact,
11 ContextDetailed,
12}
13
14#[derive(Clone)]
15pub struct Section {
16 pub kind: SectionKind,
17 pub content: String,
18 pub priority: u16, pub colors: SectionColors, pub width: usize, }
22
23impl Section {
24 pub fn with_kind(
25 kind: SectionKind,
26 content: String,
27 priority: u16,
28 colors: SectionColors,
29 ) -> Self {
30 let width = visible_len(&content);
31 Section {
32 kind,
33 content,
34 priority,
35 colors,
36 width,
37 }
38 }
39
40 pub fn new(content: String, priority: u16, colors: SectionColors) -> Self {
41 Self::with_kind(SectionKind::Generic, content, priority, colors)
42 }
43
44 pub fn new_quota_compact(
45 label: &str,
46 content: String,
47 priority: u16,
48 colors: SectionColors,
49 ) -> Self {
50 Self::with_kind(
51 SectionKind::QuotaCompact(label.to_string()),
52 content,
53 priority,
54 colors,
55 )
56 }
57
58 pub fn new_quota_detailed(
59 label: &str,
60 content: String,
61 priority: u16,
62 colors: SectionColors,
63 ) -> Self {
64 Self::with_kind(
65 SectionKind::QuotaDetailed(label.to_string()),
66 content,
67 priority,
68 colors,
69 )
70 }
71
72 pub fn new_context_compact(content: String, priority: u16, colors: SectionColors) -> Self {
73 Self::with_kind(SectionKind::ContextCompact, content, priority, colors)
74 }
75
76 pub fn new_context_detailed(content: String, priority: u16, colors: SectionColors) -> Self {
77 Self::with_kind(SectionKind::ContextDetailed, content, priority, colors)
78 }
79}
80
81pub struct ContextUsageInfo {
83 pub percentage: f64,
84 pub current_usage_tokens: u64,
85 pub context_window_size: u64,
86 pub is_exact: bool, }
88
89#[derive(Debug, Deserialize)]
90pub struct ClaudeInput {
91 pub workspace: Option<Workspace>,
92 pub model: Option<Model>,
93 pub context_window: Option<ContextWindow>,
94 pub cost: Option<Cost>,
95 pub output_style: Option<OutputStyle>,
96}
97
98#[derive(Debug, Deserialize)]
99pub struct Workspace {
100 pub current_dir: Option<String>,
101}
102
103#[derive(Debug, Deserialize)]
104pub struct Model {
105 pub display_name: Option<String>,
106}
107
108#[derive(Debug, Deserialize)]
109pub struct OutputStyle {
110 pub name: Option<String>,
111}
112
113#[derive(Debug, Deserialize)]
114pub struct ContextWindow {
115 pub context_window_size: Option<u64>,
116 pub current_usage: Option<CurrentUsage>,
117 pub used_percentage: Option<f64>,
118 pub remaining_percentage: Option<f64>,
119}
120
121#[derive(Debug, Deserialize)]
122pub struct CurrentUsage {
123 pub input_tokens: Option<u64>,
124 pub _output_tokens: Option<u64>,
125 pub cache_creation_input_tokens: Option<u64>,
126 pub cache_read_input_tokens: Option<u64>,
127}
128
129#[derive(Debug, Deserialize)]
130pub struct Cost {
131 pub total_cost_usd: Option<f64>,
132 pub total_duration_ms: Option<u64>,
133 pub total_api_duration_ms: Option<u64>,
134 pub total_lines_added: Option<u64>,
135 pub total_lines_removed: Option<u64>,
136}
137
138#[derive(Debug, Deserialize)]
139pub struct QuotaResponse {
140 pub five_hour: Option<QuotaLimit>,
141 pub seven_day: Option<QuotaLimit>,
142}
143
144#[derive(Debug, Deserialize)]
145pub struct QuotaLimit {
146 pub utilization: f64,
147 pub resets_at: Option<String>,
148}
149
150#[derive(Debug, Deserialize)]
151pub struct KeychainCredentials {
152 #[serde(rename = "claudeAiOauth")]
153 pub claude_ai_oauth: Option<OAuthCredentials>,
154}
155
156#[derive(Debug, Deserialize)]
157pub struct OAuthCredentials {
158 #[serde(rename = "accessToken")]
159 pub access_token: String,
160}
161
162#[derive(Debug, Deserialize, Serialize, Clone)]
164pub struct QuotaData {
165 pub five_hour_pct: Option<f64>,
166 pub five_hour_resets_at: Option<String>,
167 pub seven_day_pct: Option<f64>,
168 pub seven_day_resets_at: Option<String>,
169}
170
171#[derive(Serialize, Deserialize)]
172pub struct CachedQuota {
173 pub timestamp: u64,
174 pub data: QuotaData,
175}
176
177#[derive(Debug, PartialEq)]
178pub struct GitInfo {
179 pub branch: String,
180 pub is_dirty: bool,
181 pub repo_name: Option<String>,
182 pub lines_added: usize,
183 pub lines_removed: usize,
184}