Skip to content

Add focused daily spend ledger - #2635

Open
sahilaidev wants to merge 4 commits into
steipete:mainfrom
sahilaidev:agent/daily-spend-ledger-focused
Open

Add focused daily spend ledger#2635
sahilaidev wants to merge 4 commits into
steipete:mainfrom
sahilaidev:agent/daily-spend-ledger-focused

Conversation

@sahilaidev

@sahilaidev sahilaidev commented Aug 4, 2026

Copy link
Copy Markdown

Summary

This is the focused follow-up requested by repository owner @steipete in #2485: daily spend ledger only, without currency conversion or fork-packaging changes. It supersedes the closed #2615 after moving the branch to a new fork.

  • Add a read-only daily ledger beneath the existing Usage & Spend dashboard.
  • Aggregate tracked tokens, request totals, and estimated spend by provider and local calendar day.
  • Fill established coverage with zero-usage days and combine providers only across their exact common coverage.
  • Preserve unavailable data instead of presenting it as zero: unknown aggregate cost suppresses ledger rows, and incomplete or contradictory request data remains unavailable.
  • Include last30DaysRequests in the dashboard snapshot revision so request-only refreshes invalidate the rendered ledger.

Maintainer direction

In #2485, @steipete identified the daily spend ledger as the interesting part of the original mixed-scope contribution and invited a focused follow-up containing only the ledger, with tests for request aggregation and coverage semantics. This PR implements that requested scope and leaves the final product-acceptance decision to normal maintainer review.

User impact

Users can inspect the daily activity behind the existing aggregate spend dashboard without changing provider settings or cost-calculation behavior.

Verification

  • swift test --filter SpendDashboardDailyLedgerTests — 7 passed
  • swift test --filter SpendDashboardControllerTests — 25 passed
  • make check — passed with zero format or lint violations
  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 make test — 810 selections passed across 68 groups; zero failures, retries, or timeouts

Synthetic UI evidence

All values below are synthetic and contain no account identity or personal spend data.

Synthetic daily spend ledger

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 12, 2026, 8:11 AM ET / 12:11 UTC.

ClawSweeper review

What this changes

Adds a read-only daily Usage & Spend ledger that shows per-day provider activity, tracked tokens, requests, and estimated spend.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep open: the focused ledger remains useful and has direct UI proof, but the branch is merge-conflicting and still predates current main’s released 365-day token-activity heatmap.

Priority: P2
Reviewed head: 809480c8ad5b0839f6b1b000c03d38cae3bcdce4

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The UI proof and focused coverage are strong, but the unresolved dirty rebase can regress shipped dashboard behavior.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The prepared synthetic screenshot directly shows the new ledger UI and its visible columns; after rebasing, capture a fresh redacted Settings view that also retains token activity.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The prepared synthetic screenshot directly shows the new ledger UI and its visible columns; after rebasing, capture a fresh redacted Settings view that also retains token activity.
Evidence reviewed 4 items Current released behavior: Current main renders the 365-day token-activity heatmap whenever cost tracking is enabled and activity is available.
Merge-conflict regression risk: The PR head has the older snapshot-only dashboard model and adds ledger-only model structures; current main adds tokenActivityCache, TokenActivityPoint, and tokenActivity model output. GitHub reports this PR as dirty, so conflict resolution must preserve the newer path.
Feature-history and release provenance: History attributes the heatmap to the shared-cache token-activity commit, and the tag check shows that commit is included in v0.48.0; it is therefore existing shipped behavior rather than optional branch churn.
Findings 1 actionable finding [P1] Rebase without removing token activity
Security None None.

How this fits together

The Usage & Spend dashboard converts provider snapshots and cached Codex history into currency-group summaries, charts, and activity views in Settings. The proposed ledger would consume the same grouped daily data alongside the existing 365-day token-activity heatmap.

flowchart LR
A[Provider snapshots] --> B[Cached Codex activity]
A --> C[Spend dashboard loader]
B --> C
C --> D[Dashboard model]
D --> E[Spend charts]
D --> F[Token activity heatmap]
D --> G[Daily spend ledger]
Loading

Before merge

  • Rebase without removing token activity (P1) - Rebase this ledger model onto current main before resolving the dirty merge. The branch still carries the pre-heatmap dashboard shape, while main now passes cached activity into the model and renders a 365-day heatmap; retaining the branch version during conflict resolution would remove that shipped behavior. This is the previously reported blocker and remains unfixed at the current head.
  • Resolve merge risk (P1) - Resolving the dirty merge with the branch’s older dashboard model can remove the released cached token-activity path and its 365-day heatmap for existing users.
  • Complete next step (P2) - A concrete rebase-and-regression repair can preserve the requested ledger while retaining current main’s activity model.

Findings

  • [P1] Rebase without removing token activity — Sources/CodexBar/SpendDashboardModel.swift:64-91
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Implementation and regression coverage production +315, tests +277, 1 UI screenshot The feature has substantial focused model/UI code and nearly matching aggregation/controller coverage, so preserving current dashboard behavior during rebase is the key merge check.

Root-cause cluster

Relationship: canonical
Canonical: #2635
Summary: This is the focused follow-up identified by the contributor after the earlier mixed-scope and moved-fork submissions were closed.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Rebase onto the activity model (recommended)
    Resolve the branch against current main while retaining cached token activity, the 365-day heatmap, and their integration coverage before merge.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase the ledger onto current main, retain cached token activity and the 365-day heatmap, and add focused regression coverage for both outputs.

Technical review

Best possible solution:

Rebase the ledger onto current main, retaining cached token activity and the heatmap, then validate both views from a freshly built Settings bundle.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR proposes a feature; the merge conflict and missing current-main activity path are directly established by the branch/current-main comparison.

Is this the best way to solve the issue?

No—the ledger approach is focused, but this branch must first be rebased onto the current activity model so it does not regress shipped dashboard behavior.

Full review comments:

  • [P1] Rebase without removing token activity — Sources/CodexBar/SpendDashboardModel.swift:64-91
    Rebase this ledger model onto current main before resolving the dirty merge. The branch still carries the pre-heatmap dashboard shape, while main now passes cached activity into the model and renders a 365-day heatmap; retaining the branch version during conflict resolution would remove that shipped behavior. This is the previously reported blocker and remains unfixed at the current head.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a90dfed5c264.

Labels

Label justifications:

  • P2: This is a bounded Settings feature with a concrete compatibility blocker, but no active outage or data-loss evidence.
  • merge-risk: 🚨 compatibility: An incorrect conflict resolution could replace the shipped token-activity model and heatmap with this branch’s older dashboard shape.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The prepared synthetic screenshot directly shows the new ledger UI and its visible columns; after rebasing, capture a fresh redacted Settings view that also retains token activity.
  • proof: sufficient: Contributor real behavior proof is sufficient. The prepared synthetic screenshot directly shows the new ledger UI and its visible columns; after rebasing, capture a fresh redacted Settings view that also retains token activity.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The prepared synthetic screenshot directly shows the new ledger UI and its visible columns; after rebasing, capture a fresh redacted Settings view that also retains token activity.

Evidence

Acceptance criteria:

  • [P1] swift test --filter SpendDashboardDailyLedgerTests.
  • [P1] swift test --filter SpendDashboardTokenActivityIntegrationTests.
  • [P1] CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 make test.
  • [P1] make check.

What I checked:

Likely related people:

  • steipete: Introduced the shared-cache token-activity heatmap that this rebase must retain. (role: recent feature owner; confidence: high; commits: 521af81e1e10, 15a855a2132a; files: Sources/CodexBar/PreferencesSpendDashboardPane.swift, Sources/CodexBar/SpendDashboardModel.swift, Sources/CodexBar/SpendDashboardController.swift)
  • Alec Gutman: Co-authored the unified Usage & Spend dashboard introduced in the feature history. (role: original dashboard contributor; confidence: medium; commits: 0397529ae6e5; files: Sources/CodexBar/PreferencesSpendDashboardPane.swift, Sources/CodexBar/SpendDashboardModel.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main while retaining cached token activity and the 365-day heatmap.
  • Run the focused ledger and token-activity suites plus the repository checks on the rebased head.
  • Capture a fresh redacted Settings screenshot showing both the rebased ledger and retained activity view.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (26 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-07T17:08:55.847Z sha 809480c :: needs changes before merge. :: [P1] Rebase the ledger onto the current activity model
  • reviewed 2026-08-07T18:59:20.145Z sha 809480c :: needs changes before merge. :: [P1] Rebase without dropping the token-activity heatmap
  • reviewed 2026-08-08T11:53:31.384Z sha 809480c :: needs changes before merge. :: [P1] Retain the token-activity heatmap when rebasing
  • reviewed 2026-08-08T13:46:32.754Z sha 809480c :: needs changes before merge. :: [P1] Rebase without dropping the token-activity heatmap
  • reviewed 2026-08-08T16:56:09.129Z sha 809480c :: needs changes before merge. :: [P1] Rebase the ledger onto the current activity model
  • reviewed 2026-08-08T17:10:15.953Z sha 809480c :: needs changes before merge. :: [P1] Rebase the ledger onto the current activity model
  • reviewed 2026-08-08T23:41:44.661Z sha 809480c :: needs changes before merge. :: [P1] Rebase the ledger onto the current activity model
  • reviewed 2026-08-09T04:55:30.453Z sha 809480c :: needs changes before merge. :: [P1] Rebase without removing token activity

@sahilaidev
sahilaidev marked this pull request as ready for review August 4, 2026 04:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8403735fef

ℹ️ 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".

Comment on lines +691 to +695
Text(L("Day")).frame(width: 112, alignment: .leading)
Text(L("Providers")).frame(minWidth: 96, maxWidth: .infinity, alignment: .leading)
Text(L("Tracked tokens")).frame(width: 90, alignment: .trailing)
Text(L("Requests")).frame(width: 72, alignment: .trailing)
Text(L("Estimated spend")).frame(width: 116, alignment: .trailing)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make the ledger columns fit the settings pane

At the default 880-point window—and more noticeably at the supported 800-point minimum—the fixed column widths, minimum provider width, spacing, and horizontal padding require more width than the dashboard viewport provides. Because the enclosing ScrollView is vertical-only, the ledger extends beyond or clips against the right edge instead of adapting or allowing horizontal scrolling; use flexible columns, reduce fixed widths, or add a horizontal scrolling layout.

Useful? React with 👍 / 👎.


var body: some View {
HStack(spacing: 12) {
Text(self.summary.day, format: .dateTime.weekday(.abbreviated).day().month(.abbreviated))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Format ledger dates with the selected app locale

When CodexBar's selected language differs from the macOS system language, this Text date format uses the SwiftUI environment/system locale, while the surrounding labels use L(...); the preferences hierarchy only rebuilds on appLanguage changes and does not override EnvironmentValues.locale. The chart and this row's accessibility label already explicitly use codexBarLocalizedLocale(), so apply that locale to the visible date format as well to avoid mixed-language rows.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. label Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant