Skip to content

Commit 3640561

Browse files
committed
fix: Cursor 사용량 모델 구분 수정
1 parent 2ab42a9 commit 3640561

13 files changed

Lines changed: 123 additions & 118 deletions

File tree

‎docs/reference/cursor-usage-tracking.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ Platform paths:
2121

2222
## UI mapping
2323

24-
Plan total lives in `monthly`. Auto and API are named `buckets` (not Session/Weekly labels).
24+
Cursor's two included model pools are named `buckets` (not Session/Weekly labels). Orca does not synthesize a combined monthly percentage because Cursor does not show one on its dashboard.
2525

2626
| Orca field | Cursor source |
2727
|------------|----------------|
28-
| `monthly` | `individualUsage.plan.used / limit` (fallback: `totalPercentUsed`, auto/api average) |
29-
| `buckets` | `Auto` ← `autoPercentUsed`, `API` ← `apiPercentUsed`, `On-demand` ← `onDemand.used / limit` when enabled |
28+
| `monthly` | always `null` |
29+
| `buckets` | wire names `Auto` ← `autoPercentUsed`, `API` ← `apiPercentUsed`, `On-demand` ← `onDemand.used / limit` when enabled; UI shows `Cursor Models` and `Other Models` |
3030
| `session` / `weekly` | always `null` |
3131
| Reset | `billingCycleEnd` |
3232
| Auth label | cached email, `/api/auth/me`, or membership type |

‎src/main/rate-limits/cursor-fetcher.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('fetchCursorRateLimits', () => {
8989
expect(netFetchMock).not.toHaveBeenCalled()
9090
})
9191

92-
it('maps Cursor included and on-demand usage into monthly meters', async () => {
92+
it('maps Cursor dashboard model pools without a synthetic monthly total', async () => {
9393
const token = makeJwt({ sub: 'auth0|cursor-user', exp: 4_102_444_800 })
9494
dbState.token = token
9595
dbState.email = '[email protected]'
@@ -100,7 +100,7 @@ describe('fetchCursorRateLimits', () => {
100100
const result = await fetchCursorRateLimits()
101101
expect(result.status).toBe('ok')
102102
expect(result.provider).toBe('cursor')
103-
expect(result.monthly?.usedPercent).toBe(60)
103+
expect(result.monthly).toBeNull()
104104
expect(result.session).toBeNull()
105105
expect(result.weekly).toBeNull()
106106
expect(result.buckets).toEqual([

‎src/main/rate-limits/cursor-fetcher.ts‎

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import type {
55
RateLimitWindow,
66
UsageRateLimitMetadata
77
} from '../../shared/rate-limit-types'
8+
import {
9+
CURSOR_MODELS_BUCKET_NAME,
10+
ON_DEMAND_BUCKET_NAME,
11+
OTHER_MODELS_BUCKET_NAME
12+
} from '../../shared/cursor-usage-buckets'
813
import {
914
buildCursorCookieHeader,
1015
isCursorAccessTokenFresh,
@@ -18,11 +23,8 @@ const API_TIMEOUT_MS = 15_000
1823
const MONTHLY_WINDOW_MINUTES = 43_200
1924

2025
type CursorPlanUsage = {
21-
used?: number
22-
limit?: number
2326
autoPercentUsed?: number
2427
apiPercentUsed?: number
25-
totalPercentUsed?: number
2628
}
2729

2830
type CursorUsageSummary = {
@@ -107,30 +109,6 @@ function makeWindow(usedPercent: number, resetsAtIso: string | undefined): RateL
107109
}
108110
}
109111

110-
function resolvePlanPercent(summary: CursorUsageSummary): number {
111-
const plan = summary.individualUsage?.plan
112-
const fromIncludedUsage = percentFromCents(plan?.used, plan?.limit)
113-
if (fromIncludedUsage !== null) {
114-
return fromIncludedUsage
115-
}
116-
const totalPercent = normalizePercent(plan?.totalPercentUsed)
117-
if (totalPercent !== null) {
118-
return totalPercent
119-
}
120-
const autoPercent = normalizePercent(plan?.autoPercentUsed)
121-
const apiPercent = normalizePercent(plan?.apiPercentUsed)
122-
if (autoPercent !== null && apiPercent !== null) {
123-
return clampPercent((autoPercent + apiPercent) / 2)
124-
}
125-
if (apiPercent !== null) {
126-
return apiPercent
127-
}
128-
if (autoPercent !== null) {
129-
return autoPercent
130-
}
131-
return 0
132-
}
133-
134112
function mapUsageSummary(
135113
summary: CursorUsageSummary,
136114
userInfo: CursorUserInfo | null,
@@ -146,13 +124,13 @@ function mapUsageSummary(
146124
const buckets: RateLimitBucket[] = []
147125
if (autoPercent !== null) {
148126
buckets.push({
149-
name: 'Auto',
127+
name: CURSOR_MODELS_BUCKET_NAME,
150128
...makeWindow(autoPercent, summary.billingCycleEnd)
151129
})
152130
}
153131
if (apiPercent !== null) {
154132
buckets.push({
155-
name: 'API',
133+
name: OTHER_MODELS_BUCKET_NAME,
156134
...makeWindow(apiPercent, summary.billingCycleEnd)
157135
})
158136
}
@@ -162,7 +140,7 @@ function mapUsageSummary(
162140
: null
163141
if (onDemandPercent !== null) {
164142
buckets.push({
165-
name: 'On-demand',
143+
name: ON_DEMAND_BUCKET_NAME,
166144
...makeWindow(onDemandPercent, summary.billingCycleEnd)
167145
})
168146
}
@@ -171,7 +149,7 @@ function mapUsageSummary(
171149
provider: 'cursor',
172150
session: null,
173151
weekly: null,
174-
monthly: makeWindow(resolvePlanPercent(summary), summary.billingCycleEnd),
152+
monthly: null,
175153
...(buckets.length > 0 ? { buckets } : {}),
176154
planType: membership ?? null,
177155
updatedAt: Date.now(),

‎src/renderer/src/components/settings/CursorAccountsSection.tsx‎

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import { useAppStore } from '../../store'
77
import { Button } from '../ui/button'
88
import { Badge } from '../ui/badge'
99
import type { CursorAccountStatus } from '../../../../shared/rate-limit-types'
10+
import {
11+
CURSOR_MODELS_BUCKET_NAME,
12+
ON_DEMAND_BUCKET_NAME,
13+
OTHER_MODELS_BUCKET_NAME
14+
} from '../../../../shared/cursor-usage-buckets'
1015
import { SearchableSetting } from './SearchableSetting'
1116

1217
const CURSOR_DOCS_URL = 'https://cursor.com/docs'
@@ -52,10 +57,18 @@ export function CursorAccountsSection(): React.JSX.Element {
5257

5358
const signedIn = status?.signedIn === true
5459
const tokenFresh = status?.tokenFresh === true
55-
const usageWindow = cursorUsage?.monthly ?? null
56-
const autoBucket = cursorUsage?.buckets?.find((b) => b.name === 'Auto')
57-
const apiBucket = cursorUsage?.buckets?.find((b) => b.name === 'API')
58-
const onDemandBucket = cursorUsage?.buckets?.find((b) => b.name === 'On-demand')
60+
const cursorModelsBucket = cursorUsage?.buckets?.find(
61+
(bucket) => bucket.name === CURSOR_MODELS_BUCKET_NAME
62+
)
63+
const otherModelsBucket = cursorUsage?.buckets?.find(
64+
(bucket) => bucket.name === OTHER_MODELS_BUCKET_NAME
65+
)
66+
const onDemandBucket = cursorUsage?.buckets?.find(
67+
(bucket) => bucket.name === ON_DEMAND_BUCKET_NAME
68+
)
69+
const billingReset = cursorUsage?.buckets?.find(
70+
(bucket) => bucket.resetDescription
71+
)?.resetDescription
5972

6073
return (
6174
<section id="accounts-cursor" className="space-y-4 scroll-mt-6">
@@ -155,43 +168,34 @@ export function CursorAccountsSection(): React.JSX.Element {
155168
</Button>
156169
</div>
157170

158-
{usageWindow || autoBucket || apiBucket || onDemandBucket ? (
171+
{cursorModelsBucket || otherModelsBucket || onDemandBucket ? (
159172
<SearchableSetting
160173
title={translate(
161174
'auto.components.settings.CursorAccountsSection.a8f3e2c1b4',
162175
'Plan usage'
163176
)}
164177
description={translate(
165178
'auto.components.settings.CursorAccountsSection.b7e2d9f0a3',
166-
'Same plan, Auto, API, and on-demand usage as the Cursor dashboard.'
179+
'Cursor Models, Other Models, and on-demand usage from the Cursor dashboard.'
167180
)}
168-
keywords={['cursor', 'usage', 'subscription', 'plan', 'auto', 'api']}
181+
keywords={['cursor', 'usage', 'subscription', 'plan', 'models', 'on-demand']}
169182
>
170183
<div className="flex flex-wrap items-center gap-2 text-xs">
171-
{usageWindow ? (
172-
<Badge variant="secondary" className="tabular-nums">
173-
{translate(
174-
'auto.components.settings.CursorAccountsSection.d5e0b7c3a1',
175-
'Plan {{pct}}%',
176-
{ pct: String(Math.round(usageWindow.usedPercent)) }
177-
)}
178-
</Badge>
179-
) : null}
180-
{autoBucket ? (
184+
{cursorModelsBucket ? (
181185
<Badge variant="secondary" className="tabular-nums">
182186
{translate(
183187
'auto.components.settings.CursorAccountsSection.e4f1c8d2b0',
184-
'Auto {{pct}}%',
185-
{ pct: String(Math.round(autoBucket.usedPercent)) }
188+
'Cursor Models {{pct}}%',
189+
{ pct: String(Math.round(cursorModelsBucket.usedPercent)) }
186190
)}
187191
</Badge>
188192
) : null}
189-
{apiBucket ? (
193+
{otherModelsBucket ? (
190194
<Badge variant="secondary" className="tabular-nums">
191195
{translate(
192196
'auto.components.settings.CursorAccountsSection.f3a2d9e1c7',
193-
'API {{pct}}%',
194-
{ pct: String(Math.round(apiBucket.usedPercent)) }
197+
'Other Models {{pct}}%',
198+
{ pct: String(Math.round(otherModelsBucket.usedPercent)) }
195199
)}
196200
</Badge>
197201
) : null}
@@ -204,12 +208,12 @@ export function CursorAccountsSection(): React.JSX.Element {
204208
)}
205209
</Badge>
206210
) : null}
207-
{usageWindow?.resetDescription ? (
211+
{billingReset ? (
208212
<span className="text-muted-foreground">
209213
{translate(
210214
'auto.components.settings.CursorAccountsSection.c6d1a8f4e2',
211215
'Resets {{when}}',
212-
{ when: usageWindow.resetDescription }
216+
{ when: billingReset }
213217
)}
214218
</span>
215219
) : null}

‎src/renderer/src/components/stats/CursorUsagePane.test.tsx‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,21 @@ const mockStoreState = {
2929
provider: 'cursor',
3030
session: null,
3131
weekly: null,
32-
monthly: {
33-
usedPercent: 60,
34-
windowMinutes: 43_200,
35-
resetsAt: null,
36-
resetDescription: 'Aug 1'
37-
},
32+
monthly: null,
3833
buckets: [
3934
{
4035
name: 'Auto',
4136
usedPercent: 45,
4237
windowMinutes: 43_200,
4338
resetsAt: null,
44-
resetDescription: null
39+
resetDescription: 'Aug 1'
4540
},
4641
{
4742
name: 'API',
4843
usedPercent: 30,
4944
windowMinutes: 43_200,
5045
resetsAt: null,
51-
resetDescription: null
46+
resetDescription: 'Aug 1'
5247
},
5348
{
5449
name: 'On-demand',
@@ -118,9 +113,9 @@ describe('CursorUsagePane', () => {
118113
render(<CursorUsagePane />)
119114

120115
expect(screen.getByTestId('cursor-usage-pane')).toBeInTheDocument()
121-
expect(screen.getByText('Auto')).toBeInTheDocument()
116+
expect(screen.getByText('Cursor Models')).toBeInTheDocument()
122117
expect(screen.getByText('45%')).toBeInTheDocument()
123-
expect(screen.getByText('API')).toBeInTheDocument()
118+
expect(screen.getByText('Other Models')).toBeInTheDocument()
124119
expect(screen.getByText('30%')).toBeInTheDocument()
125120
expect(screen.getByText('On-demand')).toBeInTheDocument()
126121
expect(screen.getByText('20%')).toBeInTheDocument()

‎src/renderer/src/components/stats/CursorUsagePane.tsx‎

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { Button } from '../ui/button'
66
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip'
77
import { StatCard } from './StatCard'
88
import { formatUpdatedAt } from './usage-formatters'
9+
import {
10+
CURSOR_MODELS_BUCKET_NAME,
11+
ON_DEMAND_BUCKET_NAME,
12+
OTHER_MODELS_BUCKET_NAME
13+
} from '../../../../shared/cursor-usage-buckets'
914

1015
export function CursorUsagePane(): React.JSX.Element {
1116
const cursor = useAppStore((s) => s.rateLimits.cursor)
@@ -63,20 +68,23 @@ export function CursorUsagePane(): React.JSX.Element {
6368
)
6469
}
6570

66-
const monthlyPercent =
67-
cursor?.monthly && typeof cursor.monthly.usedPercent === 'number'
68-
? Math.round(cursor.monthly.usedPercent)
69-
: null
70-
const autoPercent = (() => {
71-
const used = cursor?.buckets?.find((b) => b.name === 'Auto')?.usedPercent
71+
const cursorModelsPercent = (() => {
72+
const used = cursor?.buckets?.find(
73+
(bucket) => bucket.name === CURSOR_MODELS_BUCKET_NAME
74+
)?.usedPercent
7275
return typeof used === 'number' ? Math.round(used) : null
7376
})()
74-
const apiPercent = (() => {
75-
const used = cursor?.buckets?.find((b) => b.name === 'API')?.usedPercent
77+
const otherModelsPercent = (() => {
78+
const used = cursor?.buckets?.find(
79+
(bucket) => bucket.name === OTHER_MODELS_BUCKET_NAME
80+
)?.usedPercent
7681
return typeof used === 'number' ? Math.round(used) : null
7782
})()
83+
const billingReset = cursor?.buckets?.find((bucket) => bucket.resetDescription)?.resetDescription
7884
const onDemandPercent = (() => {
79-
const used = cursor?.buckets?.find((b) => b.name === 'On-demand')?.usedPercent
85+
const used = cursor?.buckets?.find(
86+
(bucket) => bucket.name === ON_DEMAND_BUCKET_NAME
87+
)?.usedPercent
8088
return typeof used === 'number' ? Math.round(used) : null
8189
})()
8290
const isFetching = isRefreshing || cursor?.status === 'fetching'
@@ -123,20 +131,15 @@ export function CursorUsagePane(): React.JSX.Element {
123131
</div>
124132
</div>
125133

126-
<div className="grid gap-3 md:grid-cols-2 xl:grid-cols-5">
134+
<div className="grid gap-3 md:grid-cols-2 xl:grid-cols-4">
127135
<StatCard
128-
label={translate('auto.components.stats.CursorUsagePane.a1b2c3d4e5', 'Plan usage')}
129-
value={monthlyPercent !== null ? `${monthlyPercent}%` : '—'}
136+
label={translate('auto.components.stats.CursorUsagePane.a8b9c0d1e2', 'Cursor Models')}
137+
value={cursorModelsPercent !== null ? `${cursorModelsPercent}%` : '—'}
130138
icon={<Sparkles className="size-4" />}
131139
/>
132140
<StatCard
133-
label={translate('auto.components.stats.CursorUsagePane.a8b9c0d1e2', 'Auto')}
134-
value={autoPercent !== null ? `${autoPercent}%` : '—'}
135-
icon={<Sparkles className="size-4" />}
136-
/>
137-
<StatCard
138-
label={translate('auto.components.stats.CursorUsagePane.b9c0d1e2f3', 'API')}
139-
value={apiPercent !== null ? `${apiPercent}%` : '—'}
141+
label={translate('auto.components.stats.CursorUsagePane.b9c0d1e2f3', 'Other Models')}
142+
value={otherModelsPercent !== null ? `${otherModelsPercent}%` : '—'}
140143
icon={<Sparkles className="size-4" />}
141144
/>
142145
<StatCard
@@ -149,7 +152,7 @@ export function CursorUsagePane(): React.JSX.Element {
149152
'auto.components.stats.CursorUsagePane.b2c3d4e5f6',
150153
'Billing period reset'
151154
)}
152-
value={cursor?.monthly?.resetDescription ?? '—'}
155+
value={billingReset ?? '—'}
153156
icon={<CalendarClock className="size-4" />}
154157
/>
155158
</div>

‎src/renderer/src/components/status-bar/StatusBar.tsx‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ import type {
4848
RateLimitRuntimeTarget,
4949
RateLimitWindow
5050
} from '../../../../shared/rate-limit-types'
51+
import {
52+
CURSOR_MODELS_BUCKET_NAME,
53+
getUsageBucketDisplayName,
54+
OTHER_MODELS_BUCKET_NAME
55+
} from '../../../../shared/cursor-usage-buckets'
5156
import { resolveLocalAccountRuntimeTarget } from '../../../../shared/local-account-runtime'
5257
import { getRendererAppPlatform } from '../../lib/renderer-app-platform'
5358
import {
@@ -1172,8 +1177,14 @@ function getProviderLetter(provider: ProviderRateLimits['provider']): string {
11721177
// ---------------------------------------------------------------------------
11731178

11741179
// Why: Gemini exposes extra experimental buckets that made the pre-existing verbose footer noisy.
1175-
// Cursor Auto/API are first-class lanes (same role as Gemini Flash/Pro).
1176-
const STATUS_BAR_BUCKET_NAMES = new Set(['Flash', 'Pro', '1.5 Pro', 'Auto', 'API'])
1180+
// Cursor model pools are first-class lanes (same role as Gemini Flash/Pro).
1181+
const STATUS_BAR_BUCKET_NAMES = new Set([
1182+
'Flash',
1183+
'Pro',
1184+
'1.5 Pro',
1185+
CURSOR_MODELS_BUCKET_NAME,
1186+
OTHER_MODELS_BUCKET_NAME
1187+
])
11771188

11781189
function VerboseProviderUsage({
11791190
p,
@@ -1191,7 +1202,8 @@ function VerboseProviderUsage({
11911202
<React.Fragment key={bucket.name}>
11921203
{index > 0 ? <span className="text-muted-foreground">·</span> : null}
11931204
<span className="tabular-nums">
1194-
{bucket.name} {formatUsagePercentageLabel(bucket.usedPercent, display)}
1205+
{getUsageBucketDisplayName(p.provider, bucket.name)}{' '}
1206+
{formatUsagePercentageLabel(bucket.usedPercent, display)}
11951207
</span>
11961208
</React.Fragment>
11971209
))}

0 commit comments

Comments
 (0)