Skip to content

feat: show five-hour windows only when reported (#9) - #10

Merged
ChrisOsegueda merged 1 commit into
mainfrom
issue-9-five-hour-when-reported
Nov 2, 2026
Merged

ChrisOsegueda merged 1 commit into
mainfrom
issue-9-five-hour-when-reported

Conversation

@ChrisOsegueda

Copy link
Copy Markdown
Contributor

Summary

The five-hour window now appears only when the current usage data has a value for it, for both Claude and Codex. Accounts without the window no longer see -- in the label or a "5-hour Unavailable" row, and the compact label shows the weekly value. If the provider reports the window again, it comes back on the next refresh. No plan lookup, no setting.

Window reported Window not reported
Full label ✳ 45·70 ✳ 70
Compact label ✳ 45 ✳ 70
No values at all n/a ✳ -- and no 5-hour row

One change the issue did not anticipate

The issue lists rollout-scan changes as out of scope because "expired ones are rejected", but that was only partly true. The scan compares a window's reset time with when the event was written, not with the current time. A rollout snapshot written before a reset was therefore returned as current after that reset, in the ok state, whenever the Codex CLI could not report limits. A failing test reproduced this before the fix.

To meet the acceptance criterion "A Codex five-hour window whose reset time has passed is not shown", CodexProvider now drops such a window after the scan, using an injected clock. The parsers and the scan loop are unchanged. If a rollout held only that window, the refresh counts as failed, so earlier values are kept as usual.

Eight existing Codex tests read July fixtures against the real clock, so they now pin now to before their fixture resets. No assertion changed.

Left as they are:

  • A failed refresh still keeps earlier values, including a five-hour value past its reset, as the issue requires. That value shows as stale, with "resetting…".
  • The same expiry gap exists for the weekly rollout value. It's outside this issue, so I did not change it.

Related issue

Closes #9

Verification

  • DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer make test: 104 tests pass
  • DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer make build
  • git diff --check
  • git grep -n "showsFiveHourUsage" -- InferenceMeter: no output
  • UI changes include a screenshot or an explanation of why one is unavailable (see below)

Screenshots

These are not screencapture images, and the menu bar was not checked in place. macOS blocks this environment: screencapture fails with could not create image from display, and System Events fails with -1719 (no assistive access). The images come from a temporary, uncommitted probe that hosted the real MenuBarLabel and DetailPopover in an offscreen window. Still worth checking by hand: the label in the real menu bar and the popover opening from it.

Window not reported: live data from an account without the window. Both real providers returned state=ok, fiveHour=nil.

Full label Compact label
Full label without the five-hour window Compact label without the five-hour window

Popover without five-hour rows

Window reported: existing fixtures. The values are from claude-usage-response.json and codex-rollout-rate-limits.jsonl. Reset times were moved forward for the render so the countdowns read normally.

Full label Compact label
Full label with the five-hour window Compact label with the five-hour window

Popover with five-hour rows

Security and privacy

  • The read-only OAuth model is preserved: no new Keychain reads and no plan lookup
  • Fixtures and diagnostics are sanitized
  • No tokens, credentials, authorization headers, prompts, or user session content are included

https://claude.ai/code/session_01EFLAijReeyVZHXSemDq6rZ

Apply one rule to both providers: the five-hour window appears only when
the current usage data has a value for it. Accounts without one lose the
`--` in the menu bar label and the "5-hour Unavailable" popover row, the
compact label falls through to the weekly value, and a provider with no
values shows a single `--`. No plan lookup and no new credential reads.

Also stop the rollout fallback from returning a five-hour value whose
window has reset since the event was written. The scan only compares reset
times with the event's own timestamp, so without this a stale snapshot
would revive the window while the CLI cannot report limits. The check runs
after the scan and leaves the parsers and scan unchanged.

Claude-Session: https://claude.ai/code/session_01EFLAijReeyVZHXSemDq6rZ
@ChrisOsegueda

Copy link
Copy Markdown
Contributor Author

Review ledger

Pass Reviewer Model / effort Revision Result
1, initial full review Astra (Codex), independent of the Claude-authored implementation gpt-6-astra, low 88fe85a (78a85d6..88fe85a) NO FINDINGS

No findings to resolve. HEAD and the working tree were unchanged after the review.

https://claude.ai/code/session_01EFLAijReeyVZHXSemDq6rZ

@ChrisOsegueda
ChrisOsegueda merged commit 39a74e6 into main Nov 2, 2026
1 check passed
@ChrisOsegueda
ChrisOsegueda deleted the issue-9-five-hour-when-reported branch November 2, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show five-hour usage windows only when the provider reports them

1 participant