Skip to content

Add Cursor provider support#59

Merged
prakersh merged 4 commits intoonllm-dev:mainfrom
LeslieLeung:feature/cursor
Apr 18, 2026
Merged

Add Cursor provider support#59
prakersh merged 4 commits intoonllm-dev:mainfrom
LeslieLeung:feature/cursor

Conversation

@LeslieLeung
Copy link
Copy Markdown
Contributor

No description provided.

Made-with: Cursor

# Conflicts:
#	internal/config/config.go
@prakersh prakersh self-requested a review April 13, 2026 18:08
Copy link
Copy Markdown
Contributor

@prakersh prakersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Add Cursor Provider Support

Solid provider implementation - follows the established pattern well and has good test coverage across all layers. A few things to address before merge:


Blocking

ParseIntString overflows on 32-bit (cursor_types.go)
Returns int (32-bit on 32-bit systems). Billing timestamps like "1768399334000" exceed int32 max. Fix: return int64 or use strconv.ParseInt.

Duplicate account type detection (cursor_client.go + cursor_types.go)
FetchQuotas and ToCursorSnapshot both detect account type independently. FetchQuotas then overwrites what ToCursorSnapshot set, but has extra logic (request-based -> enterprise promotion) the other doesn't. Pick one place to own this.

cursorTestMode data race (cursor_token.go)
Package-level bool read by production code and written by tests without synchronization. Will fail under -race. Use atomic.Bool.


Should fix

  • Platform file duplication - cursor_token_unix.go and cursor_token_windows.go duplicate readCursorStateValue, buildCursorAuthState nearly verbatim. Extract shared logic to cursor_token.go.

  • macOS path hardcoded in !windows build - getCursorStateDBPath returns ~/Library/Application Support/Cursor/... on Linux too. Should check runtime.GOOS == "darwin" and use ~/.config/Cursor/... on Linux.

  • Unbounded io.ReadAll in RefreshCursorToken - every other HTTP read in this file uses io.LimitReader. Be consistent.

  • No menubar integration - other providers are wired into menubar.go. Cursor quotas won't appear in the macOS status bar.

  • insightStat struct change - adding Key/Metric/Severity/Desc to the shared struct works (fields are omitempty), but consider whether Cursor-specific enrichment deserves its own type.


Nits

  • Missing newline at EOF in CURSOR_SETUP.md
  • Whitespace-only changes in unrelated code (codexProfileSave, stripProviderSecrets) - adds git blame noise
  • cursorAuthToCredentials appears unused outside tests - possible dead code
  • goto processSnapshot matches existing pattern in anthropic_agent.go but remains hard to follow

What's good

  • Clean pattern compliance across all 6 layers
  • Thorough tests at every level (types, client, token detection, store, tracker, agent, handlers)
  • Token redaction, parameterized SQL, LimitReader on most reads
  • Three account types (Individual/Team/Enterprise) with appropriate quota formats
  • Auto-detection from SQLite + Keychain/keyring with refresh token rotation
  • Full dashboard wiring: charts, burn rate forecasts, cycle tracking, logging history

Nice work overall - the blocking issues are small fixes.

Copy link
Copy Markdown
Contributor

@prakersh prakersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Add Cursor Provider Support

Solid provider implementation - follows the established pattern well and has good test coverage across all layers. A few things to address before merge:


Blocking

ParseIntString overflows on 32-bit (cursor_types.go)
Returns int (32-bit on 32-bit systems). Billing timestamps like "1768399334000" exceed int32 max. Fix: return int64 or use strconv.ParseInt.

Duplicate account type detection (cursor_client.go + cursor_types.go)
FetchQuotas and ToCursorSnapshot both detect account type independently. FetchQuotas then overwrites what ToCursorSnapshot set, but has extra logic (request-based -> enterprise promotion) the other doesn't. Pick one place to own this.

cursorTestMode data race (cursor_token.go)
Package-level bool read by production code and written by tests without synchronization. Will fail under -race. Use atomic.Bool.


Should fix

  • Platform file duplication - cursor_token_unix.go and cursor_token_windows.go duplicate readCursorStateValue, buildCursorAuthState nearly verbatim. Extract shared logic to cursor_token.go.

  • macOS path hardcoded in !windows build - getCursorStateDBPath returns ~/Library/Application Support/Cursor/... on Linux too. Should check runtime.GOOS == "darwin" and use ~/.config/Cursor/... on Linux.

  • Unbounded io.ReadAll in RefreshCursorToken - every other HTTP read in this file uses io.LimitReader. Be consistent.

  • No menubar integration - other providers are wired into menubar.go. Cursor quotas won't appear in the macOS status bar.

  • insightStat struct change - adding Key/Metric/Severity/Desc to the shared struct works (fields are omitempty), but consider whether Cursor-specific enrichment deserves its own type.


Nits

  • Missing newline at EOF in CURSOR_SETUP.md
  • Whitespace-only changes in unrelated code (codexProfileSave, stripProviderSecrets) - adds git blame noise
  • cursorAuthToCredentials appears unused outside tests - possible dead code
  • goto processSnapshot matches existing pattern in anthropic_agent.go but remains hard to follow

What's good

  • Clean pattern compliance across all 6 layers
  • Thorough tests at every level (types, client, token detection, store, tracker, agent, handlers)
  • Token redaction, parameterized SQL, LimitReader on most reads
  • Three account types (Individual/Team/Enterprise) with appropriate quota formats
  • Auto-detection from SQLite + Keychain/keyring with refresh token rotation
  • Full dashboard wiring: charts, burn rate forecasts, cycle tracking, logging history

Nice work overall - the blocking issues are small fixes.

…esponding test case

- Updated `applyRefreshedCredentials` method to return false on save failure.
- Added a new test `TestCursorAgent_ApplyRefreshedCredentials_FailsWhenSaveFails` to verify behavior when token saving fails.
- Refactored `FetchQuotas` to streamline account type determination and removed unused code.
- Enhanced `ToCursorSnapshot` to include request-based usage logic.
- Updated various tests to accommodate changes in function signatures and behavior.
@prakersh
Copy link
Copy Markdown
Contributor

prakersh commented Apr 17, 2026

Hi @LeslieLeung - thanks for the quick turnaround on 3231cd6. Verified that all blocking and should-fix items from the earlier review are addressed:

  • ParseIntStringint64
  • cursorTestModeatomic.Bool
  • Account-type detection consolidated in ToCursorSnapshot
  • Platform token files deduplicated
  • Linux state DB path handled via cursorStateDBPathForOS
  • RefreshCursorToken using io.LimitReader consistently
  • Menubar integration wired up with tests

Looks good to me - happy to approve. One thing before we merge: the branch is currently behind main by 6 commits and showing conflicts. Could you rebase/merge main in and resolve them? Once that's clean, we're good to go.

Copy link
Copy Markdown
Contributor

@prakersh prakersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed all blocking/should-fix items addressed. Security review clean - no new vulnerabilities introduced. LGTM.

@prakersh prakersh merged commit a8be5cb into onllm-dev:main Apr 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants