Repository navigation
fix(menubar): decode the Codex quota windows array - #5
Merged
Merged
Conversation
Since 1.8 the backend emits quota.codex.data as { plan_type, windows: [...] }
(src/codexQuota.js), but the menubar still decoded the flat used_percent.
So the Codex % in the capsule, its menu line and the 80/95% notifications
never appeared. The capsule and alerts now follow the tightest window,
and the menu lists each window (5h / 周). The flat field stays as a
fallback for pre-1.8 snapshots. resets_at is deliberately not decoded,
since a type mismatch on any field fails the whole Summary decode.
CI has no swiftc, so test/menubar-contract.mjs checks the contract
instead. It builds a real buildSummary payload in a temp-HOME child,
compares every Decodable struct's fields (including non-optional ones)
against it by type, and asserts the max-window expression and labels.
9 checks fail against the current main.swift. Please build on macOS
(npm run build-bar) before merging: not compiled here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # test/run.mjs
# Conflicts: # test/run.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since 1.8 the backend emits the Codex quota as
quota.codex.data = { plan_type, windows: [{ window_minutes, used_percent, resets_at }] }(src/codexQuota.js).menubar/main.swift:22still decodes the old flatused_percent, so these never appear in the menubar:·C<n>%in the capsuleThis was a P2 in
docs/RELEASE-READINESS-2026-09-24.md.Change
DataQdecodeswindows: [Window]?. The flatused_percentstays as a fallback for pre-1.8 snapshots.used_percent).resets_atis deliberately not decoded. It is unused, and a type mismatch on any field makesJSONDecoderfail the wholeSummary, which would blank the capsule toT--.Tests
CI has no
swiftc, sotest/menubar-contract.mjschecks the Swift ↔ API contract instead, with 14 checks:buildSummarypayload (Codex windows, balance, active Claude 5h block) in a temp-HOME offline child.Decodablestruct the menubar declares, it compares each field's type against that payload, including non-optional fields. It reads only the struct's own fields, not nested ones.codexQuotaView.9 checks fail against the current
main.swift. Deliberately wrong versions, such as.min()instead of.max(), a mistyped field, or swapped labels, also fail.Not compiled here (no macOS on the machine this was made on). Please run
npm run build-bar && token-watcher baragainst a server with a Codex quota snapshot before merging. The capsule should readT…·C<max%>and the menu should list the 5h/周 lines.Independent of the other PRs in this set. Only the registration line in
test/run.mjsoverlaps.🤖 Generated with Claude Code