-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: handle undefined Gemini settings when toggling checkboxes #6617
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
- Add special handling for enableUrlContext and enableGrounding fields - Treat undefined as functionally equivalent to false for these boolean fields - Prevent false positives in change detection when setting from undefined to false - Fixes issue where Save button would not activate when toggling these settings Fixes #6616
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.
Reviewed my own code. Found it suspiciously free of bugs. Must have missed something.
| // Special handling for optional boolean fields where undefined is functionally equivalent to false | ||
| // If the previous value was undefined and the new value is false, consider it no change. | ||
| // This prevents false positives for change detection when an optional boolean is explicitly set to false. | ||
| if ( |
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.
Missing test coverage for this new behavior. Consider adding tests to verify:
- The Save button activates when toggling from undefined to true
- The Save button activates when toggling from undefined to true
- The Save button doesn't activate when toggling these fields from undefined to false
This would help ensure the fix works as expected and prevent regressions.
| // If the previous value was undefined and the new value is false, consider it no change. | ||
| // This prevents false positives for change detection when an optional boolean is explicitly set to false. | ||
| if ( | ||
| (field === "enableUrlContext" || field === "enableGrounding") && |
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 extracting these hardcoded field names into constants. They're repeated on line 248, which could lead to maintenance issues if more fields need similar handling in the future.
| const isInitialSync = | ||
| previousValue === undefined && | ||
| value !== undefined && | ||
| !(field === "enableUrlContext" || field === "enableGrounding") // Exclude these fields from initial sync logic |
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.
Is this approach scalable? If other optional boolean fields have similar issues in the future, we'd need to keep adding them here. Would it be worth considering a more generic solution, perhaps by maintaining a list of fields that should treat undefined as false?
|
Closing this PR as the approach doesn't fully resolve the issue. Alternative approaches have been explored but haven't provided a complete solution. |
Description
This PR fixes an issue where the Save button wouldn't activate when toggling Gemini settings checkboxes (Enable URL context and Enable Grounding with Google Search) if those settings didn't already exist in the configuration.
Problem
When the
enableUrlContextandenableGroundingsettings are undefined (not present in the settings), toggling the checkboxes from unchecked to checked doesn't trigger a state change because the code was treating the transition fromundefinedtofalseas no change.Solution
Added special handling in the
setApiConfigurationFieldfunction for these optional boolean fields:undefinedas functionally equivalent tofalsefor these specific fieldsundefinedtofalseTesting
Fixes #6616
Important
Fixes checkbox toggling issue in
SettingsView.tsxby treatingundefinedasfalsefor specific settings to ensure Save button activation.enableUrlContextandenableGroundingcheckboxes fromundefinedtocheckedinSettingsView.tsx.undefinedasfalsefor these fields insetApiConfigurationFieldto ensure state change detection.undefined.This description was created by
for a8b3490. You can customize this summary. It will automatically update as commits are pushed.