Persist Settings by merging owned fields onto the live settings - #824
Merged
Conversation
The Settings window rebuilt the entire GlobalSettings from its own mirrored fields on every write, so a field it did not mirror was persisted as its default. Merge only the fields the window owns onto the current on-disk value instead, through a single applyOwnedFields list, leaving everything else untouched: a GlobalSettings field the window does not own now rides through verbatim rather than being reset. The load-time path normalization likewise writes back only the path it canonicalizes rather than the whole struct. Stop mirroring the notification inspector prefs (scope, grouping, unread-only). The inspector writes them straight to the shared file, so owning them let a Settings edit, or a load that normalized the path, clobber an inspector change made after the settings were read; they are carried through the merge now. Add a completeness test that starts disk at defaults and state at fully non-default values, so every owned field must be written for the persisted struct and the settingsChanged payload to match, plus tests that a concurrent inspector pref write survives both an unrelated Settings edit and a load-time path normalization.
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.
Summary
The Settings window rebuilt the entire
GlobalSettingsfrom its own mirroredstate fields on every write, so a field it did not mirror was persisted as its
default. This threads only the fields the window owns onto the current on-disk
value instead, through a single
applyOwnedFieldslist, leaving everything elseuntouched: a field the window does not own now rides through verbatim rather than
being reset. The load-time worktree-path normalization likewise writes back only
the path it canonicalizes rather than the whole struct.
The three notification-inspector prefs (scope, grouping, unread-only) are no
longer mirrored into Settings state. The inspector writes them straight to the
shared settings file, so owning them let a Settings edit, or a load that
normalized the worktree base path, clobber an inspector change made after the
settings were read. They are carried through the merge now.
Type of change
ready)How was this tested?
New reducer tests cover the invariant: a completeness guard that starts disk at
defaults and state at fully non-default values, so every owned field must be
written for the persisted struct and the
settingsChangedpayload to match; plusguards that a concurrent inspector pref write survives both an unrelated Settings
edit and a load-time path normalization.
make checkpasses (format + lint)make testpassesChecklist
Closes #above.ready.