feat: free debate discovery and budget-limit copy - #70
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughHTTP 402 handling now distinguishes missing API keys from host budget exhaustion across debate and OCR flows. API-key parsing and budget messages are generalized, tests are expanded, and the welcome hero adds session-aware free-debate eligibility hints. ChangesHTTP 402 handling and free debate
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant WelcomeHero
participant FreeDebateAPI
participant UserAPIKeys
User->>WelcomeHero: Open welcome screen
WelcomeHero->>FreeDebateAPI: Check free-debate eligibility
WelcomeHero->>UserAPIKeys: Check saved API keys
FreeDebateAPI-->>WelcomeHero: Eligibility state
UserAPIKeys-->>WelcomeHero: API-key state
WelcomeHero-->>User: Render localized free-debate hint
Possibly related PRs
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/WelcomeHero.tsx`:
- Around line 327-349: Update the useEffect request flow in WelcomeHero so it
creates an AbortController, passes its signal to both fetch calls in decide, and
aborts the controller during cleanup alongside setting cancelled. Ensure the
promise handling ignores the expected abort error while preserving handling for
other failures and preventing stale state updates.
- Around line 333-340: Update the grant readiness condition in the WelcomeHero
data-loading logic to use grant.active rather than negating it. Preserve the
existing remaining-call and hasKey checks so the “ready” hint appears only for
users with an active grant and no saved API key.
- Around line 333-340: Update the free-debate readiness logic in the WelcomeHero
grant/key-status flow so an unavailable or non-OK user API keys response fails
closed instead of being treated as having no keys. Require a valid key-status
result before returning "ready", while preserving the existing saved-key
detection and grant eligibility checks.
In `@src/hooks/useDebateEngine.ts`:
- Around line 415-416: Require blocked?.kind === "no_key" before treating a 402
response as an API-key issue: update the handler around
src/hooks/useDebateEngine.ts lines 415-416 to call onApiKeyRequired only for
that kind and otherwise show a generic request failure; update lines 715-721 to
use the missing-consensus-key message only for no_key and analysis failure for
unclassified responses; apply the same explicit-kind guard in the stopped-debate
consensus flow at lines 844-853.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: c11e91c4-ffe8-4821-84e4-9c3eaceca4cd
📒 Files selected for processing (5)
src/__tests__/api-key-errors.test.tssrc/components/WelcomeHero.tsxsrc/hooks/useDebateEngine.tssrc/lib/api-key-errors.tssrc/lib/file-parser.ts
📜 Review details
🧰 Additional context used
🪛 React Doctor (0.7.6)
src/components/WelcomeHero.tsx
[warning] 327-327: fetch() inside useEffect can race, double-fire, or leak. Use a data-fetching layer or Server Component instead.
Use a data-fetching layer or Server Component so fetches do not race, double-fire, or leak from useEffect.
(no-fetch-in-effect)
🔇 Additional comments (6)
src/lib/api-key-errors.ts (1)
14-50: LGTM!src/__tests__/api-key-errors.test.ts (1)
4-62: LGTM!src/hooks/useDebateEngine.ts (1)
11-13: LGTM!Also applies to: 561-565
src/lib/file-parser.ts (1)
4-4: LGTM!Also applies to: 253-256
src/components/WelcomeHero.tsx (2)
4-9: LGTM!Also applies to: 28-38, 392-405
324-350: 🎯 Functional CorrectnessRecompute eligibility when the user identity changes.
The effect is keyed only by authentication status, but
/api/free-debateand/api/user-api-keysare user-specific. If account switching changes session data while status remains"authenticated", the previous account’s hint can persist. Include a stable session user identifier in the dependency list, or verify thatWelcomeHeroremounts on account changes.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f3f478b60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Shows the free-debate offer on the welcome screen and separates daily budget limits from missing-key errors in 402 handling.
Review fixes applied: 5a087d1 - configured-flag key check, fetch abort on cleanup, budget copy promises only unused grants.