Panel model weeks, purchased credits left, extra usage in the credit blue #18

Merged
claude merged 7 commits from oss-oo/model-week-panel-and-credits into main 2026-10-28 17:08:00 +00:00
Member

Three fixes the owner reported on the live 1.0.3 panel, plus what turned up on the way. Version 1.1.0.

1. Model weeks in the panel

Show model-specific limits in the panel merged every limit by window duration (summarizeWindows keeps the lowest value per duration), so the switch only swapped the 7d item between the all-models week and Fable. UsageFormat.selectPanelSummaries keeps the account's 5h/7d (with both panel switches) and appends each model week as an item of its own, with the model letter on its icon, in the label when the icon is hidden, and beside the value (horizontal) or above it (vertical) when icon and labels are hidden. Without an account limit the switch lists every model week; switched off, the merged fallback keeps the panel filled. Settings tooltip added.

2. Extra usage amount ($40 vs $10)

Root cause, verified with read-only probes (token in memory only, sanitized evidence outside the repo): /api/oauth/usage → extra_usage.monthly_limit is the monthly spend limit (4000 cents = $40 on the owner's account), used_credits the spend this month (608). The helper showed monthly_limit − used_credits as "left". The purchased credits live at GET /api/oauth/organizations/<org>/prepaid/credits (amount: 392 cents = $10 − $6.08), the request Claude Code itself sends.

  • The helper reads the organization UUID from the profile (cached 12 h, cache version 2) and, while extra usage is active, the balance (5 s, like Claude Code). A failed, garbled (huge number, deep JSON) or cancelled request only hides the balance: the refresh never fails for it, keeps the usage answer it already has and caches no failed profile lookup.
  • extraUsage.active follows Claude Code (is_enabled or out_of_credits / org_spend_cap_reached / org_level_disabled_until), limitReached the spend-limit flags, outOfCredits its reason, autoReload the prepaid settings.
  • The popup shows <balance> left (<spent> spent without a balance; 1.0.3 snapshots replayed after the update fall back to spent, never to the cap-based number). Out of credits reads $0.00 left. A Monthly limit row appears only while the limit ends spending first: auto-reload on, less of it left than of the credits, or reached ($0.00 left).
  • The history's spend counter never mixes in the balance (historyBalance only).
  • amount covers every tranche; the per-tranche remaining in the same answer read one cent less (391) in the probe, so claude.ai's per-tranche table may differ by a cent.

3. Extra usage in the graph

The credit segments were mint (normalColor) on green quota bars, the spend line warning yellow. Now the family credit style of z-usage/chatgpt-usage: one blue (#62c7f5, z's credit blue) for the balance, the 24h/12h/4h/1h spend and the graph segments, through legibleAccent (ported from chatgpt-usage 1.1.0) so it deepens until it reads on light popups, with a lighter top only on dark popups.

Found on the way

  • The first capture showed "Extra us… $7.66 left": the shorter balance let the row's font fit grow across a hinting threshold and the growth loop kept the overflowing step (1.0.3's receipt had called this a capture flake). Ported z-usage 1.1.0's "Cred…" fix and its test.
  • The new profile path made 23 tests ask api.anthropic.com before their stubs were switched; make check now runs the Python suites under tests/netguard/sitecustomize.py (loopback only, a BaseException no except OSError swallows), and tests/test_netguard.py proves the guard is active, also in CI.
  • An expired-login test depended on the real clock being after its fixed NOW.

Validation

  • make verify green: 140 Python tests, 17 cjs suites, translations, rights, social preview; Prettier, ruff clean. CI green on every push.
  • New tests fail on the old code and on each pre-fix review state; a baselined mutation run over the whole change incl. both review rounds ended 54/54.
  • Clock shifts 0, ±30 d, +1 y, +5 y: all suites green.
  • README screenshots retaken in a private Xvfb session with the synthetic fixture (pixel diff: only ring countdowns, the extra usage row, the graph segments and the horizontal panel's third item changed); social preview re-rendered; light-theme probe readable.
  • Independent read-only review, three rounds: round 1 (no blocker, one should-fix, six nits) fixed in 77eb570, round 2 (three nits) fixed in 670374e, round 3 found nothing; its one wording note is in e8a6c4a.

🤖 Generated with Claude Code

Three fixes the owner reported on the live 1.0.3 panel, plus what turned up on the way. Version 1.1.0. ## 1. Model weeks in the panel _Show model-specific limits in the panel_ merged every limit by window duration (`summarizeWindows` keeps the lowest value per duration), so the switch only swapped the 7d item between the all-models week and Fable. `UsageFormat.selectPanelSummaries` keeps the account's 5h/7d (with both panel switches) and appends each model week as an item of its own, with the model letter on its icon, in the label when the icon is hidden, and beside the value (horizontal) or above it (vertical) when icon and labels are hidden. Without an account limit the switch lists every model week; switched off, the merged fallback keeps the panel filled. Settings tooltip added. ## 2. Extra usage amount ($40 vs $10) Root cause, verified with read-only probes (token in memory only, sanitized evidence outside the repo): `/api/oauth/usage` → `extra_usage.monthly_limit` is the **monthly spend limit** (4000 cents = $40 on the owner's account), `used_credits` the spend this month (608). The helper showed `monthly_limit − used_credits` as "left". The purchased credits live at `GET /api/oauth/organizations/<org>/prepaid/credits` (`amount`: 392 cents = $10 − $6.08), the request Claude Code itself sends. - The helper reads the organization UUID from the profile (cached 12 h, cache version 2) and, while extra usage is active, the balance (5 s, like Claude Code). A failed, garbled (huge number, deep JSON) or cancelled request only hides the balance: the refresh never fails for it, keeps the usage answer it already has and caches no failed profile lookup. - `extraUsage.active` follows Claude Code (`is_enabled` or `out_of_credits` / `org_spend_cap_reached` / `org_level_disabled_until`), `limitReached` the spend-limit flags, `outOfCredits` its reason, `autoReload` the prepaid settings. - The popup shows `<balance> left` (`<spent> spent` without a balance; 1.0.3 snapshots replayed after the update fall back to spent, never to the cap-based number). Out of credits reads `$0.00 left`. A _Monthly limit_ row appears only while the limit ends spending first: auto-reload on, less of it left than of the credits, or reached (`$0.00 left`). - The history's spend counter never mixes in the balance (`historyBalance` only). - `amount` covers every tranche; the per-tranche remaining in the same answer read one cent less (391) in the probe, so claude.ai's per-tranche table may differ by a cent. ## 3. Extra usage in the graph The credit segments were mint (`normalColor`) on green quota bars, the spend line warning yellow. Now the family credit style of z-usage/chatgpt-usage: one blue (`#62c7f5`, z's credit blue) for the balance, the 24h/12h/4h/1h spend and the graph segments, through `legibleAccent` (ported from chatgpt-usage 1.1.0) so it deepens until it reads on light popups, with a lighter top only on dark popups. ## Found on the way - The first capture showed "Extra us… $7.66 left": the shorter balance let the row's font fit grow across a hinting threshold and the growth loop kept the overflowing step (1.0.3's receipt had called this a capture flake). Ported z-usage 1.1.0's "Cred…" fix and its test. - The new profile path made 23 tests ask `api.anthropic.com` before their stubs were switched; `make check` now runs the Python suites under `tests/netguard/sitecustomize.py` (loopback only, a `BaseException` no `except OSError` swallows), and `tests/test_netguard.py` proves the guard is active, also in CI. - An expired-login test depended on the real clock being after its fixed `NOW`. ## Validation - `make verify` green: 140 Python tests, 17 cjs suites, translations, rights, social preview; Prettier, ruff clean. CI green on every push. - New tests fail on the old code and on each pre-fix review state; a baselined mutation run over the whole change incl. both review rounds ended 54/54. - Clock shifts 0, ±30 d, +1 y, +5 y: all suites green. - README screenshots retaken in a private Xvfb session with the synthetic fixture (pixel diff: only ring countdowns, the extra usage row, the graph segments and the horizontal panel's third item changed); social preview re-rendered; light-theme probe readable. - Independent read-only review, three rounds: round 1 (no blocker, one should-fix, six nits) fixed in 77eb570, round 2 (three nits) fixed in 670374e, round 3 found nothing; its one wording note is in e8a6c4a. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude agent added 1 commit 2026-10-28 16:06:51 +00:00
Panel model weeks, purchased credits left, extra usage in the credit blue
All checks were successful
Checks / Functional checks (pull_request) Successful in 38s
919f6c9ccb
- "Show model-specific limits in the panel" adds each model week (Fable)
  as a panel item of its own next to 5h and 7d instead of merging it into
  the account's 7d by duration (the switch only swapped the 7d value).
  Without the icon the model letter moves into the label.
- Extra usage shows the purchased credits still left, read from
  /api/oauth/organizations/<org>/prepaid/credits (the organization comes
  from the cached profile), instead of the monthly spend limit minus the
  spent amount ($40 left beside $10 bought). The monthly limit gets a row
  only while it ends spending first; out of credits reads $0.00 left; the
  spend history stays on the spent counter, never the balance.
- Extra usage is drawn in the family credit style: one readable blue for
  the balance, its consumption and the graph segments on the green quota
  bars (legibleAccent and the popup-surface helpers from chatgpt-usage).
- The Python suites run under tests/netguard: loopback only, any other
  lookup or connect fails the test loudly.
- Version 1.1.0, changelog, docs, translations template.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent added 1 commit 2026-10-28 16:10:24 +00:00
Extra usage row: keep a growth step only if the line still fits
All checks were successful
Checks / Functional checks (pull_request) Successful in 37s
89fa454ac6
The capture of the new popup showed "Extra us… $7.66 left": the shorter
purchased balance left the suffix room to grow, and the fit's growth loop
checked before each step, so a step across a font hinting threshold (about
11px) stayed although the line no longer fit and the box squeezed the label.
Port the z-usage 1.1.0 fix ("Cred…"): growth keeps the next whole step only
if the line still fits, a settled size stays, and the tail counts with the
larger of its preferred and painted width. tests/test-credits-fit.js replays
the measured thresholds with Claude's labels and fails on the old loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent added 1 commit 2026-10-28 16:26:05 +00:00
Reached monthly limit reads $0.00 left; tests closing mutation survivors
All checks were successful
Checks / Functional checks (pull_request) Successful in 38s
8e0390912d
- A monthly limit Claude reports as reached (spend_limit_reached or an
  organization cap) reads "$0.00 left", also where monthly_limit − spent
  would leave some, without a known balance and beside empty credits.
- Baselined mutation run over the change: 42/42 mutants fail a suite after
  these additions (real _addCreditItem value color, transparent theme
  nodes, chatgpt's mid-gray accent case, an id-less account limit with a 7d,
  a version-1 profile cache asked again, bare organization UUIDs only).
- tests/test_netguard.py proves the guard is active under make check, also
  in subprocesses.
- Repo skills: a cut "Extra us…" row is the fit, not a capture flake; the
  social preview upload after a release; the first refresh after an update
  may still be the previous version's cached answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent added 1 commit 2026-10-28 16:30:45 +00:00
README screenshots and social preview for 1.1.0
All checks were successful
Checks / Functional checks (pull_request) Successful in 36s
0675d0d8ab
Recaptured in a private Xvfb session from 8e03909 with the synthetic
fixture: usage-menu, usage-menu-horizontal (model weeks in the panel) and
usage-menu-plan-only now show the purchased credits left and the blue extra
usage segments; a pixel diff against the previous set differs only in the
ring countdowns, the extra usage row, the 7d graph segments and the
horizontal panel's third item. panel-tooltip and both settings captures were
pixel-identical and stay as they were. Social preview re-rendered, rights
inventory hashes refreshed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent added 1 commit 2026-10-28 16:45:01 +00:00
Review round 1: garbled answers, cancellation, blocked states, fallbacks
All checks were successful
Checks / Functional checks (pull_request) Successful in 51s
77eb570f39
Fixes for the independent review of 0675d0d (no blocker):
- should-fix: a prepaid/credits amount beyond any float (OverflowError) or
  JSON nested past the parser (RecursionError) crashed the helper; both
  now only hide the balance, a deep profile answer counts as a failed
  lookup and a deep usage answer as an unreadable one (replay).
- A SIGTERM during the profile or balance request is re-raised instead of
  being cached as a failed lookup for an hour; the balance request waits
  5 s like Claude Code's.
- Blocked states read as nothing left even with a missing amount: out of
  credits without a readable balance reads $0.00 left, a reached limit
  shows the limit row without monthly_limit/spent (organization caps).
- Without an account limit the panel switch lists every model week; with
  icon and labels hidden a model item keeps its letter.
- netguard: loopback by address (127.example.com is no loopback name);
  wording about inherited environments.
- Docs: test fixture endpoints and the guard, the shipped README names the
  balance request, the tranche cent next to amount.
- The expired-login test no longer depends on the real clock being after
  its fixed NOW (it reached for the endpoint on a clock 30 days back).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent added 1 commit 2026-10-28 16:57:36 +00:00
Review round 2: a cancel keeps the usage answer; one-row letter
All checks were successful
Checks / Functional checks (pull_request) Successful in 37s
670374eaac
Fixes for the independent review of 77eb570 (no blocker, three nits):
- A SIGTERM during the profile or balance request counts as nothing
  learned, also when urllib wraps it as URLError while connecting: no
  profile failure is cached for an hour, nothing is raised, and the refresh
  ends with the usage answer it already has (saved and noted, so the next
  refresh does not ask the usage endpoint again within the spacing).
- With icon and labels hidden the model letter sits beside the value in
  horizontal panels (one row like the account values), above it in
  vertical ones.
- docs/README: extraUsage.outOfCredits, the out-of-credits display rule
  and the cancel rule; CHANGELOG wording.
- test_netguard checks the loopback decision directly (no lookup), so a
  mutant of the guard can never send a real DNS query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent added 1 commit 2026-10-28 17:06:59 +00:00
Tests for the last two mutation survivors; changelog wording
All checks were successful
Checks / Functional checks (pull_request) Successful in 40s
e8a6c4a829
- An id-less account limit keeps its own 7d with the model weeks out of
  the panel (the merge mutant was equivalent on the switched-on path).
- The balance request's 5 s timeout is asserted.
- CHANGELOG: out of credits reads $0.00 left also without a readable
  balance (review round 3's wording note).

Mutation run over the whole change incl. both review rounds: 54/54.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent merged commit dd90efe724 into main 2026-10-28 17:08:00 +00:00
claude agent deleted branch oss-oo/model-week-panel-and-credits 2026-10-28 17:08:00 +00:00
claude agent referenced this pull request from a commit 2026-10-28 17:18:48 +00:00
claude agent referenced this pull request from a commit 2026-10-28 17:19:35 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
OSS-Singularity/cinnamon-claude-usage!18
No description provided.