Skip to content

fix: show Codex credit usage in menu bar - #2655

Draft
McBrosa wants to merge 1 commit into
steipete:mainfrom
McBrosa:agent/fix-codex-credit-usage-layout
Draft

fix: show Codex credit usage in menu bar#2655
McBrosa wants to merge 1 commit into
steipete:mainfrom
McBrosa:agent/fix-codex-credit-usage-layout

Conversation

@McBrosa

@McBrosa McBrosa commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • show Codex credit-limit usage in the menu bar's automatic percentage and usage-bar tokens when the account has credits but no usable session or weekly rate window
  • preserve explicit session and weekly token semantics; only the existing Codex credits fallback can replace the automatic metric
  • honor the global "As used" / "As remaining" direction, so the reported 1,193.6 of 42,750 credits renders as 3% used or 97% remaining
  • keep the layout editor preview on the same projection path and document the fix in the changelog

Root cause

The legacy status-item renderer already had a Codex credits fallback, but the stored menu-bar layout renderer only received RateWindow values. Credit-only Business accounts therefore supplied valid credit-limit data to the menu card while Auto % received no window and rendered the standard en-dash placeholder.

This carries the existing CodexConsumerProjection.menuBarFallback decision into layout render data as a used percentage. The renderer consumes it only for automatic usage tokens, leaving session and weekly quotas unavailable when those windows do not exist.

Proof

  • swift test --filter 'MenuBarLayoutRendererTests|StatusItemAnimationCodexCreditsTests' — 16 tests passed
  • make check — locale, documentation, packaging, SwiftFormat, and strict SwiftLint checks passed with zero violations
  • make test — 812 selections across 68 groups passed

The status-item regression uses synthetic credit-limit data matching the report (1,193.6 / 42,750) and asserts that the stored default layout renders 3% instead of . No live provider probe, Keychain access, or bundle-level screenshot was used.

@clawsweeper clawsweeper Bot added 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. 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 real behavior proof before merge. Reviewed August 12, 2026, 8:59 AM ET / 12:59 UTC.

ClawSweeper review

What this changes

The PR feeds a Codex credit-limit used percentage into automatic menu-bar percentage and usage-bar layout tokens when the existing Codex projection selects its credits fallback.

Merge readiness

Blocked until real behavior proof from a real setup is added - 9 items remain

Keep open: the requested credit-only fallback remains useful, but this draft currently replaces an available automatic rate-window metric when any Codex lane is exhausted, changes the usage bar the same way, is dirty against current main, and has only synthetic-test proof.

Priority: P2
Reviewed head: d0fc33a7c62a2f78b469c97cb1ae6fdd760d1402

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The PR has a focused intent and test signal, but two P1 display regressions, a dirty branch, and mock-only proof prevent merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR reports focused and full synthetic tests, but explicitly provides no after-fix run from a freshly built app or real credit-only account; add redacted runtime evidence after correcting and rebasing the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR reports focused and full synthetic tests, but explicitly provides no after-fix run from a freshly built app or real credit-only account; add redacted runtime evidence after correcting and rebasing the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current automatic rendering: Current main derives automatic percentages directly from the selected rate window, so it does not yet implement the credit-limit fallback requested here.
Fallback can coexist with rate windows: The current Codex projection selects the credits fallback when any lane is exhausted, while its existing test uses an exhausted session and a healthy weekly window; it is not limited to accounts without rate windows.
Existing automatic-window behavior: Automatic menu-bar selection keeps a resetting exhausted lane selectable, so an exhausted session can still be the automatic metric even when a weekly lane is present.
Findings 2 actionable findings [P1] Prefer the automatic rate window to the credit fallback
[P1] Keep the usage bar tied to the automatic window
Security None None.

How this fits together

CodexBar turns Codex usage and credit snapshots into a provider projection, then supplies semantic session, weekly, and automatic values to the configurable macOS menu-bar layout. The renderer converts those values into percentages and a three-cell usage bar for the status item and editor preview.

flowchart LR
A[Codex usage snapshot] --> B[Codex usage projection]
C[Credit-limit snapshot] --> B
B --> D[Automatic window selection]
B --> E[Credit fallback decision]
D --> F[Menu-bar layout data]
E --> F
F --> G[Percentage and usage-bar tokens]
G --> H[Status item and editor preview]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR reports focused and full synthetic tests, but explicitly provides no after-fix run from a freshly built app or real credit-only account; add redacted runtime evidence after correcting and rebasing the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Prefer the automatic rate window to the credit fallback (P1) - menuBarFallback is active when any Codex lane is exhausted, not only when no rate windows exist. Since automatic selection can still return that resetting lane, this precedence makes an existing automatic layout show the credit percentage (for example 3%) instead of its actual rate-window percentage (100%). Select the rate window first and use the fallback only when it is absent; add that coexistence case to the test.
  • Keep the usage bar tied to the automatic window (P1) - The same fallback-first ordering changes the usage bar whenever any rate lane is exhausted, even though data.automatic remains available. Prefer data.automatic?.usedPercent and use the credit value only when there is no automatic window, with a regression test for both cases.
  • Resolve merge risk (P1) - Merging as written can show the credit-limit percentage and bar for users who still have an automatic rate-window metric, silently replacing the established rate-window display.
  • Resolve merge risk (P1) - The dirty branch must be reconciled with current-main layout-data changes before its tests can establish upgrade safety.
  • Complete next step (P2) - The required code correction is clear, but the draft is dirty against current main and only the contributor can provide the required real-app evidence after rebasing.
  • Improve patch quality - Make the automatic rate-window value win whenever it exists, for both percentage and usage-bar tokens.
  • Improve patch quality - Rebase onto current main and rerun the relevant renderer and status-item tests.
  • Improve patch quality - Add redacted after-fix evidence from a freshly built app showing the credit-only layout result; update the PR body to trigger re-review.

