Add support for Gemini 3 Pro Preview and Sonnet 4.5#991
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe PR refactors bulk email processing to track processed emails by ID instead of count, adds UI messaging for empty results, and introduces two new LLM models (Claude 4.5 Sonnet and Gemini 3 Pro Preview) with corresponding cost configurations. Version updated to v2.20.10. Changes
Sequence DiagramsequenceDiagram
participant UI as BulkRunRules UI
participant Handler as onRun Handler
participant Queue as Thread Queue
participant Callback as Parent Component
Note over UI,Callback: Old Flow (Count-based)
UI->>Handler: Click Run
loop Process batches
Handler->>Queue: Process threads
Handler->>Callback: incrementThreadsQueued(count)
end
Handler->>Callback: onComplete()
Note over UI,Callback: New Flow (ID-based)
UI->>Handler: Click Run
Handler->>Handler: Initialize runResult=null
loop Process batches
Handler->>Handler: Accumulate threadIds
Handler->>Callback: onThreadsQueued(threadIds[])
Handler->>Handler: Update processedThreadIds Set
end
Handler->>Handler: Compute final count
Handler->>Callback: onComplete(totalProcessed)
Handler->>UI: Display runResult (count or empty message)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/web/app/(app)/[emailAccountId]/assistant/BulkRunRules.tsx(10 hunks)apps/web/utils/llms/config.ts(1 hunks)apps/web/utils/llms/model.ts(1 hunks)apps/web/utils/usage.ts(2 hunks)version.txt(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
apps/web/utils/llms/model.ts (1)
apps/web/utils/llms/config.ts (1)
Model(17-37)
apps/web/app/(app)/[emailAccountId]/assistant/BulkRunRules.tsx (1)
apps/web/components/Typography.tsx (1)
SectionDescription(127-127)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: test
🔇 Additional comments (7)
apps/web/app/(app)/[emailAccountId]/assistant/BulkRunRules.tsx (4)
31-33: LGTM! Clean refactor to ID-based tracking.The shift from count-based to Set-based tracking enables accurate progress monitoring even when threads complete out of order or when processing is interrupted and resumed.
Also applies to: 45-47, 51-54
90-94: LGTM! Proper state reset on date changes.Resetting both
runResultandprocessedThreadIdswhen the date range changes ensures the UI accurately reflects the new query parameters.Also applies to: 100-104
135-150: LGTM! Well-structured callback pattern.The callback design enables real-time progress updates (
onThreadsQueued) while preserving final state (onComplete). The conditionalrunResultassignment correctly targets the empty-results case for display in the UI below.
184-265: LGTM! Robust batch processing with proper callback integration.The batch fetching loop correctly:
- Paginates through threads using
nextPageToken- Filters threads without plans to avoid reprocessing
- Notifies the UI via
onThreadsQueuedbefore queuing work- Reports final count via
onComplete- Handles errors and respects abort signals
apps/web/utils/llms/config.ts (1)
26-26: LGTM! Model constants follow existing conventions.The new entries align with the established naming pattern and are properly integrated with
model.ts(default selection) andusage.ts(cost tracking).Also applies to: 33-33
apps/web/utils/usage.ts (1)
89-89: Pricing verified as correct.Claude Sonnet 4.5 on OpenRouter is priced at $3.00 per 1M input tokens and $15.00 per 1M output tokens, which matches the constants defined in the code. No updates needed.
apps/web/utils/llms/model.ts (1)
101-101: Model verified as available and correctly configured.Claude Sonnet 4.5 is available on OpenRouter with the model ID
anthropic/claude-sonnet-4.5(oranthropic/claude-sonnet-4-5—both formats are accepted). The code uses the correct format and the model is production-ready.
| "google/gemini-3-pro-preview": { | ||
| input: 2 / 1_000_000, | ||
| output: 12 / 1_000_000, | ||
| }, |
There was a problem hiding this comment.
🧩 Analysis chain
Verify Gemini 3 Pro Preview pricing.
Confirm the pricing for google/gemini-3-pro-preview ($2/$12 per 1M tokens) matches the current OpenRouter rates before deployment.
🌐 Web query:
What is the pricing for Gemini 3 Pro Preview on OpenRouter?
💡 Result:
OpenRouter charges the Google (Gemini 3 Pro Preview) pass‑through rates — Gemini 3 Pro Preview is billed at $2 per 1M input tokens and $12 per 1M output tokens for contexts ≤200k tokens, and $4 per 1M input / $18 per 1M output for contexts >200k tokens. OpenRouter typically applies a small platform/processing fee on top of provider costs (≈5%) and credit‑purchase fees. [1][2]
Sources:
- Google Gemini 3 Pro Preview model docs (pricing). [1]
- OpenRouter / aggregator notes on pass‑through pricing and platform fee. [2]
Pricing structure is incomplete — missing higher tier for contexts >200k tokens.
The pricing $2/$12 per 1M tokens is correct for contexts ≤200k, but OpenRouter charges $4 per 1M input / $18 per 1M output for contexts >200k tokens. Update the pricing to handle both tiers based on context length.
🤖 Prompt for AI Agents
In apps/web/utils/usage.ts around lines 124 to 127, the pricing entry for
"google/gemini-3-pro-preview" only lists the lower-tier rates (2/12 per 1M
tokens) for contexts ≤200k; update it to include both tiers so consumers can
select rates based on context length — add a structure or tiered object with
keys for "standard" (≤200k: input 2/1_000_000, output 12/1_000_000) and
"large_context" (>200k: input 4/1_000_000, output 18/1_000_000), and ensure any
place that reads this value selects the correct tier based on the context length
(e.g., check contextTokens > 200_000 to use large_context rates).
There was a problem hiding this comment.
2 issues found across 5 files
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="apps/web/app/(app)/[emailAccountId]/assistant/BulkRunRules.tsx">
<violation number="1" location="apps/web/app/(app)/[emailAccountId]/assistant/BulkRunRules.tsx:146">
`runResult` is set whenever the queue reports a total of 0 threads, but `onComplete(totalProcessed)` is called for cancellations and fetch errors as well. If the user aborts immediately (or the API fails before any threads queue), the UI still shows “No unread emails found in the selected date range,” which is misleading because nothing actually completed. Guard this message behind a successful completion flag or pass abort/error state through `onComplete` before showing it.</violation>
</file>
<file name="apps/web/utils/usage.ts">
<violation number="1" location="apps/web/utils/usage.ts:125">
Gemini 3 Pro Preview on OpenRouter uses tiered pricing; contexts over 200k tokens are billed at higher rates. Using a single-tier rate here will underreport costs for large contexts. Add tiered rates or select the correct rate based on context length.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| }, | ||
| (count) => { | ||
| setRunning(false); | ||
| if (count === 0) { |
There was a problem hiding this comment.
runResult is set whenever the queue reports a total of 0 threads, but onComplete(totalProcessed) is called for cancellations and fetch errors as well. If the user aborts immediately (or the API fails before any threads queue), the UI still shows “No unread emails found in the selected date range,” which is misleading because nothing actually completed. Guard this message behind a successful completion flag or pass abort/error state through onComplete before showing it.
Prompt for AI agents
Address the following comment on apps/web/app/(app)/[emailAccountId]/assistant/BulkRunRules.tsx at line 146:
<comment>`runResult` is set whenever the queue reports a total of 0 threads, but `onComplete(totalProcessed)` is called for cancellations and fetch errors as well. If the user aborts immediately (or the API fails before any threads queue), the UI still shows “No unread emails found in the selected date range,” which is misleading because nothing actually completed. Guard this message behind a successful completion flag or pass abort/error state through `onComplete` before showing it.</comment>
<file context>
@@ -111,9 +132,21 @@ export function BulkRunRules() {
+ },
+ (count) => {
+ setRunning(false);
+ if (count === 0) {
+ setRunResult({ count });
+ }
</file context>
| "google/gemini-2.5-pro-preview": gemini2_5pro, | ||
| "google/gemini-2.5-pro": gemini2_5pro, | ||
| "google/gemini-3-pro-preview": { | ||
| input: 2 / 1_000_000, |
There was a problem hiding this comment.
Gemini 3 Pro Preview on OpenRouter uses tiered pricing; contexts over 200k tokens are billed at higher rates. Using a single-tier rate here will underreport costs for large contexts. Add tiered rates or select the correct rate based on context length.
Prompt for AI agents
Address the following comment on apps/web/utils/usage.ts at line 125:
<comment>Gemini 3 Pro Preview on OpenRouter uses tiered pricing; contexts over 200k tokens are billed at higher rates. Using a single-tier rate here will underreport costs for large contexts. Add tiered rates or select the correct rate based on context length.</comment>
<file context>
@@ -120,6 +121,10 @@ const costs: Record<
"google/gemini-2.5-pro-preview": gemini2_5pro,
"google/gemini-2.5-pro": gemini2_5pro,
+ "google/gemini-3-pro-preview": {
+ input: 2 / 1_000_000,
+ output: 12 / 1_000_000,
+ },
</file context>
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.