Skip to content

Fix plan display showing wrong tier and usage stuck at 0%#6

Open
amanzainal wants to merge 2 commits intobabakarto:masterfrom
amanzainal:fix/plan-display-and-usage-parsing
Open

Fix plan display showing wrong tier and usage stuck at 0%#6
amanzainal wants to merge 2 commits intobabakarto:masterfrom
amanzainal:fix/plan-display-and-usage-parsing

Conversation

@amanzainal
Copy link
Copy Markdown

Summary

Fixes #5 — Plan indicator showed "Max 5x" instead of the correct "Max 20x", and session/weekly usage were stuck at 0%.

Root causes:

  • Plan name was derived from the locally cached rateLimitTier in ~/.claude/.credentials.json, which can become stale after a plan change
  • Usage parsing only looked for field names like daily_usage/session_limit etc., but the actual Claude API returns five_hour/seven_day objects with a utilization percentage field

Changes:

  • _resolve_plan_name() — new static method that parses rateLimitTier strings into clean plan names with multiplier (e.g. "default_claude_max_20x""Max 20x")
  • _fetch_oauth_direct() — new primary OAuth fetch path using api.anthropic.com/api/oauth/usage (same endpoint as upstream macOS CodexBar), which returns five_hour/seven_day with utilization percentages
  • _enrich_plan_from_account() — fetches the live rate_limit_tier from /api/oauth/account to get the accurate plan with multiplier, even when CLI is the usage data source
  • _parse_api_usage() update — web API fallback now also handles five_hour/seven_day + utilization response format

Test plan

  • Verified _resolve_plan_name() correctly maps all tier strings (Max 5x/20x, Pro, Team, Enterprise, Free, Ultra)
  • Verified /api/oauth/usage returns live utilization data (session 35%, weekly 43%)
  • Verified /api/oauth/account returns live rate_limit_tier: "default_claude_max_20x"
  • Confirmed CodexBar displays "Max 20x" and live usage percentages after the fix

- Add _resolve_plan_name() to parse rateLimitTier strings into clean
  plan names with multiplier (e.g. "default_claude_max_20x" -> "Max 20x")
- Add _fetch_oauth_direct() using api.anthropic.com/api/oauth/usage
  endpoint which returns five_hour/seven_day utilization percentages
- Add _enrich_plan_from_account() to fetch live rate_limit_tier from
  /api/oauth/account, fixing stale local credentials showing wrong plan
- Update _parse_api_usage() to handle the actual Claude API response
  format (five_hour/seven_day with utilization field)

Fixes babakarto#5
- Dark mode: full dark palette for Claude tab with warm gradient,
  toggled via ☾/☀ button, persisted to ~/.codexbar/config.json
- Compact mode: minimal layout showing only plan badge and usage
  bars, hides cost section and footer, toggled via ⤒/⤓ button
- Pin to top: keeps popup open when clicking away, toggled via
  📋/📌 button with visual indicator
- Draggable: click and drag the tab bar to reposition the popup
- All preferences persist across restarts
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.

Max 20x plan shows as Max 5x, session/weekly usage stuck at 0%

1 participant