Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Merge PR #2054: LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched

aiongg61ad2ff85388
diff --cc crates/ui-egui/src/tests_grid.rs
index af113c4ee,dd4e625c5..3776821de
--- a/crates/ui-egui/src/tests_grid.rs
+++ b/crates/ui-egui/src/tests_grid.rs
@@@ -218,21 -218,144 +218,163 @@@ fn double_clicking_a_stack_badge_toggle
assert!(!collapsed(&h), "a single click toggles it");
}
+#[test]
+fn grid_stack_badge_toggles_a_stack_that_is_not_selected() {
+ let mut h = grid(ViewMode::PhotoGrid);
+ // a stack on screen, and a loose photo as the active one
+ let top = PhotoId(2001);
+ select(&mut h, top);
+ let vis = h.app.session.visible().to_vec();
+ let i = vis.iter().position(|p| *p == top).unwrap();
+ let loose = vis[i.saturating_sub(1)..].iter().copied().find(|p| h.app.session.catalog.stack_of(*p).is_none()).unwrap();
+ select(&mut h, loose);
+ assert!(!h.app.session.selection.contains(top));
+ assert!(widget(&h, &format!("stack:{}", top.0)).is_some(), "badge drawn");
+ let r = h.request("ui.clickWidget", json!({"id": format!("stack:{}", top.0)}), T);
+ assert_eq!(r["ok"], true, "{r}");
+ h.settle(SETTLE);
+ assert!(h.app.session.catalog.stack_of(top).unwrap().collapsed, "a click on an unselected stack's badge toggles it");
+ assert_eq!((h.app.session.selection.ids.clone(), h.app.session.selection.active), (vec![loose], Some(loose)), "and leaves the selection alone");
+}
++
+ /// What the grid shows (its date runs, and each cell's shape) is what a grid made afresh for the
+ /// same list shows.
+ fn assert_as_made_afresh(h: &mut Headless, what: &str) {
+ let vis = h.app.session.visible().to_vec();
+ if vis.is_empty() {
+ // (no photo matches: the grid says so and draws none)
+ return;
+ }
+ let (runs, shapes) = h.app.caches.grid.runs_and_shapes().expect("the grid was drawn");
+ let cat = &h.app.session.catalog;
+ let by = crate::panels::grid::resolve_group(h.app.session.sort.group, h.app.ui.thumb_size);
+ assert_eq!(*runs, cat.date_runs(&vis, h.app.session.sort.key, by), "date runs {what}");
+ // (the square grid's cells are all alike: it reads no shape)
+ let fresh: Vec<f32> =
+ if h.app.ui.view == ViewMode::SquareGrid { Vec::new() } else { vis.iter().map(|id| crate::panels::grid::shape_of(cat, *id)).collect() };
+ assert_eq!(shapes, fresh, "cell shapes {what}");
+ }
+
+ fn photo(h: &mut Headless, n: u64, captured: &str) -> Op {
+ let id = h.app.session.catalog.alloc_photo_id();
+ let (w, h_) = if n.is_multiple_of(3) { (4000, 6000) } else { (6000, 4000) };
+ let mut p = Photo::new(
+ id,
+ Source::File { path: format!("/lightcraft-grid-test/NEW_{n:05}.jpg") },
+ &format!("NEW_{n:05}.jpg"),
+ "JPEG",
+ w,
+ h_,
+ "2026-01-02T00:00:00",
+ );
+ p.captured = Some(captured.to_string());
+ Op::AddPhoto { photo: Box::new(p) }
+ }
+
+ /// An import lands its photos a batch at a time: the grid reads the batch's photos, not the
+ /// whole list again (at 180,000 photos that was most of a 100 ms frame per batch). An edit to a
+ /// photo's date or shape reads that photo.
+ #[test]
+ fn a_batch_of_new_photos_or_an_edit_to_one_is_read_photo_by_photo() {
+ let mut h = grid(ViewMode::PhotoGrid);
+ let read = h.app.caches.grid_stats.photos_read;
+ assert_eq!(read, N, "the first frame reads every photo");
+ // sixteen photos, on days already shown, a new day, and with no date at all
+ let ops: Vec<Op> = (0..16)
+ .map(|k| {
+ let day = ["2026-12-28T09:30:00", "2026-11-03T10:00:00", "2027-01-05T12:00:00", "nope"][k as usize % 4];
+ photo(&mut h, k, day)
+ })
+ .collect();
+ h.app.session.commit("Import", Op::Batch { ops }).unwrap();
+ h.step();
+ assert_eq!(h.app.caches.grid_stats.photos_read - read, 16, "only the batch's photos are read");
+ assert!(widget(&h, "group:2027-01-05").is_some(), "the new day heads the grid");
+ assert_as_made_afresh(&mut h, "after the batch");
+ // a photo taken on another day: it moves there, and only it is read
+ let read = h.app.caches.grid_stats.photos_read;
+ h.app.session.commit("Capture time", Op::SetCaptured { id: PhotoId(500), captured: Some("2027-02-01T08:00:00".into()) }).unwrap();
+ h.step();
+ assert_eq!(h.app.caches.grid_stats.photos_read - read, 1, "only the photo edited is read");
+ assert!(widget(&h, "group:2027-02-01").is_some(), "its new day heads the grid");
+ assert_as_made_afresh(&mut h, "after a capture time");
+ }
+
+ /// Whatever the edit, the grid shows what a grid made afresh would: followed photo by photo when
+ /// the list changed by the photos the edit touched, else read whole.
+ #[test]
+ fn a_grid_followed_through_edits_shows_what_a_grid_made_afresh_shows() {
+ for seed in [11u64, 12, 13, 14, 15] {
+ let mut h = grid(ViewMode::PhotoGrid);
+ let mut dice = seed;
+ let mut roll = |sides: u64| {
+ dice = lightcraft_catalog::mix64(dice);
+ dice % sides
+ };
+ for step in 0..120 {
+ let vis = h.app.session.visible().to_vec();
+ if vis.is_empty() {
+ // (no picks shown: back to every photo)
+ h.app.session.filter.flag = None;
+ continue;
+ }
+ let id = vis[roll(vis.len() as u64) as usize].0;
+ let n = roll(1000);
+ match roll(12) {
+ 0 => {
+ let ops: Vec<Op> = (0..1 + roll(20))
+ .map(|k| photo(&mut h, n * 100 + k, &format!("2026-{:02}-{:02}T10:00:00", 1 + n % 12, 1 + k % 28)))
+ .collect();
+ h.app.session.commit("Import", Op::Batch { ops }).unwrap();
+ }
+ 1 => {
+ let _ = h.app.session.commit("Delete", Op::SetDeleted { id: PhotoId(id), deleted: true });
+ }
+ 2 => {
+ let _ = h
+ .app
+ .session
+ .commit("Capture time", Op::SetCaptured { id: PhotoId(id), captured: Some(format!("2026-{:02}-03T10:00:00", 1 + n % 12)) });
+ }
+ 3 => {
+ h.app.session.execute("library.select", &json!({"ids": [id]})).unwrap();
+ let r = h.app.session.execute("photo.rotateRight", &json!({}));
+ assert!(r.is_ok(), "{r:?}");
+ }
+ 4 => {
+ let mut d = (*h.app.session.catalog.photo(PhotoId(id)).unwrap().develop).clone();
+ d.crop.geometry.rect = lightcraft_geom::Rect::new(0.1, 0.0, 0.9 - 0.1 * (n % 4) as f64, 1.0);
+ h.app
+ .session
+ .commit("Crop", Op::SetDevelop { id: PhotoId(id), settings: std::sync::Arc::new(d), label: "Crop".into(), edited: None })
+ .unwrap();
+ }
+ 5 => h.app.session.commit("Rating", Op::SetRating { id: PhotoId(id), rating: (n % 6) as u8 }).unwrap(),
+ 6 => {
+ let key = ["captureDate", "fileName", "importDate"][n as usize % 3];
+ let r = h.app.session.execute("library.sort", &json!({"key": key, "ascending": n.is_multiple_of(2)}));
+ assert!(r.is_ok(), "{r:?}");
+ }
+ 7 => {
+ // a stack: an edit to more than its photos, read whole
+ let other = vis[n as usize % vis.len()].0;
+ let _ = h.app.session.execute("stack.group", &json!({"ids": [id, other], "top": id, "collapsed": n.is_multiple_of(2)}));
+ }
+ 8 => {
+ let _ = h.app.session.execute("edit.undo", &json!({}));
+ }
+ 9 => {
+ // picks, for the filter below to show some
+ for k in 0..1 + n % 40 {
+ let p = vis[(n as usize * 7 + k as usize * 13) % vis.len()];
+ h.app.session.commit("Flag", Op::SetFlag { id: p, flag: lightcraft_catalog::Flag::Pick }).unwrap();
+ }
+ }
+ 10 => h.app.ui.view = if h.app.ui.view == ViewMode::PhotoGrid { ViewMode::SquareGrid } else { ViewMode::PhotoGrid },
+ _ => h.app.session.filter.flag = n.is_multiple_of(2).then_some(lightcraft_catalog::Flag::Pick),
+ }
+ h.step();
+ assert_as_made_afresh(&mut h, &format!("seed {seed}, after step {step}"));
+ }
+ }
+ }
diff --cc docs/parity-checklist.md
index c539eedfe,e53fa2525..ee8c78466
--- a/docs/parity-checklist.md
+++ b/docs/parity-checklist.md
@@@ -1,6 -1,7 +1,7 @@@
# Lightroom parity checklist
+ > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-16 · **Change:** minor (LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6
-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-20 · **Change:** minor (LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6
+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; earlier: LRC-PRINT-PAGE: Print Page Options) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6
The measured, row-by-row checklist: one row per Lightroom feature, menu item and shortcut, what we
have and what is missing. It answers *does the feature exist?* (feature breadth). Whether it is good
@@@ -901,5 -897,4 +902,6 @@@ Latin stays upright. Advanced Japanese
| 2026-10-14 | patch | LRC-LIB-CATALOG-IMPORT: reconciled with upstream phased progress, cancellation kinds, WAL-only import, translations and current progress tracking. Status and summary counts unchanged. |
| 2026-10-13 | minor | KEYC-COMPARE: `=` / `-` (also `+`) increase / decrease the grid thumbnail size (`view.thumbSizeUp` / `view.thumbSizeDown`, View menu), grids only; status unchanged (🟡) |
| 2026-10-16 | patch | LR-META-XMP: a TIFF or JPEG imported beside a raw of its stem reads its own `<file>.xmp` and takes nothing from the raw's `IMG_0001.xmp`, whether it arrives with the raw or after it (a stem sidecar belongs to one file: a raw first, then the first by name); status unchanged (✅) |
+| 2026-10-16 | minor | LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan row says how many folders and files it has listed while it lists the folder (an indeterminate bar, not "0 of N"), and ✕ stops the listing; statuses unchanged |
+| 2026-10-19 | patch | LRC-LIB-LIBFOLDERS: Synchronize Folder on a folder that is up to date says so with one Close instead of four empty choices and a Synchronize that started an empty job; status unchanged (✅) |
+ | 2026-10-16 | minor | LR-VIEW-PHOTOGRID: when the photos shown change by those an edit touched (an import's batch, a capture time, a crop), the grid reads only those photos' dates and shapes again instead of every photo of the list (a 16-photo batch at 181,749 photos: grid frame 101 ms → 7 ms); status unchanged |
diff --cc docs/whats-new.md
index 69f70706b,b42eb9dbc..876b627c8
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@@ -51,13 -26,11 +51,18 @@@
## 2026-10-16
+### Synchronize Folder shows that it is listing the folder
+- A folder with tens of thousands of photos, above all on a network share, can take minutes to list before
+ Synchronize Folder checks a single photo. Its row in the activity stack used to sit at "0 of 64085" with an empty
+ bar all that time, as if it had stopped. It now says how many folders and files it has listed so far, with a bar
+ that moves on its own, and then counts the photos it checks. The dialog says the same.
+- ✕ on the row stops the listing too, not only the checks after it.
+
+ ### The photo grid keeps up with imports into a large library
+ - While photos are imported into a large library, the grid takes in each batch as it arrives instead of reading
+ every photo of the view again: at about 180,000 photos a batch cost the window a tenth of a second, over and over
+ for as long as the import ran. Changing one photo's capture time or crop is quicker too.
+
## 2026-10-15
### Constrain Crop tightens the crop you see