Skip to content

feat(cost): split Codex and Claude local cost by live weekly windows - #3358

Open
stabey wants to merge 9 commits into
steipete:mainfrom
stabey:review/cursor-quota-windows-9066
Open

feat(cost): split Codex and Claude local cost by live weekly windows#3358
stabey wants to merge 9 commits into
steipete:mainfrom
stabey:review/cursor-quota-windows-9066

Conversation

@stabey

@stabey stabey commented Sep 1, 2026

Copy link
Copy Markdown

Summary

  • Show Codex and Claude local cost/tokens for the current weekly quota window, split at the live Weekly reset instant instead of a rolling calendar last-7-days.
  • Add a Recent windows list under the daily chart (range, cost, tokens) with window-based labels (Current window / Previous window / N windows ago), including same-day official and banked resets.
  • Gate the UI to Codex and Claude via the provider descriptor, and read weekly reset timestamps without rewriting plan-utilization history during menu render.
  • Keep independently priced model subtotals when a sibling model (for example Codex auto-review) has no list price, so Usage & Spend does not fail-close the whole day or current window.

Test plan

  • make check
  • make test (986 selections / 83 groups, first-pass all green)
  • Focused: CostUsageQuotaWeekLinuxTests, CostUsageDailyReportMergeTests, InlineCostHistoryDashboardLabelTests, ProviderArchitectureGatekeeperTests
  • Open Settings → Usage & Spend for Codex and Claude and confirm Current window sits next to Today, with Recent windows under the chart
  • Confirm other providers still show the existing cost dashboard with no quota-window rows
  • Confirm a weekly reset (or banked reset on the same day) does not double-count the reset calendar day

Screenshots

Live Usage & Spend from a local adhoc build of this branch (2026-09-02). Codex account name is redacted. Codex was a live refresh; Claude is last-known usage from about 7 hours earlier because this adhoc build could not read Claude OAuth from Keychain.

Codex Claude
Codex live Claude live

Synthetic layout captures used by MenuLayoutScreenshotRenderTests/test_renderQuotaWindowCostScreenshots remain at docs/screenshots/quota-window-{codex,claude}-{light,dark}.png.

stabey added 4 commits August 31, 2026 07:14
Bring in 0.56.1, 0.56.2, and 0.56.3 development through steipete#3318. Keep quota-window history and fail-closed cost completeness across the merged coverage/request-count accumulators.
Menu rendering now reads weekly reset dates without migrating history
buckets, and the window UI stays Codex/Claude-only via the descriptor.
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T14:37:06.118410Z 5267187 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 10:39 AM ET / 14:39 UTC.

ClawSweeper review

What this changes

Adds Codex and Claude Usage & Spend totals and recent-history rows partitioned by live weekly quota-reset windows rather than calendar days.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open pending maintainer confirmation of this new Usage & Spend direction. Current main does not contain the quota-window presentation, and the branch now has direct redacted app captures plus focused boundary coverage; no discrete correctness or security defect was identified in the introduced change.

Priority: P2
Reviewed head: ef1ab5db4d8bddbce19cee0f29986f2299961f49
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A substantial, well-covered feature branch with direct built-app UI proof; the remaining blocker is product sponsorship rather than an identified patch defect.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The changed production path is local cost scanning through quota-window projection into the Usage & Spend menu card; the inspected redacted Codex live-refresh and Claude last-known built-app captures directly show the resulting Current window KPI and Recent windows rows after the change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The changed production path is local cost scanning through quota-window projection into the Usage & Spend menu card; the inspected redacted Codex live-refresh and Claude last-known built-app captures directly show the resulting Current window KPI and Recent windows rows after the change.
Evidence reviewed 4 items Introduced quota projection: The introduced projection derives consecutive weekly windows from live reset metadata, preserved reset observations, exact slices, and daily fallback data before supplying totals to the dashboard.
Current-main necessity check: The current fetched main revision has no quota-window, Current window, or Recent windows presentation symbols in the dashboard or cost models, so it has not already absorbed this feature.
Real UI proof inspected: The supplied redacted screenshots show the built Codex and Claude Usage & Spend cards with a Current window KPI and Recent windows rows; the Codex capture is described as a live refresh and the Claude capture visibly labels its last-known data state.
Findings None None.
Security None None.

How this fits together

Local Codex and Claude transcript scanners produce cost and token history that flows through provider presentation rules into the macOS Usage & Spend menu card. This change uses the provider’s weekly reset timing to turn that history into current and prior quota-window totals.

flowchart LR
A[Local Codex and Claude logs] --> B[Cost and token scanner]
B --> C[Timed cost history]
D[Weekly quota reset data] --> E[Quota window projection]
C --> E
E --> F[Provider presentation rules]
F --> G[Usage and Spend menu card]
Loading

Decision needed

Question Recommendation
Should CodexBar add live weekly quota-window cost and token history to the Codex and Claude Usage & Spend cards? Sponsor the quota-window dashboard: Accept the Codex- and Claude-only window history as the intended Usage & Spend presentation and continue normal merge review.

