Skip to content

Commit 230ddc5

Browse files
committed
Add cost summary display style
1 parent ada3660 commit 230ddc5

44 files changed

Lines changed: 300 additions & 19 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Sources/CodexBar/InlineUsageDashboardContent.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ extension UsageMenuCardView.Model {
162162

163163
private static func resolveInlineUsageDashboard(input: Input) -> InlineUsageDashboardModel? {
164164
if self.usesProviderCostHistoryAsPrimaryDashboard(input.provider),
165+
input.tokenCostInlineDashboardEnabled,
165166
let tokenSnapshot = primaryCostHistorySnapshot(input: input),
166167
!tokenSnapshot.daily.isEmpty
167168
{
@@ -203,7 +204,7 @@ extension UsageMenuCardView.Model {
203204
return Self.poeInlineDashboard(usage, now: input.now)
204205
}
205206
if [.codex, .claude, .vertexai, .bedrock].contains(input.provider),
206-
input.tokenCostUsageEnabled,
207+
input.tokenCostInlineDashboardEnabled,
207208
let tokenSnapshot = input.tokenSnapshot,
208209
!tokenSnapshot.daily.isEmpty
209210
{

Sources/CodexBar/MenuCardView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ extension UsageMenuCardView.Model {
794794
let usageBarsShowUsed: Bool
795795
let resetTimeDisplayStyle: ResetTimeDisplayStyle
796796
let tokenCostUsageEnabled: Bool
797+
let tokenCostInlineDashboardEnabled: Bool
798+
let tokenCostMenuSectionEnabled: Bool
797799
let showOptionalCreditsAndExtraUsage: Bool
798800
let copilotBudgetExtrasEnabled: Bool
799801
let sourceLabel: String?
@@ -822,6 +824,8 @@ extension UsageMenuCardView.Model {
822824
usageBarsShowUsed: Bool,
823825
resetTimeDisplayStyle: ResetTimeDisplayStyle,
824826
tokenCostUsageEnabled: Bool,
827+
tokenCostInlineDashboardEnabled: Bool? = nil,
828+
tokenCostMenuSectionEnabled: Bool? = nil,
825829
showOptionalCreditsAndExtraUsage: Bool,
826830
copilotBudgetExtrasEnabled: Bool = false,
827831
sourceLabel: String? = nil,
@@ -849,6 +853,8 @@ extension UsageMenuCardView.Model {
849853
self.usageBarsShowUsed = usageBarsShowUsed
850854
self.resetTimeDisplayStyle = resetTimeDisplayStyle
851855
self.tokenCostUsageEnabled = tokenCostUsageEnabled
856+
self.tokenCostInlineDashboardEnabled = tokenCostInlineDashboardEnabled ?? tokenCostUsageEnabled
857+
self.tokenCostMenuSectionEnabled = tokenCostMenuSectionEnabled ?? tokenCostUsageEnabled
852858
self.showOptionalCreditsAndExtraUsage = showOptionalCreditsAndExtraUsage
853859
self.copilotBudgetExtrasEnabled = copilotBudgetExtrasEnabled
854860
self.sourceLabel = sourceLabel
@@ -904,7 +910,7 @@ extension UsageMenuCardView.Model {
904910
let tokenUsageSnapshot = Self.tokenUsageSnapshot(input: input)
905911
let tokenUsage = Self.tokenUsageSection(
906912
provider: input.provider,
907-
enabled: input.tokenCostUsageEnabled,
913+
enabled: input.tokenCostMenuSectionEnabled,
908914
snapshot: tokenUsageSnapshot,
909915
error: input.tokenError)
910916
let subtitle = Self.subtitle(

Sources/CodexBar/PreferencesGeneralPane.swift

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,34 @@ struct GeneralPane: View {
142142
.fixedSize(horizontal: false, vertical: true)
143143

144144
if self.settings.costUsageEnabled {
145-
CostHistoryDaysEditor(settings: self.settings)
145+
VStack(alignment: .leading, spacing: 10) {
146+
HStack(alignment: .center, spacing: 12) {
147+
Text(L("cost_summary_style_title"))
148+
.font(.body)
149+
Spacer()
150+
Picker(
151+
L("cost_summary_style_title"),
152+
selection: self.$settings.costSummaryDisplayStyle)
153+
{
154+
ForEach(CostSummaryDisplayStyle.allCases) { style in
155+
Text(style.label).tag(style)
156+
}
157+
}
158+
.labelsHidden()
159+
.pickerStyle(.menu)
160+
.frame(maxWidth: 180)
161+
}
146162

147-
Text(L("cost_auto_refresh_info"))
148-
.font(.footnote)
149-
.foregroundStyle(.tertiary)
163+
CostHistoryDaysEditor(settings: self.settings)
150164

151-
self.costStatusLine(provider: .claude)
152-
self.costStatusLine(provider: .codex)
165+
Text(L("cost_auto_refresh_info"))
166+
.font(.footnote)
167+
.foregroundStyle(.tertiary)
168+
169+
self.costStatusLine(provider: .claude)
170+
self.costStatusLine(provider: .codex)
171+
}
172+
.padding(.leading, 20)
153173
}
154174
}
155175
}

Sources/CodexBar/PreferencesProvidersPane.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ struct ProvidersPane: View {
745745
usageBarsShowUsed: self.settings.usageBarsShowUsed,
746746
resetTimeDisplayStyle: self.settings.resetTimeDisplayStyle,
747747
tokenCostUsageEnabled: self.settings.isCostUsageEffectivelyEnabled(for: provider),
748+
tokenCostInlineDashboardEnabled: self.settings.costSummaryShowsInlineDashboard(for: provider),
749+
tokenCostMenuSectionEnabled: self.settings.costSummaryShowsSubmenu(for: provider),
748750
showOptionalCreditsAndExtraUsage: self.settings.showOptionalCreditsAndExtraUsage,
749751
copilotBudgetExtrasEnabled: self.settings.copilotBudgetExtrasEnabled,
750752
hidePersonalInfo: self.settings.hidePersonalInfo,

Sources/CodexBar/Resources/ar.lproj/Localizable.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@
417417
"start_at_login_subtitle" = "يفتح تلقائيا CodexBar عند تشغيل جهاز الماك.";
418418
"show_cost_summary" = "ملخص تكلفة العرض";
419419
"show_cost_summary_subtitle" = "يقرأ سجلات الاستخدام المحلية. يعرض اليوم + نافذة التاريخ المحددة في القائمة.";
420+
"cost_summary_style_title" = "نمط العرض";
421+
"cost_summary_style_inline" = "ملخص مضمن";
422+
"cost_summary_style_submenu" = "قائمة التكلفة الفرعية";
423+
"cost_summary_style_both" = "كلاهما";
420424
"cost_history_days_title" = "نافذة التاريخ: %d أيام";
421425
"cost_auto_refresh_info" = "تحديث تلقائي: كل ساعة · وقت الاستراحة: 10m";
422426
"refresh_cadence_title" = "وتيرة التحديث";

Sources/CodexBar/Resources/ca.lproj/Localizable.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@
415415
"start_at_login_subtitle" = "Obre el CodexBar automàticament en iniciar el Mac.";
416416
"show_cost_summary" = "Mostreu el resum de cost";
417417
"show_cost_summary_subtitle" = "Llegeix els registres d'ús locals. Mostra el cost d'avui + la finestra d'historial seleccionada al menú.";
418+
"cost_summary_style_title" = "Estil de visualització";
419+
"cost_summary_style_inline" = "Resum integrat";
420+
"cost_summary_style_submenu" = "Submenú de cost";
421+
"cost_summary_style_both" = "Tots dos";
418422
"cost_history_days_title" = "Finestra d'historial: %d dies";
419423
"cost_auto_refresh_info" = "Actualització automàtica: cada hora · Temps d'espera: 10 min";
420424
"refresh_cadence_title" = "Freqüència d'actualització";

Sources/CodexBar/Resources/de.lproj/Localizable.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@
417417
"start_at_login_subtitle" = "Startet CodexBar automatisch, wenn dein Mac hochfährt.";
418418
"show_cost_summary" = "Kostenübersicht anzeigen";
419419
"show_cost_summary_subtitle" = "Liest lokale Nutzungsprotokolle. Zeigt heute + das gewählte Verlaufsfenster im Menü.";
420+
"cost_summary_style_title" = "Anzeigestil";
421+
"cost_summary_style_inline" = "Inline-Übersicht";
422+
"cost_summary_style_submenu" = "Kosten-Untermenü";
423+
"cost_summary_style_both" = "Beides";
420424
"cost_history_days_title" = "Verlaufsfenster: %d Tage";
421425
"cost_auto_refresh_info" = "Auto-Aktualisierung: stündlich · Timeout: 10 Min.";
422426
"refresh_cadence_title" = "Aktualisierungsintervall";

Sources/CodexBar/Resources/en.lproj/Localizable.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@
417417
"start_at_login_subtitle" = "Automatically opens CodexBar when you start your Mac.";
418418
"show_cost_summary" = "Show cost summary";
419419
"show_cost_summary_subtitle" = "Reads local usage logs. Shows today + the selected history window in the menu.";
420+
"cost_summary_style_title" = "Display style";
421+
"cost_summary_style_inline" = "Inline";
422+
"cost_summary_style_submenu" = "Submenu";
423+
"cost_summary_style_both" = "Both";
420424
"cost_history_days_title" = "History window: %d days";
421425
"cost_auto_refresh_info" = "Auto-refresh: hourly · Timeout: 10m";
422426
"refresh_cadence_title" = "Refresh cadence";

Sources/CodexBar/Resources/es.lproj/Localizable.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@
415415
"start_at_login_subtitle" = "Abre CodexBar automáticamente al iniciar tu Mac.";
416416
"show_cost_summary" = "Mostrar resumen de coste";
417417
"show_cost_summary_subtitle" = "Lee los registros de uso locales. Muestra el coste de hoy + la ventana de historial seleccionada en el menú.";
418+
"cost_summary_style_title" = "Estilo de visualización";
419+
"cost_summary_style_inline" = "Resumen integrado";
420+
"cost_summary_style_submenu" = "Submenú de coste";
421+
"cost_summary_style_both" = "Ambos";
418422
"cost_history_days_title" = "Ventana de historial: %d días";
419423
"cost_auto_refresh_info" = "Actualización automática: cada hora · Tiempo de espera: 10 m";
420424
"refresh_cadence_title" = "Frecuencia de actualización";

Sources/CodexBar/Resources/fa.lproj/Localizable.strings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@
417417
"start_at_login_subtitle" = "وقتی مک را روشن می کنید، CodexBar به طور خودکار باز می شود.";
418418
"show_cost_summary" = "خلاصه هزینه نمایش";
419419
"show_cost_summary_subtitle" = "گزارش های استفاده محلی را می خواند. امروز نمایش داده می شود + پنجره تاریخچه انتخاب شده در منو.";
420+
"cost_summary_style_title" = "سبک نمایش";
421+
"cost_summary_style_inline" = "خلاصه درون‌خطی";
422+
"cost_summary_style_submenu" = "زیرمنوی هزینه";
423+
"cost_summary_style_both" = "هر دو";
420424
"cost_history_days_title" = "پنجره تاریخچه: %d روز";
421425
"cost_auto_refresh_info" = "تازه سازی خودکار: ساعتی · زمان استراحت: 10m";
422426
"refresh_cadence_title" = "کادانس تازه سازی";

0 commit comments

Comments
 (0)