Skip to content

Conversation

@indiesewell
Copy link

@indiesewell indiesewell commented May 24, 2025

Summary

This PR enhances OpenRouter model management with a refresh button and fixes critical provider switching issues that prevented proper model selection display across different API providers.

Changes Made

✨ OpenRouter Model Refresh Feature

  • Added refresh button with multilingual support (16 languages)
  • Implemented Node.js native https module to bypass Cloudflare blocking issues
  • Added auto-initialization of OpenRouter models on startup
  • Enhanced error handling for network issues and API failures

🔧 Provider Switching Fixes

  • Fixed useSelectedModel hook with proper React useMemo dependency management
  • Resolved Gemini and static providers model display issues when switching between providers
  • Optimized apiModelId update logic to only apply to static providers
  • Ensured correct model values are displayed when switching between API providers

🌐 Internationalization

  • Added refreshModels translation key across all 16 supported languages
  • Maintained consistent UI experience across different locales

🚀 Performance Improvements

  • Reduced redundant API calls through smart caching
  • Improved provider switching responsiveness
  • Better error handling for network connectivity issues

Technical Details

Files Modified

  • src/api/providers/fetchers/openrouter.ts - Native https implementation
  • webview-ui/src/components/settings/ApiOptions.tsx - Provider switching logic
  • webview-ui/src/components/settings/providers/OpenRouter.tsx - Refresh button UI
  • webview-ui/src/components/ui/hooks/useSelectedModel.ts - React dependency fixes
  • src/core/webview/webviewMessageHandler.ts - Auto-initialization logic
  • webview-ui/src/i18n/locales/*/settings.json - Multilingual support

Bug Fixes

  • Fixed React Hook dependency warnings in useSelectedModel
  • Resolved model selection not updating when switching providers
  • Fixed Cloudflare blocking issues with OpenRouter API calls
  • Corrected static provider model initialization

Testing

  • ✅ TypeScript compilation passes
  • ✅ ESLint validation passes
  • ✅ All provider switching scenarios tested
  • ✅ Multilingual UI verified across all supported languages
  • ✅ OpenRouter refresh functionality validated

Breaking Changes

None. All changes are backward compatible.

Related Issues

Fixes provider switching model display issues and enhances OpenRouter usability.


Important

Enhances OpenRouter model management with a refresh button, fixes provider switching issues, and adds multilingual support.

  • OpenRouter Model Management:
    • Added refresh button with multilingual support in OpenRouter.tsx.
    • Implemented Node.js native https module in openrouter.ts to bypass Cloudflare blocking.
    • Auto-initialization of OpenRouter models on startup in webviewMessageHandler.ts.
    • Enhanced error handling for network issues.
  • Provider Switching Fixes:
    • Fixed useSelectedModel hook in useSelectedModel.ts with React useMemo dependency management.
    • Resolved model display issues for Gemini and static providers in ApiOptions.tsx.
    • Optimized apiModelId update logic for static providers.
  • Internationalization:
    • Added refreshModels translation key across 16 languages in locales/*/settings.json.
  • Performance Improvements:
    • Reduced redundant API calls through caching.
    • Improved provider switching responsiveness.
    • Better error handling for network issues.

This description was created by Ellipsis for 003299e. You can customize this summary. It will automatically update as commits are pushed.

✨ OpenRouter Model Refresh:
- Add refresh button with multilingual support (16 languages)
- Implement Node.js native https module to bypass Cloudflare blocking
- Add auto-initialization of router models on startup
- Optimize model fetching with graceful error handling

🔧 Provider Switching Fixes:
- Fix useSelectedModel hook with React useMemo for proper dependency management
- Resolve Gemini and static providers model display issues
- Optimize apiModelId update logic for static providers only
- Ensure correct model values when switching between API providers

🌐 Multilingual Support:
- Add 'refreshModels' translation key across all 16 supported languages
- Maintain consistent UI experience across different locales

🚀 Performance Improvements:
- Reduce redundant API calls with smart caching
- Improve provider switching responsiveness
- Better error handling for network issues
@indiesewell indiesewell requested review from cte and mrubens as code owners May 24, 2025 17:34
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap May 24, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap May 24, 2025
@indiesewell indiesewell deleted the feature/model-refresh branch May 24, 2025 17:40
@indiesewell indiesewell restored the feature/model-refresh branch May 24, 2025 17:44
@indiesewell indiesewell deleted the feature/model-refresh branch May 25, 2025 03:22
SmartManoj pushed a commit to SmartManoj/Raa-Code that referenced this pull request Jun 13, 2025
…s are created using .create() in more contexts (RooCodeInc#3929)

* feat(lint): Add custom ESLint rules for protobuf type checking

Add two custom ESLint rules to enforce proper usage patterns when creating protobuf objects.

Using .create() to build protobufs ensures that the protobuf is type checked when it is created. Protobufs created using
object literals are not type checked,  which can lead to subtle bugs and type mismatches. The linter rules detect when protobufs are created without using .create() or .fromPartial().

- no-protobuf-object-literals: Enforces the use of `.create()` or `.fromPartial()` methods instead of object literals when creating protobuf types.

```
/Users/sjf/cline/src/shared/proto-conversions/state/chat-settings-conversion.ts
   9:9  warning  Use ChatSettings.create() or ChatSettings.fromPartial() instead of object literal for protobuf type
Found: return {
             mode: chatSettings.mode === "plan" ? PlanActMode.PLAN : PlanActMode.ACT,
             preferredLanguage: chatSettings.preferredLanguage,
             openAiReasoningEffort: chatSettings.openAIReasoningEffort,
     }
  Suggestion: ChatSettings.create({
             mode: chatSettings.mode === "plan" ? PlanActMode.PLAN : PlanActMode.ACT,
             preferredLanguage: chatSettings.preferredLanguage,
             openAiReasoningEffort: chatSettings.openAIReasoningEffort,
     })
```

- no-grpc-client-object-literals: Enforces proper protobuf creation for gRPC service client parameters. This needs a separate rule
because the type signatures of the ServiceClients methods are too generic to be detected by the previous rule.

```
/Users/sjf/cline/webview-ui/src/components/mcp/configuration/tabs/add-server/AddRemoteServerForm.tsx
   41:62  warning  Use the appropriate protobuf .create() or .fromPartial() method instead of object literal for gRPC client parameters.
Found: McpServiceClient.addRemoteMcpServer({
                             serverName: serverName.trim(),
                             serverUrl: serverUrl.trim(),
                     })
```

These rules help maintain code quality by enforcing consistent patterns for working with protocol buffers throughout the codebase, reducing potential runtime errors from improper message construction.

* Update test

* Add custom eslint rules to new webview-ui config

* formatting

* stuff

* undo protobuf fixes

* update rule

* update rule

* protobuf fixes

* rename unused params

* formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant