fix(usage): fetch and compute Cursor quota/usage - #3367
Open
Villoh wants to merge 1 commit into
Open
Conversation
9Router never called any Cursor usage endpoint — getUsageForProvider had no cursor handler in USAGE_HANDLERS, so the dashboard just showed "Usage API not implemented for cursor". - open-sse/providers/registry/cursor.js: register the Connect RPC usage/plan endpoints (api2.cursor.sh DashboardService) and flip features.usage so cursor joins USAGE_SUPPORTED_PROVIDERS. - open-sse/services/usage/cursor.js: new handler — POSTs GetCurrentPeriodUsage (Bearer auth, empty proto body), maps totalPercentUsed/autoPercentUsed/apiPercentUsed into the same percent-quota shape claude/codex use, with plan name from the optional GetPlanInfo call. - open-sse/services/usage.js: wire cursor into USAGE_HANDLERS. - ProviderLimits/utils.js: add the cursor case to parseQuotaData. - tests/unit/cursor-usage.test.js: request shape, percent mapping, fallback ratio, and error-path coverage. Scope: individual/Pro percent-of-limit accounts only. Team/enterprise pooled-dollar accounts and the request-based legacy fallback (cursor.com/api/usage + CSV export) aren't covered — noted in the registry comment for whoever picks that up next. Verified against a live Cursor Pro connection in the dashboard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
api2.cursor.shDashboardService/GetCurrentPeriodUsage+GetPlanInfo) in the provider registry and flipfeatures.usageso cursor joinsUSAGE_SUPPORTED_PROVIDERSgetCursorUsage(open-sse/services/usage/cursor.js): POSTsGetCurrentPeriodUsagewith the existing Bearer token + empty proto body, mapstotalPercentUsed/autoPercentUsed/apiPercentUsedinto the same percent-quota shape Claude/Codex already use, with a best-effort plan name fromGetPlanInfoUSAGE_HANDLERSand add thecursorcase toparseQuotaDataRoot cause
getUsageForProviderhad nocursorentry inUSAGE_HANDLERSat all, so every Cursor connection just fell through to the generic{ message: "Usage API not implemented for cursor" }fallback — no request was ever made and the dashboard never showed real quota data.Scope
Individual/Pro percent-of-limit accounts only. Team/enterprise pooled-dollar accounts and the request-based legacy fallback (
cursor.com/api/usage+ CSV export) aren't covered — noted inline in the registry so it's easy to pick up if reports come in from those account shapes.Tests
cd tests && npx vitest run unit/cursor-usage.test.js(new — request shape, percent mapping, ratio fallback, error paths)node tests/__baseline__/verify-providers.mjs(registry snapshot re-verified byte-for-byte, only the newusage/featuresfields differ, both already excluded from the diff check)