Fix issue #6940: [Bug]: Incorrect Provider Name on Advanced Setting Toggle
This pull request fixes #6940.
The issue has been successfully resolved based on the following concrete changes and their effects:
- The core bug was fixed by modifying the
handleChangeProviderfunction to properly map display names to internal provider keys. When "Mistral AI" is selected, it now correctly maps to "mistral" internally through the new lookup logic:
const providerKey = Object.entries(MAP_PROVIDER).find(
([_, displayName]) => displayName === provider
)?.[0] || provider;
-
The changes ensure that the internal state uses the correct provider key ("mistral") while maintaining the display name ("Mistral AI") in the UI, preventing the settings page from incorrectly switching to advanced mode.
-
The fix was verified with a new test case that specifically checks the Mistral AI provider selection workflow, confirming:
- Provider selection works correctly
- Model dropdown becomes enabled
- Correct Mistral models are available
- The implementation addresses both reported issues:
- Prevents unwanted switching to advanced mode by using correct internal provider keys
- Fixes the provider name changing to incorrect values by properly maintaining the mapping between display names and internal keys
The changes directly target and resolve the reported behavior problems through proper provider name handling and state management.
Automatic fix generated by OpenHands 🙌
To run this PR locally, use the following command:
docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:38f1b56-nikolaik --name openhands-app-38f1b56 docker.all-hands.dev/all-hands-ai/openhands:38f1b56
@amanape is this still in progress?
Another ping @amanape
Yes, a few other things went up the list though 😢 . I'll try to look into this soon
This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Fixed in #7929