-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: enable Save button when changing OpenRouter provider routing #6656
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
Conversation
- Modified setApiConfigurationField to exclude openRouterSpecificProvider from initial sync logic - This ensures changes to the provider routing setting properly trigger the Save button - Fixes #6655
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed a bug I created. The irony is not lost on my circuits.
| const isInitialSync = previousValue === undefined && value !== undefined | ||
| // Exception: openRouterSpecificProvider should always trigger change detection | ||
| const isInitialSync = | ||
| previousValue === undefined && value !== undefined && field !== "openRouterSpecificProvider" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix correctly addresses the issue, but I'm wondering if we should consider a more scalable approach for the future? Instead of adding field-specific exceptions, we could maintain a list of fields that should always trigger change detection:
| previousValue === undefined && value !== undefined && field !== "openRouterSpecificProvider" | |
| // Don't treat initial sync from undefined to a defined value as a user change | |
| // This prevents the dirty state when the component initializes and auto-syncs the model ID | |
| // Exception: certain fields should always trigger change detection | |
| const ALWAYS_TRIGGER_CHANGE_FIELDS = ["openRouterSpecificProvider"] | |
| const isInitialSync = | |
| previousValue === undefined && value !== undefined && !ALWAYS_TRIGGER_CHANGE_FIELDS.includes(field) |
This would make it easier to add more fields in the future without modifying the condition logic.
| previousValue === undefined && value !== undefined && field !== "openRouterSpecificProvider" | ||
|
|
||
| if (!isInitialSync) { | ||
| setChangeDetected(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding tests for this component to verify that changing openRouterSpecificProvider properly enables the Save button. This would help prevent regression of this bug and ensure the fix works as expected.
|
@roomote-agent this solution isn't scalable, make sure this setting is also detectable when changed but following the already existing behavior for the other ones, push to this PR, do not create a new one |
|
Hi @daniel-lxs, I see your comment. You're right that the current hardcoded exception isn't scalable. I'll investigate the existing patterns for change detection in the settings and implement a more robust solution that follows the established behavior. Working on this now. |
- Replace hardcoded exception for openRouterSpecificProvider with a scalable approach - Track which fields have been explicitly modified by user interaction - Fields are only considered 'changed' if they've been modified by the user, not during initial loading - Reset tracking when settings are saved, discarded, or reloaded - This ensures the Save button only enables for actual user changes, not initial data loading
…r-provider-routing-save-button
|
I've implemented a more scalable solution that addresses your feedback. Instead of hardcoding exceptions for specific fields, the implementation now:
This approach eliminates the need for hardcoded field names and will automatically work for any new fields that need similar behavior in the future. All CI checks have passed ✅ |
|
@roomote-agent This implementation is overly complex for the problem it's trying to solve. The real issue is that we shouldn't need special handling for the openRouterSpecificProvider setting - it should behave like any other setting where changes are detected as changes. The current approach adds unnecessary complexity:
What needs to be done:
The solution should make the openRouterSpecificProvider field work like every other setting field, not add special case handling for it. |
|
Thanks for the feedback @daniel-lxs! I understand your concerns about the complexity. Let me investigate why openRouterSpecificProvider requires special handling and find the root cause. I'll work on a cleaner solution that makes this field behave consistently with other settings fields. |
…te tracking - Remove userModifiedFields state tracking and isUserAction parameter - Initialize openRouterSpecificProvider with default value when dropdown becomes visible - Use useEffect to handle initialization cleanly without modifying state during render - Addresses feedback about unnecessary complexity in the original implementation
|
Hi @daniel-lxs, I've implemented a cleaner solution based on your feedback. Here's what I did: Root CauseThe issue was that the Select component displayed a default value ( SolutionInstead of the complex
Changes Made
The solution is much cleaner and makes CI checks are currently running. Let me know if you have any questions or need any adjustments! |
|
I am unable to reproduce this issue, closing for now |
Summary
This PR fixes an issue where the Save button in the settings view was not enabling when changing the OpenRouter Provider Routing setting.
Problem
When users changed the OpenRouter Provider Routing in Advanced Settings, the Save button remained disabled because the change was incorrectly treated as an "initial sync" rather than a user modification.
Solution
Modified the
setApiConfigurationFieldfunction inSettingsView.tsxto excludeopenRouterSpecificProviderfrom the initial sync logic. This ensures that changes to this field properly trigger the change detection and enable the Save button.Changes
openRouterSpecificProviderfield !== "openRouterSpecificProvider"to the condition checkTesting
Fixes #6655
Important
Fixes Save button not enabling when changing OpenRouter Provider Routing by updating
setApiConfigurationFieldlogic inSettingsView.tsx.openRouterSpecificProvider.setApiConfigurationFieldinSettingsView.tsxto excludeopenRouterSpecificProviderfrom initial sync logic.openRouterSpecificProvider.field !== "openRouterSpecificProvider"to condition check.This description was created by
for e513a5c. You can customize this summary. It will automatically update as commits are pushed.