Skip to content

Conversation

@rossmanko
Copy link
Contributor

@rossmanko rossmanko commented Jan 31, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Implemented automatic fallback retry mechanism for interrupted streaming requests
  • Bug Fixes

    • Fixed modal rendering issues within constrained containers
    • Improved error recovery with fallback model retries and enhanced logging
  • Refactor

    • Streamlined AI model routing configuration
    • Updated default fallback model provider

✏️ Tip: You can customize this high-level summary in your review settings.

rossmanko and others added 2 commits January 31, 2026 15:34
The ImageViewer modal was rendering inside message blocks instead of
full-screen when clicking images in already-sent messages. This was
caused by contentVisibility: auto on message containers creating a
containing block for fixed-positioned elements.

Using createPortal to render directly to document.body fixes this.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…t modes

- Rename agent-fallback-model to fallback-model for use in both modes
- Switch fallback from Google Gemini to moonshotai/kimi-k2.5
- Remove provider routing (vertex/ai-studio) from providers config
- Simplify buildProviderOptions by removing Google-specific options
- Add fallback verification logging with assistant message IDs
- Track fallback duration, success status, and part types

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hackerai Ready Ready Preview, Comment Jan 31, 2026 9:00pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Jan 31, 2026

📝 Walkthrough

Walkthrough

This PR consolidates AI model provider routing by removing provider-level constraints and standardizing all model mappings to OpenRouter with Google's Gemini backend. A new fallback model (Moonshot's Kimi K2.5) is introduced, and direct gateway and Google SDK dependencies are removed. The chat handler is enhanced with expanded streaming lifecycle hooks for analytics and a fallback retry mechanism for incomplete streams. A UI modal is rendered via portal to escape CSS containment.

Changes

Cohort / File(s) Summary
Model Provider Consolidation
lib/ai/providers.ts, package.json
Removed provider-level routing constraints, simplified model mappings to use openrouter/google/gemini-3-flash-preview, introduced new fallback-model mapped to moonshot/kimi-k2.5, and removed @ai-sdk/gateway and @ai-sdk/google dependencies.
Streaming & Retry Logic
lib/api/chat-handler.ts
Enhanced prepareStep with conditional system prompt caching; expanded streaming lifecycle with onChunk/onFinish/onError hooks for tool call tracking, analytics, and usage accounting; introduced fallback retry mechanism for incomplete streams with detailed metadata logging.
Provider Options Cleanup
lib/api/chat-stream-helpers.ts
Removed GoogleGenerativeAIProviderOptions and GatewayProviderOptions imports; eliminated gateway and google provider configuration blocks from buildProviderOptions return value.
UI Portal Rendering
app/components/FilePartRenderer.tsx
Updated ImageViewer modal rendering to use createPortal with document existence guard to escape CSS contentVisibility containment.
Test Formatting
lib/rate-limit/__tests__/token-bucket.test.ts
Reformatted multi-line assertion statements for readability without logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ChatHandler
    participant Stream
    participant Providers
    
    Client->>ChatHandler: initiate chat request
    ChatHandler->>Providers: prepare with model config
    ChatHandler->>Stream: start streaming
    
    loop Stream Processing
        Stream->>Stream: receive chunk
        Stream-->>ChatHandler: onChunk event (tool calls)
        ChatHandler->>ChatHandler: log analytics
    end
    
    Stream-->>ChatHandler: onFinish event
    ChatHandler->>ChatHandler: record usage & cost
    
    alt Incomplete Stream (step-start only)
        ChatHandler->>ChatHandler: detect incomplete
        ChatHandler->>Providers: retry with fallback-model
        Providers-->>Stream: retry stream
        Stream-->>ChatHandler: onFinish (fallback response)
        ChatHandler->>ChatHandler: save new messages
        ChatHandler->>ChatHandler: log fallback metadata
    else Complete Stream
        ChatHandler->>ChatHandler: finalize response
    end
    
    ChatHandler-->>Client: emit completion event
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Daily branch 2026 01 28 #194: Modifies lib/ai/providers.ts and package.json to switch model provider endpoints toward OpenRouter while removing gateway/google dependencies, directly overlapping with this PR's provider consolidation.
  • Daily branch 2026 12 06 #156: Modifies lib/api/chat-handler.ts streaming lifecycle and event handling, with overlapping changes to streaming behavior and retry logic.
  • Daily branch 2025 10 27 #64: Removes @ai-sdk/gateway dependency and related Google/gateway provider imports and configuration, directly aligning with this PR's dependency cleanup.

Poem

🐰 With portals wide, we leap so free,
Models unified in harmony,
When streams falter, fallback springs,
Through OpenRouter's cleaner wings,
Fewer gates, more hops to see! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the two main changes: refactoring AI model routing (lib/ai/providers.ts and related files) and adding ImageViewer portal rendering (app/components/FilePartRenderer.tsx).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch daily-branch-2026-01-31

Comment @coderabbitai help to get the list of available commands and usage tips.

@rossmanko rossmanko changed the title Daily branch 2026 01 31 Refactor AI model routing and add ImageViewer portal rendering' Jan 31, 2026
@rossmanko rossmanko changed the title Refactor AI model routing and add ImageViewer portal rendering' Refactor AI model routing and add ImageViewer portal rendering Jan 31, 2026
@rossmanko rossmanko merged commit 66a7350 into main Jan 31, 2026
4 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