Skip to content

fix(cursor): prefer GetCurrentPeriodUsage and label the real window - #190

Merged
CodeZeno merged 1 commit into
CodeZeno:mainfrom
arshcaria:fix/cursor-current-period-usage
Oct 25, 2026
Merged

CodeZeno merged 1 commit into
CodeZeno:mainfrom
arshcaria:fix/cursor-current-period-usage

Conversation

@arshcaria

Copy link
Copy Markdown
Contributor

Summary

Cursor monitoring only read the dashboard /api/usage-summary endpoint, which can describe a stale monthly period with zero usage while Cursor itself shows the current allowance from its application service (see #186 for a side-by-side comparison: summary reported 0% for October 1–November 1, GetCurrentPeriodUsage reported ~7% in an October 19–26 window).

  • Prefer GetCurrentPeriodUsage (bearer + empty JSON POST), and fall back to the dashboard summary when the internal endpoint is unavailable or returns no plan usage.
  • Parse the application-service response defensively (epoch-millisecond bounds as string or number, percentage fields under planUsage with snake_case aliases, flexible numeric types) and log the response keys when the expected shape is missing.
  • Derive the displayed session window from the returned billingCycleStart/billingCycleEnd bounds via a new optional session_label (mirrors weekly_label), so a seven-day window reads 7d instead of the default 5h. Exposed to themes as {provider}.session.label and used in the tray summary.

Closes #186

Testing

  • cargo fmt --all -- --check
  • cargo test --locked — 568 passed (6 new tests, including the live response shape from Cursor shows 0% and monthly reset while GetCurrentPeriodUsage reports 7% in a weekly window #186: string epoch-millisecond bounds, planUsage percentages, seven-day label derivation, fallback triggers for disabled/empty payloads, and bearer-token extraction from the cookie forms)
  • cargo build --locked --release
  • Live account verification against the issue reporter's Cursor login is still needed for the undocumented application-service endpoint; the summary fallback remains in place if its shape drifts.

Checklist

  • I have read CONTRIBUTING.md and CODE_OF_CONDUCT.md.
  • The change is focused and contains no credentials or sensitive data.
  • I have added or updated relevant documentation and tests, where applicable.
  • I have left changelog and version changes to maintainers unless requested.

The dashboard usage-summary endpoint can report a stale monthly period with
zero usage while Cursor itself shows the current allowance from its
application service. Query GetCurrentPeriodUsage first and fall back to the
summary, then derive the session window label from the returned billing-cycle
bounds so a seven-day window is not displayed as the default five-hour one.

Fixes CodeZeno#186
@CodeZeno
CodeZeno merged commit 89112d5 into CodeZeno:main Oct 25, 2026
CodeZeno added a commit that referenced this pull request Oct 25, 2026
Resolve Cursor issue #186 with PR #190 and defensive fallback handling.
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.

Cursor shows 0% and monthly reset while GetCurrentPeriodUsage reports 7% in a weekly window

2 participants