Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## 0.51.1 — Unreleased
### Added
- Usage & Spend: aggregate per-project spend into ranked, window-scoped rows and carry project/session breakdowns through the cached Codex prefill so the dashboard and the menu chart agree on project data (#2984). Thanks @Yuxin-Qiao!
- Usage & Spend: add a Projects panel to the settings pane and let the Models and Projects lists expand beyond the top eight rows (#2985). Thanks @Yuxin-Qiao!

### Fixed
- Cost history chart: localize the Projects, Conversations, session, and standard/fast mode labels that previously stayed English for all 23 app languages (#2983). Thanks @Yuxin-Qiao!
Expand Down
87 changes: 86 additions & 1 deletion Sources/CodexBar/PreferencesSpendDashboardPane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ private struct SpendCurrencySection: View {

SpendProviderPanel(group: self.group)
SpendModelPanel(group: self.group)
if !self.group.projects.isEmpty {
SpendProjectPanel(group: self.group)
}
SpendDailyChart(group: self.group)
}
}
Expand Down Expand Up @@ -507,6 +510,9 @@ private struct SpendProviderPanel: View {

private struct SpendModelPanel: View {
let group: SpendDashboardModel.CurrencyGroup
@State private var showsAllRows = false

private static let collapsedRowCount = 8

var body: some View {
SpendDashboardPanel {
Expand All @@ -529,7 +535,7 @@ private struct SpendModelPanel: View {
.foregroundStyle(.secondary)
.padding(.bottom, 6)
}
ForEach(self.group.models.prefix(8)) { row in
ForEach(self.visibleRows) { row in
if row.rank > 1 {
Divider()
}
Expand Down Expand Up @@ -558,10 +564,89 @@ private struct SpendModelPanel: View {
}
.padding(.vertical, 9)
}
SpendPanelExpandButton(
rowCount: self.group.models.count,
collapsedRowCount: Self.collapsedRowCount,
showsAllRows: self.$showsAllRows)
}
}
}
}

private var visibleRows: ArraySlice<SpendDashboardModel.ModelRow> {
self.group.models.prefix(
self.showsAllRows ? self.group.models.count : Self.collapsedRowCount)
}
}

private struct SpendProjectPanel: View {
let group: SpendDashboardModel.CurrencyGroup
@State private var showsAllRows = false

private static let collapsedRowCount = 8

var body: some View {
SpendDashboardPanel {
VStack(alignment: .leading, spacing: 0) {
Text(L("Projects")).font(.headline).padding(.bottom, 8)
ForEach(self.visibleRows) { row in
if row.rank > 1 {
Divider()
}
HStack(spacing: 10) {
Text(spendDashboardRankText(row.rank))
.font(.caption.monospacedDigit())
.foregroundStyle(.tertiary)
.frame(width: 26, alignment: .leading)
Image(systemName: "folder")
.font(.caption)
.foregroundStyle(.tertiary)
VStack(alignment: .leading, spacing: 2) {
Text(row.projectName).lineLimit(1)
Text(row.providerName).font(.caption).foregroundStyle(.secondary)
}
Spacer()
Text(row.totalCost.map {
UsageFormatter.currencyString($0, currencyCode: self.group.currencyCode)
} ?? "—")
.monospacedDigit()
}
.padding(.vertical, 9)
}
SpendPanelExpandButton(
rowCount: self.group.projects.count,
collapsedRowCount: Self.collapsedRowCount,
showsAllRows: self.$showsAllRows)
}
}
}

private var visibleRows: ArraySlice<SpendDashboardModel.ProjectRow> {
self.group.projects.prefix(
self.showsAllRows ? self.group.projects.count : Self.collapsedRowCount)
}
}

private struct SpendPanelExpandButton: View {
let rowCount: Int
let collapsedRowCount: Int
@Binding var showsAllRows: Bool

var body: some View {
if self.rowCount > self.collapsedRowCount {
Button {
self.showsAllRows.toggle()
} label: {
Text(
self.showsAllRows
? L("Show less")
: L("Show all (%d)", self.rowCount))
.font(.caption)
}
.buttonStyle(.borderless)
.padding(.top, 6)
}
}
}

struct SpendDailyChartPresentation: Equatable {
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "المشاريع";
"Session %@" = "الجلسة %@";
"Std" = "قياسي";
"Show all (%d)" = "إظهار الكل (%d)";
"Show less" = "إظهار أقل";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/ca.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Projectes";
"Session %@" = "Sessió %@";
"Std" = "Est.";
"Show all (%d)" = "Mostra-ho tot (%d)";
"Show less" = "Mostra menys";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Projekte";
"Session %@" = "Sitzung %@";
"Std" = "Std.";
"Show all (%d)" = "Alle anzeigen (%d)";
"Show less" = "Weniger anzeigen";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
"Projects" = "Projects";
"Session %@" = "Session %@";
"Std" = "Std";
"Show all (%d)" = "Show all (%d)";
"Show less" = "Show less";
"Workspace" = "Workspace";
"Credits history" = "Credits history";
"Cursor login failed" = "Cursor login failed";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Proyectos";
"Session %@" = "Sesión %@";
"Std" = "Est.";
"Show all (%d)" = "Mostrar todo (%d)";
"Show less" = "Mostrar menos";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/fa.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "پروژه‌ها";
"Session %@" = "نشست %@";
"Std" = "استاندارد";
"Show all (%d)" = "نمایش همه (%d)";
"Show less" = "نمایش کمتر";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Projets";
"Session %@" = "Session %@";
"Std" = "Std";
"Show all (%d)" = "Tout afficher (%d)";
"Show less" = "Afficher moins";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/gl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Proxectos";
"Session %@" = "Sesión %@";
"Std" = "Est.";
"Show all (%d)" = "Mostrar todo (%d)";
"Show less" = "Mostrar menos";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/id.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Proyek";
"Session %@" = "Sesi %@";
"Std" = "Std";
"Show all (%d)" = "Tampilkan semua (%d)";
"Show less" = "Tampilkan lebih sedikit";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Progetti";
"Session %@" = "Sessione %@";
"Std" = "Std.";
"Show all (%d)" = "Mostra tutto (%d)";
"Show less" = "Mostra meno";
"Sync settings and providers across your Macs via iCloud" = "Sincronizza impostazioni e provider sui tuoi Mac tramite iCloud";
"Include API keys, cookies, and tokens" = "Includi chiavi API, cookie e token";
"Sync usage snapshots" = "Sincronizza istantanee di utilizzo";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "プロジェクト";
"Session %@" = "セッション %@";
"Std" = "標準";
"Show all (%d)" = "すべて表示(%d)";
"Show less" = "表示を減らす";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "프로젝트";
"Session %@" = "세션 %@";
"Std" = "표준";
"Show all (%d)" = "모두 보기(%d)";
"Show less" = "간략히 보기";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/nl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Projecten";
"Session %@" = "Sessie %@";
"Std" = "Std";
"Show all (%d)" = "Alles tonen (%d)";
"Show less" = "Minder tonen";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Projekty";
"Session %@" = "Sesja %@";
"Std" = "Std";
"Show all (%d)" = "Pokaż wszystko (%d)";
"Show less" = "Pokaż mniej";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Projetos";
"Session %@" = "Sessão %@";
"Std" = "Padrão";
"Show all (%d)" = "Mostrar tudo (%d)";
"Show less" = "Mostrar menos";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Проекты";
"Session %@" = "Сессия %@";
"Std" = "Стандарт";
"Show all (%d)" = "Показать все (%d)";
"Show less" = "Показать меньше";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/sv.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Projekt";
"Session %@" = "Session %@";
"Std" = "Std";
"Show all (%d)" = "Visa alla (%d)";
"Show less" = "Visa färre";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/th.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "โปรเจกต์";
"Session %@" = "เซสชัน %@";
"Std" = "มาตรฐาน";
"Show all (%d)" = "แสดงทั้งหมด (%d)";
"Show less" = "แสดงน้อยลง";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/tr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Projeler";
"Session %@" = "Oturum %@";
"Std" = "Std";
"Show all (%d)" = "Tümünü göster (%d)";
"Show less" = "Daha az göster";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Проєкти";
"Session %@" = "Сесія %@";
"Std" = "Стандарт";
"Show all (%d)" = "Показати всі (%d)";
"Show less" = "Показати менше";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/vi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "Dự án";
"Session %@" = "Phiên %@";
"Std" = "Std";
"Show all (%d)" = "Hiện tất cả (%d)";
"Show less" = "Thu gọn";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "项目";
"Session %@" = "会话 %@";
"Std" = "标准";
"Show all (%d)" = "显示全部(%d)";
"Show less" = "收起";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodexBar/Resources/zh-Hant.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"Projects" = "專案";
"Session %@" = "對話 %@";
"Std" = "標準";
"Show all (%d)" = "顯示全部(%d)";
"Show less" = "收起";
"Sync settings and providers across your Macs via iCloud" = "Sync settings and providers across your Macs via iCloud";
"Include API keys, cookies, and tokens" = "Include API keys, cookies, and tokens";
"Sync usage snapshots" = "Sync usage snapshots";
Expand Down