diff --git a/crates/engine/src/settings/prefs.rs b/crates/engine/src/settings/prefs.rs index 1f855f8ed..fd50835ce 100644 --- a/crates/engine/src/settings/prefs.rs +++ b/crates/engine/src/settings/prefs.rs @@ -39,7 +39,7 @@ pub use sections::{ use sections::{Extra, default_labels, lenient_comp_presets}; /// Current settings layout version. -pub const PREFS_VERSION: u32 = 5; +pub const PREFS_VERSION: u32 = 6; /// Settings file name in the config store. pub const PREFS_FILE: &str = "prefs.json"; diff --git a/crates/engine/src/settings/prefs/document.rs b/crates/engine/src/settings/prefs/document.rs index 32e7126ec..74c24099b 100644 --- a/crates/engine/src/settings/prefs/document.rs +++ b/crates/engine/src/settings/prefs/document.rs @@ -14,6 +14,10 @@ use super::{Appearance, General, Map, PREFS_VERSION, Prefs, Startup, Value, json /// - version 4 and earlier had the Layer Cache, Footage Frame Cache and Preview (RAM) Cache /// budgets (`memory.layerCacheMb` / `mediaCacheMb` / `previewCacheMb`); they are dropped: the /// caches share one budget (#3298). +/// - version 5 and earlier saved Cache Frames When Idle off, the default then (every save kept +/// it); it becomes the new default, on, once (#3321). Off saved later is the user's choice. +/// (Released builds wrote version 4; version 5 came only from pre-release builds of #3301, +/// nearly all of them with the default still off. A file without a version predates both.) pub fn migrate(mut v: Value) -> Value { let Some(obj) = v.as_object_mut() else { return json!({}) }; let version = obj.get("version").and_then(Value::as_u64).unwrap_or(0); @@ -61,6 +65,12 @@ pub fn migrate(mut v: Value) -> Value { m.remove(key); } } + if version < 6 + && let Some(p) = obj.get_mut("previews").and_then(Value::as_object_mut) + && p.get("cacheFramesWhenIdle") == Some(&json!(false)) + { + p.insert("cacheFramesWhenIdle".into(), json!(true)); + } // Settings saved before appearance modes had one theme: keep showing it, as a fixed Dark or // Light mode, instead of switching established users to Auto. if let Some(a) = obj.get_mut("appearance").and_then(Value::as_object_mut) diff --git a/crates/engine/src/tests/m145.rs b/crates/engine/src/tests/m145.rs index 08ed81a3c..07e2a947f 100644 --- a/crates/engine/src/tests/m145.rs +++ b/crates/engine/src/tests/m145.rs @@ -263,15 +263,23 @@ fn a_low_memory_episode_toasts_once_and_reapplies_the_budget() { assert_eq!(toasts(&mut s), 1); } -/// #3321: Cache Frames When Idle is on by default; a saved "off" stays off. +/// #3321: Cache Frames When Idle is on by default. Settings saved before held the old default +/// (off) and turn it on once; off saved after that is the user's choice and stays. #[test] fn cache_frames_when_idle_is_on_by_default() { use crate::prefs::Prefs; assert!(Prefs::default().previews.cache_frames_when_idle); - assert!(Prefs::from_json(r#"{"version": 5, "previews": {"fastPreviews": true}}"#).previews.cache_frames_when_idle, "not saved: on"); - let off = Prefs::from_json(r#"{"version": 5, "previews": {"cacheFramesWhenIdle": false}}"#); + assert!(Prefs::from_json(r#"{"version": 6, "previews": {"fastPreviews": true}}"#).previews.cache_frames_when_idle, "not saved: on"); + // An old file with the old default: on, once. + let old = Prefs::from_json(r#"{"version": 5, "previews": {"cacheFramesWhenIdle": false}}"#); + assert!(old.previews.cache_frames_when_idle, "the old default becomes the new one"); + assert!(Prefs::from_json(r#"{"version": 4, "previews": {"cacheFramesWhenIdle": true}}"#).previews.cache_frames_when_idle, "on stays on"); + // Turned off after the migration: stays off, also after the next save. + let off = Prefs::from_json(r#"{"version": 6, "previews": {"cacheFramesWhenIdle": false}}"#); assert!(!off.previews.cache_frames_when_idle, "saved off: off"); - assert!(!Prefs::from_json(&off.to_json()).previews.cache_frames_when_idle, "and after the next save"); + let mut p = old; + p.previews.cache_frames_when_idle = false; + assert!(!Prefs::from_json(&p.to_json()).previews.cache_frames_when_idle, "and after the next save"); } /// #3298: settings saved with the three cache budgets (version 4, or a later file that still diff --git a/docs/preferences.md b/docs/preferences.md index c5a3f4cdb..d0eae0dbd 100644 --- a/docs/preferences.md +++ b/docs/preferences.md @@ -57,7 +57,8 @@ Commands (CLI, MCP, control channel): after a second without input or edits, the viewer renders the work area into the RAM preview in the background, from the current time on, until it is cached or the budget is full. Any input, edit, playback or a frame the viewer waits for stops it at once (it starts again after - the next quiet second). A saved setting of off stays off + the next quiet second). Settings saved by an older version hold the old default (off) and are + switched on once when read; off saved after that stays off - `previews.fastPreviews`: Fast Previews (Draft 3D, Faster Effects) - `appearance.appearanceMode`: Appearance Mode (`auto` / `dark` / `light`). `auto` (Sync with System) follows the operating system's light or dark appearance while the app runs: on Linux the desktop app reads the XDG desktop portal (`org.freedesktop.appearance` `color-scheme`) once and then listens for its `SettingChanged` signal on a worker thread, repainting only when the value changes (nothing polls); `gsettings` runs at most once at start-up, by absolute path, when the portal gives no answer. Elsewhere it uses what the window system reports. With no answer it shows the dark theme. New installs stay `dark`; Sync with System is opt-in. The Tools bar's appearance button (a monitor, sun or moon) cycles Sync with System, Light and Dark (`view.theme.toggle`, Next Appearance Mode). - `appearance.darkTheme`: Dark Theme (`dark` / `darker`), shown in dark appearance