Repository navigation
fix(cursor): distinguish usage failures from expired login - #24575
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 0e811fea1b1d91be1eb02fdd07213d58b5f3c019 and aa07e58. 📒 Files selected for processing (2)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 3f37fcc and 0e811fea1b1d91be1eb02fdd07213d58b5f3c019. 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughfetchDashboardJson now classifies only HTTP 401 responses as expired Cursor sessions. HTTP 403 and 3xx responses use the existing non-OK response handling. Tests cover these statuses and a 403 from the legacy usage endpoint. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The change preserves expired-session guidance for HTTP 401 while other tested HTTP failures retain server-error handling; the supplied evidence shows no remaining actionable merge risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor test-fidelity suggestion inline.
Reviewed changes
- Cursor HTTP classification (
src/main/rate-limits/cursor-fetcher.ts): the auth branch narrows tores.status === 401, so 403 and redirect-status responses now fall through to the genericCursor usage request failed (HTTP <status>)result withfailureKind: 'server'instead ofstale-token. Theredirect: 'manual'comment is reworded. - Regression coverage (
src/main/rate-limits/cursor-fetcher.test.ts): the "redirect → expired sign-in" test is replaced by anit.each([403, 302, 304])case asserting the HTTP status andserverkind, plus a new legacy-endpoint 403 case.
The production change is small and correct: 401 and the local isCursorSessionTokenExpired check still produce the actionable login message, the service stale policy only special-cases rate-limited (so server vs stale-token changes no caching behavior), and the renderer's Cursor stale-token copy is unaffected. The only note below concerns which responses the new test can actually observe.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| it.each([403, 302, 304])('reports HTTP %i without claiming the login expired', async (status) => { | ||
| netFetchMock.mockResolvedValueOnce(jsonResponse({}, status, { location: '/login' })) | ||
| const limits = await fetchCursorRateLimits({ authReadResult: session() }) | ||
| expect(limits.usageMetadata?.failureKind).toBe('stale-token') | ||
| expect(limits.error).toContain('cursor-agent login') | ||
| expect(limits.usageMetadata?.failureKind).toBe('server') | ||
| expect(limits.error).toBe(`Cursor usage request failed (HTTP ${status})`) | ||
| expect(limits.usageMetadata?.authProvenance).toBeTruthy() | ||
| expect(netFetchMock.mock.calls[0]?.[1]?.redirect).toBe('manual') | ||
| }) |
There was a problem hiding this comment.
The 302 case reportedly pins a branch production never reaches: real Electron net.fetch with redirect: 'manual' rejects 302/307 before returning a Response (the loopback behavior recorded in #23626, where it was found the login-path matcher could not work for this reason). A dashboard login redirect therefore surfaces as a thrown error → failureKind: 'network', not server/HTTP 302, so this case gives false confidence about redirect handling. The reworded comment at line 85 ("Keep dashboard redirects visible") reads the same way. Consider dropping 302 (or asserting the reject → network path) and narrowing the comment to 304, which does return a response.
0e811fe to
aa07e58
Compare
Keep Cursor quota requests tied to the selected account by omitting ambient Electron session credentials. Preserve explicit account cookies and redirect handling. Credit: Li-Sanze for the original credential-mode fix in #23626, carried through #24575; jjongsta and chengjiaxiao for the reports. Native HTTP/HTTPS cookie isolation, mutation controls and proxy behavior were verified before merging. This does not claim to resolve the separate initial-authentication failure in #23612.

ELI5
A refused Cursor usage request could tell users their login had expired even when Orca had no evidence of that. Orca now reports the HTTP failure instead.
What Changed
Before, HTTP 401, 403, and any redirect all became “Cursor sign-in expired.” After, only HTTP 401 or the existing local token-expiry check produces that message. Other responses retain their HTTP status and account fingerprint through the existing error result, on both usage endpoints. Requests still use manual redirects; transport failures stay generic and reveal no request credentials.
Why
A forbidden response does not establish token expiry. This independently reimplements the reviewed classification approach from #23626, with credit to @Li-Sanze, rather than adding another account subsystem. It addresses the misleading message; the account-specific failure behind #23612 remains unverified.
Linked Issue
Refs #23612
Visual Proof
N/A — no renderer layout change. Deterministic before/after: a synthetic HTTP 403 previously classified as
stale-tokenand displayed login-expiry guidance; the same response now reportsCursor usage request failed (HTTP 403)with failure kindserver. Regression cases cover both the summary and legacy usage routes, and 302/304 responses. No real account response or UI screenshot is claimed.Testing
ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/rate-limits/cursor-fetcher.test.ts src/main/rate-limits/service-cursor-usage.test.ts— 25 passed.ORCA_BACKGROUND_LAUNCH=1 pnpm tcand changed-lines quality gate passed.AI Disclosure
Implemented with Codex.
Review
Reviewed existing #23626 and tested the current source implementation. Existing 401, local expiry, rate-limit, and server-error behavior remain covered. No HTTP body, cookie, or account identity is exposed.
Agent skill upstream boundary
Notes
Shared host-side fetcher serves existing desktop/mobile results. No platform-specific logic, wire changes, workspace assumptions, or SSH routing changes. Live usage and rendered notification proof remain outside this narrow classification fix.
Checklist