Why: The implementation is a new user-visible dashboard mode rather than a repair to an established contract, and no maintainer decision in the supplied discussion establishes that this product surface should be added.

Before merge

  • Resolve merge risk (P1) - This is a substantial new visible cost-history mode and persisted temporal-data projection, so maintainers should explicitly confirm that the added dashboard scope is desired before landing it.
  • Complete next step (P2) - Confirm that the expanded Codex and Claude quota-window dashboard is desired before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and regression coverage production +1,791/-134; tests +1,921/-22 The implementation adds a temporal cost projection with broadly matched boundary and persistence coverage.
Changed surface 58 files affected The feature spans scanners, persisted report payloads, provider descriptors, UI, documentation, and localized labels.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    If sponsored, merge the provider-gated window projection with its backward-compatible optional cache fields and retain the reset-boundary regression coverage.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

If sponsored, merge the provider-gated window projection with its backward-compatible optional cache fields and retain the reset-boundary regression coverage.

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

Not applicable: this PR adds a new dashboard presentation rather than reporting a broken current behavior; its redacted built-app captures directly show the proposed UI.

Is this the best way to solve the issue?

Unclear: the code path is coherent and covered, but a maintainer must first confirm that this new quota-window dashboard is the preferred product direction.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed production path is local cost scanning through quota-window projection into the Usage & Spend menu card; the inspected redacted Codex live-refresh and Claude last-known built-app captures directly show the resulting Current window KPI and Recent windows rows after the change.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The changed production path is local cost scanning through quota-window projection into the Usage & Spend menu card; the inspected redacted Codex live-refresh and Claude last-known built-app captures directly show the resulting Current window KPI and Recent windows rows after the change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The changed production path is local cost scanning through quota-window projection into the Usage & Spend menu card; the inspected redacted Codex live-refresh and Claude last-known built-app captures directly show the resulting Current window KPI and Recent windows rows after the change.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a meaningful but non-urgent Usage & Spend feature addition with bounded provider scope.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The changed production path is local cost scanning through quota-window projection into the Usage & Spend menu card; the inspected redacted Codex live-refresh and Claude last-known built-app captures directly show the resulting Current window KPI and Recent windows rows after the change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production path is local cost scanning through quota-window projection into the Usage & Spend menu card; the inspected redacted Codex live-refresh and Claude last-known built-app captures directly show the resulting Current window KPI and Recent windows rows after the change.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The changed production path is local cost scanning through quota-window projection into the Usage & Spend menu card; the inspected redacted Codex live-refresh and Claude last-known built-app captures directly show the resulting Current window KPI and Recent windows rows after the change.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Nikolai Berezovskii: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Yuxin Qiao: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-01T14:29:57.312Z sha 5267187 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-01T15:07:54.595Z sha ec56af0 :: needs real behavior proof before merge. :: [P1] Preserve exact slices when a Pi daily residual crosses a reset
  • reviewed 2026-09-01T15:20:17.979Z sha 724e3c3 :: needs real behavior proof before merge. :: none

@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: 5267187751

ℹ️ 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 thread Sources/CodexBarCore/CostUsageModels+QuotaWindows.swift Outdated
Comment thread Sources/CodexBarCore/CostUsageModels.swift Outdated
Comment thread Sources/CodexBarCore/CostUsageModels+QuotaWindows.swift Outdated
Comment thread Sources/CodexBarCore/CostUsageModels+QuotaWindows.swift Outdated
Comment thread Sources/CodexBarCore/CostUsageModels+QuotaWindows.swift Outdated
Comment thread Sources/CodexBar/InlineUsageDashboardContent.swift Outdated
Fill sparse observed-reset holes, fail closed on incomplete days and
model costs, omit windows that start before scanned history, keep
calendar fallback on local midnight, and read the weekly reset from
semantic windows so Claude OAuth still aligns.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. and removed merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Sep 1, 2026
A merged Pi daily-only total can make a reset day residual; still project
the exact native timestamps into each window instead of dropping the day.
Unpriced Codex auto-review rows were fail-closing the whole day and current
window after Pi merge. Keep independently priced models so Usage & Spend still
shows amounts.
Replace the PR's synthetic layout proof with redacted Usage & Spend shots from
this branch.
@stabey

stabey commented Sep 2, 2026

Copy link
Copy Markdown
Author

Live Codex and Claude Usage & Spend captures from this branch are now in the PR body (replacing the synthetic layout shots).

  • Codex: live refresh, Current window Aug 31 10:40–Sep 7 10:40 with cost shown next to Today
  • Claude: last-known usage (~7h) on the same UI; Current window Aug 28 04:59–Sep 4 04:59

The cost-fix commit keeps priced model subtotals when codex-auto-review has no list price, which is what made the Codex dollar amounts show up again.

@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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: 🐚 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant