feat: add standalone token activity heatmap - #2548
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 8:19 PM ET / August 3, 2026, 00:19 UTC. ClawSweeper reviewWhat this changesAdds a 365-day token-activity heatmap to Usage & Spend with daily, weekly, and cumulative views, coverage-aware aggregation, an annual Codex-history cache, localization, and keyboard/VoiceOver inspection. Merge readiness⛔ Blocked until stronger real behavior proof is added - 6 items remain Keep this PR open for maintainer feature-direction review rather than closing it: current main does not contain the heatmap, but the PR adds a substantial new Usage & Spend capability that VISION.md says needs sign-off. The submitted screenshots and current-head accessibility transcript demonstrate core UI behavior, yet the prepared local proof artifacts are unrelated umbrella-PR images and do not establish the latest annual-cache refresh and fallback behavior on the mergeable head. Priority: P3 Review scores
Verification
How this fits togetherUsage & Spend collects local provider snapshots and turns them into cost and token summaries in CodexBar’s preferences UI. This PR adds a separate annual token-history path for Codex accounts, aggregates it into activity points, and renders those points as an interactive heatmap beneath the existing dashboard. flowchart LR
A[Local provider snapshots] --> B[Usage and Spend loader]
B --> C[30-day spend snapshot]
B --> D[365-day Codex activity cache]
C --> E[Coverage-aware activity aggregation]
D --> E
E --> F[Daily weekly and cumulative heatmap]
F --> G[Preferences UI and accessibility tree]
Decision needed
Why: VISION.md explicitly requires sign-off for new features and meaningful complexity; the repository evidence cannot determine whether the added dashboard surface and annual scan are desired product scope. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: If the product direction is sponsored, rebase the focused heatmap onto current main, retain the existing 30-day spend path, and provide redacted signed-app proof for initial annual loading, cached refresh, and annual-scan fallback before merging. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug report: this PR proposes a new dashboard capability. The supplied source and PR body clearly identify the intended load, aggregation, and rendering paths, but no current-main failure is being repaired. Is this the best way to solve the issue? Unclear: the heatmap implementation is coherent and preserves the existing 30-day spend path, but a built-in annual local-history scan is a product-scope choice that VISION.md reserves for maintainer sign-off; a rebased signed-app proof is needed before judging the final integration path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f13ef61c49bd. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (21 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review Native macOS proof for Daily, Weekly, Cumulative, right-edge tooltip placement, weekday alignment, and English date formatting is now attached and described in the PR body. The PR remains Draft; the mixed-provider annual coverage finding is explicitly tracked as an open follow-up. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Addressed the mixed-provider coverage blocker in
The PR body now includes the updated contract and evidence, and the PR is Ready so the required macOS CI can run. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4990426840
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed both current-head review findings in
Validation on the pushed head:
Contributor-action items are complete. Maintainer sponsorship of the feature direction under @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2114dc017
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Final accessibility follow-up is pushed in
The PR body has the final contract and validation evidence. Contributor-action items are complete; maintainer feature-direction sponsorship remains the only explicit owner decision. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 554ef51df5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let hasCompleteHistory = Self.hasCompleteTokenHistory(input, displayCalendar: calendar) | ||
| let aggregateIsInconsistent = input.snapshot.last30DaysTokens != nil && !hasCompleteHistory | ||
| if hasUnplacedTokens || aggregateIsInconsistent { | ||
| invalidDays.formUnion(coveredDays) | ||
| } | ||
| return SpendTokenActivityInputSummary( | ||
| coveredDays: coveredDays, | ||
| totalsByDay: totalsByDay, | ||
| invalidDays: invalidDays, | ||
| zeroKnownDays: hasCompleteHistory ? coveredDays : []) |
There was a problem hiding this comment.
Treat successful empty scans as zero activity
When a Codex account has no sessions in the requested window, CostUsageFetcher.tokenSnapshot returns an empty daily array and last30DaysTokens == nil while leaving historyCoverageIsEstablished true. This makes hasCompleteHistory false and leaves zeroKnownDays empty, so every day from a successful 365-day scan is rendered as unavailable rather than showing “No activity in the last 12 months.” Treat an established, empty history as confirmed zero coverage while continuing to reject nonempty histories with missing or inconsistent totals.
Useful? React with 👍 / 👎.
The stacked integration unified the spend and activity scans on a 365-day budget; the steipete#2548-authored scan budget tests still expected a 30-day spend scan. Update expectations and distinguish the activity failure case by call order instead of historyDays.
|
Maintainer decision on the Usage & Spend program (applies to #2322, #2527, #2548, #2569, #2575, #2577 — closing together): We want the ideas — the token-activity view and the cross-provider cost overview in particular are genuinely good, and we're adopting them. What we can't absorb is the delivery shape: 8k–20k-line PRs bundling scanners, pricing, identity, and UI can't be reviewed honestly, and live testing of the current heads surfaced the kind of defects that big surfaces hide (duplicate token-activity cards in the Models view; the unified Overview rendering no chip for an enabled provider; the account-attribution issue flagged earlier). So we're taking this work as a base in-house and rebuilding it in small, individually landable slices — first the token-activity view rebuilt on the shared scan cache (no separate annual scan), then the cost overview aligned with the #2578 design discussion. Your commits will be cherry-picked where they fit, and every slice that draws on this work will credit you in the changelog, as today's merges already do. @Yuxin-Qiao — you're this repo's most prolific contributor and much of today's release is your work. Focused PRs the size of #2574 land same-day; that's the shape that serves both of us. |
Overview
Adds a standalone 365-day token activity heatmap to Usage & Spend. The view makes long-term token usage patterns inspectable without changing the existing 7/30-day spend chart range.
The UI and data path are intentionally kept in this independent,
main-based PR so the heatmap can be reviewed separately from the larger Usage & Spend work in #2322.What the UI does
Mon,Wed, andFrivisually aligned.Native macOS proof
Captured from the locally signed release build at commit
2af1b1cbf009b901c4b1b906c9745c4cad1675c7, with the CodexBar app language set to English. The screenshots contain only aggregated token activity; no account identifiers or credentials are shown. The later range, coverage, and accessibility follow-ups do not change the demonstrated alignment, hover placement, modes, or locale behavior.Daily — aligned default state
The month headers, weekday labels, cells, and legend share one layout. Empty history remains visually quiet while recent activity stays easy to scan.
Daily — right-edge hover behavior
The tooltip stays adjacent to the hovered late-July cell, moves inward only enough to remain inside the chart, and formats the date in English.
Weekly — calendar-week aggregation
Each column represents one calendar week; the tooltip reports the selected week’s aggregate and anchor date.
Cumulative — running total
The cumulative mode uses the same grid and date range while exposing progression toward the full-period token total.
Current-head accessibility proof
Built, signed, and launched commit
2f820c94c0688327e39362fc80789f1aac8017ea, then queried the running AppKit accessibility tree through macOS System Events. This is system-level output from the shipped view, not a source-code assertion or an isolated SwiftUI host:This verifies that all 365 visible days and all 53 visible week columns are individually traversable, each node publishes its English date plus token/availability value, and the daily grid exposes chronological VoiceOver adjustment actions on the current PR head. Cumulative stays unavailable when earlier source coverage is unknown instead of presenting a fabricated running total.
Data behavior
tokenActivityseries toSpendDashboardModelLocalization
The heatmap includes localized strings across all app catalogs for the title, view modes, empty state, legend, weekly grouping, and cumulative description. The coverage follow-up reuses the existing localized
CoverageandUnavailablekeys. Locale regression coverage verifies that an English app selection produces English weekday/date output even when the system locale differs.Scope / relationship
mainValidation
make checkswift test --filter 'SpendActivityHeatmapTests|SpendDashboardModelTests|SpendDashboardControllerTests'2f820c94make startReview follow-up
The contributor-action findings are addressed through
2f820c94. The PR remains Ready for current-head CI and maintainer feature-direction review underVISION.md.Split PRs
Part of the #2322 umbrella split, stacked on #2527: