Skip to content

feat: account spend-pace rows and auth self-recovery#39

Open
oyardena wants to merge 3 commits into
CodeZeno:mainfrom
oyardena:feat/account-usage-rows
Open

feat: account spend-pace rows and auth self-recovery#39
oyardena wants to merge 3 commits into
CodeZeno:mainfrom
oyardena:feat/account-usage-rows

Conversation

@oyardena

@oyardena oyardena commented Jun 20, 2026

Copy link
Copy Markdown

Summary

  • Add enterprise Mo/Wk/Dy spend-pace rows (and credit/spend display) for account usage when rate-limit buckets are absent
  • Fix stuck taskbar ! after auth failures: keep last-good values, actively retry polls on a timer, and refresh Claude tokens on 401
  • Repair stuck spend anchors that zeroed week/day, plus embedded drag / leftmost tray positioning fixes

Test plan

  • cargo test --release (10 passed)
  • Deployed local WinGet binary with --diagnose; boot refreshed expired token and rendered pace rows (credit_pct=100)
  • Confirm widget no longer sticks on ! after forcing an auth hiccup (expire token / disconnect briefly)
  • Confirm Mo/Wk/Dy update after normal Claude usage and remain correct across day/week rollover

@oyardena
oyardena force-pushed the feat/account-usage-rows branch from c87c9e6 to fa5c927 Compare June 20, 2026 15:54
For users on an enterprise Claude plan (no five-hour / seven-day rate-limit
buckets), the widget now shows two dedicated rows:

  Cr  9%·20/6   — credit remaining (%) and expiry date in system locale format
  Sp  $12/$50   — spend used / spend limit

For personal (Pro/Free) accounts the rows continue to show the normal 5h/7d
rate-limit bars.

Implementation notes:
- Parses `cinder_cove` and `spend` fields from the usage endpoint response
- Locale-aware date format via GetLocaleInfoW (respects separator and D/M order)
- Disk cache at %APPDATA%\ClaudeCodeUsageMonitor\account_cache.json survives
  widget restarts; cleared when plan has no enterprise fields (prevents stale
  enterprise rows appearing for Pro users after a 429)
- Tray tooltip uses dynamic row labels ("Cr"/"Sp" vs "5h"/"7d")
- tray_icon.rs: guard empty text before DrawTextW to avoid GDI crash
@oyardena
oyardena force-pushed the feat/account-usage-rows branch from fa5c927 to a8be4f8 Compare June 21, 2026 20:08
oyardena added 2 commits June 29, 2026 15:29
- native_interop: add move_window_async (SetWindowPos + SWP_ASYNCWINDOWPOS)
  to reposition WS_CHILD windows in Explorer without cross-process blocking;
  add detach_from_taskbar, raise_above_taskbar, TIMER_DRAG constant
- window: fix drag in embedded mode — replace early-return + move_window with
  move_window_async; poll mouse via TIMER_DRAG (16 ms) instead of SetCapture
  (SetCapture on a taskbar child freezes Explorer)
- window: widen drag-handle hit target from 3 px to 10 logical px
  (LEFT_DIVIDER_HIT_W) without changing the visual divider width; this makes
  the handle reliably hittable at high DPI (e.g. 20 physical px at 200% DPI)
- window: add verbose diagnose logging to WM_LBUTTONDOWN / is_drag_handle_point
  / start_drag_reposition / TIMER_DRAG / update_drag_reposition_from_cursor
- window: spawn_taskbar_watchdog improvements — detect stale embeds via window
  parentage check (GetParent) rather than HWND equality; post WM_APP_RECOVER_TASKBAR
  to re-attach without relaunching on transient failures; relaunch only after
  TASKBAR_RECOVER_MAX_ATTEMPTS consecutive failures
- spend_pace: new module; .cargo/config.toml: linker config for MinGW cross-build
Keep last-good Mo/Wk/Dy instead of painting !, retry auth polls on a
timer rather than only credential-file mtime changes, and refresh Claude
tokens on 401. Also repair stuck spend anchors and leftmost tray defaults.
@oyardena oyardena changed the title feat: display enterprise account credit and spend usage rows feat: account spend-pace rows and auth self-recovery Jul 14, 2026
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.

1 participant