-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: Addresses overeager 'there are unsaved changes' dialog in settings #8410
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
| // This prevents the dirty state when the component initializes and auto-syncs values | ||
| const isInitialSync = !isUserAction && previousValue === undefined && value !== undefined | ||
| // Treat undefined, null, and empty string as uninitialized states | ||
| const isInitialSync = |
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.
Nice improvement: treating undefined, null, and empty string as uninitialized prevents false change detection. Consider extracting this check into a helper for reuse and clarity.
This comment was generated because it violated a code review rule: irule_tTqpIuNs8DV0QFGj.
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.
I found some issues that need attention. See inline comments for details.
| setApiConfigurationField("apiModelId", selectedModelId) | ||
| // Pass false as third parameter to indicate this is not a user action | ||
| // This is an internal sync, not a user-initiated change | ||
| setApiConfigurationField("apiModelId", selectedModelId, false) |
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.
[P2] Internal sync path correctly marks isUserAction=false. To avoid future drift, audit similar internal sync sites (provider/model defaults, migrations) and consider centralizing via a small helper to ensure they always pass false.
| const isInitialSync = !isUserAction && previousValue === undefined && value !== undefined | ||
| // Treat undefined, null, and empty string as uninitialized states | ||
| const isInitialSync = | ||
| !isUserAction && |
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.
[P3] The isInitialSync detection is duplicated logic you’ll likely want consistent across fields. Consider extracting a small helper (e.g., isInitializingValue(prev, next, isUserAction)) and unit-testing it so future edits don’t regress this behavior.
Description
Up to now, the "Done" button in settings would always warn about unsaved changes, even when there weren't any.
This fixes the behavior of one of the panels, which was flipping a dirty bit unnecessarily.
Test Procedure
There are automated tests, but to manually check it:
Important
Fixes overeager unsaved changes dialog in settings by refining change detection logic in
SettingsView.tsxandApiOptions.tsx.SettingsView.tsxby refining change detection logic.setApiConfigurationFieldinApiOptions.tsxto passfalsefor non-user actions.SettingsView.change-detection.spec.tsxto test change detection logic.SettingsView.unsaved-changes.spec.tsxto verify unsaved changes dialog behavior.setCachedStatelogic inSettingsView.tsxto prevent unnecessary change detection.This description was created by
for 4e54cf9. You can customize this summary. It will automatically update as commits are pushed.