Skip to content

fix+feat(daemon): overage-mode usage and per-account-type device screens#83

Open
skie97 wants to merge 4 commits into
HermannBjorgvin:mainfrom
skie97:fix/daemon-overage-mode
Open

fix+feat(daemon): overage-mode usage and per-account-type device screens#83
skie97 wants to merge 4 commits into
HermannBjorgvin:mainfrom
skie97:fix/daemon-overage-mode

Conversation

@skie97

@skie97 skie97 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Started as a zero-display bug in overage mode, then — through three-account probing — became a proper per-account screen design.

The bug. In overage mode the Anthropic API drops the 5h-utilization and 7d-utilization headers entirely. The daemon found nothing, fell back to 0, and sent {"s":0,"w":0,"st":"unknown"} to the device — both bars empty, status unknown.

fix(windows-daemon): report overage-mode usage instead of zeros
Detects overage-in-use: true, marks both windows as 100% / status="overage", prefers the unified-status headline (authoritative across all windows), and falls back to unified-reset when per-window resets are absent. Also fixes a Python 3.12+ regression where asyncio.get_event_loop() raised "no current event loop", silently skipping all 17 poll tests.

fix(daemon): port overage-mode handling to macOS and bash daemons
Same fix applied to claude_usage_daemon.py (macOS) and claude-usage-daemon.sh (bash/Linux) so all three daemons report consistently.

feat(overage): show real Extra Usage instead of two phantom 100% bars
Probing a live overage account showed the API provides overage-utilization and overage-reset. Daemons now carry these as o / or on the wire. Both existing Current/Weekly bars retain their real values — the o/or wire fields are carried for use by the Enterprise screen.

feat(overage): per-account-type device screens (Pro/Max Extra Usage + Enterprise)
A three-account probe (probe_headers.py) showed the discriminator falls straight out of header presence:

Account 5h/7d headers overage-in-use Screen
Pro/Max (normal) present absent Usage (unchanged)
Pro/Max (overage) present true Extra Usage — same two real Current/Weekly pills, amber-yellow banner title
Enterprise absent true Enterprise — overage-utilization spend gauge + mini splash strip

Two new BLE wire fields (oiu, acct) drive the switch. Enterprise allocates the animation strip from PSRAM (100×100 cells) or falls back to internal SRAM (60×60) on PSRAM-free boards (C6). All three firmware targets build green; both screens verified on hardware.

Test plan

  • Pro/Max normal: existing Usage screen unchanged
  • Pro/Max overage: "Extra Usage" amber-yellow banner title, Current/Weekly pills retain real values, second bar shows real overage %
  • Enterprise: spend-gauge screen with mini animations
  • macOS and bash daemons report same overage payloads as Windows

🤖 Generated with Claude Code

skie97 and others added 4 commits June 20, 2026 13:29
In overage mode (subscription allowance spent) the Anthropic API omits the
-5h-/-7d- utilization headers and reports representative-claim=overage. The
daemon read only those windows, hit its "0"/"unknown" defaults, and sent
{"s":0,"w":0,"st":"unknown"} to the device.

- Detect overage via overage-in-use and represent the spent subscription
  windows as full (100%) with status "overage".
- Prefer the unified-status headline; fall back to per-window 5h-status.
- Fall back to unified-reset for the reset timestamps when the per-window
  reset headers are absent.

Also repair the poll test harness: asyncio.get_event_loop() no longer
auto-creates a loop on Python 3.12+ and raised "no current event loop",
silently failing all 17 poll tests (switch to asyncio.run). Adds tests for
overage mode, the status preference, and the unchanged normal path.

Ref: anthropics/claude-code#12829

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
claude_usage_daemon.py (macOS) and claude-usage-daemon.sh (bash/Linux) shared
the same stale rate-limit logic and would also report 0% in overage mode.

Apply the same fix: detect overage via overage-in-use, represent the spent
5h/7d windows as full with status "overage", prefer unified-status, and fall
back to unified-reset. Adds poll tests for the macOS daemon (the bash awk path
was verified to emit identical payloads for normal/overage/empty headers).

Ref: anthropics/claude-code#12829

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
In overage the daemon previously faked both windows to 100%, discarding
the actual overage figure the API provides. The device then showed two
meaningless full bars with no indication of how much extra had been spent.

Carry the real overage spend on the wire and redesign the overage view:
- Daemons (Windows, macOS, bash) add "o" (overage utilization %, from
  anthropic-ratelimit-unified-overage-utilization) and "or" (extra-usage
  reset minutes, from the representative-claim unified reset). Absent
  outside overage -> 0, so no phantom Extra Usage bar.
- Firmware parses o/or and, when status=="overage", relabels the screen:
  title "Extra Usage" in red 48px Tiempos, plan bar 100%/red/"Allowance
  spent", second bar becomes "Extra Usage" driven by the real overage %.
  The existing adaptive format_reset_time (Xd Yh / Xh Ym) renders the reset.

The overage title gets its own size between the existing 34/56 Tiempos
faces: a new pre-compiled 48px LVGL face (font_tiempos_48.c, generated
from assets/TiemposText-400-Regular.otf, patched to LVGL 9 per the font
gotcha). set_title now takes explicit color and y-offset args so the
title color resets cleanly when leaving overage and the shorter 48px
cap-height is nudged 4px down to sit on the same baseline as "Usage".

All changes are in shared, board-agnostic code, so the feature builds for
all three display targets (amoled_216, amoled_18, amoled_216_c6).

Note: "or" is a reserved keyword in awk, so the bash daemon uses a renamed
local while keeping the JSON key "or".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… Enterprise)

Branch the device screen on the account type via two new BLE wire fields:
- oiu (overage-in-use): Pro/Max shows an "Extra Usage" title over the normal
  session/weekly pills (values unchanged — the windows are still real).
- acct ("pro-max"|"ent"), derived from 5h/7d header presence: usage-based
  Enterprise (no subscription windows) gets a dedicated "Enterprise" screen —
  an overage-utilization spend gauge (% of the monthly dollar-spend limit, on
  the normal green/amber/red ramp) + reset, with a row of mini splash
  animations where the second pill would be.

All three daemons (Windows, macOS, bash) + probe_headers.py emit both fields;
data.h/main.cpp parse them; ui.cpp selects the screen, replacing the prior
status=="overage" two-panel "Allowance spent" layout. The Enterprise strip
allocates from PSRAM (100x100 cells) or internal SRAM (60x60) on PSRAM-free
boards (C6). Daemon tests cover the acct/oiu derivation; firmware builds green
on all three envs (216, 18, 216_c6); both screens verified on hardware.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@skie97 skie97 force-pushed the fix/daemon-overage-mode branch from 0701b74 to d696fae Compare June 20, 2026 05:31
@skie97

skie97 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author
clawd-enterprise clawd-extra usage

@pRieStaKos

pRieStaKos commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This overrides the clock feature. Is there any other way to display Enterprise and Extra Usage and keep the clock ?

Suggestion, something like:
Enterprice: put the title above usage, as you have space and move usage below
Extra Usage: change the usage background or the label "Current" to "Extra Usage"

@HermannBjorgvin

Copy link
Copy Markdown
Owner

This overrides the clock feature. Is there any other way to display Enterprise and Extra Usage and keep the clock ?

Suggestion, something like: Enterprice: put the title above usage, as you have space and move usage below Extra Usage: change the usage background or the label "Current" to "Extra Usage"

Suggest changing the "Current" pill on the current session indicator to indicate extra usage instead, i.e. change it from "Current" with a gray background to "Extra usage" with the yellow background and black text.

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.

3 participants