Skip to content

Port upstream 0.64.0: Usage & Spend provider grouping, consolidated chart selector, clear selected day - #705

Closed
Finesssee wants to merge 1 commit into
port/upstream-0.64.0from
port/micro-0.64.0-usage-spend-provider-grouping
Closed

Finesssee wants to merge 1 commit into
port/upstream-0.64.0from
port/micro-0.64.0-usage-spend-provider-grouping

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Found by the 0.60.4-0.69.0 port gap audit (gap G9, audit-0.64.0).

Summary

Settings -> Usage & Spend now groups model history by provider, folds the daily and hourly charts behind one compact selector, and adds a control that clears the selected day.

  • The flat "Models" list is replaced by collapsible provider groups. Each group header shows the provider name and its spend/tokens (with ~ when some models are unpriced). Each group shows six models, with Show all / Show less, and a "Partial model breakdown" note when local history is incomplete.
  • The standalone hourly heatmap is now one panel with a Day / Hour selector. The Day view is a new daily spend bar chart built from the existing contract.daily points. The Hour view is the existing heatmap. With only one view available the selector is hidden.
  • Clicking a day bar selects it. The chip with the date has a clear (x) button and clicking the selected bar again also clears it. Changing the 7d/30d/all-time range clears the selection.

Upstream reference

  • Release note (v0.64.0, Improved): "Usage & Spend: group sources and models by provider, consolidate detail and daily/hourly chart selectors, and add a clear selected-day control while preserving incomplete-history warnings, local-history labels, calendar boundaries, privacy, and exports (feat(spend): group usage details by provider steipete/CodexBar#3353)."
  • Commit 212c8d63a (feat(spend): group usage details by provider steipete/CodexBar#3353). Tag-pinned v0.64.0 files read: Sources/CodexBar/SpendDashboardProviderBreakdown.swift (spendDashboardProviderBreakdowns ordering, spendProviderModelDisplayLimit = 6, per-provider model rows, partial model warning), SpendDashboardSummary.swift (selected-day chip and clear button), PreferencesSpendDashboardPane.swift (SpendDashboardTrendSection daily/hourly picker), SpendDashboardModel.swift (incompleteModelProviders).

Ported / Deferred

Ported: provider grouping and ordering rule, six-model collapse, partial-model-history label, single Day/Hour selector, selected-day chip and clear control.

Deferred, because the Windows data model does not carry it and inventing fields is out of bounds:

  • Per-provider model rows for providers other than the contract provider. The shell builds one model-level contract (contract.providerId, Codex, merged with OpenCodex imports), so only that provider gets a group. Other providers stay in the existing provider table. The grouping helper takes the contract, so more groups appear when the backend supplies them.
  • Upstream's "Sources / Accounts" children per provider group: there is no per-native-source cost row on Windows.
  • Selected day only scopes the Spend card (from contract.daily). Models, projects and hourly activity stay on the full range because the contract has no per-day breakdown of them. The panel says so when a day is selected.
  • Upstream's Sessions/Projects/Providers detail picker, daily ledger, and incompleteModelProviders per-provider set (Windows uses historyCoverageEstablished for the single contract).

Unchanged: incomplete-history labels, calendar/reporting day, privacy redaction, share card and JSON export, provider table.

Validation

  • pnpm --dir apps/desktop-tauri exec vitest run (full): 69 files, 413 tests passed, including 11 new tests (usageSpendBreakdown.test.ts, UsageSpendBreakdownPanels.test.tsx).
  • pnpm --dir apps/desktop-tauri run lint: no findings in the touched files (pre-existing warnings elsewhere).
  • pnpm --dir apps/desktop-tauri run build: passed.
  • cargo +1.98.0 fmt --all: clean.
  • cargo +1.98.0 test -p codexbar locale: 16 passed (new locale keys are in the enum, en-US.ftl, and keys.ts).
  • cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: passed (workspace, both crates)

Affected areas

  • Settings UI (Usage & Spend tab)
  • Locale catalog (6 new en-US keys; other locales fall back)
  • Rust provider/backend logic (none)

UI proof

Pending: coordinator will capture CUA proof on a fresh build (CODEXBAR_PROOF_MODE=settings:usageSpend with a seeded spend file).

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Adversarial validation (lane-B review)

Head validated: c25f083a ("Port upstream 0.64.0: group Usage & Spend models by provider, consolidate chart selector, clear selected day"). Spec: audit-0.64.0.md G9.

Verdict: no blocking defects. The grouping/selector/selected-day behavior matches the spec:

  • usageSpendBreakdown.ts implements upstream ordering (highest known cost, then tokens, unknown last, then name with numeric/base compare) and the 6-model display limit (spendProviderModelDisplayLimit).
  • Partial-cost markers (~ via costIsPartial when priceCoverage.unpriced > 0) and partial-history markers (hasPartialModelHistory from historyCoverageEstablished) match the partial-cost/partial-history semantics.
  • UsageSpendTab.tsx consolidates the daily/hourly selectors into UsageSpendTrendPanel (155 lines, own component) with a clear-selected-day control; the selected day flows into SpendContractOverview.
  • Locale keys added for the new controls (en-US, 6 keys; check-locale 885 OK).
  • Provider grouping note in the spec ("one group per provider") is correctly reduced: the desktop shell builds model-level history for one provider contract, so only that provider renders a group; the rest stay in the provider table — consistent with the data model, documented in buildSpendProviderGroups's doc comment.

Validation re-run at head (pinned 1.98.0, E-cores): cargo +1.98.0 fmt --all -- --check clean; cargo +1.98.0 clippy --workspace --all-targets -- -D warnings clean; cargo +1.98.0 test -p codexbar --lib 2160 passed / 0 failed (1 ignored); frontend: pnpm test 68 files / 413 tests passed (11 in the two new suites); pnpm run check-locale OK (885 keys); pnpm run build OK.

UI proof: waived per user 2026-10-02 directive (fast-track); component tests + build cover the new surfaces.

Integrator: merge with #610/#609 coordination noted in the spec (usage_spend.rs is #610's file — no conflict at this head since the change is frontend-only).

@Finesssee

Copy link
Copy Markdown
Collaborator Author

UI proof (browser-use)

Combined build of integrate/v0.70.0-ports at ddd85594 (all 40 port PRs and the follow-ups). Debug desktop build in proof mode, isolated config/data dirs, driven by browser-use over the WebView2 DevTools protocol with DOM events only (no mouse or keyboard input, no focus changes). All data is synthetic: local mock servers for L1, a seeded usage snapshot plus synthetic local logs for L2.

Scenario Check Result
L2 seeded snapshot + synthetic local logs #705 Usage & Spend: Day/Hour trend toggle present with labelled day bars PASS
L2 seeded snapshot + synthetic local logs #705 Hour view renders the hourly activity chart PASS
L2 seeded snapshot + synthetic local logs #705 provider groups use the release period caption ('Local model history for: ...'), no 'days of local history' PASS
L2 seeded snapshot + synthetic local logs #705 section order: trend before provider groups before projects PASS

Every surface also passed the privacy check (no email-like text, account e-mail nodes or profile paths in the DOM) and theme auto rendered dark on the tray flyout, float bar and settings windows.

Validation at ddd85594: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test -p codexbar (3567 passed, 0 failed) and cargo test -p codexbar-desktop-tauri (606 passed, 0 failed). Screenshots were captured for each scenario and kept with the local proof kit.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

Shipped in v0.70.0: this PR's head is included in main via #735 (merge commit 9d0a37a). Closing as integrated.

@Finesssee Finesssee closed this Oct 3, 2026
junglesub-bot Bot pushed a commit to junglesub/Win-CodexBar that referenced this pull request Oct 4, 2026
…ouping, consolidated chart selector, clear selected day

Conflicts in UsageSpendTab.tsx: imports keep the release CostPeriodControl
and ProjectConversations next to the new panels; the inline heatmap and
the flat models panel move into UsageSpendTrendPanel and
UsageSpendProviderGroups as in the PR.

Combined with the release History window:
- the selected day clears when the History window (period) changes, since
  the 7d/30d/all-time buttons no longer exist;
- the provider groups keep the release period caption
  (UsageSpendModelsPeriodCaption with the window label) instead of the
  fixed "N days of local history" text, so the prop is now a caption;
- order follows upstream: summary, Day/Hour trend panel, then the release
  daily ledger, then the provider groups and projects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant