Skip to content

Re-add silent usage API polling with exponential backoff - #8

Merged
stevensouza merged 1 commit into
mainfrom
stevensouza/remove-usage-polling
Mar 2, 2026
Merged

stevensouza merged 1 commit into
mainfrom
stevensouza/remove-usage-polling

Conversation

@stevensouza

Copy link
Copy Markdown
Owner

Summary

Usage API polling is valuable for frequent updates (every 5 min, free, no tokens) and richer data (per-model breakdowns). Rather than removing it, re-add with silent degradation: on 429s, exponential backoff (max 30 min) with no user-facing errors. Ping data fills in seamlessly when API is unavailable.

Key improvements:

  • Silent backoff: 429s logged to NSLog only, not event log
  • Configurable polling: 1-10 min picker in settings (default: 5 min)
  • Smart merging: Usage data from polling + pings (latest wins)
  • Sleep/wake aware: Pauses polling on sleep, resumes on wake
  • Max backoff: 30 min (tolerates extended outages without aggressive retries)

Test plan

  1. Deploy and verify plan tier detection works
  2. Check event log — clean entries, no 429 errors polluting it
  3. Open Settings — verify polling picker present with 1/2/5/10 min options
  4. Monitor usage updates — should see "Usage API OK" entries
  5. If 429 occurs — check Console.app for silent NSLog entries, not event log

🤖 Generated with Claude Code

The usage API provides richer data (per-model breakdowns) and can poll frequently without consuming tokens. Rather than removing it entirely, re-add with silent degradation: on 429s, back off exponentially (max 30 min) without user-facing error messages. When working, provides updates every 5 min (configurable). When failing, ping data fills in seamlessly.

Key improvements over previous version:
- No @published lastError — silent backoff, no UI errors
- NSLog only for 429s, not event log pollution
- Default 5 min polling interval (was 60s, too aggressive)
- Max backoff 30 min (was 600s, better during outages)
- Settings picker back for user control (1-10 min options)
- Usage data merges from two sources: polling + pings
- Sleep/wake aware: pauses polling on sleep, resumes on wake

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@stevensouza
stevensouza merged commit ee31c9e into main Mar 2, 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