fix+feat(daemon): overage-mode usage and per-account-type device screens#83
fix+feat(daemon): overage-mode usage and per-account-type device screens#83skie97 wants to merge 4 commits into
Conversation
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>
0701b74 to
d696fae
Compare
|
This overrides the clock feature. Is there any other way to display Enterprise and Extra Usage and keep the clock ? Suggestion, something like: |
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. |


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-utilizationand7d-utilizationheaders entirely. The daemon found nothing, fell back to0, 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 zerosDetects
overage-in-use: true, marks both windows as 100% /status="overage", prefers theunified-statusheadline (authoritative across all windows), and falls back tounified-resetwhen per-window resets are absent. Also fixes a Python 3.12+ regression whereasyncio.get_event_loop()raised "no current event loop", silently skipping all 17 poll tests.fix(daemon): port overage-mode handling to macOS and bash daemonsSame fix applied to
claude_usage_daemon.py(macOS) andclaude-usage-daemon.sh(bash/Linux) so all three daemons report consistently.feat(overage): show real Extra Usage instead of two phantom 100% barsProbing a live overage account showed the API provides
overage-utilizationandoverage-reset. Daemons now carry these aso/oron the wire. Both existing Current/Weekly bars retain their real values — theo/orwire 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:overage-in-usetruetrueTwo 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
🤖 Generated with Claude Code