Skip to content

feat: enhance OpenRouter model management and fix provider switching issues #3931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

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.
  • Bug Fixes:
    • Fixed React Hook dependency warnings in useSelectedModel.ts.
    • Resolved model selection not updating when switching providers.
    • Fixed Cloudflare blocking issues with OpenRouter API calls.
    • Corrected static provider model initialization.

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
@samhvw8
Copy link
Collaborator

samhvw8 commented May 24, 2025

it is better to separate this pr into multiple pr

  • enhance OpenRouter model management
  • fix provider switching issues

@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap May 25, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap May 25, 2025
@indiesewell indiesewell deleted the feature/model-refresh branch May 25, 2025 03:22
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.

2 participants