From 9b88f71afcb486dc0389c123e510aa08511ebb31 Mon Sep 17 00:00:00 2001 From: SamLovick <39815276+SamLovick@users.noreply.github.com> Date: Sun, 8 Nov 2026 13:52:52 +1100 Subject: [PATCH 1/6] #3947: background preparation builds previews at Build Standard-Sized Previews' size The background build sent no edge, so the engine built at max(2048, loupe edge), while Build Standard-Sized Previews asks for 2560 px in a session that has not drawn a loupe yet (or the chosen preview limit). Its skip check then rejected every background preview as too small and rendered it again. Both now use AppSettings::standard_build_edge (a chosen limit, else max(2560, loupe edge)): the app hands it to the engine's PrepState::edge every pass, and prep_tick passes it on. --- crates/engine/src/prep.rs | 9 ++++++++- crates/engine/src/tests/preview_prep.rs | 24 +++++++++++++++++++++++ crates/ui-egui/src/app.rs | 2 ++ crates/ui-egui/src/menus/menubar.rs | 13 +++++------- crates/ui-egui/src/state/settings.rs | 12 ++++++++++++ crates/ui-egui/src/tests/lifecycle_037.rs | 14 +++++++++++++ crates/ui-egui/src/tests/preview_limit.rs | 11 +++++++---- docs/parity-checklist.md | 2 +- docs/whats-new.md | 5 +++++ 9 files changed, 78 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/prep.rs b/crates/engine/src/prep.rs index bb53d244184..04ab8038b25 100644 --- a/crates/engine/src/prep.rs +++ b/crates/engine/src/prep.rs @@ -220,6 +220,10 @@ pub struct PrepState { /// A build that couldn't start: the view (its signature), and when it may try again (not on /// every tick while the cause lasts; CodeRabbit on #3080). pub retry_at: Option<(u64, web_time::Instant)>, + /// The long edge (px) the frontend builds standard previews at (its Build Standard-Sized + /// Previews size; 0: [`crate::cmd::previews::standard_edge`]). The background build uses it + /// too, so a later build asked for skips what it made instead of rendering it again (#3947). + pub edge: usize, /// Tests: the next starts to fail, as a build thread that can't be spawned does. #[cfg(test)] pub(crate) fail_starts: usize, @@ -420,7 +424,10 @@ impl Session { if ids.is_empty() { return; } - let p = json!({"ids": ids, "background": true, "from": at.0, "backward": backward}); + let mut p = json!({"ids": ids, "background": true, "from": at.0, "backward": backward}); + if let Some(o) = p.as_object_mut().filter(|_| self.prep.edge > 0) { + o.insert("edge".into(), json!(self.prep.edge)); + } // (tests: a start made to fail, as a build thread that can't be spawned fails) #[cfg(test)] let fail = self.prep.fail_starts.checked_sub(1).map(|left| self.prep.fail_starts = left).is_some(); diff --git a/crates/engine/src/tests/preview_prep.rs b/crates/engine/src/tests/preview_prep.rs index 0981c2cf960..a44726022df 100644 --- a/crates/engine/src/tests/preview_prep.rs +++ b/crates/engine/src/tests/preview_prep.rs @@ -291,6 +291,30 @@ fn the_background_preparation_starts_when_culling_and_can_be_stopped() { let _ = std::fs::remove_dir_all(root); } +/// #3947: the background build makes standard previews at the size the frontend's Build +/// Standard-Sized Previews asks for, so that build skips them instead of rendering every one again. +#[test] +fn the_background_build_makes_previews_at_the_frontends_standard_size() { + let (mut s, root, ids) = library("prep-edge", 3); + s.prep.edge = 300; + let mode = crate::prep::Mode::Library; + for id in &ids { + s.prep_tick(mode, Some(*id), false); + } + let b = s.preview_build.clone().expect("culling: the view is prepared"); + assert!(b.background); + assert!(wait_finished(&b), "built"); + assert_eq!(b.failed.load(Ordering::Relaxed), 0); + for id in &ids { + let p = s.catalog.photo(*id).unwrap().clone(); + let (w, h) = s.media.rendered.disk().expect("a disk cache").dims(s.view_key(&p, true)).expect("on disk"); + assert_eq!(w.max(h), 300, "built at the frontend's standard size"); + } + let r = s.execute("library.buildPreviews", &json!({"ids": ids_json(&ids), "edge": 300, "wait": true})).unwrap(); + assert_eq!(r["skipped"], 3, "the build asked for skips what the background made {r}"); + let _ = std::fs::remove_dir_all(root); +} + /// While editing, the whole view's build follows the Library row (its switch and "which photos"); /// the Editing row's scope is only for the photos kept ready ahead. #[test] diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index 6d9faaafc90..0a420ff72d5 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -519,6 +519,8 @@ impl LightcraftApp { let loupe = self.ui.fullscreen || self.ui.view == state::ViewMode::Detail; let at = if loupe { self.session.active() } else { None }; let backward = self.look_ahead.backward(); + // the background build makes previews at Build Standard-Sized Previews' size (#3947) + self.session.prep.edge = self.ui.settings.standard_build_edge(self.session.loupe_edge) as usize; self.session.prep_tick(mode, at, backward); if self.session.preview_build.as_ref().is_some_and(|b| b.running()) { ctx.request_repaint_after(std::time::Duration::from_millis(500)); diff --git a/crates/ui-egui/src/menus/menubar.rs b/crates/ui-egui/src/menus/menubar.rs index b73729a9131..26468d0af54 100644 --- a/crates/ui-egui/src/menus/menubar.rs +++ b/crates/ui-egui/src/menus/menubar.rs @@ -465,15 +465,12 @@ fn live_label(app: &LightcraftApp, id: &str, label: &str) -> String { } /// The parameterized submenus. -/// The params of Build Standard-Sized Previews: automatic builds as big as the loupe on this screen shows photos -/// (the engine's standard size, once a loupe has been drawn); before that, in a fresh session, the standard -/// 2560 px, not the engine's 2048 px minimum, so a typical fit view needn't render again; a chosen limit is used as is. +/// The params of Build Standard-Sized Previews: automatic builds at the standard 2560 px (not the engine's +/// 2048 px minimum, so a typical fit view needn't render again), or as big as the loupe on this screen shows +/// photos when that is more; a chosen limit is used as is. The background preparation builds at the same size +/// ([`crate::state::AppSettings::standard_build_edge`]), so this build skips what it made (#3947). pub(crate) fn standard_build_params(settings: &crate::state::AppSettings, loupe_edge: usize) -> Value { - match settings.preview_limit { - 0 if loupe_edge == 0 => json!({"size": "standard", "edge": settings.standard_preview_edge()}), - 0 => json!({"size": "standard"}), - edge => json!({"size": "standard", "edge": edge}), - } + json!({"size": "standard", "edge": settings.standard_build_edge(loupe_edge)}) } pub(crate) fn expanded(app: &LightcraftApp, name: &str) -> Option> { diff --git a/crates/ui-egui/src/state/settings.rs b/crates/ui-egui/src/state/settings.rs index 62b50557ccd..b9917100496 100644 --- a/crates/ui-egui/src/state/settings.rs +++ b/crates/ui-egui/src/state/settings.rs @@ -408,6 +408,18 @@ impl AppSettings { pub fn standard_preview_edge(&self) -> u32 { if self.preview_limit == 0 { STANDARD_PREVIEW_EDGE } else { self.preview_limit } } + + /// The long edge standard previews are built at, by Build Standard-Sized Previews and by the + /// background preparation alike: a chosen limit as is; on Automatic the standard size, or the + /// loupe's size on this screen (`loupe_edge`, 0: no loupe drawn yet) when that is bigger. The + /// same in every session, so a build skips the previews an earlier one made (#3947). + pub fn standard_build_edge(&self, loupe_edge: usize) -> u32 { + if self.preview_limit != 0 { + return self.preview_limit; + } + let loupe = u32::try_from(loupe_edge.min(8192)).unwrap_or(8192); + STANDARD_PREVIEW_EDGE.max(loupe) + } } /// How the Keywording box lays out the selection's keywords. diff --git a/crates/ui-egui/src/tests/lifecycle_037.rs b/crates/ui-egui/src/tests/lifecycle_037.rs index e29946baa2a..56f0146c592 100644 --- a/crates/ui-egui/src/tests/lifecycle_037.rs +++ b/crates/ui-egui/src/tests/lifecycle_037.rs @@ -2354,6 +2354,20 @@ fn background_preparation_advances_while_the_window_is_hidden() { let _ = ctx.run_logic(&visible, |ctx| app.logic(ctx)); assert_eq!(app.prep_ticks, 3, "a shown pass advances it once"); } + +/// #3947: the background preparation builds previews at Build Standard-Sized Previews' size (a +/// chosen limit, else the standard 2560 px), so that build skips them instead of rendering them again. +#[test] +fn background_preparation_builds_at_the_standard_build_size() { + let mut app = app(); + let ctx = egui::Context::default(); + let hidden = viewport_raw(egui::vec2(800.0, 600.0), false); + let _ = ctx.run_logic(&hidden, |ctx| app.logic(ctx)); + assert_eq!(app.session.prep.edge, crate::state::STANDARD_PREVIEW_EDGE as usize); + app.ui.settings.preview_limit = 1600; + let _ = ctx.run_logic(&hidden, |ctx| app.logic(ctx)); + assert_eq!(app.session.prep.edge, 1600, "a chosen limit"); +} /// CodeRabbit on #3077/#3080: a background build that couldn't start asks for a frame at its retry /// time, so the retry happens with no input and no other timed frame. #[test] diff --git a/crates/ui-egui/src/tests/preview_limit.rs b/crates/ui-egui/src/tests/preview_limit.rs index 248ce781cc6..97f0277bbe7 100644 --- a/crates/ui-egui/src/tests/preview_limit.rs +++ b/crates/ui-egui/src/tests/preview_limit.rs @@ -1643,15 +1643,18 @@ mod in_the_loupe { } } -// Build Standard-Sized Previews on Automatic: the loupe's size once one was drawn (the engine's standard), the -// standard 2560 px in a fresh session, not the engine's 2048 px minimum a fit view would render again over -// (CodeRabbit on #3077); a chosen limit as is +// Build Standard-Sized Previews on Automatic: the standard 2560 px, not the engine's 2048 px minimum a fit +// view would render again over (CodeRabbit on #3077), or the loupe's size when bigger; a chosen limit as is. +// The same with or without a loupe drawn, so a fresh session's build skips the previews an earlier +// session's background preparation made (#3947) #[test] fn standard_build_keeps_the_standard_size_before_a_loupe_was_drawn() { use crate::menubar::standard_build_params; use serde_json::json; assert_eq!(standard_build_params(&with_limit(0), 0), json!({"size": "standard", "edge": STANDARD_PREVIEW_EDGE})); - assert_eq!(standard_build_params(&with_limit(0), 2400), json!({"size": "standard"})); + assert_eq!(standard_build_params(&with_limit(0), 2400), json!({"size": "standard", "edge": STANDARD_PREVIEW_EDGE})); + assert_eq!(standard_build_params(&with_limit(0), 3000), json!({"size": "standard", "edge": 3000})); + assert_eq!(standard_build_params(&with_limit(0), 50_000), json!({"size": "standard", "edge": 8192})); assert_eq!(standard_build_params(&with_limit(3840), 0), json!({"size": "standard", "edge": 3840})); assert_eq!(standard_build_params(&with_limit(3840), 2400), json!({"size": "standard", "edge": 3840})); } diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index baa3bb7fe58..9f26c2717f3 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -721,7 +721,7 @@ From `08-lightroom-classic-extras.md` (Classic-only features) and part 2 of `06- | LRC-LIB-VISUALSEARCH | Find similar photos | P2 | ✅ | `cmd:library.findSimilar`, `crates/pipeline/src/cull.rs` (`signature`), `crates/engine/src/cmd/similar.rs`, `crates/ui-egui/src/find_similar.rs` | photo menu / Photo ▸ Find Similar Photos: look-alike photos (composition and tones), most similar first, as a filter (`only`); the app reads the photos on a worker thread under an activity row with ✕ | | LRC-LIB-MISSING | Missing files & relink | P1 | ✅ | `cmd:library.missing`, `cmd:photo.relink`, `cmd:library.findMissing`, `cmd:file.findMissing`, `cmd:photo.locate`, `crates/engine/src/cmd/missing.rs` (`checked_path`), `crates/ui-egui/src/missing_sweep.rs`, `crates/ui-egui/src/panels/left.rs` (`locate_missing_item`) | File → Find Missing Photos… (anywhere in a folder: same name, size and content hash; renamed files by size + content hash; same name and size alone only when unambiguous — look-alikes are skipped and reported; searched on a worker thread, one undo step), photo menu → Locate Missing File…; a folder or disk row's Locate Missing Files… chooses its new location and scopes the same recursive background finder to that folder and its subfolders. Unreadable files show "!" in the grid and a reason in the loupe; undo never moves files. Missing Photos in the sidebar (counted on a worker thread; the view, the Info panel, the grid's context menu and thumbnails read file availability from a cache a worker thread fills, so an offline NAS never stalls a frame); it covers library photos only — Local browse records are never checked, for the count, the view, `library.missing` and Find Missing alike; `library.missing` from the control channel or `mcp --connect` checks the files on a worker thread (a "Missing Photos" row in the activity stack, ✕ stops it) and answers when it ends, so a large library on a network share never stalls the window; the same request meanwhile shares the running check | | LRC-LIB-CONVERT | Convert to DNG | P2 | ✅ | `cmd:photo.convertToDng`, `crates/engine/src/cmd/convert.rs` | Photo ▸ Convert to DNG: lossless DNG next to the raw with the settings embedded, photo (and its virtual copies) relinked; originals kept; undoable; the DNG is decoded and compared with the raw data, written to a temp file, synced, read back and only then given a free name (never replacing a file) — a failed write leaves no DNG and the photo on its raw (issue #106) | -| LRC-LIB-PREVIEWS | Build / discard previews | P1 | ✅ | `cmd:library.buildPreviews`, `cmd:library.previewProgress`, `cmd:library.cancelPreviews`, `cmd:library.clearPreviews`, `crates/engine/src/cmd/previews.rs`, `crates/preview/src/lib.rs`, `crates/engine/src/tests/preview_prep.rs` | File ▸ Previews: build standard-sized (as big as the loupe shows photos on this screen, at least 2048 px, or the Settings → Performance size) or 1:1 previews of the selected photos (more than one) or every photo in view, in the background (a row in the activity stack, ✕ to stop), discard the cache; disk thumbnail + view cache. The loupe shows a built preview that is big enough as the photo (fitted down, no render); a build skips photos whose previews are there and writes each to disk before it counts it; the disk cache's automatic size makes room for every photo of the library (about 1.5 MB a photo, no ceiling: a low drive is told once per session, see LR-PREF-LOCALSTORAGE), and memory for previews follows the memory budget | +| LRC-LIB-PREVIEWS | Build / discard previews | P1 | ✅ | `cmd:library.buildPreviews`, `cmd:library.previewProgress`, `cmd:library.cancelPreviews`, `cmd:library.clearPreviews`, `crates/engine/src/cmd/previews.rs`, `crates/preview/src/lib.rs`, `crates/engine/src/tests/preview_prep.rs` | File ▸ Previews: build standard-sized (as big as the loupe shows photos on this screen, at least 2560 px, or the Settings → Performance size; background preparation builds at the same size, so this build skips what it made, issue #3947) or 1:1 previews of the selected photos (more than one) or every photo in view, in the background (a row in the activity stack, ✕ to stop), discard the cache; disk thumbnail + view cache. The loupe shows a built preview that is big enough as the photo (fitted down, no render); a build skips photos whose previews are there and writes each to disk before it counts it; the disk cache's automatic size makes room for every photo of the library (about 1.5 MB a photo, no ceiling: a low drive is told once per session, see LR-PREF-LOCALSTORAGE), and memory for previews follows the memory budget | | LRC-PERF-PREP | Prepare photos in the background (beyond Lightroom) | P1 | 🟡 | `cmd:prefs.backgroundPrep`, `cmd:prefs.setBackgroundPrep`, `crates/engine/src/prep.rs`, `crates/ui-egui/src/dialogs/settings/performance.rs` | Settings ▸ Performance ▸ Prepare photos in the background, per mode (Culling, Library, Editing), app-wide or for one library: previews of every photo in view built in the spare time once the user steps through photos (yields to the photo on screen, nearest photos first in the direction of travel, one cancellable row), photos ahead rendered for the loupe (0 = off), eye focus strips ahead, which photos (every / picks, rated and labelled / only the one on screen); editing keeps the next photos decoded. Not yet: face detection, AI masks and AI Denoise as background jobs of these settings (they keep their own switches) | | LRC-LIB-SLIDESHOW-IMPROMPTU | Impromptu slideshow | P2 | ✅ | `cmd:view.slideshow` | see LR-VIEW-SLIDESHOW | | LRC-DEV-SNAPSHOTS | Named snapshots | P1 | ✅ | `cmd:version.create`, `cmd:version.restore` | = versions | diff --git a/docs/whats-new.md b/docs/whats-new.md index f3339263784..995b5bd2327 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -13,6 +13,11 @@ the other exports do, and writes the file atomically. It used to write the presets over whatever file it was given, and a failed write (a full disk) could leave a cut-off file where an earlier export was. +### Previews are built once +- Background preparation now builds previews at the same size as File ▸ Previews ▸ Build Standard-Sized Previews + (the Settings → Performance size, else at least 2560 px), so that build skips them instead of rendering every one + again (issue #3947). + ### Film grain that looks like film (process V7) - Grain now comes from a simulated emulsion of crystal layers (after Aurélien Pierre's model): dense, soft and cloudy rather than dots on top of the photo. It fades out towards black and white as on a print, so shadows keep their depth From cd0ae35ed16ab32eb5e0b5633dab02d70f713e5f Mon Sep 17 00:00:00 2001 From: SamLovick <39815276+SamLovick@users.noreply.github.com> Date: Wed, 11 Nov 2026 14:58:43 +1100 Subject: [PATCH 2/6] Contributors: credit SamLovick as Sam Lovick --- contributors/people.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index 04286cc129a..9f9a06979b2 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -86,3 +86,8 @@ sync_github_name = true [people.Peaperfish] real_name = "Yule Wang" display_name = "Brian Wang" + +[people.SamLovick] +real_name = "Sam Lovick" +display_name = "Sam Lovick" +sync_github_name = false From 430443ab54f5d0948a8b400f9947c7c0aa0fc4db Mon Sep 17 00:00:00 2001 From: SamLovick <39815276+SamLovick@users.noreply.github.com> Date: Mon, 30 Nov 2026 00:40:44 +1100 Subject: [PATCH 3/6] LRC-LIB-PREVIEWS: a new preview size in the same view is prepared again (#4096 review) Background preparation remembered the view it had built but not the size, so changing Build Standard-Sized Previews' size while staying in a folder built nothing. The started build is now keyed by view and size; a stop from its row still holds for the view whatever the size. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/prep.rs | 24 +++++++++++++++--------- crates/engine/src/tests/preview_prep.rs | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/crates/engine/src/prep.rs b/crates/engine/src/prep.rs index 04ab8038b25..ed83fd584eb 100644 --- a/crates/engine/src/prep.rs +++ b/crates/engine/src/prep.rs @@ -214,8 +214,10 @@ pub struct PrepState { pub library: Option, /// The background build this preparation started. build: Option>, - /// The view (its signature) whose build was started, or that the user stopped. - started_for: Option, + /// The view (its signature) whose build was started, with the [`Self::edge`] it builds at: a + /// new size in the same view is built again (vangel76 on #4096). And the view the user stopped + /// it in, which holds whatever the size. + started_for: Option<(u64, usize)>, declined_for: Option, /// A build that couldn't start: the view (its signature), and when it may try again (not on /// every tick while the cause lasts; CodeRabbit on #3080). @@ -368,10 +370,14 @@ impl Session { if b.running() { if !wanted { b.cancel.store(true, Ordering::Relaxed); - } else if self.prep.started_for.is_some_and(|sig| sig != signature(&self.visible_cloned(), self, want.scope)) { - // another view (a folder, a filter, another library): this build's photos are - // not the ones shown; stopped, and the view now shown is prepared in its place - // (not counted as stopped by the user) + } else if self + .prep + .started_for + .is_some_and(|(sig, edge)| edge != self.prep.edge || sig != signature(&self.visible_cloned(), self, want.scope)) + { + // another view (a folder, a filter, another library) or another size: this + // build's previews are not the ones wanted; stopped, and the view now shown is + // prepared in its place (not counted as stopped by the user) b.cancel.store(true, Ordering::Relaxed); self.prep.started_for = None; } else if let Some(id) = at { @@ -384,7 +390,7 @@ impl Session { if b.cancel.load(Ordering::Relaxed) { if mine && wanted { // stopped from its row: not again for this view - self.prep.declined_for = self.prep.started_for; + self.prep.declined_for = self.prep.started_for.map(|(sig, _)| sig); } else { // replaced by a build that was asked for, or switched off: may start again later self.prep.started_for = None; @@ -409,7 +415,7 @@ impl Session { let busy = self.preview_build.as_ref().is_some_and(|b| b.running()); if busy || self.prep.steps < STEPS_BEFORE_BUILD - || self.prep.started_for == Some(sig) + || self.prep.started_for == Some((sig, self.prep.edge)) || self.prep.declined_for == Some(sig) || self.prep.retry_at.is_some_and(|(view, at)| view == sig && web_time::Instant::now() < at) || self.library.as_ref().is_none_or(|l| !l.on_disk) @@ -420,7 +426,7 @@ impl Session { Scope::Marked => ids.into_iter().filter(|id| marked(self, *id)).map(|id| id.0).collect(), _ => ids.into_iter().map(|id| id.0).collect(), }; - self.prep.started_for = Some(sig); + self.prep.started_for = Some((sig, self.prep.edge)); if ids.is_empty() { return; } diff --git a/crates/engine/src/tests/preview_prep.rs b/crates/engine/src/tests/preview_prep.rs index a44726022df..b48ed37833a 100644 --- a/crates/engine/src/tests/preview_prep.rs +++ b/crates/engine/src/tests/preview_prep.rs @@ -312,6 +312,30 @@ fn the_background_build_makes_previews_at_the_frontends_standard_size() { } let r = s.execute("library.buildPreviews", &json!({"ids": ids_json(&ids), "edge": 300, "wait": true})).unwrap(); assert_eq!(r["skipped"], 3, "the build asked for skips what the background made {r}"); + // vangel76 on #4096: a new size in the same view is prepared again, at that size + let first = s.preview_build.clone().expect("the build asked for"); + s.prep.edge = 500; + s.prep_tick(mode, Some(ids[2]), false); + let bigger = s.preview_build.clone().filter(|b| !std::sync::Arc::ptr_eq(b, &first)).expect("built again at the new size"); + assert!(bigger.background); + assert!(wait_finished(&bigger), "built"); + for id in &ids { + let p = s.catalog.photo(*id).unwrap().clone(); + let (w, h) = s.media.rendered.disk().expect("a disk cache").dims(s.view_key(&p, true)).expect("on disk"); + assert!(w.max(h) > 300, "bigger than the size before"); + } + // a stop from its row still holds for the view, whatever size comes next + let hold = crate::prep::TestHold::new(); + s.prep.edge = 400; + s.prep_tick(mode, Some(ids[2]), false); + let stopped = s.preview_build.clone().filter(|b| !std::sync::Arc::ptr_eq(b, &bigger)).expect("started at the next size"); + stopped.cancel.store(true, Ordering::Relaxed); + drop(hold); + assert!(wait_finished(&stopped), "a cancelled build stops"); + s.prep_tick(mode, Some(ids[2]), false); + s.prep.edge = 450; + s.prep_tick(mode, Some(ids[1]), false); + assert!(same_build(&s, &stopped), "not started again in the view it was stopped in"); let _ = std::fs::remove_dir_all(root); } From 453d8b121844bed16bdbd9a6a3d6bc7da22a0ddc Mon Sep 17 00:00:00 2001 From: SamLovick <39815276+SamLovick@users.noreply.github.com> Date: Mon, 30 Nov 2026 03:34:31 +1100 Subject: [PATCH 4/6] LRC-LIB-PREVIEWS: a stop holds when the size changes while the build winds down (#4096 review) A build stopped from its row runs until its photos finish; a size change in that time cleared the view it was for, so the stop was lost and the view could be prepared again. A build already stopping is now left alone. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/prep.rs | 3 +++ crates/engine/src/tests/preview_prep.rs | 26 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/engine/src/prep.rs b/crates/engine/src/prep.rs index ed83fd584eb..563fbb0df8f 100644 --- a/crates/engine/src/prep.rs +++ b/crates/engine/src/prep.rs @@ -370,6 +370,9 @@ impl Session { if b.running() { if !wanted { b.cancel.store(true, Ordering::Relaxed); + } else if b.cancel.load(Ordering::Relaxed) { + // stopping already (from its row, say): the view it was for is kept until it has, so + // a stop still holds for that view when the size changes meanwhile (CodeRabbit on #4096) } else if self .prep .started_for diff --git a/crates/engine/src/tests/preview_prep.rs b/crates/engine/src/tests/preview_prep.rs index b48ed37833a..491ae10727e 100644 --- a/crates/engine/src/tests/preview_prep.rs +++ b/crates/engine/src/tests/preview_prep.rs @@ -339,6 +339,32 @@ fn the_background_build_makes_previews_at_the_frontends_standard_size() { let _ = std::fs::remove_dir_all(root); } +/// CodeRabbit on #4096: a size that changes while a stopped build is still finishing its photos +/// doesn't undo the stop: the view it was stopped in isn't prepared again at the new size. +#[test] +fn a_stop_holds_when_the_size_changes_while_the_build_winds_down() { + let (mut s, root, ids) = library("prep-edge-stop", 3); + s.prep.edge = 300; + let mode = crate::prep::Mode::Library; + // the build's lanes wait at their foreground check, so it is still running when stopped + let hold = crate::prep::TestHold::new(); + for id in &ids { + s.prep_tick(mode, Some(*id), false); + } + let b = s.preview_build.clone().expect("the view is prepared"); + b.cancel.store(true, Ordering::Relaxed); + s.prep.edge = 500; + s.prep_tick(mode, Some(ids[2]), false); + drop(hold); + assert!(wait_finished(&b), "a cancelled build stops"); + for k in 0..3 { + s.prep_tick(mode, Some(ids[k]), false); + } + assert!(same_build(&s, &b), "not started again at the new size in the view it was stopped in"); + drop(s); + std::fs::remove_dir_all(&root).unwrap(); +} + /// While editing, the whole view's build follows the Library row (its switch and "which photos"); /// the Editing row's scope is only for the photos kept ready ahead. #[test] From 4fe79e514c7e5370c132c92f050f0881a0ac3918 Mon Sep 17 00:00:00 2001 From: SamLovick <39815276+SamLovick@users.noreply.github.com> Date: Mon, 30 Nov 2026 06:57:36 +1100 Subject: [PATCH 5/6] LRC-LIB-PREVIEWS: the stop-during-resize test holds its build at the test gate (#4096 review) The foreground hold gives up once the build is cancelled, so the stopped build could finish before the size changed and the test could pass without reaching the case it names. A lane parked at the preview test gate keeps the build unfinished until the gate opens; the test now checks the build is still winding down when the size changes. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/tests/preview_prep.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/tests/preview_prep.rs b/crates/engine/src/tests/preview_prep.rs index 491ae10727e..ac8c2855898 100644 --- a/crates/engine/src/tests/preview_prep.rs +++ b/crates/engine/src/tests/preview_prep.rs @@ -343,19 +343,26 @@ fn the_background_build_makes_previews_at_the_frontends_standard_size() { /// doesn't undo the stop: the view it was stopped in isn't prepared again at the new size. #[test] fn a_stop_holds_when_the_size_changes_while_the_build_winds_down() { + use crate::cmd::previews::test_gate::{self, PreviewGate, ReleaseOnDrop}; let (mut s, root, ids) = library("prep-edge-stop", 3); s.prep.edge = 300; let mode = crate::prep::Mode::Library; - // the build's lanes wait at their foreground check, so it is still running when stopped - let hold = crate::prep::TestHold::new(); + // a lane parked at the gate keeps the build unfinished whatever `cancel` says (the foreground + // hold doesn't: its wait gives up once `cancel` is set), so the stop is still winding down + // when the size changes; the gate also opens if an assertion below fails + let gate = PreviewGate::new(); + let release = ReleaseOnDrop(gate.clone()); + test_gate::install(gate.clone()); for id in &ids { s.prep_tick(mode, Some(*id), false); } let b = s.preview_build.clone().expect("the view is prepared"); + assert!(gate.wait_entered(1), "a lane reached its first photo"); b.cancel.store(true, Ordering::Relaxed); s.prep.edge = 500; s.prep_tick(mode, Some(ids[2]), false); - drop(hold); + assert!(b.running(), "the size changed while the stopped build was still winding down"); + drop(release); assert!(wait_finished(&b), "a cancelled build stops"); for k in 0..3 { s.prep_tick(mode, Some(ids[k]), false); From d94b2eb65eccea9ec105e6fdc393734b47f7fdc0 Mon Sep 17 00:00:00 2001 From: SamLovick <39815276+SamLovick@users.noreply.github.com> Date: Thu, 3 Dec 2026 06:50:09 +1100 Subject: [PATCH 6/6] contributors: move the SamLovick entry to its own pull request (#4096 review) Co-Authored-By: Claude Opus 5.5 --- contributors/people.toml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contributors/people.toml b/contributors/people.toml index 25e26584e38..da155105b8e 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -89,8 +89,3 @@ display_name = "Brian Wang" [people.Terra854] display_name = "Terra854" - -[people.SamLovick] -real_name = "Sam Lovick" -display_name = "Sam Lovick" -sync_github_name = false