Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
Reviewed by Codex gpt-6-luna (xhigh); verified and validated by Claude Adversarial review of #636 (Cursor cost 403 cooldown) against upstream v0.66.0 (
No other defects found: 403 is typed and does not invalidate the session, 401/503 start no cooldown, the cookie is only stored as a SHA-256 fingerprint, no lock is held across an await, and the Commands run: |
|
Adversarial validation (Claude Opus 5.5) passed at 24db68a Scope: GAP-32, the Cursor cost 403 cooldown, plus the codex-2 review fix in 24db68a.
Compared with upstream v0.66.0 (
Checks run at this SHA (toolchain 1.98.0, isolated target dir):
|
… cost requests for six hours
Summary
POST https://cursor.com/api/dashboard/get-filtered-usage-eventsis now a typed cost-only rejection (TokenCostError::CostRequestForbidden) instead ofProviderError::AuthRequired. It never touches the usage session or the validated app-session cache; quota usage and the local-CSV fallback are unchanged.Origin: https://cursor.com(upstream documents it as a CSRF requirement for these POST endpoints).cost_cooldown.rs) because the shell builds a fresh provider for every refresh. It is bounded to 32 credentials and prunes expired entries. The clock is injectable for tests.CursorApinow holds its base URL (defaulthttps://cursor.com) so the existingmockitoapproach can drive it; production behavior is unchanged.Upstream reference
1c0f70e3).Sources/CodexBarCore/Providers/Cursor/CursorUsageEventsFetcher.swift(fetchPageOrigin header,validatecase 403),CursorStatusProbe.swift(costRequestForbidden),Sources/CodexBar/UsageStore+TokenCost.swift(tokenFetchFailureRetryDelay=max(ttl, 6 h), timeout keepsttl,tokenRefreshFailureIsCoolingDown),docs/cursor.md(Caching paragraph).Ported / Deferred
Ported: typed 403, six-hour in-memory cooldown scoped per credential,
Originheader, timeout and transient failures keep the normal cadence, quota session and CSV fallback untouched, restart clears state.Deferred:
FetchContexthas no force signal (checkedrust/src/core/provider.rs; the shell'sforceflag incommands/providers.rsonly reaches the refresh lock, not the provider). Adding one is cross-provider plumbing, which this PR avoids. Until then only a changed credential or a restart recovers early;codexbarCLI runs are separate processes and always retry.max(cadence, 6 h). Win-CodexBar's slowest refresh interval is 30 minutes, so the six-hour floor is always the binding term and a constant is used; the provider does not know the cadence.default_since) is fixed, so the credential fingerprint is the only scope here. Note a rotating cookie value (same account, new token) retries early, which is the previous behavior.Validation
Toolchain
cargo +1.98.0, process-local target dir.cargo +1.98.0 fmt --all: clean.cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: pass, no warnings.cargo +1.98.0 test -p codexbar cursor: 62 passed, 0 failed. New tests:cost_cooldown::tests(5): six-hour boundary (6 h - 1 scooling,6 hnot), per-credential isolation,clear, bounded map with expired-entry pruning, fingerprint hides the cookie.token_cost::tests(4,mockito): 403 maps toCostRequestForbidden(notAuthRequired), 401 staysAuthRequired, 503 stays a generic failure, the request carriesOriginequal to the base URL.cursor::tests(5,mockito, injected clock): 403 events + 200 usage-summary gives exactly one events request across two fetches inside the window with identical usage and cost output; retried at exactly the six-hour mark; a different Cookie retries immediately while the first stays parked; 503 starts no cooldown (two events requests); a successful response after the window ends the cooldown.core,settings,cost_scanner); fullcargo test -p codexbarnot run.Affected areas
Rust backend, Cursor provider only (
rust/src/providers/cursor/{api,mod,token_cost,cost_cooldown}.rs). No Tauri shell, frontend, settings, dependency, or wire-shape changes beyond the documentedOriginheader.UI proof
Not applicable (no UI surface changes).