Claude Usage Monitor 0.1.0 — Claude plan usage with sign-in reuse, Fable weeks and login renewal #1

Merged
ClaudiuSchuster merged 8 commits from oss-oo/claude-usage-0.1.0 into main 2026-10-27 00:50:59 +00:00
Owner

The third applet of the OSS Singularity usage family: Claude Usage Monitor (claude-usage@oss-singularity), forked from cinnamon-z-usage 1.0.10 with shared history.

Claude Usage Monitor

What it does

  • Reads GET https://api.anthropic.com/api/oauth/usage (the request the Claude apps send): 5-hour session, all-models week, model- and surface-scoped weeks such as Fable, extra usage; plan pill from the login (Max 20x).
  • Sign-in sources in order (setting → CLAUDE_CODE_OAUTH_TOKEN → token file → Claude Code login), falling through on 401/403. The setting token reaches the helper through its environment, never argv.
  • Expired Claude Code logins (8 h) are renewed by Claude Code itself (claude auth login with CLAUDE_CODE_OAUTH_REFRESH_TOKEN), switchable, on by default; the applet never writes credentials.
  • Without any sign-in: Claude Desktop's own usage samples (percentages only), rows without reset times stay clean.
  • Launchers: Claude Desktop deep links for chat and Claude Code, web/CLI fallbacks, setup help.

Validation

  • make check: 68 Python tests, 13 CJS suites, translation template, schema, icons, rights inventory, ShellCheck, social preview.
  • Two independent review rounds by a fresh agent (first round: no blockers, all majors/minors fixed; second round on the fix delta).
  • Isolated Xvfb captures (11 variants) from a synthetic fixture; masked token widget proof in the real Cinnamon settings widget chain.
  • Live on Cinnamon 6.6.9: copy install + targeted ReloadXlet, unchanged Cinnamon PID, 24/24 payload files byte-identical, live data matching the Claude app (5h reset 03:50, weekly Fri 07:00, Fable week).

Not affiliated with or endorsed by Anthropic.

🤖 Generated with Claude Code

The third applet of the OSS Singularity usage family: **Claude Usage Monitor** (`claude-usage@oss-singularity`), forked from cinnamon-z-usage 1.0.10 with shared history. ![Claude Usage Monitor](https://oss-oo.io/OSS-Singularity/cinnamon-claude-usage/raw/commit/c9999a092fb57b9c9b9af747c485677d548edc62/.github/social-preview.png) ## What it does - Reads `GET https://api.anthropic.com/api/oauth/usage` (the request the Claude apps send): 5-hour session, all-models week, model- and surface-scoped weeks such as **Fable**, extra usage; plan pill from the login (`Max 20x`). - Sign-in sources in order (setting → `CLAUDE_CODE_OAUTH_TOKEN` → token file → Claude Code login), falling through on 401/403. The setting token reaches the helper through its environment, never argv. - Expired Claude Code logins (8 h) are renewed by Claude Code itself (`claude auth login` with `CLAUDE_CODE_OAUTH_REFRESH_TOKEN`), switchable, on by default; the applet never writes credentials. - Without any sign-in: Claude Desktop's own usage samples (percentages only), rows without reset times stay clean. - Launchers: Claude Desktop deep links for chat and Claude Code, web/CLI fallbacks, setup help. ## Validation - `make check`: 68 Python tests, 13 CJS suites, translation template, schema, icons, rights inventory, ShellCheck, social preview. - Two independent review rounds by a fresh agent (first round: no blockers, all majors/minors fixed; second round on the fix delta). - Isolated Xvfb captures (11 variants) from a synthetic fixture; masked token widget proof in the real Cinnamon settings widget chain. - Live on Cinnamon 6.6.9: copy install + targeted `ReloadXlet`, unchanged Cinnamon PID, 24/24 payload files byte-identical, live data matching the Claude app (5h reset 03:50, weekly Fri 07:00, Fable week). Not affiliated with or endorsed by Anthropic. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fork cinnamon-z-usage 1.0.10 into claude-usage@oss-singularity:

- claude_usage.py reads GET /api/oauth/usage (5-hour session, all-models
  week, Sonnet/Opus and model-scoped weeks, extra usage) with the first
  token from the masked setting, CLAUDE_CODE_OAUTH_TOKEN, the token file
  or the Claude Code login; logins are read, never refreshed. Without a
  usable token it falls back to the samples Claude Desktop records in
  plan-usage-history.json.
- The applet setting reaches the helper through its environment instead
  of the world-readable command line.
- Plan pill from the login or the cached profile endpoint, extra usage in
  currency, desktop deep links for the Claude and Claude Code launchers.
- Original coral artwork, warm brand gradient, recolored social preview
  and fresh isolated captures from a synthetic fixture.
- Z.ai-only code, settings, captures, receipts and project skills removed;
  tests rewritten for the Claude backend (53 Python tests, 12 CJS suites).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Scoped weekly limits accept a model or a surface name, so Fable (and
  surface weeks) appear like in the Claude apps.
- The "Via Claude Desktop" status block is gone; the fallback reason stays
  in source.reason for diagnosis only.
- Rows without a reset time (Claude Desktop samples) skip the reset line
  and the empty countdown ring instead of reading "unknown".
- Capture fixture and docs show Fable as the model week.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude's resets_at carries sub-second noise (02:49:59.97); truncation
showed 03:49:59 instead of 03:50:00.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- New "Renew the Claude Code login automatically" switch (on by default):
  an expired login is renewed by the official CLI (`claude auth login`
  with CLAUDE_CODE_OAUTH_REFRESH_TOKEN/SCOPES in a minimal environment);
  the helper never writes credentials, failed attempts wait 30 minutes.
- Sign-in sources fall through on 401/403; the popup shows the helper's
  concrete sign-in reason.
- Model graphs (Fable, ...) open by default with their sections.
- Extra usage history counts spend, not the remaining cap; unknown spend
  reads "on".
- Hardening from the independent review: refused redirects, redacted
  server errors, cached profile failures, private cache files, ms/garbage
  timestamps, non-UTF-8 files, history dedupe, Python 3.10 ISO forms,
  token character validation, "Claude" skipped in model badges.
- Tests are hermetic against real CLIs (68 Python tests, 13 CJS suites).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fresh captures with the Fable week and open model graphs
All checks were successful
Checks / Functional checks (pull_request) Successful in 45s
c9999a092f
README pairs the vertical overview with the horizontal-panel popup (the
history view now equals the overview), social preview mentions Fable,
inventories refreshed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Always-open model graphs and a bold C in the usage emblem
All checks were successful
Checks / Functional checks (pull_request) Successful in 33s
354314961b
- Model weeks (Fable, ...) render their 24-hour graphs like the account
  windows under "<model> · 7d usage"; the collapsible history leaf and its
  default-open logic are gone (owner: KISS).
- The applet and panel icons carry a bold C inside the quota ring, the
  counterpart of the Z in cinnamon-z-usage.
- Fresh captures, social preview and rights inventory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Show only the decimals a percentage really has
All checks were successful
Checks / Functional checks (pull_request) Successful in 34s
55274dc074
Claude reports whole percents: 5.00% read like a precision the data never
carried. Values below ten keep up to two real decimals (0.5%, 2.25%), the
capture fixture uses whole percents, screenshots refreshed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Make login renewal an opt-in, detached re-login; second review fixes
All checks were successful
Checks / Functional checks (pull_request) Successful in 36s
4c16397916
Second independent review of the renewal delta:
- `claude auth login` with a refresh token is a complete re-login (it
  replaces every login the CLI stores and resets its trusted-device state),
  so "Renew the Claude Code login automatically" is now opt-in (off).
- The CLI runs in its own session, is waited for but never killed (no
  sign-out between token rotation and save), under a lock, with
  exponential backoff (30 min .. 12 h), no retry once the refresh token
  expired, proxy/CA/telemetry variables passed through, cwd=$HOME, and a
  fresh expiresAt as the success proof.
- Tests can never reach a real CLI (default stubs, real-clock logins far in
  the future); verified with the clock set to 2030.
- Every sign-in failure reason is kept; an open popup follows sign-in and
  error changes; "Claude sign-in needed" title.
- Plausible timestamps only (2000..3000), zero-decimal currencies in the
  backend too, CLAUDE_CONFIG_DIR stripped from the API test environment.
- Docs describe the opt-in re-login, the CLI's own network/telemetry and
  every CLI location.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ClaudiuSchuster deleted branch oss-oo/claude-usage-0.1.0 2026-10-27 00:50:59 +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!1
No description provided.