Store framework sections as remembered state, not a settings edit (#18794)

A dialog that remembers its place writes its framework section on every
frame of a move or resize. PrefSections::sync stored it with edit_prefs,
which moves the settings revision every panel version holds, so the dock
rebuilt all its panels each frame and the engine re-applied its
preferences. No view reads the sections from the preferences, so they
are now stored with PrefsStore::remember: saved, no settings revision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-12-01 20:04:26 +01:00
1 parent 91bf9f75d2
commit 28d4f2d8d3
1 file changed
+17 -1
+17 -1
View File
@@ -831,8 +831,11 @@ impl PrefSections {
.filter_map(|key| Some((key.clone(), serde_json::to_value(t.tables.get(key)?).ok()?)))
.filter(|(key, value)| session.prefs().sections.get(key) != Some(value))
.collect();
// Remembered, not a settings edit: no view reads the sections back from the preferences (the components
// read them here), so the panels keep their versions and the engine applies nothing. A dialog that
// remembers its place writes on every frame of a drag.
if !changed.is_empty() {
session.edit_prefs(|p| p.sections.extend(changed));
session.prefs.remember(|p| p.sections.extend(changed));
}
for key in written {
let rev = session.section_rev(&key);
@@ -986,6 +989,19 @@ mod tests {
assert_eq!(store.read("one"), None);
}
/// A component's section write is saved, but is no settings edit: the panels' versions hold the settings revision,
/// so an edit would rebuild every panel on each frame a dialog that remembers its place is dragged.
#[test]
fn a_section_write_is_saved_without_a_settings_edit() {
let store = PrefSections::default();
let mut session = Session::new();
let (saved, settings) = (session.prefs.rev(), session.prefs.settings_rev());
store.write("one", table(1));
store.sync(&mut session);
assert_ne!(session.prefs.rev(), saved, "the write reaches the saved preferences");
assert_eq!(session.prefs.settings_rev(), settings, "the panels keep their versions");
}
/// Every theme PhotoCraft has a palette for names a framework built-in.
#[test]
fn every_palette_theme_is_a_builtin() {