Skip to content

Always remaining 500 times again. #15

Description

@qwe0001

Issue Description

This extension is currently displaying a hardcoded value of 500 requests instead of fetching the actual remaining usage from the Cursor API.
This appears to be related to recent changes in Cursor's pricing model from a fixed monthly request limit to a dollar-based usage system.

Root Cause Analysis

1. Hardcoded Total Requests

File: dist/statusBar.js:29

const TOTAL_REQUESTS = 500;  // ❌ Hardcoded value

2. Deprecated API Endpoint

File: dist/extension.js (minified)

The extension is using the old API endpoint:

// Old endpoint that no longer returns request counts
async function F(e,s){return x(`usage?user=${e}`,s)}

3. Fallback to Hardcoded Value

The code falls back to the hardcoded 500 when the API doesn't return the expected data:

// In the minified extension.js
let g=n["gpt-4"].maxRequestUsage||500;  // ❌ Falls back to 500

Proposed Solution

1. Update API Endpoint

Replace the deprecated /usage?user=${userId} endpoint with the new /usage-summary endpoint:

// New API call
async function fetchUsageSummary(cookie) {
    return fetch('https://cursor.com/api/usage-summary', {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'Cookie': `WorkosCursorSessionToken=${cookie}`
        }
    });
}

2. Remove Hardcoded Values

File: src/statusBar.js

// ❌ Remove this line
const TOTAL_REQUESTS = 500;

// ✅ Use dynamic values from API
function updateStatusBar(usageData) {
    const { individualUsage } = usageData;
    const { used, limit, remaining } = individualUsage.plan;
    
    // Convert cents to dollars
    const usedDollars = (used / 100).toFixed(2);
    const limitDollars = (limit / 100).toFixed(2);
    const remainingDollars = (remaining / 100).toFixed(2);
    
    statusBarItem.text = `⚡ Remaining $${remainingDollars} ($${usedDollars} / $${limitDollars})`;
}

3. Update Data Processing

File: src/extension.js

// Replace the old usage fetching logic
const usageData = await fetchUsageSummary(cookie);
const { individualUsage } = usageData;

// Use the new API response structure
const used = individualUsage.plan.used;      // in cents
const limit = individualUsage.plan.limit;    // in cents  
const remaining = individualUsage.plan.remaining; // in cents

New API Response Structure

The /usage-summary endpoint returns:

{
  "individualUsage": {
    "plan": {
      "used": 1664,      // 16.64 USD in cents
      "limit": 2000,     // 20.00 USD in cents
      "remaining": 336   // 3.36 USD in cents
    }
  },
  "billingCycleEnd": "2025-11-10T07:17:43.000Z"
}

Expected Behavior After Fix

  • Status bar should display: ⚡ Remaining $3.36 ($16.64 / $20.00)
  • Dynamic updates based on actual usage
  • Proper warning states when approaching limits
  • Accurate billing cycle information

Thanks for making such a super cool extension!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions