mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-18 10:14:34 +00:00
feat(bar): live Codex usage sync with force refresh and spend-chart periods
Codex quota in the menu bar came only from frozen local session logs, so it
showed stale data ("older session") that no refresh could update. Fetch it live
from the same source the dashboard uses, under the existing Claude-style safety
controls (10-min TTL, in-flight coalescing, 429 backoff, circuit breaker,
serve-stale), falling back to local logs when offline or rate-limited. A success
with no usable 5h/weekly window keeps the local reading rather than caching a
contentless row. The footer refresh and a new inline button on the Codex card
force a live pull past the open debounce, and a forced /summary re-pulls native
rows while serving the last-known cached rows if the live pull overruns its
budget, so the Claude/Codex cards never blank mid-refresh.
The spend strip gains a Today / 7d / 30d selector (default 7d), a taller chart,
and bottom time-axis labels (local hours for today, weekday for 7d, dates for
30d). The analytics endpoint now exposes a 24-bucket hourly series for today,
converted from the pipeline's UTC hour keys to the user's local clock so the
intra-day chart matches the dashboard.
This commit is contained in:
1 parent
9977c49fab
commit
6ed5b2d62b
13 files changed
+1263
-53
No files matched your search
@@ -92,8 +92,8 @@ struct BarMenuView: View {
|
||||
accountsSection
|
||||
|
||||
// (3) SPEND — demoted to a thin informational strip below the cockpit.
|
||||
// spendChartStyle is threaded from the viewModel and toggled inline
|
||||
// from the Spend header, so a change updates the chart immediately.
|
||||
// spendChartStyle and spendPeriod are threaded from the viewModel and
|
||||
// toggled/selected inline from the Spend header so changes are live.
|
||||
if let analytics = viewModel.analytics {
|
||||
Divider()
|
||||
BarAnalyticsView(
|
||||
@@ -102,7 +102,9 @@ struct BarMenuView: View {
|
||||
onToggleSpendStyle: {
|
||||
viewModel.spendChartStyle =
|
||||
viewModel.spendChartStyle == .bars ? .line : .bars
|
||||
})
|
||||
},
|
||||
spendPeriod: viewModel.spendPeriod,
|
||||
onSelectPeriod: { viewModel.spendPeriod = $0 })
|
||||
}
|
||||
|
||||
// (4) POOL ACCOUNTS — compact generic rows, subordinate.
|
||||
@@ -185,7 +187,7 @@ struct BarMenuView: View {
|
||||
} else {
|
||||
subscriptionsHeader(parts.subscriptions)
|
||||
ForEach(orderedSubscriptions(parts.subscriptions)) { row in
|
||||
BarSubscriptionCard(row: row)
|
||||
BarSubscriptionCard(row: row, onRefresh: { viewModel.forceRefresh() })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -341,7 +343,7 @@ struct BarMenuView: View {
|
||||
.help("Settings — appearance/theme, menu-bar glance, and alerts")
|
||||
Spacer()
|
||||
Button {
|
||||
viewModel.onOpen()
|
||||
viewModel.forceRefresh()
|
||||
} label: {
|
||||
Image(systemName: "arrow.clockwise")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user