LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge remote-tracking branch 'upstream/main' into fix/local-browse-stamps
Michael Anderson290005a8e742
diff --cc crates/engine/src/cmd/browse.rsindex 29b7d65e6,49f6e46e9..55041ca5a--- a/crates/engine/src/cmd/browse.rs+++ b/crates/engine/src/cmd/browse.rs@@@ -45,20 -49,71 +49,81 @@@ fn browse(s: &mut Session, p: &Value) -stamp_browsed(s, &dir_s, &files);s.browse = Some(Browse { path: dir_s.clone(), subfolders });s.source = LibrarySource::Folder;+ s.keep_active_in_view();let shown = s.visible().len();- Ok(json!({"path": dir_s, "subfolders": subfolders, "photos": shown, "new": report.imported.len(), "failed": report.failed.len()}))+ Ok(json!({+ "path": dir_s,+ "subfolders": subfolders,+ "photos": shown,+ "new": report.imported.len(),+ "failed": report.failed.len(),+ "forgotten": forgotten,+ }))+ }++ impl Session {+ /// Forget the untouched Local records of files gone from the folder `dir` (with its subfolders when+ /// `subfolders`) that a browse just listed as `files`: what `library.browse` does after reading a folder, for a+ /// UI that reads it on a worker thread instead. Returns how many went.+ pub fn forget_gone_from(&mut self, dir: &str, subfolders: bool, files: &[String]) -> usize {+ forget_gone(self, dir, subfolders, files)+ }+ }++ /// Local records in the browsed folder whose files are no longer on disk (deleted or moved by+ /// another app) and that nothing was changed on are forgotten, as `library.forgetLocal` forgets+ /// them: the folder shows what is on disk, not photos that fail to load (and log an error) on+ /// every visit (issue #1392). Records the user changed stay, shown as missing, and so do those+ /// the session holds (selected, edited, in the undo history) or with a smart preview. Returns how+ /// many went.+ fn forget_gone(s: &mut Session, dir: &str, subfolders: bool, files: &[String]) -> usize {+ let listed: std::collections::HashSet<&str> = files.iter().map(String::as_str).collect();+ let held = held(s);+ let smart = s.media.smart_dir.clone();+ let gone: Vec<PhotoId> = s+ .catalog+ .photos()+ .filter(|p| p.local && !p.deleted && !held.contains(&p.id))+ // a smart preview may be all that is left of the picture+ .filter(|p| !smart.as_ref().is_some_and(|d| crate::smart::file_path(d, p).exists()))+ .filter(|p| match &p.source {+ // a file left out of the listing is checked on disk: another spelling of its path, or+ // a listing that missed it, keeps it+ Source::File { path } => in_folder(path, dir, subfolders) && !listed.contains(path.as_str()) && !Path::new(path).exists(),+ Source::Demo { .. } => false,+ })+ .map(|p| p.id)+ .collect();+ if gone.is_empty() {+ return 0;+ }+ let mut forgotten = 0;+ for chunk in s.catalog.forgettable_local(&gone).chunks(2000) {+ let op = Op::Batch { ops: chunk.iter().map(|id| Op::RemovePhoto { id: *id }).collect() };+ match s.catalog.apply(op.clone()) {+ Ok(_) => {+ s.pending_log.push(op);+ forgotten += chunk.len();+ }+ Err(e) => log::warn!("forget Local records of files gone from {dir}: {e}"),+ }+ }+ if forgotten > 0 {+ log::info!("forgot {forgotten} untouched Local record(s) of files gone from {dir}");+ }+ forgotten}+impl Session {+ /// Record that the folder `root` was browsed now, with the folders of `files` (the photos it showed): what+ /// `library.browse` does after reading a folder, for a UI that reads it on a worker thread instead. Untouched+ /// Local photos are forgotten only from folders not browsed for the set number of days, so a browse that+ /// isn't recorded lets a folder in daily use be forgotten.+ pub fn note_browsed(&mut self, root: &str, files: &[String]) {+ stamp_browsed(self, root, files);+ }+}+/// Folders whose browse time is refreshed at most this often (keeps repeated browsing from/// growing the log; far finer than the days the eviction counts in).const RESTAMP_SECS: i64 = 3600;diff --cc crates/ui-egui/src/headless.rsindex 1fa154b18,6178990b0..18908b5ff--- a/crates/ui-egui/src/headless.rs+++ b/crates/ui-egui/src/headless.rs@@@ -2983,30 -3228,43 +3228,67 @@@ mod testslet _ = std::fs::remove_dir_all(&dir);}+ /// Browsing a folder from the UI (read on a worker thread) records it as browsed, as `library.browse` does:+ /// untouched Local photos are only forgotten from folders not browsed for the set number of days.+ #[test]+ fn browsing_from_the_ui_records_the_folder() {+ let mut h = demo([1200.0, 900.0]);+ let t = Duration::from_secs(10);+ let dir = std::env::temp_dir().join(format!("lc-browse-stamp-{}", std::process::id()));+ let day = dir.join("2026/10/14");+ std::fs::create_dir_all(&day).unwrap();+ let img = lightcraft_raster::Rgba8::from_fn(8, 8, |x, y| [(x * 9) as u8, (y * 12) as u8, 80, 255]);+ let o = lightcraft_engine::export::ExportOptions { format: lightcraft_engine::export::ExportFormat::Png, ..Default::default() };+ std::fs::write(day.join("a.png"), lightcraft_engine::export::encode_image(&img, &o).unwrap()).unwrap();+ let root = dir.to_string_lossy().trim_end_matches(['/', '\\']).to_string();+ let day_s = day.to_string_lossy().to_string();+ assert!(h.app.session.catalog.last_browsed(&root).is_none());+ let r = h.request("engine.execute", json!({"command": "library.browse", "params": {"path": root, "subfolders": true}}), t);+ assert_eq!(r["result"]["scanning"], true, "{r}");+ h.settle(SETTLE);+ assert_eq!(h.app.session.visible_cloned().len(), 1);+ assert!(h.app.session.catalog.last_browsed(&root).is_some(), "the browsed folder");+ assert!(h.app.session.catalog.last_browsed(&day_s).is_some(), "the folder its photo is in");+ let _ = std::fs::remove_dir_all(&dir);+ }++ /// Browsing a folder again from the sidebar forgets the untouched Local records of files deleted from it by+ /// another app, as `library.browse` does (issue #1392).+ #[test]+ fn browsing_again_from_the_ui_forgets_deleted_files() {+ let mut h = demo([1200.0, 900.0]);+ let t = Duration::from_secs(10);+ let dir = std::env::temp_dir().join(format!("lc-browse-gone-{}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ let img = lightcraft_raster::Rgba8::from_fn(8, 8, |x, y| [(x * 9) as u8, (y * 12) as u8, 80, 255]);+ let o = lightcraft_engine::export::ExportOptions { format: lightcraft_engine::export::ExportFormat::Png, ..Default::default() };+ let png = lightcraft_engine::export::encode_image(&img, &o).unwrap();+ std::fs::write(dir.join("a.png"), &png).unwrap();+ std::fs::write(dir.join("b.png"), &png).unwrap();+ let path = dir.to_string_lossy().to_string();+ let browse = |h: &mut Headless| {+ let r = h.request("engine.execute", json!({"command": "library.browse", "params": {"path": path}}), t);+ assert_eq!(r["result"]["scanning"], true, "{r}");+ h.settle(SETTLE);+ };+ browse(&mut h);+ assert_eq!(h.app.session.visible_cloned().len(), 2);+ // another app deletes the photo that isn't selected (a selected or open one stays, shown as missing)+ let held: Vec<lightcraft_catalog::PhotoId> =+ h.app.session.selection.ids.iter().copied().chain(h.app.session.selection.active).chain(h.app.session.previous_active).collect();+ let name = |id: &lightcraft_catalog::PhotoId| h.app.session.catalog.photo(*id).map(|p| p.file_name.clone()).unwrap_or_default();+ let gone = if held.iter().any(|id| name(id) == "b.png") { "a.png" } else { "b.png" };+ std::fs::remove_file(dir.join(gone)).unwrap();+ // a later session: the browse's "Add 2 Photos" step is no longer in the undo history (photos it refers to+ // are kept, like selected ones)+ h.app.session.undo.clear();+ h.app.session.redo.clear();+ // the folder clicked again in the sidebar+ browse(&mut h);+ assert_eq!(h.app.session.visible_cloned().len(), 1, "the deleted file's record is forgotten");+ let _ = std::fs::remove_dir_all(&dir);+ }+#[test]fn add_folder_scans_in_the_background() {let mut h = demo([1200.0, 900.0]);diff --cc crates/ui-egui/src/import.rsindex 64e90acb8,11b35f1e3..c313d0804--- a/crates/ui-egui/src/import.rs+++ b/crates/ui-egui/src/import.rs@@@ -559,12 -584,12 +584,18 @@@ pub fn poll_scan(app: &mut LightcraftAp}app.session.import_probes = out.probes;if task.browse {+ // the folder and the ones its photos are in count as browsed now, as `library.browse` records them, so+ // their untouched Local photos aren't forgotten while the folder is in use+ if let Some(root) = app.session.browse.as_ref().map(|b| b.path.clone()) {+ let shown: Vec<String> = out.candidates.iter().map(|c| c.path.clone()).collect();+ app.session.note_browsed(&root, &shown);+ }+ // records of files gone from the folder (deleted or moved by another app) that nothing was changed on go,+ // as `library.browse` forgets them (issue #1392)+ if let Some(b) = app.session.browse.clone() {+ let listed: Vec<String> = out.candidates.iter().map(|c| c.path.clone()).collect();+ app.session.forget_gone_from(&b.path, b.subfolders, &listed);+ }// what the library doesn't know yet joins the Local viewlet queue: Vec<String> =out.candidates.iter().filter(|c| c.duplicate != Some("path".into()) && c.error.is_none()).map(|c| c.path.clone()).collect();diff --cc docs/parity-checklist.mdindex 4fcfc1852,d5c62bc6f..e3fdcbe23--- a/docs/parity-checklist.md+++ b/docs/parity-checklist.md@@@ -1,6 -1,6 +1,6 @@@# Lightroom parity checklist- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (LR-IMP-LOCAL: browsing from the sidebar records the folder; catalog import: persistent result, offline Local promotion and library-switch dismissal; integration batch 35: KEYC-SELECTONLYACTIVE, Select Only Active Photo ⌘⇧D; LR-BEHAV-AUTOSAVE, damaged snapshots repaired on open; LR-EDIT-OPTICS-PROFILE, Nikon Z 6II / Z 8 / Z f in-file distortion; LRC-LIB-CATALOG-IMPORT, WAL-only catalogs open; LR-EXP-DIM, enlargements stop at 512 MP; LR-IMP-CAMERA-COVERAGE, Canon EOS RP CR3 verified; model folder retry) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (integration batch 36: slideshow module, print-ready PDF fixes, local adjustment presets, Layout Image loupe overlay, Delete in an album removes from it, new languages Czech, Polish, Italian-ready catalogs; many rows' notes updated by their PRs) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (LR-IMP-LOCAL: browsing from the sidebar records the folder; integration batch 36: slideshow module, print-ready PDF fixes, local adjustment presets, Layout Image loupe overlay, Delete in an album removes from it, new languages Czech, Polish, Italian-ready catalogs; many rows' notes updated by their PRs) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6The measured, row-by-row checklist: one row per Lightroom feature, menu item and shortcut, what wehave and what is missing. It answers *does the feature exist?* (feature breadth). Whether it is good@@@ -790,7 -795,14 +795,15 @@@ Latin stays upright. Advanced Japanese| Date | Change | Summary ||---|---|---|+ | 2026-10-14 | minor | LR-IMP-CAMERA-COVERAGE: 17 uncompressed Olympus and Samsung Adobe models verified on one CC0 file each; status unchanged (🟡) |+ | 2026-10-13 | minor | LR-EDIT-SECTION-SOLO: Solo Mode for Edit sections (Window ▸ Edit Sections, section-header menu, ⌥-click); KEYC-PANELS notes it |+ | 2026-10-14 | minor | LR-MERGE-HDR ✅ → 🟡: tested on real 67 MP Sony brackets; moving clipped highlights (black-hole stars) and dark-sky ghosts fixed, merge memory cut ~25 %; AI Denoise on merged DNGs, JPEG response curves and per-frame memory remain (gap 29). LR-MERGE-HEADLESS, MENU-PHOTO-MERGE: HDR for Each Bracket Set (`merge.hdrBatch`) |+ | 2026-10-15 | patch | LR-VIEW-BEFOREAFTER: side by side and stacked panes share click-zoom animation for whole-frame images, window tiles and input; render requests keep the final target (#1821); status unchanged |+ | 2026-10-14 | patch | LR-META-XMP: automatic sidecar writes that fail (folder offline or read-only) wait and are written again once the files are reachable, with a notice (`cmd:library.retrySidecars`); status unchanged |+ | 2026-10-13 | minor | LR-BEHAV-WINDOW (new, 🟡): the desktop app's window opens at the size it was left at, zoomed / maximized if it was; full screen and the place on the desktop are not remembered |+ | 2026-10-14 | minor | LR-IMP-CAMERA-COVERAGE: Nikon D600, D610 and D5000 NEFs drop the filler and noise columns on the right (a band), and the D600 and D610 measure their white level inside the image (#1627); status unchanged (🟡) |+ | 2026-10-15 | patch | LR-VIEW-BEFOREAFTER: side by side and stacked panes share click-zoom animation for whole-frame images, window tiles and input; render requests keep the final target (#1821); status unchanged |+| 2026-10-14 | patch | LR-IMP-LOCAL: browsing a folder from the sidebar records it as browsed, as `library.browse` does, so its untouched photos aren't forgotten while in use; status unchanged (✅) || 2026-10-13 | patch | LR-VIEW-COMPARE, LRC-LIB-COMPARE: ⌘/Ctrl- and Shift-clicks on the filmstrip in Compare change the selection as in the grid; the two photos shown stay selected and the active photo is unchanged (#187); statuses unchanged || 2026-10-13 | minor | KEYC-SELECTONLYACTIVE: Edit → Select Only Active Photo (⌘⇧D) lands as a new row; status 🟡 (headless-tested, native macOS menu path unverified) || 2026-10-13 | patch | LRC-LIB-CATALOG-IMPORT: a catalog whose tables are all still in its `-wal` file (main file schema format 0) opens instead of failing as an unsupported schema format; status unchanged |diff --cc docs/whats-new.mdindex 2a184da48,3404dc978..1630169f2--- a/docs/whats-new.md+++ b/docs/whats-new.md@@@ -2,13 -2,121 +2,127 @@@## 2026-10-14+ ### Lightroom radial masks on the right side+ - Radial masks brought over from Lightroom Classic (catalog import, XMP sidecars, edits inside DNGs and presets) now+ apply their effect inside the circle, as Lightroom does, instead of outside it (issue #1815). A mask inverted in+ Lightroom stays inverted, and older Radial Filters keep their Effect Outside / Invert Mask setting. Photos imported+ before this keep the masks they got: Photo ▸ Read Metadata from File reads a sidecar's again.++ ### Delete in an album removes from the album only+ - In an album, the Delete key now takes the selected photos out of the album, as in Lightroom. It used to move them+ to Recently Deleted, so they also left their folder's view (issue #1805). They stay in the library and in their+ folder; Edit ▸ Undo puts them back in the album. Photo ▸ Remove from Album does the same and now shows the key.+ To delete photos from the library from an album, use Photo ▸ Delete Photo or right-click ▸ Delete Photo. In a smart+ album, Delete changes nothing: its rules decide what it shows.++ ### Local folders select a photo+ - Showing a Local folder now makes its first photo the active one, as albums and the other sources do (issue+ #1447), or keeps the photo you had when the folder holds it. Before, the photo from the previous view stayed active:+ Photo Grid marked nothing, and Detail, the histogram and the photo info showed a photo that isn't in the folder.++ ### HDR merges of moving lights, and many brackets at once+ - A star, the moon or a light that moves between the photos of a bracket (a night bracket on a tripod) no longer+ leaves a black hole where the middle photo had it clipped. With Deghost, the brightest photo's copy of it in a+ dark sky is now removed too.+ - Photo ▸ Photo Merge ▸ HDR for Each Bracket Set merges every bracket among the selected photos with the last HDR+ settings, one after the other: each stack, and photos taken less than a second apart at different exposures.+ From the command line: `lightcraft-cli merge hdr-batch FOLDER`.+ - Merging uses about a quarter less memory: three 67 MP raws need 3.8 GB instead of 4.8 GB.++ ### XMP sidecars catch up after a network share comes back+ - With automatic XMP writing on, an edit to a photo whose folder can't be written (a network share that dropped+ out, a folder that went read-only) used to be written only to the library, with a line in the log, so the sidecar+ stayed behind the edit. LightCraft now says once that the sidecars are waiting, tries again every few seconds once+ the files are reachable, and says when they're written. `library.retrySidecars` does it on request.++ ### Reliability+ - A damaged or crafted raw can no longer make LightCraft set aside gigabytes of memory before finding out the file is+ bad (issue #1512): a compressed PEF whose data is too short for the size it declares, an uncompressed TIFF-based+ raw whose tile claims far more samples than it holds, and an ARW6 with a broken tile are refused first. All 74+ files in the test corpus still decode.++ ### Reliability+ - Thumbnails and previews are written to the cache on disk by one background writer instead of a new thread for+ each image (issue #1522). When renders come in faster than the disk takes them, at most 128 MB of images wait;+ past that a write is skipped (the image stays in memory and is written by a later render), so a slow disk can't+ pile up threads and memory.++ ### Reliability+ - Saving the catalog and resuming a model download no longer write through a link left at the temporary file's+ name (`catalog.snap.tmp`, `model.onnx.part`): the link is removed and a new file made in its place, so the file it+ pointed to is never changed (issue #1502).++ ### Reliability+ - A photo whose file was replaced (Reload Changed Files after an outside edit) no longer keeps the faces recognition+ made from the old pixels: they are made again from the new file, and a scan still busy with the old file when it+ changed doesn't put its faces on the new one (issue #1524).++ ### Settings stays put when you change tabs+ - The Settings window keeps its top edge and width when you switch tabs, so the tab row no longer jumps around+ under the pointer. It used to be centred, so every tab of a different height moved it.++ ### Layout image over the loupe+ - View ▸ Loupe Overlay ▸ Choose Layout Image… draws a PNG with transparency over the photo in the loupe, such as+ a magazine cover's masthead and cover lines, so you can frame a shot for the page it is made for. It fits inside+ the photo, follows zoom and pan, and ⌥⌘O shows or hides it. The same menu sets its opacity and a matte that+ darkens the photo outside it. The layout stays chosen across launches.++ ### Smaller JPEG exports+ - JPEG exports are 12–14 % smaller at the same quality, with exactly the same pixels (issue #1373): each file now+ carries Huffman tables made for its own picture instead of the standard example tables. Every viewer opens them+ as before.++ ### Reliability+ - A photo whose Defringe amount was stored far past the sliders' 20 (in a damaged catalog or sidecar) no longer+ crashes LightCraft each time it renders: the amount acts as 20.++ ### Lens names for Nikon DSLR raws+ - Photos from Nikon DSLRs like the D700, D750, D80 or D5300 now show which lens they were taken with, for example+ "24.0-70.0 mm f/2.8". Those cameras don't write a lens name, so the lens field was empty and you couldn't filter or+ search by lens. LightCraft now reads the lens range Nikon keeps in its own maker note, the way Lightroom shows a+ lens it doesn't have a name for. Newly imported photos show it.++ ### Import when a card is connected+ - Settings → Import → Cameras and Cards has an option to open the import review as soon as a camera or memory card+ is connected, the same review File → Import from Device opens. It's off by default. A card that's already in when+ LightCraft starts doesn't ask, and if a dialog is open or an import is running it waits until that's done.++ ### Local folders+ - Photos deleted (or moved) by another app no longer stay in a Local folder, failing to load and logging an error+ each time you look (issue #1392): the next time you browse the folder, in a later session, they're left out. A photo you had rated, flagged or+ edited stays, marked missing, so its changes aren't lost; photos in My Photos are unchanged.++ ### Full-resolution panoramas+ - Panorama and HDR Panorama merges keep the resolution of their photos instead of stopping at 40 megapixels+ (issue #1455), up to 512 MP and 65,000 pixels on the long edge, as in Lightroom. When the full size needs more+ memory than the computer has, the panorama is made as large as fits (five 51 MP photos: up to 166 MP with+ 16 GB, 355 MP with 32 GB) and the message says so. The merge also frees each photo's pixels once they are+ projected, so it needs less memory than before at any size (an 81 MP stitch: 4.4 GB instead of 6.2 GB).++ ### Nikon D600, D610 and D5000+ - Raws from the Nikon D600, D610 and D5000 no longer show a bright line down the right edge (issue #1627). Their+ sensor data runs a few columns of filler past the picture, which stayed in the image; these bodies now develop+ at the camera JPEG's size (6016 × 4016 for the D600 and D610, 4288 × 2848 for the D5000, as the D90 already+ did). On the D600 and D610 the white level is also measured inside the picture, so the filler can't pass for+ clipped highlights.++ ### More Canon EOS R6 Mark II C-RAW files decode+ - Some EOS R6 Mark II C-RAW files (about 1 in 50 in one photographer's library) opened as their preview with+ "Canon CRX adaptive QP value 172" or "175". They now decode from the sensor data. Photos imported before this+ switch over with Photo ▸ Reload from Disk.++ ### Nikon raws without coloured edge bars+ - Raws from older Nikon bodies no longer show a thin coloured or dark bar along one edge (the right edge, or the top+ of a portrait photo): masked sensor columns were being developed as part of the picture (issues #976, #914,+ #1236). The D7000, D5100, D800, D800E, Df, D4, D3, D3S, D700, D300, D300S, D600, D610, D810, D4S, D5600,+ Coolpix A, D3000, D40X, D60, D80, D2Xs, D200, D3200, D3100, D5000, D40, D50, D70, D70s and Nikon 1 V1 now show+ the area the camera itself frames, a few pixels smaller than before.+### Local folders you browse are kept+- Browsing a folder under Local now records it as browsed, so the photos in folders you use aren't forgotten after+ the number of days set in Settings → Performance. Only the `library.browse` command recorded it before, so a+ folder browsed every day from the sidebar was forgotten anyway and read again from scratch on the next visit,+ which is slow on a network share.-+## 2026-10-14### Hard-edged Heal and Clone spots- A spot with Feather at 0 no longer draws black pixels exactly on its radius. This also fixes spots at 0% Opacity