Findings

  • [P1] Prefer the automatic rate window to the credit fallback — Sources/CodexBar/MenuBarLayoutRenderer.swift:246-247
  • [P1] Keep the usage bar tied to the automatic window — Sources/CodexBar/MenuBarLayoutRenderer.swift:277-284
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch footprint 7 files, +126/-9 The focused display change spans four production files, two test files, and one release-owned changelog file.
Regression coverage tests +89/-6 The added renderer assertion currently encodes the fallback-over-window behavior that requires correction.

Merge-risk options

Maintainer options:

  1. Preserve the automatic window (recommended)
    Rebase, make the rate-window value take precedence over the credit fallback for both tokens, add the two precedence regressions, and then provide after-fix app evidence.
  2. Adopt credit-over-window semantics
    Maintain the proposed precedence only with explicit approval and tests documenting that automatic layouts intentionally replace an exhausted rate-window metric with credits.

Technical review

Best possible solution:

Rebase onto current main, use the credit value only when the automatic rate window is absent, cover both the credit-only and available-window cases, then attach redacted freshly built-app evidence for the intended credit-only display.

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

Yes, at source level: an exhausted resetting Codex session plus a valid weekly lane and 3%-used credit limit reaches the fallback while an automatic rate window remains available. No after-fix real-app run has been supplied.

Is this the best way to solve the issue?

No. The fallback should fill an absent automatic rate window rather than override one; that preserves existing automatic-layout semantics while solving the stated credit-only case.

Full review comments:

  • [P1] Prefer the automatic rate window to the credit fallback — Sources/CodexBar/MenuBarLayoutRenderer.swift:246-247
    menuBarFallback is active when any Codex lane is exhausted, not only when no rate windows exist. Since automatic selection can still return that resetting lane, this precedence makes an existing automatic layout show the credit percentage (for example 3%) instead of its actual rate-window percentage (100%). Select the rate window first and use the fallback only when it is absent; add that coexistence case to the test.
    Confidence: 0.98
  • [P1] Keep the usage bar tied to the automatic window — Sources/CodexBar/MenuBarLayoutRenderer.swift:277-284
    The same fallback-first ordering changes the usage bar whenever any rate lane is exhausted, even though data.automatic remains available. Prefer data.automatic?.usedPercent and use the credit value only when there is no automatic window, with a regression test for both cases.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

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 but user-visible menu-bar usage-display correction with no demonstrated wider service outage.
  • merge-risk: 🚨 compatibility: The patch can change existing automatic percentage and usage-bar output for accounts that have both an exhausted rate lane and credit-limit data.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports focused and full synthetic tests, but explicitly provides no after-fix run from a freshly built app or real credit-only account; add redacted runtime evidence after correcting and rebasing the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Houge: Commit 2ac8f1a is the latest current-main change on both the layout renderer and its status-item data producer. (role: recent layout contributor; confidence: high; commits: 2ac8f1a47e0c; files: Sources/CodexBar/MenuBarLayoutRenderer.swift, Sources/CodexBar/StatusItemController+MenuBarLayout.swift)

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 (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-05T16:01:23.748Z sha d0fc33a :: needs real behavior proof before merge. :: [P1] Preserve the automatic rate-window metric | [P1] Keep the usage bar on the automatic window
  • reviewed 2026-08-06T01:56:44.293Z sha d0fc33a :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-07T12:07:30.929Z sha d0fc33a :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-07T13:53:30.261Z sha d0fc33a :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T11:53:33.217Z sha d0fc33a :: needs real behavior proof before merge. :: [P1] Preserve the automatic rate-window metric | [P1] Keep the usage bar on the automatic window | [P3] Remove the release-owned changelog edit
  • reviewed 2026-08-08T13:46:44.615Z sha d0fc33a :: needs real behavior proof before merge. :: [P1] Preserve the automatic rate-window metric | [P1] Keep the usage bar on the automatic window | [P3] Remove the release-owned changelog edit
  • reviewed 2026-08-08T23:41:31.843Z sha d0fc33a :: needs real behavior proof before merge. :: [P1] Preserve the automatic rate-window metric | [P1] Keep the usage bar on the automatic window
  • reviewed 2026-08-09T04:55:33.283Z sha d0fc33a :: needs real behavior proof before merge. :: [P1] Prefer the rate window over the credit fallback | [P1] Keep the usage bar on the automatic window

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Aug 4, 2026
@McBrosa
McBrosa force-pushed the agent/fix-codex-credit-usage-layout branch from 4756403 to d0fc33a Compare August 5, 2026 15:57
@clawsweeper clawsweeper Bot added 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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant