@@ -25,7 +25,7 @@ import type { KimiHomeResolution } from '../kimi/kimi-runtime-home'
2525import { fetchGrokRateLimits } from './grok-fetcher'
2626import { readGrokAuthSession } from './grok-auth'
2727import { fetchCursorRateLimits } from './cursor-fetcher'
28- import { readCursorAuthSession } from './cursor-auth'
28+ import { readCursorAuthSession , type CursorAuthReadResult } from './cursor-auth'
2929import { hasMiniMaxSessionCookie } from '../minimax/minimax-cookie-store'
3030import { fetchMiniMaxRateLimits } from './minimax-fetcher'
3131import { fetchOpenCodeGoRateLimits } from './opencode-go-usage-fetcher'
@@ -115,6 +115,10 @@ type InternalRateLimitState = {
115115 cursor : ProviderRateLimits | null
116116}
117117
118+ function cursorAccountIdentity ( readResult : CursorAuthReadResult ) : string | null {
119+ return readResult . status === 'ok' ? readResult . session . userId : null
120+ }
121+
118122function normalizePollingInterval ( ms : number ) : number {
119123 if ( ! Number . isFinite ( ms ) ) {
120124 return DEFAULT_POLL_MS
@@ -1765,6 +1769,7 @@ export class RateLimitService {
17651769 this . grokAuthConfigured = grokAuthReadResult . status === 'ok'
17661770 const cursorAuthReadResult = readCursorAuthSession ( )
17671771 this . cursorAuthConfigured = cursorAuthReadResult . status === 'ok'
1772+ const cursorAccountId = cursorAccountIdentity ( cursorAuthReadResult )
17681773
17691774 // Discard stale data on config change — it belongs to a different session/workspace.
17701775 const currentConfigHash = `${ cookie } |${ workspaceIdOverride } `
@@ -2043,6 +2048,12 @@ export class RateLimitService {
20432048 if ( signal . aborted ) {
20442049 return
20452050 }
2051+ const latestCursorAuthReadResult = readCursorAuthSession ( )
2052+ this . cursorAuthConfigured = latestCursorAuthReadResult . status === 'ok'
2053+ if ( cursorAccountIdentity ( latestCursorAuthReadResult ) !== cursorAccountId ) {
2054+ this . updateState ( { ...this . state , cursor : null } )
2055+ return
2056+ }
20462057 const cursor =
20472058 cursorResult . status === 'fulfilled'
20482059 ? cursorResult . value
@@ -2250,6 +2261,7 @@ export class RateLimitService {
22502261 const previousState = this . state
22512262 const cursorAuthReadResult = readCursorAuthSession ( )
22522263 this . cursorAuthConfigured = cursorAuthReadResult . status === 'ok'
2264+ const cursorAccountId = cursorAccountIdentity ( cursorAuthReadResult )
22532265
22542266 this . updateState ( {
22552267 ...previousState ,
@@ -2274,6 +2286,13 @@ export class RateLimitService {
22742286 return
22752287 }
22762288
2289+ const latestCursorAuthReadResult = readCursorAuthSession ( )
2290+ this . cursorAuthConfigured = latestCursorAuthReadResult . status === 'ok'
2291+ if ( cursorAccountIdentity ( latestCursorAuthReadResult ) !== cursorAccountId ) {
2292+ this . updateState ( { ...this . state , cursor : null } )
2293+ return
2294+ }
2295+
22772296 this . trackActiveFailureStreak ( 'cursor' , cursor )
22782297 this . updateState ( {
22792298 ...this . state ,
0 commit comments