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 new(content: String, priority: u16, colors: SectionColors) -> Self {
25 let width = visible_len(&content);
26 Section {
27 kind: SectionKind::Generic,
28 content,
29 priority,
30 colors,
31 width,
32 }
33 }
34
35 pub fn new_quota_compact(
36 label: &str,
37 content: String,
38 priority: u16,
39 colors: SectionColors,
40 ) -> Self {
41 let width = visible_len(&content);
42 Section {
43 kind: SectionKind::QuotaCompact(label.to_string()),
44 content,
45 priority,
46 colors,
47 width,
48 }
49 }
50
51 pub fn new_quota_detailed(
52 label: &str,
53 content: String,
54 priority: u16,
55 colors: SectionColors,
56 ) -> Self {
57 let width = visible_len(&content);
58 Section {
59 kind: SectionKind::QuotaDetailed(label.to_string()),
60 content,
61 priority,
62 colors,
63 width,
64 }
65 }
66
67 pub fn new_context_compact(content: String, priority: u16, colors: SectionColors) -> Self {
68 let width = visible_len(&content);
69 Section {
70 kind: SectionKind::ContextCompact,
71 content,
72 priority,
73 colors,
74 width,
75 }
76 }
77
78 pub fn new_context_detailed(content: String, priority: u16, colors: SectionColors) -> Self {
79 let width = visible_len(&content);
80 Section {
81 kind: SectionKind::ContextDetailed,
82 content,
83 priority,
84 colors,
85 width,
86 }
87 }
88}
89
90pub struct ContextUsageInfo {
92 pub percentage: f64,
93 pub current_usage_tokens: u64, pub context_window_size: u64, }
96
97#[derive(Debug, Deserialize)]
98pub struct ClaudeInput {
99 pub workspace: Option<Workspace>,
100 pub model: Option<Model>,
101 pub context_window: Option<ContextWindow>,
102 pub cost: Option<Cost>,
103}
104
105#[derive(Debug, Deserialize)]
106pub struct Workspace {
107 pub current_dir: Option<String>,
108}
109
110#[derive(Debug, Deserialize)]
111pub struct Model {
112 pub display_name: Option<String>,
113}
114
115#[derive(Debug, Deserialize)]
116pub struct ContextWindow {
117 pub context_window_size: Option<u64>,
118 pub current_usage: Option<CurrentUsage>,
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}
133
134#[derive(Debug, Deserialize)]
135pub struct QuotaResponse {
136 pub five_hour: Option<QuotaLimit>,
137 pub seven_day: Option<QuotaLimit>,
138}
139
140#[derive(Debug, Deserialize)]
141pub struct QuotaLimit {
142 pub utilization: f64,
143 pub resets_at: Option<String>,
144}
145
146#[derive(Debug, Deserialize)]
147pub struct KeychainCredentials {
148 #[serde(rename = "claudeAiOauth")]
149 pub claude_ai_oauth: Option<OAuthCredentials>,
150}
151
152#[derive(Debug, Deserialize)]
153pub struct OAuthCredentials {
154 #[serde(rename = "accessToken")]
155 pub access_token: String,
156}
157
158#[derive(Debug, Deserialize, Serialize, Clone)]
160pub struct QuotaData {
161 pub five_hour_pct: Option<f64>,
162 pub five_hour_resets_at: Option<String>,
163 pub seven_day_pct: Option<f64>,
164 pub seven_day_resets_at: Option<String>,
165}
166
167#[derive(Serialize, Deserialize)]
168pub struct CachedQuota {
169 pub timestamp: u64,
170 pub data: QuotaData,
171}
172
173pub struct GitInfo {
174 pub branch: String,
175 pub is_dirty: bool,
176}