Skip to content

Conversation

@mihirpenugonda
Copy link

@mihirpenugonda mihirpenugonda commented Jun 8, 2025

Summary

  • Improved the model selection dropdown to group models by their API providers (Google AI, OpenAI, OpenRouter)
  • Added clear visual indicators showing which providers have configured API keys
  • Enabled direct navigation to settings for unconfigured providers with a single click
image

Summary by CodeRabbit

  • New Features
    • Chat model selection dropdown now groups AI models by provider, displaying each provider in a separate labeled section.
    • Provider groups indicate whether an API key is configured and allow direct navigation to settings if not configured.
  • Style
    • Dropdown menu width increased for improved readability and layout.
    • Visual separators added between provider groups for clearer organization.

@vercel
Copy link

vercel bot commented Jun 8, 2025

@mihirpenugonda is attempting to deploy a commit to the Harsh's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Jun 8, 2025

Walkthrough

The PureChatModelDropdown component was refactored to organize AI models by provider within the dropdown menu. Each provider group displays a label, its models, and indicates API key status. The dropdown's width was increased, and navigation to the settings page is enabled for providers missing API keys. UI structuring components were added.

Changes

File(s) Change Summary
frontend/components/ChatInput.tsx Refactored PureChatModelDropdown to group models by provider, added provider labels, separators, clickable labels for missing API keys, increased dropdown width, and integrated new UI structuring components.

Poem

In dropdown fields where models grow,
Now grouped by name, their banners show.
Providers listed, keys in sight—
Click to settings, set things right!
Wider menus, clearer view,
Rabbits cheer this change for you.
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

frontend/components/ChatInput.tsx

Oops! Something went wrong! :(

ESLint: 9.28.0

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in " » eslint-config-next/core-web-vitals » /node_modules/.pnpm/eslint-config-next@15.3.2_eslint@9.28.0_jiti@2.4.2__typescript@5.8.3/node_modules/eslint-config-next/index.js".

If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/components/ChatInput.tsx (1)

251-295: Excellent grouped dropdown implementation with minor accessibility improvement needed.

The grouped dropdown implementation is well-structured with proper conditional navigation and visual indicators. The logic correctly handles API key status and model enablement.

Consider adding keyboard navigation support for the provider labels:

  <DropdownMenuLabel 
    className={cn(
      "flex items-center justify-between px-2 py-1.5",
      !group.hasApiKey && "cursor-pointer hover:bg-accent/50 transition-colors"
    )}
    onClick={!group.hasApiKey ? () => navigate('/settings') : undefined}
+   onKeyDown={!group.hasApiKey ? (e) => {
+     if (e.key === 'Enter' || e.key === ' ') {
+       e.preventDefault();
+       navigate('/settings');
+     }
+   } : undefined}
+   tabIndex={!group.hasApiKey ? 0 : -1}
+   role={!group.hasApiKey ? "button" : "presentation"}
+   aria-label={!group.hasApiKey ? `Configure API key for ${providerDisplayNames[provider as keyof typeof providerDisplayNames]}` : undefined}
  >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed9c4c3 and 3088c01.

📒 Files selected for processing (1)
  • frontend/components/ChatInput.tsx (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/components/ChatInput.tsx (3)
lib/models.ts (3)
  • AIModel (12-12)
  • AI_MODELS (3-10)
  • getModelConfig (53-55)
lib/utils.ts (1)
  • cn (4-6)
frontend/components/ui/dropdown-menu.tsx (4)
  • DropdownMenuGroup (246-246)
  • DropdownMenuLabel (247-247)
  • DropdownMenuItem (248-248)
  • DropdownMenuSeparator (252-252)
🔇 Additional comments (4)
frontend/components/ChatInput.tsx (4)

11-13: LGTM! Correct imports for new dropdown structure.

The imports for DropdownMenuLabel, DropdownMenuSeparator, and DropdownMenuGroup are appropriately added to support the new grouped dropdown functionality.


193-193: LGTM! Navigate hook correctly added for settings navigation.

The useNavigate hook is properly imported and used to enable navigation to the settings page when users click on provider labels without configured API keys.


249-249: LGTM! Appropriate width increase for grouped content.

The dropdown width increase from 10rem to 14rem accommodates the new grouped layout with provider labels and API key status indicators.


204-225:

Details

❌ Incorrect review comment

Verify type safety for provider key access.

The grouping logic is well-structured and properly memoized. However, there's a potential type safety issue with the provider key access.

The config.provider values should be validated to ensure they match the expected provider keys. Consider adding type checking:

   AI_MODELS.forEach((model) => {
     const config = getModelConfig(model);
     const provider = config.provider;
+    if (!provider || typeof provider !== 'string') {
+      console.warn(`Invalid provider for model ${model}:`, provider);
+      return;
+    }
     const apiKey = getKey(provider);

Let me verify the provider types and values used in the model configurations:


🏁 Script executed:

#!/bin/bash
# Description: Check model configurations and provider values to ensure type safety

# Search for model configurations and provider definitions
ast-grep --pattern 'provider: $_'

# Search for provider type definitions
rg -A 3 -B 3 "provider.*:" --type ts

# Look for MODEL_CONFIGS usage
rg -A 5 "MODEL_CONFIGS" --type ts

Length of output: 2328


No runtime provider validation required

TypeScript’s ModelConfig defines provider as the Provider union and MODEL_CONFIGS is declared as const satisfies Record<AIModel, ModelConfig>. This guarantees at compile time that config.provider is always a valid Provider string, so an extra runtime check isn’t needed.

Likely an incorrect or invalid review comment.

Comment on lines +227 to +231
const providerDisplayNames = {
google: 'Google AI',
openai: 'OpenAI',
openrouter: 'OpenRouter'
};
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add type safety for provider display name mapping.

The provider display names mapping should include type checking to handle unknown providers gracefully.

- const providerDisplayNames = {
+ const providerDisplayNames: Record<string, string> = {
   google: 'Google AI',
   openai: 'OpenAI',
-  openrouter: 'OpenRouter'
+  openrouter: 'OpenRouter',
+  // Add fallback for unknown providers
+ };
+ 
+ const getProviderDisplayName = (provider: string): string => {
+   return providerDisplayNames[provider] || provider;
  };

Then update the usage in line 261:

- {providerDisplayNames[provider as keyof typeof providerDisplayNames]}
+ {getProviderDisplayName(provider)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const providerDisplayNames = {
google: 'Google AI',
openai: 'OpenAI',
openrouter: 'OpenRouter'
};
// original context…
const providerDisplayNames: Record<string, string> = {
google: 'Google AI',
openai: 'OpenAI',
openrouter: 'OpenRouter',
// Add fallback for unknown providers
};
const getProviderDisplayName = (provider: string): string => {
return providerDisplayNames[provider] || provider;
};
// …later in your JSX (around line 261)
- {providerDisplayNames[provider as keyof typeof providerDisplayNames]}
+ {getProviderDisplayName(provider)}
🤖 Prompt for AI Agents
In frontend/components/ChatInput.tsx around lines 227 to 231, the
providerDisplayNames object lacks type safety, which can cause issues with
unknown providers. Define a TypeScript type or interface for the provider keys
and use it to type the providerDisplayNames object. Then, update the usage at
line 261 to safely access the display name, providing a fallback value for
unknown providers to handle them gracefully.

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.

1 participant