Fix stale settings saves resetting style selection#747
Open
snvtac wants to merge 1 commit into
Open
Conversation
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Summary
PreferencesStorewrite path so a stale settings payload cannot roll back the current active style pack.set_settingsandset_update_channelpersist.Root Cause
Generic settings saves send a complete
UserPreferencessnapshot. If the user switches to a local style pack and a later settings save uses an older snapshot, that stale payload can overwriteactive_style_pack_idand related legacy style fields, sending the app back to the previous formal/builtin style.Fix
The generic settings save path now treats style-pack preferences as owned by the style-pack commands. Before writing a generic settings payload,
PreferencesStore::set_preserving_current_style_preferencescopies the current store style fields under the same store lock used for the disk write and in-memory update. Style-pack commands still use the normal store write path, so intentional style changes continue to persist.Fixes #742.
Validation
rustfmt --edition 2021 --check openless-all/app/src-tauri/src/commands/settings.rs openless-all/app/src-tauri/src/persistence/preferences.rs openless-all/app/src-tauri/src/types.rscargo test settingscargo test sync_style_pack_preferencescargo test set_preserving_current_style_preferencesgit diff --checkPR Type
Bug fix
Description
Preserve active style pack across generic settings saves
Add new write path that copies current style fields before persisting
Add tests verifying style preferences are retained
Diagram Walkthrough
File Walkthrough
settings.rs
Preserve style in settings persist pathopenless-all/app/src-tauri/src/commands/settings.rs
write_settings_preserving_current_style_preferencestrait methodpersist_settingsandset_settingsto use the new preservingwrite path
preferences.rs
Add preserving write to PreferencesStoreopenless-all/app/src-tauri/src/persistence/preferences.rs
set_preserving_current_style_preferencesmethodtypes.rs
Add style preservation helperopenless-all/app/src-tauri/src/types.rs
preserve_style_preferences_frommethod onUserPreferencesdefault_mode,enabled_modes,active_style_pack_id,style_system_prompts,custom_style_prompts