LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Merge main into feat/1449-people-search
Arekatla Nishanth Chowdary597fb998dd84
diff --cc crates/catalog/src/query.rsindex 1e1c58f13,d1548f8bd..f98a083ef--- a/crates/catalog/src/query.rs+++ b/crates/catalog/src/query.rs@@@ -114,40 -135,15 +135,46 @@@ fn shuffle_rank(seed: u64, id: PhotoIdmix64(mix64(seed) ^ id.0)}+/// The tokens of a search text: split at whitespace, except inside double quotes, so+/// `person:"Jane Doe"` is one token (issue #1449). An unclosed quote runs to the end of the text; a+/// backslash is an ordinary character. One pass over the text, nothing allocated.+fn search_tokens(text: &str) -> impl Iterator<Item = &str> {+ let mut rest = text;+ std::iter::from_fn(move || {+ rest = rest.trim_start();+ if rest.is_empty() {+ return None;+ }+ let mut quoted = false;+ let end = rest+ .char_indices()+ .find(|&(_, c)| {+ quoted ^= c == '"';+ !quoted && c.is_whitespace()+ })+ .map_or(rest.len(), |(i, _)| i);+ let (tok, tail) = rest.split_at(end);+ rest = tail;+ Some(tok)+ })+}++/// `s` without the double quotes around it (a missing closing quote is allowed).+fn unquote(s: &str) -> &str {+ s.strip_prefix('"').map_or(s, |inner| inner.strip_suffix('"').unwrap_or(inner))+}++ /// What [`Filter::prepare`] works out once for a pass over many photos.+ pub(crate) struct Prepared {+ root: Option<String>,+ only: Option<std::collections::HashSet<PhotoId>>,+ }+fn token_matches(p: &Photo, tok: &str) -> bool {let t = tok.to_lowercase();- if let Some((field, val)) = t.split_once(':') {+ // a token that starts with a quote is a phrase, even with a colon in it+ if let Some((field, val)) = t.split_once(':').filter(|_| !t.starts_with('"')) {+ let val = unquote(val);let num = |s: &str| -> Option<(char, f64)> {let (op, rest) = match s.chars().next()? {c @ ('>' | '<' | '=') => (c, &s[1..]),diff --cc crates/catalog/src/tests.rsindex e90f116e2,8f1aaf151..401d62020--- a/crates/catalog/src/tests.rs+++ b/crates/catalog/src/tests.rs@@@ -738,64 -794,80 +794,142 @@@ fn cmp_name_ignores_case_without_allocaassert_eq!(cmp_name("a", "ab"), Less);}+/// Search Photos finds named people in free text, and a quoted value keeps a name of several words+/// together: `person:"Jane Doe"` (issue #1449). Malformed quotes narrow the result or change nothing.+#[test]+fn search_text_finds_people_and_quoted_values() {+ use lightcraft_meta::{Rect, Region, RegionKind};+ let region = |name: &str, kind: RegionKind| Region {+ rect: Rect { x0: 0.4, y0: 0.4, x1: 0.6, y1: 0.6 },+ kind,+ name: Some(name.to_string()),+ description: None,+ };+ let mut c = Catalog::new();+ let mut add = |name: &str, regions: Vec<Region>, keywords: &[&str]| {+ let id = c.alloc_photo_id();+ let mut p = Photo::new(id, Source::Demo { scene: 1 }, name, "JPEG", 6000, 4000, "2026-09-30T10:00:00");+ p.meta.regions = regions;+ p.meta.keywords = keywords.iter().map(|k| k.to_string()).collect();+ c.apply(Op::AddPhoto { photo: Box::new(p) }).unwrap();+ id+ };+ let jane = add("a.jpg", vec![region("Jane Doe", RegionKind::Face), region("Rex", RegionKind::Pet)], &[]);+ let both = add("b.jpg", vec![region("Jane Roe", RegionKind::Face), region("John Doe", RegionKind::Face)], &[]);+ let zoe = add("c.jpg", vec![region("Zoë Ångström", RegionKind::Face)], &["New York"]);+ let none = add("d.jpg", vec![], &["york minster"]);+ let q = |text: &str| {+ let mut ids = c.query(&Filter { text: text.into(), ..Default::default() }, &Sort::default());+ ids.sort();+ ids+ };++ // free text: a person's name, any case, any part of it; pets are not people+ assert_eq!(q("jane"), vec![jane, both]);+ assert_eq!(q("DOE"), vec![jane, both]);+ assert_eq!(q("ångström"), vec![zoe]);+ assert!(q("rex").is_empty(), "a pet is not a person");+ // words are still ANDed: b.jpg has a Jane and a Doe, a quoted phrase asks for them together+ assert_eq!(q("jane doe"), vec![jane, both]);+ assert_eq!(q("\"jane doe\""), vec![jane]);++ // fielded: the exact name, of several words when quoted+ assert_eq!(q("person:\"Jane Doe\""), vec![jane]);+ assert_eq!(q("who:\"jane roe\""), vec![both]);+ assert_eq!(q("person:\"Zoë Ångström\""), vec![zoe]);+ assert!(q("person:jane").is_empty(), "person: is the whole name, as before");+ assert!(q("person:Jane Doe").is_empty(), "unquoted, the second word is its own token, as before");+ assert_eq!(q("keyword:\"new york\""), vec![zoe], "other fields take quoted values too");+ assert_eq!(q("person:\"Jane Doe\" a.jpg"), vec![jane], "tokens after a quoted one still count");++ // malformed input never widens the match and never panics+ assert_eq!(q("person:\"Jane Doe"), vec![jane], "an unclosed quote runs to the end");+ assert!(q("person:\"Jane Doe a.jpg").is_empty(), "…and takes the rest of the text with it");+ assert!(q("person:\"\"").is_empty());+ assert!(q("person:").is_empty());+ assert_eq!(q("\""), vec![jane, both, zoe, none], "a lone quote is an empty phrase, like an empty search");+ assert_eq!(q("\"\" jane"), vec![jane, both]);+ assert!(q("\"jane:doe\"").is_empty(), "a quoted phrase is free text even with a colon");+ assert!(q("jane\\\"").is_empty(), "a backslash is an ordinary character");+ let long = format!("person:\"{}", "é ".repeat(50_000));+ assert!(q(&long).is_empty());+ assert_eq!(q(" \t jane \u{3000} "), vec![jane, both], "any whitespace separates tokens");+}+++ /// What the catalog remembers of its latest ops: which photos each changed and what of them, as long as that can be+ /// said photo by photo.+ #[test]+ fn the_catalog_remembers_which_photos_its_latest_ops_changed_and_what_of_them() {+ let mut c = Catalog::default();+ let photo = |c: &mut Catalog, name: &str| {+ let id = c.alloc_photo_id();+ c.apply(Op::AddPhoto {+ photo: Box::new(Photo::new(id, Source::File { path: format!("/p/{name}") }, name, "JPEG", 60, 40, "2026-01-01T10:00:00")),+ })+ .unwrap();+ id+ };+ let (a, b) = (photo(&mut c, "a.jpg"), photo(&mut c, "b.jpg"));+ let start = c.revision;+ assert_eq!(c.touched_since(start), Some(vec![]));+ assert_eq!(c.aspects_since(start), Some(Aspects::NONE));+ // a rating, then a flag on another photo, as one batch+ c.apply(Op::SetRating { id: a, rating: 3 }).unwrap();+ assert_eq!(c.touched_since(start), Some(vec![a]));+ assert_eq!(c.aspects_since(start), Some(Aspects::RATING));+ let after_rating = c.revision;+ c.apply(Op::Batch { ops: vec![Op::SetFlag { id: b, flag: Flag::Pick }, Op::SetRating { id: a, rating: 4 }] }).unwrap();+ assert_eq!(c.touched_since(start), Some(vec![a, b]), "each once");+ assert_eq!(c.touched_since(after_rating), Some(vec![a, b]));+ assert_eq!(c.aspects_since(after_rating), Some(Aspects::FLAG.with(Aspects::RATING)));+ assert_eq!(c.touched_since(c.revision), Some(vec![]));+ // a photo that goes counts for everything+ let before = c.revision;+ c.apply(Op::RemovePhoto { id: b }).unwrap();+ assert_eq!(c.touched_since(before), Some(vec![b]));+ assert!(c.aspects_since(before).is_some_and(|x| x.any_of(Aspects::PRESENCE) && x.any_of(Aspects::FILE)));+ // an op that changes more than photos of its own: nothing is said of what came before it+ let before = c.revision;+ let album = c.alloc_album_id();+ c.apply(Op::AddAlbum { album: Album::new(album, "Trip") }).unwrap();+ assert_eq!(c.touched_since(before), None);+ assert_eq!(c.aspects_since(start), None);+ assert_eq!(c.touched_since(c.revision), Some(vec![]), "from after it, it is known again");+ // a revision that is not this catalog's past+ assert_eq!(c.touched_since(c.revision + 5), None);+ // a revision set from outside (a library just loaded): nothing is known of how the catalog got there, and after+ // the next op nothing of before it+ let old = c.revision;+ c.revision = 7 << 32;+ assert_eq!(c.touched_since(old), None);+ assert_eq!(c.aspects_since(c.revision), None);+ let loaded = c.revision;+ c.apply(Op::SetRating { id: a, rating: 1 }).unwrap();+ assert_eq!(c.touched_since(loaded), Some(vec![a]));+ assert_eq!(c.touched_since(old), None);+ // an op that fails changes nothing, and what is remembered never says less than what happened+ let before = c.revision;+ assert!(c.apply(Op::SetRating { id: PhotoId(9_999), rating: 1 }).is_err());+ assert_eq!(c.revision, before);+ c.apply(Op::SetFlag { id: a, flag: Flag::Pick }).unwrap();+ assert!(c.touched_since(before).is_some_and(|ids| ids.contains(&a)));+ assert!(c.aspects_since(before).is_some_and(|x| x.any_of(Aspects::FLAG)));+ // a batch that fails midway is undone as a whole; a batch in a batch is remembered photo by photo; a batch+ // with an op that changes more than photos is not+ let before = c.revision;+ assert!(c.apply(Op::Batch { ops: vec![Op::SetRating { id: a, rating: 5 }, Op::SetRating { id: PhotoId(9_999), rating: 1 }] }).is_err());+ assert_eq!((c.revision, c.photo(a).map(|p| p.rating)), (before, Some(1)));+ c.apply(Op::Batch { ops: vec![Op::Batch { ops: vec![Op::SetRating { id: a, rating: 2 }] }] }).unwrap();+ // (the photo the failed batch asked for and never found may be named too: more is said, never less)+ assert!(c.touched_since(before).is_some_and(|ids| ids.contains(&a)));+ let before = c.revision;+ c.apply(Op::Batch { ops: vec![Op::SetRating { id: a, rating: 3 }, Op::RenameAlbum { id: album, name: "Journey".into() }] }).unwrap();+ assert_eq!(c.touched_since(before), None);+ // more ops than are remembered: the oldest are answered with "anything"+ let long_ago = c.revision;+ for i in 0..9000u32 {+ c.apply(Op::SetRating { id: a, rating: (i % 5) as u8 }).unwrap();+ }+ assert_eq!(c.touched_since(long_ago), None);+ assert_eq!(c.touched_since(c.revision - 10), Some(vec![a]));+ }diff --cc docs/whats-new.mdindex d7e1e1a78,97e1367a8..67687512a--- a/docs/whats-new.md+++ b/docs/whats-new.md@@@ -6,13 -156,74 +156,79 @@@- A spot with Feather at 0 no longer draws black pixels exactly on its radius. This also fixes spots at 0% Opacitychanging pixels along their edge. The hard edge now leaves pixels on the radius unchanged.+### Search finds people+- Typing a person's name in Search Photos finds the photos with that named face (issue #1449).+- Quotes keep several words together: `person:"Jane Doe"` finds exactly that person, `"jane doe"` those words side+ by side, and `keyword:"new york"` a keyword of two words.++ ### Where the camera focused+ - **View ▸ Show Focus Point** (⌥F) draws the autofocus frame the camera recorded over the photo, in Detail, Compare+ and Survey, following rotation and crops; the Info panel says how it focused (`AF-C · Wide · Animal Eye Tracking`).+ Lightroom has no such view.+ - **Z zooms to it**: Toggle Zoom centres on the focus point, so checking that the subject is sharp is one key+ (View ▸ Zoom to Focus Point turns this off). Photos without a point zoom as before.+ - Sony α1 (ILCE-1) and A7S III (ILCE-7SM3) raws for now; manual-focus shots and Wide shots that only report the frame+ centre show nothing. More cameras will follow. Details: [focus-points.md](focus-points.md).+ - **Photos already in your library get theirs in the background**: LightCraft reads just the few kilobytes of each+ file that hold the focus point (about 100 photos a second from a spinning disk), with a *Reading focus points* row+ in the activity stack you can stop. Photo ▸ Read Focus Points runs it by hand.++ ### Cleaner HDR merges+ - Bright windows in an HDR made with Photo ▸ Photo Merge ▸ HDR no longer take a magenta tinge from the brighter+ photos along the areas they clipped: right next to a clipped area, a photo's colour isn't used. It showed most when+ the highlights were darkened or saturated.+ - The same photos give the same HDR whatever order they are selected in; before, a different order could change a+ few pixels.++ ### HDR merges keep the white balance+ - An HDR merged from raws that LightCraft colours from the camera's JPEG (CR2, NEF, ARW…) now opens at the same+ As Shot temperature and tint as its photos, and changing the white balance no longer turns it green. Sony ARW+ merges used to open at about 7000 K / +115 where the photos show 4000–5300 K / +8. HDRs merged before this keep+ their old white balance; merge them again.+## 2026-10-13+ ### Edits keep up in a large library+ - A small edit (a keyword, a rating, a flag, a slider) no longer has the grid's list worked out again from every+ photo: only the photos the edit touched are asked about again and put at their place in the order. In a library of+ 67,000 photos that step went from 37 ms to under 1 ms. Still worked out whole: an edit to more than 256 photos, a+ change to an album, a stack or the keyword list, an album shown in its own order, Recently Added, Missing Photos,+ and a view that asks about "the last N days".+ - With no filter set, the count of the source is taken from the list instead of from a second pass over the library.+ - The side panels keep a tally an edit cannot have changed: a rating or a slider changes none of the folders,+ keywords, dates, people and counts; a keyword leaves the folders, the dates and the counts as they are. With both+ side panels open, the frame after a keyword went from about 156 ms to about 54 ms in that library (2 ms with the+ panels closed, from 71 ms).+ - The count beside each smart album in the left panel follows an edit the same way: the album asks only the photos+ the edit touched, where it asked every photo of the library after each edit (about 25 ms an album in that library).+ With that, the frame after a keyword is at about 29 ms there. New rules, a change to an album or the keyword list,+ an edit to more than 256 photos, and each new minute for an album that asks about "the last N days" are still+ counted from every photo.+ - Still tallied from every photo on each edit: the filter bar's lists of cameras, lenses and keywords.++ ### A view can hold its photos until you refresh it+ - View ▸ Hold View Until Refreshed (off unless you turn it on; kept with the library). With it on, an edit that makes+ a photo stop matching the view keeps it in the view: a keyword given in a smart album of photos without keywords,+ a flag taken off in Picks, a rating that falls under the filter bar's. With it off, as before, the photo leaves the+ grid at once and every photo after it moves up. View ▸ Refresh View (also in the sort menu while the hold is on),+ Reshuffle, another source, filter or sort, or new rules for the smart album shows what matches now.+ - Photos that start matching still appear at once, and deleting a photo or taking it out of the album or folder+ shown still takes it out of the view.++ ### The window opens at the size you left it+ - LightCraft's window opens at the size it had when you last used it, and zoomed (macOS) / maximized if it was: it+ used to open at 1600 × 1000 every time. Double-click the top bar to zoom the window, quit, and it is zoomed when+ you come back; un-zoom it and it goes back to the size it had before.+ - Full screen is not remembered (the app opens as a window), and neither is where on the desktop the window was:+ the system places it.+ - On macOS the system does not tell LightCraft when a window is zoomed from the Window menu or resized after a+ zoom, so it goes by the window's size, and when in doubt takes the window for a window of the size it has: it+ comes back as large as you left it, but not as a zoomed window. That is so after a zoom from the Window menu+ with the Dock at a side of the screen, or of a window already as wide as the screen. Zoomed by a double-click+ on the top bar it comes back zoomed. The other way round, a window you drag out until it is as wide as the+ screen and nearly as tall counts as zoomed.+ - For scripts: a size set with `ui.resize` is remembered like any other, so a script that needs a size sets it.+### HDR merges keep the lens correction- An HDR made with Photo ▸ Photo Merge ▸ HDR now keeps the lens correction the photos carry (Sony's, Panasonic'sand Leica's, and the one some DNGs carry, e.g. from drones): Optics ▸ Enable Lens Corrections straightens it as it