Repository navigation
Conversation
Decode the seven_day_breakdown block of the Claude usage response and list nonzero product shares in a Usage breakdown detail section beneath the weekly bar. Malformed rows or shares that do not compose 100% drop the breakdown without touching the weekly window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: ready, awaiting a maintainer decision. What this changesThis PR displays Claude’s weekly usage shares by product through existing menu and CLI detail rows. Example: Claude reports 4% weekly usage split between Claude Code 65%, Cowork 22%, and Chats 13%.
Review scores
ProductKind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⏳ Ready, awaiting maintainer decision Keep open for a product decision: current main omits the reported Claude product split, and this focused implementation has no identified correctness blocker. Reviewed head: Decision needed
Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherClaude Web and OAuth response parsers feed a shared usage snapshot, whose detail sections reach the native menu and CLI renderers. flowchart LR
A[Claude usage response] --> B[Web or OAuth parser]
B --> C[Validated product shares]
C --> D[Claude usage snapshot]
D --> E[Provider detail sections]
E --> F[Native menu]
E --> G[CLI output]
Technical reviewBest possible solution: Retain the shared optional decoder and existing renderers if the owner approves showing shares of weekly consumption. Do we have a high-confidence way to reproduce the issue? This is an additional display capability; source inspection confirms main ignores the field, and the supplied live CLI output demonstrates the proposed behavior. Is this the best way to solve the issue? A shared decoder feeding existing detail sections is a focused implementation that preserves quota calculations and isolates malformed optional data. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a26ca57b5186. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 28, 2026, 7:16 AM ET / 12:16 UTC (Revision 2). |
|
Added a live run against claude.ai to the description (CLI from this branch, real @clawsweeper re-review |
|
@clawsweeper re-review The description now has a live run against claude.ai: |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Summary
The claude.ai usage response that CodexBar's Claude web source already fetches (
GET /api/organizations/{org}/usage) includes aseven_day_breakdownblock that splits the week's usage across products. CodexBar has ignored it so far. This PR decodes it and shows the nonzero shares, largest first, as plain rows in the existing provider detail section ("Usage breakdown") beneath the weekly bar. It uses the same seam and style as Grok's product breakdown (#3988, #4041). There are no new requests, no new UI components, no menu code changes, and no new localization keys: the section title reuses the existing localized "Usage breakdown" string, and row labels come from the response'sdisplay_name.ClaudeWeeklyProductBreakdown(new, 75 lines) decodesrows[].key,display_name(falls back tokey) andpercent. It ignores unknown keys. A missing block, any malformed row (missing or blank key, non-numeric/boolean/out-of-range percent) or shares that do not add up to 100 ± 2 (integer rounding across four rows) drop the whole breakdown. The weekly window is left as is.WebUsageData→ClaudeUsageSnapshot→UsageSnapshot.details. It is only added when the same snapshot has the weekly window, so shares never appear without the bar they split. The OAuth response type decodes the same key with the same decoder, in the same wayiguana_necktiecloud credits already work.percent). They are not separate quotas and never change the weekly percentage.Why the API does expose a breakdown
#4123 was closed on the premise that the Claude usage API reports only combined weekly windows. That holds for the windows themselves, but the web usage response also returns this block beside
seven_day. Redacted from a Max account today:The field was present in all 208 stored responses over the last ~19 hours (2026-11-23), across three accounts. The reporter's September sample in #4123 has the same shape without
percent_of_limit. That is why this PR keys onpercent, the field both shapes have.percent_of_limit(points of the weekly limit, which sum toseven_day.utilization) would be a one-line switch if you would rather have the rows add up to the bar, the way Grok's do.Screenshot
Synthetic render of the production
UsageMenuCardViewfrom the redacted fixture. It is rendered offscreen to PNG byClaudeWeeklyProductBreakdownRenderTests(skipped unlessCODEXBAR_CLAUDE_PRODUCT_PROOF_DIRis set). No app launch, account, network request or credential access is involved.Live run against claude.ai
CodexBarCLIbuilt from this branch (e59c964) and run on a Max account on 2026-11-24, fetching the real claude.ai usage response with the user's existing browser session. Only the account line is redacted:The last three usage rows are the new breakdown: decoded from the live
seven_day_breakdown, nonzero shares only, largest first, and they sum to 100. They are shares of this week's 4% usage, so the weekly bar is unchanged. One caveat about the build: this machine runs the macOS 27.2 beta (26B5091g), whose Foundation lacks theDate >=/<=symbols that Xcode 27.2 links against, so the local build carried an uncommitted shim that defines those two operators with the same semantics. The shim is not part of this PR.Verification
Swift commands ran with
CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1,CODEXBAR_TEST_CODEX_FILE_ISOLATION=1andCODEXBAR_TEST_SESSION_FILE_ISOLATION=1.swift test --filter ClaudeWeeklyProductBreakdown: 6 Swift Testing tests passed, including 15 absent/malformed cases. The XCTest render test was skipped (no proof dir set).CODEXBAR_CLAUDE_PRODUCT_PROOF_DIR=… swift test --filter ClaudeWeeklyProductBreakdownRenderTests: passed and wrote before/after light/dark PNGs.swift test --filter 'ClaudeCloudCredits|ClaudeWeb|ClaudeOAuthUsage|ClaudeUsage|ClaudeMenuCard|ProviderDetailSection|ClaudeWeeklyProductBreakdownTests': 186 tests in 23 suites passed.make check: passed (0 SwiftLint violations in 3262 files; app locales, widget catalogs and provider docs OK).Not verified: whether
api.anthropic.com/api/oauth/usagealso returnsseven_day_breakdown. The OAuth path decodes it if present, and nothing changes if it is absent. The live run above used the web source only.Refs #4123
🤖 Generated with Claude Code