Port upstream 0.58.0: re-land stranded Usage & Spend daily ledger (#492) with the 0.67.0 30-row cap - #715
Conversation
(cherry picked from commit f43cb6e)
Adapted to main: main already keeps the canonical spend formatters in lib/usageSpendSharing.ts (formatUsd, formatSpendMetric), so the daily ledger reuses them and the token-cell helper is added there as formatSpendTokens instead of a second lib/usageSpendFormatters.ts module. UsageSpendTab keeps main's layout unchanged. (cherry picked from commit 89edce6)
The re-landed daily ledger added six keys to en-US only. Add them to the other seven locale files so every .ftl stays aligned with locale.rs and keys.ts.
Port upstream 0.67.0 steipete#3998 (ce1b808) now that the daily ledger exists: the ledger opens with the newest 30 days and a Show all (N) / Show less control expands it to the complete history. Translates the upstream SpendDashboardDailyLedgerTests expansion test.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
UI proof (browser-use)Result: PASS on build
At the maintainer's direction, this proof drove the app's WebView2 over CDP with the browser-use CLI instead of CUA. It used no keyboard, mouse or focus. Clicks were DOM Setup
Results
Explicit zero in the ledger: the Codex scanner keeps no day for an event whose token totals are all zero, so the contract had no 2026-09-22 point and the ledger had no row for it. The ledger's Validation at
|
| Command | Result |
|---|---|
pnpm install --frozen-lockfile |
pass |
pnpm run check-locale |
877 keys match between Rust and TS |
pnpm test |
66 files, 404 tests passed |
pnpm run lint |
0 errors. The 11 warnings are the same unused imports as on main. |
pnpm run build |
pass |
cargo +1.98.0 fmt --all --check |
pass |
cargo +1.98.0 clippy --workspace --all-targets -- -D warnings |
pass |
cargo +1.98.0 test -p codexbar |
2160 passed, 0 failed, 1 ignored |
cargo +1.98.0 test -p codexbar-desktop-tauri -- --skip bootstrap_payload_exposes_every_provider_variant |
459 passed, 0 failed. The skipped test is the non-hermetic #684 test that #711 fixes. |
ci/circleci: pr-check |
success |
Screenshots
All paths are under %LOCALAPPDATA%\Win-CodexBar\port-audit\proof\715\shots\.
| File | What it shows |
|---|---|
715-ledger-alltime-collapsed.png |
All time, top of the ledger: newest first, with the 2026-09-26 "Unknown" / "50,000 tokens" row. |
715-ledger-alltime-toggle-collapsed.png |
All time, end of the collapsed ledger: the last row is 2026-09-01, followed by "Show all (44)". |
715-ledger-alltime-expanded-end.png |
Expanded: the ledger ends at 2026-08-18 (146,000 tokens), followed by "Show less". |
715-tray-local-chart.png |
The tray panel, dark, with the Codex card's Usage details open: Today $0.15, 30d cost $4.71, 30d tokens 3.3M, the token bar chart and the Cost (30 days) chart. |
Not blocking (found on main, not caused by this PR)
- The two 30-day cost totals disagree when a model is unpriced.
- With the same logs, the tray card's "30d cost" reads $4.71, while the panel header and Settings > Usage & Spend (30 days) read $4.59.
- The $0.125 difference is the unpriced day. The card's local-usage summary prices
proof-unpriced-modelwithcodex_cost_usd_fallback(rust/src/codex_costs.rs, default $2.50 per million input tokens). The daily history and the spend contract leave that day's cost unknown.
- Provider detail rows render twice when the overview is detailed or a provider is selected.
MenuCardDetails.tsxrendersprovider.displayDetailsin two identicalmenu-card__provider-detailssections. One is gated on!compactOverviewand one isn't, so outside the compact overview the rows appear twice.- Providers that set
displayDetailsinclude CodeRabbit, Hugging Face, Muse, Nous, Replicate and Venice. - This was found by reading the code. This proof didn't show it, because Codex has no display details.
- An empty
global_shortcutlogsWARN codexbar_desktop_tauri::shortcut_bridge: Could not parse global shortcut:at every launch. This was already reported on Fix reset refresh timer for resets over 24.8 days away #720.
|
Adversarial validation passed at ef15c0d Scope: re-land Usage & Spend daily ledger (#715, stranded #492 + 0.67.0 30-row cap steipete#3998), validated as merged into release/v0.70.0 (merge ef15c0d = merge of 07f1bb7 into 1313c80). Attacks:
No defects found. The browser-use proof (issuecomment-5924578228 at 07f1bb7) already showed 29 ledger rows @30d, an unknown-cost row, and the 44-day "Show all"/"Show less" round-trip. READY for the un-draft rule. |
Summary
Re-lands the upstream v0.58.0 Usage & Spend port #492. It was merged on 2026-09-13 only into the stacked base
port/upstream-0.58.0and never reachedmain;git cherryagainstmain@7695471bstill reported both commits as missing.SpendContract.dailycost and token fields, newest day first. A missing cost or token count shows "Unknown", and an explicit zero stays$0.00/0 tokens.chartData.tokensHistory.Show all (N)/Show lesscontrol.0.67.0.mdrow 18 marked this SKIP because Windows had no ledger. This PR adds the ledger, so the row is ported here.The original commits are cherry-picked with
-x. The second commit adapts them tomain, which already keeps the canonical spend formatters inlib/usageSpendSharing.ts. The ledger reusesformatUsd, and the token-cell helper is added there asformatSpendTokensinstead of a second formatter module.Upstream reference
36cf4e3aeaee18ebe9cd2655efb8b9e09cfb0a2c(Add hover details to inline cost charts steipete/CodexBar#3413, inline cost chart hover details) and5e5a9003efb26b9291e48b31a0088e7b666b65c0(Add focused daily spend ledger steipete/CodexBar#2635, daily spend ledger), v0.58.0.ce1b80863e4b78607d7323dc18087cc199a71c38(perf(spend): bound initial ledger layout on long ranges steipete/CodexBar#4001, v0.67.0 release note Fix Usage & Spend scroll lag on long ranges steipete/CodexBar#3998).spendDailyLedgerVisibleSummariesandSpendDailyLedger.collapsedRowCount = 30are inSources/CodexBar/PreferencesSpendDashboardPane.swift, unchanged atv0.70.0(tag-pinned GET).SpendDashboardDailyLedgerTestsledger expansion preserves every day in newest first order(arguments 0, 7, 30, 31, 365) →dailyLedgerVisibleRowsinUsageSpendDailyLedger.test.tsx.Ported / Deferred
SpendContract.dailypoint has no per-day provider mix or request count, and wire shapes are not invented.Locale: six new keys (
UsageSpendDailyLedger,UsageSpendDailyLedgerHelper,UsageSpendNoDailyData,UsageSpendColDate,UsageSpendColCost,UsageSpendColTokens) are inrust/src/locale.rs,keys.tsand all eight.ftlfiles. The toggle reuses the existingUsageSpendShowAll/UsageSpendShowLess.Validation
Run in the worker worktree on Rust 1.98.0 and Node 24:
pnpm install --frozen-lockfilepnpm run check-localepnpm testpnpm run lintmainpnpm run buildcargo +1.98.0 fmt --all --checkcargo +1.98.0 clippy --workspace --all-targets -- -D warningscargo +1.98.0 test -p codexbarcargo +1.98.0 test -p codexbar-desktop-tauri -- --skip bootstrap_payload_exposes_every_provider_variantThe skipped desktop test is the non-hermetic #684 test, which reads the real
%APPDATA%\CodexBar\settings.jsononmain. #711 fixes it separately.Affected areas
apps/desktop-tauri/src/components/UsageSpendDailyLedger.tsx(new) and its testapps/desktop-tauri/src/components/MenuCardDetails.tsx(chart hover titles) andMenuCard.test.tsxapps/desktop-tauri/src/lib/usageSpendSharing.ts(formatSpendTokens) and its testapps/desktop-tauri/src/surfaces/settings/tabs/UsageSpendTab.tsx(mounts the ledger)apps/desktop-tauri/src/styles.css,apps/desktop-tauri/src/i18n/keys.ts,rust/src/locale.rs,rust/src/locale/*.ftlUI proof
Pending: a browser-use proof over WebView2 CDP of Settings > Usage & Spend (ledger, 30-row cap, Show all) and the tray card chart titles, built from this head with isolated data. It will be posted as a "UI proof (browser-use)" comment.