diff --git a/AGENTS.md b/AGENTS.md index de65402c3c..94b88ca730 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -71,7 +71,8 @@ never a panic. Never ship a panic path; fix crashes before building on them. Thi (JNI VM/activity adoption), `crates/winspool` (Win32 print spooler), `crates/winmsi` (`MsiEnumClientsW` + `MsiGetComponentPathW` for the updater), `crates/winjob` (a kill-on-close job object, so the Windows CLI launcher's app ends with it), `crates/firstclick` (macOS: replaces `acceptsFirstMouse:` on winit's window view, - for the background-click setting), `crates/libraw` (FFI into its C shim over LibRaw, opt-in, see Non-negotiables), and `apps/android`'s `#[unsafe(no_mangle)] android_main`. Every other + for the background-click setting), `crates/opendocs` (macOS: adds `application:openURLs:` to winit's application + delegate, so photos opened from Finder, the Dock or Open With reach the app), `crates/libraw` (FFI into its C shim over LibRaw, opt-in, see Non-negotiables), and `apps/android`'s `#[unsafe(no_mangle)] android_main`. Every other production crate root has `#![forbid(unsafe_code)]`. New unsafe need → isolated, well-tested helper crate: `// SAFETY:` everywhere, safe API, safe fallback, and a line here naming it. - Input-derived numbers are hostile: `get()` not `[i]`/`[a..b]`; checked/saturating math; no division by zero, diff --git a/Cargo.lock b/Cargo.lock index 0164286e72..be8ef03290 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4581,6 +4581,7 @@ dependencies = [ "lcc-gpu", "lcc-gpumem", "lcc-hdrmeta", + "lcc-opendocs", "lcc-pipeline", "lcc-preview", "lcc-raster", @@ -5325,6 +5326,17 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "lcc-opendocs" +version = "26.48.2" +dependencies = [ + "block2 0.6.2", + "log", + "objc2 0.6.4", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", +] + [[package]] name = "lcc-pdf" version = "26.48.2" diff --git a/Cargo.toml b/Cargo.toml index 2d9d171589..7826c94262 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ lcc-winspool = { path = "crates/winspool" } lcc-winmsi = { path = "crates/winmsi" } lcc-winjob = { path = "crates/winjob" } lcc-firstclick = { path = "crates/firstclick" } +lcc-opendocs = { path = "crates/opendocs" } lcc-android-host = { path = "crates/android-host" } lcc-peer = { path = "crates/peer" } lcc-sync = { path = "crates/sync" } diff --git a/apps/app/Cargo.toml b/apps/app/Cargo.toml index 93a96481b9..3c36b5f3be 100644 --- a/apps/app/Cargo.toml +++ b/apps/app/Cargo.toml @@ -38,6 +38,8 @@ libraw = ["lcc-engine/libraw", "lcc-cli/libraw"] # the command-line tool, run when the program is started as `` (`main`); its features follow # the app's, so a build without HEIF leaves it out of the CLI too lcc-cli = { path = "../cli", default-features = false } +# photos macOS hands the app from Finder, the Dock or Open With (a no-op elsewhere) +lcc-opendocs = { workspace = true } # reading the Logi plugin package's version (`logi_plugin`) and the control-surface e2e test lcc-surface = { workspace = true } lcc-brand = { workspace = true } diff --git a/apps/app/src/main.rs b/apps/app/src/main.rs index 40f908aafd..f29bb6f90e 100644 --- a/apps/app/src/main.rs +++ b/apps/app/src/main.rs @@ -42,6 +42,7 @@ mod midi; mod native_dialog; #[cfg(target_os = "macos")] mod native_menu; +mod reveal; #[cfg(any(target_os = "linux", windows))] mod screen_icc; #[cfg(target_os = "macos")] @@ -169,6 +170,8 @@ impl eframe::App for App { } fn raw_input_hook(&mut self, _ctx: &egui::Context, raw: &mut egui::RawInput) { self.0.raw_input_hook(raw); + // after the hook, which replaces `dropped_files` with the control channel's drops + raw.dropped_files.extend(opened_as_dropped(lcc_opendocs::take())); } fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) { self.0.perf.host_frame_ms = frame.info().cpu_usage.map(|s| f64::from(s) * 1000.0); @@ -807,6 +810,10 @@ fn services(cc: &eframe::CreationContext<'_>, log_file: Option<&std::path::Path> launch(open_url_command(url)) })), reveal: Some(Box::new(|path: &str| { + // Linux/BSD: select the file in the file manager, never waiting for it (upstream #4653) + if cfg!(any(target_os = "linux", target_os = "freebsd")) { + return reveal::reveal_one(path); + } let status = if cfg!(target_os = "macos") { std::process::Command::new("open").args(["-R", path]).status() } else if cfg!(target_os = "windows") { @@ -819,6 +826,11 @@ fn services(cc: &eframe::CreationContext<'_>, log_file: Option<&std::path::Path> .map_err(|e| e.to_string()) .and_then(|s| if s.success() || cfg!(target_os = "windows") { Ok(()) } else { Err(format!("reveal failed: {s}")) }) })), + reveal_many: if cfg!(any(target_os = "linux", target_os = "freebsd")) { + Some(Box::new(|paths: &[String]| reveal::reveal_files(paths))) + } else { + None + }, pick_files: picker!(|| { file_dialog() .add_filter_nocase(lcc_ui_egui::i18n::tr("Photos"), lcc_engine::import::EXTENSIONS) @@ -1247,6 +1259,25 @@ fn launch_imports(args: &[String]) -> LaunchArgs { launch_imports_in(args, cwd.as_deref(), home.as_deref()) } +/// A file the system asked the app to open (`lcc_opendocs`; macOS: Finder, the Dock, Open With), +/// handed to the UI as a file dropped on the window: imported like a drop, or held while no library +/// is open yet (`library_problem::hold_dropped`). Adapted from upstream #1204. +#[derive(Debug)] +struct OpenedFile(std::path::PathBuf); + +impl egui::DroppedFile for OpenedFile { + fn path(&self) -> &std::path::Path { + &self.0 + } + fn bytes(&self) -> Result, String> { + std::fs::read(&self.0).map_err(|e| e.to_string()) + } +} + +fn opened_as_dropped(paths: Vec) -> impl Iterator { + paths.into_iter().map(|p| std::sync::Arc::new(OpenedFile(p.into())) as egui::DroppedFileHandle) +} + /// What the launch arguments ask for: files and folders to import, a library to open (a library's `catalog.snap` /// or folder, double-clicked in the file manager), and a notice for each argument /// left alone. @@ -1341,8 +1372,9 @@ fn panic_log_path(args: impl IntoIterator) -> Option< /// skipped, as the parser takes them. /// Whether the window looks for a newer release at start: only a session that keeps its settings, and not when /// `--no-update-check` was given (Settings > General still decides within that). +/// `_DISABLE_UPDATES` (a distro package) turns it off too (adapted from upstream #4663). fn startup_update_check(keeps_settings: bool, no_update_check: bool) -> bool { - keeps_settings && !no_update_check + keeps_settings && !no_update_check && !lcc_engine::update::disabled_by_env() } fn in_memory_session(args: impl IntoIterator) -> bool { @@ -1646,11 +1678,17 @@ fn run() -> eframe::Result { b.with_x11(); })); } + // macOS hands photos opened from Finder, the Dock or Open With to the running app, not as + // arguments; installed before the event loop exists, so the ones it was launched with arrive too + lcc_opendocs::install(); let started = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { eframe::run_native( lcc_brand::DISPLAY_NAME, options, Box::new(move |cc| { + // opened files that arrive from now on wake the window, which takes them as drops + let opened_ctx = cc.egui_ctx.clone(); + lcc_opendocs::set_waker(move || opened_ctx.request_repaint()); // the window's renderer is up (eframe calls this after creating it) win_files_app.started(window_renderer); came_up_app.store(true, std::sync::atomic::Ordering::Relaxed); @@ -1867,7 +1905,7 @@ fn run() -> eframe::Result { let started = started.unwrap_or_else(|_| Err(eframe::Error::AppCreation("the window's renderer panicked while starting".into()))); if let Err(e) = &started { // the renderer never came up: start again, which tries the next one in the chain - if window_gpu::relaunch_after_failure(&win_files) { + if window_gpu::relaunch_after_failure(&win_files, lcc_opendocs::take()) { log::error!("{} could not open its window with {}: {e}; trying the next renderer", lcc_brand::DISPLAY_NAME, window_renderer.name()); return Ok(()); } @@ -1927,6 +1965,16 @@ fn startup_failed(error: &str, log_file: Option<&std::path::Path>) { mod tests { use super::*; + /// Files the system asks the app to open (macOS, `lcc_opendocs`) reach the UI as dropped files, + /// path for path and in order. + #[test] + fn opened_files_are_handed_over_as_drops() { + let dropped: Vec<_> = opened_as_dropped(vec!["/tmp/a b.arw".into(), "/tmp/c.heic".into()]).collect(); + let paths: Vec<_> = dropped.iter().map(|f| f.path().to_path_buf()).collect(); + assert_eq!(paths, [std::path::PathBuf::from("/tmp/a b.arw"), std::path::PathBuf::from("/tmp/c.heic")]); + assert_eq!(opened_as_dropped(Vec::new()).count(), 0); + } + fn os(args: &[&str]) -> Vec { args.iter().map(std::ffi::OsString::from).collect() } @@ -2694,7 +2742,7 @@ mod config_path_tests { /// that keeps its settings looks. #[test] fn no_update_check_flag_disables_the_startup_check() { - assert!(startup_update_check(true, false)); + assert_eq!(startup_update_check(true, false), !lcc_engine::update::disabled_by_env()); assert!(!startup_update_check(true, true)); assert!(!startup_update_check(false, false)); } diff --git a/apps/app/src/reveal.rs b/apps/app/src/reveal.rs new file mode 100644 index 0000000000..b9246f14b2 --- /dev/null +++ b/apps/app/src/reveal.rs @@ -0,0 +1,100 @@ +//! Revealing photos in the Linux/BSD file manager. Adapted from upstream #4653 (issues #4652, +//! #4658 there): a file is selected through `org.freedesktop.FileManager1.ShowItems` over D-Bus +//! (several files in one window), and only where that service is missing does the parent folder +//! open with `xdg-open`, which is spawned without waiting so the app never freezes until the file +//! manager window closes. + +/// `file://` URI for `ShowItems`: every byte outside the unreserved set (and `/`) is +/// percent-encoded, so spaces and non-ASCII names survive the D-Bus call. +pub(crate) fn file_uri(path: &str) -> String { + const HEX: &[u8; 16] = b"0123456789ABCDEF"; + let mut out = String::with_capacity(path.len().saturating_add(7)); + out.push_str("file://"); + for &byte in path.as_bytes() { + match byte { + b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' | b'/' => out.push(char::from(byte)), + _ => { + out.push('%'); + out.push(HEX.get(usize::from(byte >> 4)).map_or('0', |&c| char::from(c))); + out.push(HEX.get(usize::from(byte & 0xF)).map_or('0', |&c| char::from(c))); + } + } + } + out +} + +/// `ShowItems` on the running file manager (Linux: `zbus` is a Linux dependency). Managers +/// without `FileManager1` answer with an error and the caller falls back to `xdg-open`. +#[cfg(target_os = "linux")] +fn show_items(uris: &[String]) -> Result<(), String> { + let connection = zbus::blocking::connection::Builder::session() + .map_err(|e| e.to_string())? + .method_timeout(std::time::Duration::from_secs(2)) + .build() + .map_err(|e| e.to_string())?; + let proxy = + zbus::blocking::Proxy::new(&connection, "org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1") + .map_err(|e| e.to_string())?; + let startup_id = ""; + proxy.call::<_, _, ()>("ShowItems", &(uris, startup_id)).map_err(|e| e.to_string()) +} + +#[cfg(not(target_os = "linux"))] +fn show_items(_: &[String]) -> Result<(), String> { + Err("no FileManager1 on this system".into()) +} + +/// Opens `dir` with `xdg-open` without waiting for it; the child is reaped on a thread so no +/// zombie is left behind. +fn xdg_open_dir(dir: &str) -> Result<(), String> { + let mut child = std::process::Command::new("xdg-open").arg(dir).spawn().map_err(|e| format!("xdg-open: {e}"))?; + std::thread::spawn(move || { + let _ = child.wait(); + }); + Ok(()) +} + +/// Reveals one path: a folder opens, a file is selected in its folder, falling back to opening +/// the folder. +pub(crate) fn reveal_one(path: &str) -> Result<(), String> { + let p = std::path::Path::new(path); + if p.is_dir() { + return xdg_open_dir(path); + } + if show_items(std::slice::from_ref(&file_uri(path))).is_ok() { + return Ok(()); + } + let dir = p.parent().map(|d| d.to_string_lossy().to_string()).filter(|d| !d.is_empty()).unwrap_or_else(|| ".".into()); + xdg_open_dir(&dir) +} + +/// Reveals several files: one `ShowItems` call selects them all in one window; without the +/// service, the first file's folder opens, as a single reveal does. +pub(crate) fn reveal_files(paths: &[String]) -> Result<(), String> { + let Some(first) = paths.first() else { return Err("no photo selected".into()) }; + if paths.len() > 1 { + let uris: Vec = paths.iter().map(|path| file_uri(path)).collect(); + if show_items(&uris).is_ok() { + return Ok(()); + } + } + reveal_one(first) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn file_uris_encode_for_show_items() { + assert_eq!(file_uri("/photos/IMG_0001.CR3"), "file:///photos/IMG_0001.CR3"); + assert_eq!(file_uri("/home/Me/My Photos/IMG 1.jpg"), "file:///home/Me/My%20Photos/IMG%201.jpg"); + assert_eq!(file_uri("/photos/café-étude.jpg"), "file:///photos/caf%C3%A9-%C3%A9tude.jpg"); + assert_eq!(file_uri("/photos/a#b%c.jpg"), "file:///photos/a%23b%25c.jpg"); + } + + #[test] + fn revealing_nothing_is_an_error() { + assert!(reveal_files(&[]).is_err()); + } +} diff --git a/apps/app/src/window_gpu.rs b/apps/app/src/window_gpu.rs index f7039a4a0e..b4637eb19f 100644 --- a/apps/app/src/window_gpu.rs +++ b/apps/app/src/window_gpu.rs @@ -464,7 +464,7 @@ pub fn check_pipeline(device: &wgpu::Device, build: impl FnOnce(&wgpu::Device)) /// The start failed (error or panic) before the window's renderer came up: start the app again, /// which then tries the next renderer. `false`: not relaunched (it came up, nothing written to /// disk, or the retries are used up). -pub fn relaunch_after_failure(files: &Files) -> bool { +pub fn relaunch_after_failure(files: &Files, opened: Vec) -> bool { if !files.armed() { return false; } @@ -479,6 +479,8 @@ pub fn relaunch_after_failure(files: &Files) -> bool { log::warn!("window: the renderer failed to start; starting again with the next one"); std::process::Command::new(exe) .args(std::env::args_os().skip(1)) + // files the system handed this launch (macOS: opened from Finder), so the next one imports them + .args(opened) .env(lcc_brand::env_var(RETRY_VAR), (tries + 1).to_string()) .spawn() .map_err(|e| log::error!("window: could not start again: {e}")) @@ -543,7 +545,7 @@ mod tests { // nothing written without a settings folder let none = Files::new(None); none.arm(dx); - assert!(!none.armed() && !relaunch_after_failure(&none)); + assert!(!none.armed() && !relaunch_after_failure(&none, Vec::new())); let _ = std::fs::remove_dir_all(&d); } @@ -633,7 +635,7 @@ mod tests { let f = Files::new(Some(d.clone())); assert_eq!(f.take_failed(), None); f.arm(WindowRenderer::Glow); - assert!(!f.armed() && !relaunch_after_failure(&f)); + assert!(!f.armed() && !relaunch_after_failure(&f, Vec::new())); let _ = std::fs::remove_dir_all(&d); } diff --git a/apps/cli/src/calibrate_lightroom.rs b/apps/cli/src/calibrate_lightroom.rs index 41abb6967d..6a0a6ede54 100644 --- a/apps/cli/src/calibrate_lightroom.rs +++ b/apps/cli/src/calibrate_lightroom.rs @@ -180,6 +180,9 @@ fn probe_check_cmd(args: &[String]) -> Result<(), String> { let (Some(probes), Some(exports)) = (probes, exports) else { return Err("probe-check needs --probes DIR (from `probe`) and --exports DIR (Lightroom's exports of them)".into()); }; + // the app's side of the comparison is its default render, so the camera's calibration and the + // installed profiles apply as they do in a render (they are installed by a session, and none is made here) + lcc_engine::camera_profiles::install_dcps(); let report = lcc_colourfit::probe::check(&probes, &exports).map_err(|e| e.to_string())?; if let Some(path) = &out { let text = serde_json::to_string_pretty(&report).map_err(|e| e.to_string())?; diff --git a/apps/cli/src/lib.rs b/apps/cli/src/lib.rs index 848f1d6c02..6ac35db23c 100644 --- a/apps/cli/src/lib.rs +++ b/apps/cli/src/lib.rs @@ -644,8 +644,15 @@ fn mcp(args: &[String]) -> Result<(), String> { }; if !files.is_empty() { let paths = expand_paths(&files); - let r = h.session.execute("library.import", &json!({"paths": paths})).map_err(|e| e.to_string())?; - eprintln!("{CLI} mcp: imported {} photo(s)", r.get("imported").and_then(Value::as_array).map_or(0, Vec::len)); + // A folder with no photos yet still serves (photos come later through `import`); + // `library.import` refuses an empty list, which would end the server before it starts + // (adapted from upstream #4538). + if paths.is_empty() { + eprintln!("{CLI} mcp: no photos found in {}; nothing imported", files.join(", ")); + } else { + let r = h.session.execute("library.import", &json!({"paths": paths})).map_err(|e| e.to_string())?; + eprintln!("{CLI} mcp: imported {} photo(s)", r.get("imported").and_then(Value::as_array).map_or(0, Vec::len)); + } } Box::new(h) } diff --git a/apps/cli/tests/mcp_empty_folder.rs b/apps/cli/tests/mcp_empty_folder.rs new file mode 100644 index 0000000000..ebfe31c9db --- /dev/null +++ b/apps/cli/tests/mcp_empty_folder.rs @@ -0,0 +1,29 @@ +//! ` mcp FOLDER` serves even when the folder holds no photos yet (adapted from upstream #4538). + +use std::io::Write; +use std::process::{Command, Stdio}; + +#[test] +fn empty_folder_still_serves() { + let dir = std::env::temp_dir().join(format!("lcc-cli-test-{}", std::process::id())).join("mcp-empty-folder"); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + let mut child = Command::new(env!("CARGO_BIN_EXE_app-cli")) + .arg("mcp") + .arg(&dir) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap(); + let mut input = child.stdin.take().unwrap(); + input.write_all(b"{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-06-18\",\"capabilities\":{},\"clientInfo\":{\"name\":\"test\",\"version\":\"1\"}}}\n").unwrap(); + drop(input); + let out = child.wait_with_output().unwrap(); + let stdout = String::from_utf8_lossy(&out.stdout); + let stderr = String::from_utf8_lossy(&out.stderr); + let _ = std::fs::remove_dir_all(&dir); + assert!(out.status.success(), "an empty folder must not stop the server: {stderr}"); + assert!(stderr.contains("serving MCP on stdio"), "CLI must reach the MCP transport: {stderr}"); + assert!(stdout.contains("\"id\":1") && stdout.contains("\"result\""), "initialize must be answered: {stdout}"); +} diff --git a/apps/web/src/web.rs b/apps/web/src/web.rs index 334937eff7..e4f56bb346 100644 --- a/apps/web/src/web.rs +++ b/apps/web/src/web.rs @@ -243,6 +243,7 @@ fn services(originals: Originals, backend: Option, files: Files, frozen lcc_codecs::encode_png(&lcc_codecs::EncodeImage::rgba8(img), &lcc_codecs::EncodeMeta::default()).unwrap_or_default() })), reveal: None, + reveal_many: None, log_file: None, open_with: None, open_all_with: None, diff --git a/crates/engine/src/cmd/browse.rs b/crates/engine/src/cmd/browse.rs index 514a43f3d8..6fc99ea653 100644 --- a/crates/engine/src/cmd/browse.rs +++ b/crates/engine/src/cmd/browse.rs @@ -17,7 +17,7 @@ use lcc_catalog::{Op, PhotoId, Source}; use serde_json::{Value, json}; use super::{CommandSpec, always, bad, bool_or, cmd, str_param}; -use crate::import::{ImportMode, ImportOptions, import_with, is_supported}; +use crate::import::{ImportMode, ImportOptions, browse_folder_string, import_with, is_supported}; use crate::{Browse, LibrarySource, Result, Session}; fn browse(s: &mut Session, p: &Value) -> Result { @@ -27,7 +27,7 @@ fn browse(s: &mut Session, p: &Value) -> Result { if !dir.is_dir() { return Err(bad(C, format!("{path}: not a folder"))); } - let dir_s = dir.to_string_lossy().trim_end_matches(['/', '\\']).to_string(); + let dir_s = browse_folder_string(&dir); // subfolders: given, it wins; left out, a re-browse of the same folder keeps the choice and a // new folder starts with subfolders in (the Import tab's browse applies the same rule) let subfolders = bool_or(p, "subfolders", s.browse.as_ref().is_none_or(|b| b.path != dir_s || b.subfolders)); @@ -143,8 +143,7 @@ const RESTAMP_SECS: i64 = 3600; fn stamp_browsed(s: &mut Session, root: &str, files: &[String]) { let now = (s.clock)(); let now_s = lcc_catalog::stacks::iso_seconds(&now); - let mut folders: std::collections::BTreeSet = - files.iter().filter_map(|f| Path::new(f).parent().map(|d| d.to_string_lossy().trim_end_matches(['/', '\\']).to_string())).collect(); + let mut folders: std::collections::BTreeSet = files.iter().filter_map(|f| Path::new(f).parent().map(browse_folder_string)).collect(); folders.insert(root.to_string()); let ops: Vec = folders .into_iter() diff --git a/crates/engine/src/cmd/keywords.rs b/crates/engine/src/cmd/keywords.rs index 858f3ff4b0..c58f49b59d 100644 --- a/crates/engine/src/cmd/keywords.rs +++ b/crates/engine/src/cmd/keywords.rs @@ -286,14 +286,21 @@ pub fn specs() -> Vec { ), None => None, }; - // keywords not given: the renamed set's own, else the current nine - let keywords = if p.get("keywords").is_some() { - slots(&strs(p, "keywords")) - } else { - match renames.and_then(|at| s.keyword_sets.get(at)) { + // Validate every supplied slot before replacing or renaming the saved set. + let invalid_keywords = || bad("keyword.saveSet", "`keywords` must be a string, null or an array of strings"); + let keywords = match p.get("keywords") { + Some(Value::String(k)) => slots(std::slice::from_ref(k)), + Some(Value::Array(a)) => { + let typed = a.iter().map(|k| k.as_str().map(str::to_string).ok_or_else(invalid_keywords)).collect::>>()?; + slots(&typed) + } + Some(Value::Null) => Vec::new(), + Some(_) => return Err(invalid_keywords()), + // keywords not given: the renamed set's own, else the current nine + None => match renames.and_then(|at| s.keyword_sets.get(at)) { Some(x) => x.keywords.clone(), None => current_keywords(s), - } + }, }; let set = KeywordSet { name: name.clone(), keywords }; match renames { diff --git a/crates/engine/src/cmd/metadata.rs b/crates/engine/src/cmd/metadata.rs index 7bfa3718da..5d3281d66c 100644 --- a/crates/engine/src/cmd/metadata.rs +++ b/crates/engine/src/cmd/metadata.rs @@ -93,9 +93,11 @@ pub fn apply_to(m: &mut Meta, fields: &Value) { m.copyright_status = st; } } else if k == "keywords" { + let mut seen: std::collections::HashSet = m.keywords.iter().map(|k| k.to_lowercase()).collect(); for kw in v.as_array().into_iter().flatten().filter_map(Value::as_str) { - if !m.keywords.iter().any(|x| x.eq_ignore_ascii_case(kw)) { - m.keywords.push(kw.to_string()); + let kw = lcc_catalog::keywords::clean(kw); + if !kw.is_empty() && seen.insert(kw.to_lowercase()) { + m.keywords.push(kw); } } } else if let (Some(f), Some(l)) = (list_field(m, k), text_list(v)) { diff --git a/crates/engine/src/cmd/preset_files.rs b/crates/engine/src/cmd/preset_files.rs index 220bcd134b..3d4d606554 100644 --- a/crates/engine/src/cmd/preset_files.rs +++ b/crates/engine/src/cmd/preset_files.rs @@ -5,7 +5,7 @@ use serde_json::{Value, json}; use super::mask_effect_files as mef; use super::{CommandSpec, always, bad, cmd, str_param}; use crate::preset_import::{group_from_dir, read_presets}; -use crate::presets::{LCPRESET_EXT, expand_preset_paths, to_lcpreset}; +use crate::presets::{LCPRESET_EXT, expand_preset_paths_with_seen, to_lcpreset}; use crate::{Result, Session}; fn strings(p: &Value, key: &str) -> Option> { @@ -28,9 +28,10 @@ fn import(s: &mut Session, p: &Value) -> Result { let mut export_found = Vec::new(); // every file's presets, added in one go below (adding one at a time indexed the library each time) let mut pending: Vec<(lcc_develop::Preset, Value)> = Vec::new(); + let mut seen_dirs = std::collections::HashSet::new(); for top in &paths { let from_dir = std::path::Path::new(top).is_dir(); - for f in expand_preset_paths(std::slice::from_ref(top)) { + for f in expand_preset_paths_with_seen(std::slice::from_ref(top), &mut seen_dirs) { // presets in a folder go to a group named after it (unless the file names its own) // the path from the imported folder (inclusive) to the file's folder let base = std::path::Path::new(top).parent().unwrap_or(std::path::Path::new("")); @@ -136,13 +137,18 @@ fn export(s: &mut Session, p: &Value) -> Result { if path.extension().is_none() { path.set_extension(LCPRESET_EXT); } - let ids = strings(p, "ids"); + let invalid_ids = || bad("preset.export", "`ids` must be an array of preset IDs"); + let ids = match p.get("ids") { + None | Some(Value::Null) => None, + Some(Value::Array(ids)) => Some(ids.iter().map(|id| id.as_str().ok_or_else(invalid_ids)).collect::>>()?), + Some(_) => return Err(invalid_ids()), + }; let group = str_param(p, "group"); let chosen: Vec<_> = s .presets .iter() .filter(|x| match (&ids, group) { - (Some(ids), _) => ids.contains(&x.id), + (Some(ids), _) => ids.contains(&x.id.as_str()), (None, Some(g)) => x.group == g, (None, None) => !x.builtin, }) diff --git a/crates/engine/src/cmd/update.rs b/crates/engine/src/cmd/update.rs index 18d005c049..2532ea2e65 100644 --- a/crates/engine/src/cmd/update.rs +++ b/crates/engine/src/cmd/update.rs @@ -23,6 +23,10 @@ fn check(s: &mut Session, p: &Value) -> Result { if p.get("feed").is_some() { return Err(bad(C, "`feed` is not a parameter: the app reads only its own release feed")); } + if crate::update::disabled_by_env() { + let var = lcc_brand::env_var(crate::update::DISABLE_ENV); + return Err(bad(C, format!("updates are disabled ({var} is set); your package manager handles updates"))); + } let wait = p.get("wait").and_then(Value::as_bool).unwrap_or(false); if wait && !s.updater.checking() { s.updater.check_now(); diff --git a/crates/engine/src/crs.rs b/crates/engine/src/crs.rs index ff0613711e..016f43d8ca 100644 --- a/crates/engine/src/crs.rs +++ b/crates/engine/src/crs.rs @@ -390,9 +390,14 @@ pub fn to_partial(props: &Props, target: Target) -> Value { n(o, "ParametricMidtoneSplit", "curve.split_mid"); n(o, "ParametricHighlightSplit", "curve.split_highlights"); n(o, "CurveRefineSaturation", "curve.refine_saturation"); + // Under the older process versions an untouched photo's curve is the one named "Medium + // Contrast", as Contrast 25, Blacks 5 and Brightness 50 are its sliders' defaults (read + // relative to them above): it is no edit, and our rendering has its own base contrast, so it + // is not applied. A changed curve is named otherwise ("Custom", "Strong Contrast"). + let old_default_curve = first(props, "crs:ToneCurveName").is_some_and(|n| n.eq_ignore_ascii_case("Medium Contrast")); if let Some(c) = curve(props, "crs:ToneCurve").filter(|c| c.as_array().is_some_and(|a| !a.is_empty())) { // the older single curve, used when no 2012 curve is present - if !props.contains_key("crs:ToneCurvePV2012") { + if !props.contains_key("crs:ToneCurvePV2012") && !old_default_curve { put(o, "curve.master", c); } } @@ -430,7 +435,13 @@ pub fn to_partial(props: &Props, target: Target) -> Value { n(o, "SplitToningBalance", "grading.balance"); // ---- Detail - n(o, "Sharpness", "detail.sharpen_amount"); + // An older process version's raw sharpening default (25) is an untouched photo's, like its + // tone sliders' defaults above: the photo keeps our own raw default. (Rendered files defaulted + // to 0 there, and 25 under the 2012 process is a choice: both are read as written.) + let raw = matches!(target, Target::RawAbsolute | Target::RawRelative); + if !(raw && !pv2012 && num(props, "crs:Sharpness") == Some(25.0)) { + n(o, "Sharpness", "detail.sharpen_amount"); + } n(o, "SharpenRadius", "detail.sharpen_radius"); n(o, "SharpenDetail", "detail.sharpen_detail"); n(o, "SharpenEdgeMasking", "detail.sharpen_masking"); @@ -617,12 +628,36 @@ pub fn to_partial_report(props: &Props, values: Option<&crate::crs_masks::Values // Point Color slots that are all empty (-1) let value_is = |k: &str, f: &dyn Fn(&[String]) -> bool| props.get(&format!("crs:{k}")).is_some_and(|v| f(v)); let empty_points = |v: &[String]| v.iter().all(|s| s.split(',').all(|n| n.trim().parse::().is_ok_and(|x| x == -1.0) || n.trim().is_empty())); + // a channel curve that is the identity: ascending points from x = 0 to 255, each with y == x (upstream #4747) + let identity_curve = |v: &[String]| { + let mut previous = None; + for point in v { + let Some((x, y)) = point.split_once(',') else { return false }; + let (Ok(x), Ok(y)) = (x.trim().parse::(), y.trim().parse::()) else { + return false; + }; + let ascending = match previous { + None => x == 0.0, + Some(prior) => x > prior, + }; + if !ascending || !(0.0..=255.0).contains(&x) || x != y { + return false; + } + previous = Some(x); + } + previous == Some(255.0) + }; let quiet = |k: &str| { k.starts_with("Enable") || k.starts_with("ToneCurveName") || k == "AutoTone" || k == "AutoGrayscaleMix" + || k == "AutoWhiteVersion" || (k == "PointColors" && value_is(k, &empty_points)) + // inactive legacy optics fields at zero, and identity channel curves (upstream #4747) + || (matches!(k, "ChromaticAberrationB" | "ChromaticAberrationR" | "Defringe") + && value_is(k, &|v| v.len() == 1 && v.iter().all(|s| s.trim().parse::().is_ok_and(|n| n == 0.0)))) + || (matches!(k, "ToneCurveRed" | "ToneCurveGreen" | "ToneCurveBlue") && value_is(k, &identity_curve)) // Point Color's variance means nothing without a used slot || (k == "ColorVariance" && (!props.contains_key("crs:PointColors") || value_is("PointColors", &empty_points))) // the lens profile's strength, written at its default (100 %) next to every profile @@ -1093,6 +1128,79 @@ mod tests { assert!(["/curve/master", "/curve/red", "/curve/green", "/curve/blue"].iter().all(|p| all.pointer(p).is_some()), "{all}"); } + /// An older-process packet (written for this test, as old DNGs, sidecars and catalogs carry it) of + /// a photo nobody edited: its sliders and raw sharpening at their old defaults and its curve named + /// as the old default one. `extra`: more attributes. + fn old_process_packet(curve_name: &str, sharpness: &str, extra: &str) -> String { + format!( + r#" + + 0, 070, 58180, 190255, 255 + "# + ) + } + + /// An untouched raw from an older process version keeps the look it is imported with (so it isn't + /// taken for an edited one, whose thumbnails need the whole raw decoded); what was changed there + /// still comes in, and so does a sharpening of 25 where it isn't that version's raw default. + #[test] + fn the_older_process_defaults_are_no_edit() { + let raw = DevelopSettings::for_raw(5000.0, 0.0); + let read = |base: &DevelopSettings, packet: String, target| apply_partial(base, &to_partial(&props(&packet), target), 1.0); + let untouched = old_process_packet("Medium Contrast", "25", ""); + assert_eq!(read(&raw, untouched.clone(), Target::RawAbsolute), raw, "an untouched older-process raw is unchanged"); + assert_eq!(read(&raw, untouched, Target::RawRelative), raw); + for changed in ["Custom", "Strong Contrast"] { + assert!(!read(&raw, old_process_packet(changed, "25", ""), Target::RawAbsolute).curve.master.is_empty(), "{changed}: the curve is read"); + } + let sharpening = |packet: String, base: &DevelopSettings, target| read(base, packet, target).detail.sharpen_amount; + assert_eq!(sharpening(old_process_packet("Medium Contrast", "50", ""), &raw, Target::RawAbsolute), 50.0, "a changed amount is read"); + let current = old_process_packet("Medium Contrast", "25", r#"crs:ProcessVersion="11.0" crs:Contrast2012="0""#); + assert_eq!(sharpening(current, &raw, Target::RawAbsolute), 25.0, "25 under the 2012 process is a choice"); + let rendered = DevelopSettings::default(); + assert_eq!( + sharpening(old_process_packet("Medium Contrast", "25", ""), &rendered, Target::Rendered), + 25.0, + "a rendered file's old default was 0" + ); + } + + #[test] + fn legacy_optics_defaults_and_identity_channel_curves_do_not_warn() { + let attrs = r#"crs:AutoWhiteVersion="134348800" crs:ChromaticAberrationR="+0" crs:ChromaticAberrationB="0.0" crs:Defringe="0""#; + let curve = r#"0, 0255, 255"#; + assert!(unmapped(&preset_packet(attrs, curve)).is_empty()); + + let collinear = curve.replace("255, 255", "128, 128255, 255"); + assert!(unmapped(&preset_packet(attrs, &collinear)).is_empty()); + let unordered = collinear.replace("255, 255", "64, 64255, 255"); + assert_eq!(unmapped(&preset_packet(attrs, &unordered)), ["ToneCurveRed"]); + + let attrs = attrs.replace(r#"crs:Defringe="0""#, r#"crs:Defringe="1""#); + let curve = curve.replace("255, 255", "255, 220"); + assert_eq!(unmapped(&preset_packet(&attrs, &curve)), ["Defringe", "ToneCurveRed"]); + } + + #[test] + fn auto_white_version_preserves_an_explicit_crop_reset() { + let packet = r#" + + + "#; + let target = Target::RawAbsolute; + let defaults = DevelopSettings::default(); + let cropped = apply_partial(&defaults, &to_partial(&props(SIDECAR), target), 1.0); + assert_ne!(cropped.crop.geometry, defaults.crop.geometry); + + let sidecar = crate::sidecar::parse_sidecar(packet, target).unwrap(); + assert!(sidecar.warnings.is_empty()); + let Some(crate::sidecar::DevelopPatch::Partial(patch)) = sidecar.develop else { panic!("expected a crop reset") }; + assert_eq!(apply_partial(&cropped, &patch, 1.0).crop.geometry, defaults.crop.geometry); + } + fn unmapped(x: &str) -> Vec { to_partial_report(&props(x), None, Target::Any, 1.5).1 } diff --git a/crates/engine/src/denoise.rs b/crates/engine/src/denoise.rs index e09335f532..90e2d9df75 100644 --- a/crates/engine/src/denoise.rs +++ b/crates/engine/src/denoise.rs @@ -1563,8 +1563,13 @@ fn loaded(spec: &JobSpec) -> Result, MakeError> { Ok(m) } -/// The cell `[(0,0), (1,0), (0,1), (1,1)]` colours of a Bayer mosaic and so its layout. -fn layout_of(cfa: &lcc_raw::Cfa) -> Option { +/// The layout of a Bayer mosaic, from the colours of its cell `[(0,0), (1,0), (0,1), (1,1)]`; `None` for any other +/// pattern. The pattern itself must be the 2 × 2 cell: 16 of X-Trans's 36 phases have a top-left 2 × 2 that reads as a +/// Bayer cell, and one of those packed as Bayer would hand the model a sensor it was not looking at. +pub(crate) fn layout_of(cfa: &lcc_raw::Cfa) -> Option { + if !cfa.is_bayer() { + return None; + } Layout::from_cell([cfa.color_at(0, 0), cfa.color_at(1, 0), cfa.color_at(0, 1), cfa.color_at(1, 1)]) } @@ -1602,20 +1607,35 @@ pub(crate) fn make_product(spec: &JobSpec, progress: Option<&Progress>) -> Resul drop(bytes); // hot, dead and stuck pixels go before the denoiser sees them, as in the plain development crate::files::repair_pixels(&mut raw, &crate::files::RawOptions::for_path(&spec.path, true)); - if raw.cpp != 1 || !raw.cfa.as_ref().is_some_and(lcc_raw::Cfa::is_bayer) { + if raw.cpp != 1 || raw.cfa.is_none() { return Err(MakeError::Unsupported( - "only Bayer raw files can be denoised (this one has another sensor layout or is already demosaiced)".into(), + "only raw files with a colour filter array can be denoised (this one is monochrome or already demosaiced)".into(), )); } let n = raw.normalized().map_err(|e| MakeError::Failed(e.to_string()))?; drop(raw); - let layout = - n.cfa.as_ref().and_then(layout_of).ok_or_else(|| MakeError::Unsupported("the colour filter layout is not a Bayer pattern".into()))?; + let layout = n.cfa.as_ref().and_then(layout_of); (n, layout) }; if cancelled() { return Err(MakeError::Cancelled); } + // X-Trans and the other non-Bayer layouts: the model's contract is four RGGB planes, so the mosaic is interpolated + // and rebuilt as RGGB first. The picture keeps its size and the sites the two patterns share keep their own + // samples; the rest reach the model already interpolated (see docs/denoise.md). This holds the mosaic, its green + // plane and the RGGB copy at once, after the decode's memory has gone back. + let (mosaic, layout) = match layout { + Some(layout) => (mosaic, layout), + None => { + let _held = crate::memory::work_gate().acquire(mosaic.data.len().saturating_mul(12)); + let rggb = lcc_raw::demosaic::remosaic_rggb(&mosaic) + .ok_or_else(|| MakeError::Unsupported("this sensor layout cannot be read as a Bayer mosaic, so it cannot be denoised".into()))?; + (rggb, Layout { dx: 0, dy: 0 }) + } + }; + if cancelled() { + return Err(MakeError::Cancelled); + } let decoded = began.elapsed(); let model = loaded(spec)?; model.prepare(&mosaic.data, mosaic.width, mosaic.height); diff --git a/crates/engine/src/import.rs b/crates/engine/src/import.rs index 992d4177a2..8e9e811cea 100644 --- a/crates/engine/src/import.rs +++ b/crates/engine/src/import.rs @@ -745,9 +745,12 @@ fn expand_report_noting( subfolders: bool, ) -> Expansion { let mut out = Expansion::default(); + // canonical folders walked so far: overlapping roots (an alias, a folder inside another) are walked once + let mut seen_dirs = std::collections::HashSet::new(); + let skipped = skip.and_then(|p| std::fs::canonicalize(p).ok()); for p in paths { let p = Path::new(p); - if skip.is_some_and(|s| p == s) { + if skip.is_some_and(|s| p == s) || skipped.as_ref().is_some_and(|s| std::fs::canonicalize(p).as_ref().ok() == Some(s)) { continue; } if p.is_dir() { @@ -761,9 +764,12 @@ fn expand_report_noting( } keep }; + // one root can't overlap another: it is walked without asking for canonical paths let w = match note.as_mut() { - Some(note) => crate::walk::files_in_noting(p, skip, walk_limits, keep, &mut **note), - None => crate::walk::files_in(p, skip, walk_limits, keep), + Some(note) if paths.len() < 2 => crate::walk::files_in_noting(p, skip, walk_limits, keep, &mut **note), + None if paths.len() < 2 => crate::walk::files_in(p, skip, walk_limits, keep), + Some(note) => crate::walk::files_in_with_seen(p, skip, walk_limits, keep, Some(&mut **note), &mut seen_dirs), + None => crate::walk::files_in_with_seen(p, skip, walk_limits, keep, None, &mut seen_dirs), }; let truncated = if subfolders { w.truncated } else { w.entries >= limits.max_entries }; if truncated { @@ -789,6 +795,37 @@ fn expand_report_noting( out } +/// The string used for an absolute folder in Local browse: trailing separators trimmed, except on a +/// filesystem root (`/`, `C:\`, a UNC share), which keeps its own (adapted from upstream #4628). +pub fn browse_folder_string(path: &Path) -> String { + let text = path.to_string_lossy(); + if path.parent().is_none() { text.into_owned() } else { text.trim_end_matches(['/', '\\']).to_string() } +} + +#[cfg(test)] +mod browse_folder_tests { + use super::{Path, browse_folder_string}; + + #[test] + fn browse_folder_string_keeps_filesystem_roots() { + #[cfg(windows)] + { + assert_eq!(browse_folder_string(Path::new(r"C:\")), r"C:\"); + assert_eq!(browse_folder_string(Path::new(r"\\server\share\")), r"\\server\share\"); + } + #[cfg(not(windows))] + assert_eq!(browse_folder_string(Path::new("/")), "/"); + } + + #[test] + fn browse_folder_string_removes_trailing_separators_from_other_folders() { + #[cfg(windows)] + assert_eq!(browse_folder_string(Path::new(r"C:\photos\")), r"C:\photos"); + #[cfg(not(windows))] + assert_eq!(browse_folder_string(Path::new("/photos/")), "/photos"); + } +} + /// What a path given on the command line at launch becomes ([`launch_path`]). #[derive(Clone, Debug, PartialEq, Eq)] pub enum LaunchPath { @@ -2803,10 +2840,14 @@ fn apply_settings(s: &Session, p: &mut Photo, opts: &ImportOptions, now: &str) { if let Some(mp) = opts.metadata_preset.as_ref().and_then(|n| s.metadata_presets.iter().find(|m| m.name.eq_ignore_ascii_case(n))) { crate::cmd::metadata::apply_to(&mut p.meta, &mp.fields); } - for k in &opts.keywords { - let k = lcc_catalog::keywords::clean(k); - if !k.is_empty() && !p.meta.keywords.iter().any(|x| x.eq_ignore_ascii_case(&k)) { - p.meta.keywords.push(k); + // Most imports add no keywords: don't index the file's existing keywords then. + if !opts.keywords.is_empty() { + let mut seen: std::collections::HashSet = p.meta.keywords.iter().map(|k| k.to_lowercase()).collect(); + for k in &opts.keywords { + let k = lcc_catalog::keywords::clean(k); + if !k.is_empty() && seen.insert(k.to_lowercase()) { + p.meta.keywords.push(k); + } } } // the camera profile before the presets: a preset doesn't take it away unless the import says so diff --git a/crates/engine/src/lightroom_catalog.rs b/crates/engine/src/lightroom_catalog.rs index 46775e432b..14fbe9155a 100644 --- a/crates/engine/src/lightroom_catalog.rs +++ b/crates/engine/src/lightroom_catalog.rs @@ -1560,6 +1560,14 @@ fn read_lightroom(path: &Path, reader: Reader, source_guard: SourceGuard, cancel Ok(out) } +/// A video the catalog lists with the format `VIDEO` and a video extension. It becomes a video record +/// by reference, so the import never runs an image probe on it (adapted from upstream #4741). +pub(crate) fn is_catalog_video(p: &CatalogPhoto) -> bool { + const EXTENSIONS: [&str; 12] = ["mp4", "mov", "m4v", "avi", "mts", "m2ts", "3gp", "mkv", "webm", "wmv", "mpg", "mpeg"]; + text(&p.image, "fileFormat").eq_ignore_ascii_case("VIDEO") + && Path::new(&p.path).extension().and_then(|e| e.to_str()).is_some_and(|e| EXTENSIONS.iter().any(|x| e.eq_ignore_ascii_case(x))) +} + /// How many of the images left out of an import (no file, folder or root record) the warnings name one by one. const LEFT_OUT_NAMED: usize = 20; /// Drop the virtual copies whose master was skipped, adding them to the skipped images: a copy has @@ -2970,11 +2978,11 @@ pub(crate) mod tests { dropped.sort(); let mapped = PUBLIC_CRS_FIELDS.len() - dropped.len(); eprintln!("crs coverage: {mapped} of {} public fields map; dropped: {dropped:?}", PUBLIC_CRS_FIELDS.len()); - // No equivalent in the app: Lightroom's algorithm / tool bookkeeping (auto white version, + // No equivalent in the app: Lightroom's tool bookkeeping (auto white version is quiet since upstream #4747; // Upright's preview, centre mode and focal length: ours computes its own) and the pre-2012 // single Defringe switch. Reported as unmapped and kept in the archive. (Lens profile setup // is bookkeeping the import ignores, `crs::IGNORED`: not reported.) - let expected = ["AutoWhiteVersion", "Defringe", "UprightCenterMode", "UprightFocalLength35mm", "UprightPreview"]; + let expected = ["Defringe", "UprightCenterMode", "UprightFocalLength35mm", "UprightPreview"]; assert_eq!(dropped, expected, "{mapped} mapped"); } @@ -5104,6 +5112,31 @@ pub(crate) mod tests { std::fs::remove_dir_all(dir).unwrap(); } + #[test] + fn native_catalog_links_present_video_without_an_image_probe_failure() { + let dir = std::env::temp_dir().join(format!("app-lrcat-video-link-{}", std::process::id())); + std::fs::create_dir_all(dir.join("Photos")).unwrap(); + let path = dir.join("videos.lrcat"); + let clip = dir.join("Photos").join("clip.MOV"); + std::fs::write(&clip, b"opaque movie bytes").unwrap(); + let mut tables = photo_tables((dir.to_str().unwrap(), "")); + tables[2].2[2] = SqlValue::Text("clip.MOV".into()); + tables[3].2[3] = SqlValue::Text("VIDEO".into()); + std::fs::write(&path, native_catalog(&tables)).unwrap(); + let mut s = crate::Session::new(); + s.media.file_probe = Some(Arc::new(|_| Err("unsupported image format".into()))); + + let imported = s.execute("library.importLightroom", &json!({"path": path})).unwrap(); + + assert_eq!(imported["failed"], json!([])); + assert_eq!(imported["missing"], json!([])); + let id = PhotoId(imported["mapping"]["1"].as_u64().unwrap()); + let photo = s.catalog.photo(id).unwrap(); + assert_eq!(photo.kind, lcc_catalog::MediaKind::Video); + assert_eq!(photo.source, Source::File { path: clip.to_str().unwrap().into() }); + std::fs::remove_dir_all(dir).unwrap(); + } + #[test] fn native_video_reimport_repairs_kind_without_losing_edits_or_memberships() { let dir = std::env::temp_dir().join(format!("app-lrcat-video-reimport-{}", std::process::id())); diff --git a/crates/engine/src/lightroom_job.rs b/crates/engine/src/lightroom_job.rs index ed9f2122b5..40641993dc 100644 --- a/crates/engine/src/lightroom_job.rs +++ b/crates/engine/src/lightroom_job.rs @@ -483,10 +483,12 @@ fn original_paths(data: &CatalogImport, cancel: &AtomicBool) -> crate::Result<(V if !seen.insert(key.clone()) { continue; } - if photo.original_is_file() { - paths.push(photo.path.clone()); - } else { + if !photo.original_is_file() { missing.insert(key); + } else if !lightroom_catalog::is_catalog_video(photo) { + // Catalog videos are references. The image probe reads the entire + // file before rejecting it, even though its catalog entry is added. + paths.push(photo.path.clone()); } } Ok((paths, missing)) diff --git a/crates/engine/src/presets.rs b/crates/engine/src/presets.rs index 7ca2ea91a9..71ffb59c9c 100644 --- a/crates/engine/src/presets.rs +++ b/crates/engine/src/presets.rs @@ -233,6 +233,13 @@ pub fn without_unavailable_masks(preset: &Preset, available: bool) -> (Preset, V /// Expand files/folders (recursively, bounded: see [`crate::walk`]) into preset files /// (`.lcpreset`, `.xmp`). pub fn expand_preset_paths(paths: &[String]) -> Vec { + expand_preset_paths_with_seen(paths, &mut std::collections::HashSet::new()) +} + +/// [`expand_preset_paths`] sharing the canonical folders and files already expanded in `seen`, so +/// overlapping roots of one import (an alias, a folder inside another) yield each preset once, under +/// the first path that reached it (adapted from upstream #1638). +pub(crate) fn expand_preset_paths_with_seen(paths: &[String], seen: &mut std::collections::HashSet) -> Vec { let preset_file = |p: &Path| { let ext = p.extension().map(|e| e.to_string_lossy().to_ascii_lowercase()).unwrap_or_default(); lcc_brand::preset_exts().any(|e| e == ext) @@ -252,12 +259,13 @@ pub fn expand_preset_paths(paths: &[String]) -> Vec { for p in paths { let path = Path::new(p); if path.is_dir() { - let w = crate::walk::files_in(path, None, crate::walk::Limits::default(), preset_file); + let w = crate::walk::files_in_with_seen(path, None, crate::walk::Limits::default(), preset_file, None, seen); out.extend(w.files.into_iter().map(|f| f.to_string_lossy().to_string())); } else { out.push(p.clone()); } } + out.retain(|p| std::fs::canonicalize(p).map_or(true, |real| seen.insert(real))); out } diff --git a/crates/engine/src/print/layout.rs b/crates/engine/src/print/layout.rs index afff879ed5..8c783d4e9f 100644 --- a/crates/engine/src/print/layout.rs +++ b/crates/engine/src/print/layout.rs @@ -632,7 +632,7 @@ impl Layout { return Err(format!("duplicate cell id {}", c.id)); } if c.page >= self.pages { - return Err(format!("cell {} is on page {} but the layout has {} pages", c.id, c.page + 1, self.pages)); + return Err(format!("cell {} is on page {} but the layout has {} pages", c.id, u64::from(c.page) + 1, self.pages)); } self.check_rect(&c.rect, area)?; } @@ -1409,3 +1409,23 @@ mod tests { } } } + +#[cfg(test)] +mod page_overflow_tests { + use super::{Layout, Style}; + + #[test] + fn oversized_cell_pages_are_errors_without_changing_the_layout() { + let mut source = Layout { style: Style::PicturePackage, ..Default::default() }; + let id = source.add_cell(2.0, 2.0).unwrap(); + source.validate().unwrap(); + for (page, shown) in [(1, "2"), (u32::MAX, "4294967296")] { + let mut value = serde_json::to_value(&source).unwrap(); + value["cells"][0]["page"] = serde_json::json!(page); + let mut imported: Layout = serde_json::from_value(value).unwrap(); + let before = imported.clone(); + assert_eq!(imported.validate().unwrap_err(), format!("cell {id} is on page {shown} but the layout has 1 pages")); + assert_eq!(imported, before, "a rejected page changed the layout"); + } + } +} diff --git a/crates/engine/src/proof.rs b/crates/engine/src/proof.rs index 046ff0a85b..3584bba3b3 100644 --- a/crates/engine/src/proof.rs +++ b/crates/engine/src/proof.rs @@ -16,7 +16,6 @@ pub struct ProofProfile { /// Load the profile at `path` for proofing with `intent`, simulating paper and ink or not. pub fn load(path: &str, intent: ProofIntent, paper_ink: bool) -> Result { - let path = path.trim(); let meta = std::fs::metadata(path).map_err(|e| format!("{path}: {e}"))?; if meta.len() > MAX_PROFILE_BYTES as u64 { return Err(format!("{path}: too large for an ICC profile")); @@ -45,6 +44,17 @@ mod tests { use super::*; use lcc_codecs::space::NamedSpace; + #[test] + fn loads_an_icc_path_with_trailing_whitespace() { + let profile = lcc_codecs::icc::write_named(NamedSpace::DisplayP3); + let path = std::env::temp_dir().join(format!("lc-proof-{}.icc\u{00a0}", std::process::id())); + std::fs::write(&path, &profile).unwrap(); + let result = load(path.to_str().unwrap(), ProofIntent::Perceptual, false); + std::fs::remove_file(&path).unwrap(); + let expected = from_bytes(&profile, ProofIntent::Perceptual, false, "x").unwrap(); + assert_eq!(result.unwrap().id, expected.id); + } + #[test] fn profiles_register_by_content_and_options() { let p3 = lcc_codecs::icc::write_named(NamedSpace::DisplayP3); diff --git a/crates/engine/src/slideshow_export.rs b/crates/engine/src/slideshow_export.rs index 846bf6b153..9296278041 100644 --- a/crates/engine/src/slideshow_export.rs +++ b/crates/engine/src/slideshow_export.rs @@ -511,10 +511,11 @@ impl Prepared { if pages == 0 { return Err("no slide could be rendered".into()); } - let bytes = pdf.len(); let catalog = if self.request.settings.full_screen { " /PageMode /FullScreen" } else { "" }; let pdf_file = pdf.finish(catalog)?.into_inner().map_err(|e| format!("PDF: {}", e.error()))?; lcc_catalog::safe_file::sync_file(&pdf_file, false).map_err(|e| format!("PDF: {e}"))?; + // the finished file's size: the trailer and cross-reference table come after the pages + let bytes = pdf_file.metadata().map_err(|e| format!("PDF: {e}"))?.len(); // closed before the rename: Windows can't rename a file that is still open drop(pdf_file); part.commit(&self.guard)?; diff --git a/crates/engine/src/tests_denoise.rs b/crates/engine/src/tests_denoise.rs index fbe5ce9cee..439d132d72 100644 --- a/crates/engine/src/tests_denoise.rs +++ b/crates/engine/src/tests_denoise.rs @@ -14,7 +14,7 @@ use serde_json::{Value, json}; use crate::Session; use crate::denoise::{Loader, Model, PhotoState, RunOn}; use crate::export::{ExportOptions, export_photo}; -use crate::tests_xmp::{synthetic_dng_of, temp_dir}; +use crate::tests_xmp::{synthetic_dng_cfa, synthetic_dng_of, temp_dir}; /// A model that makes every output pixel half of its cell's colour: a picture that is plainly not the plain one. struct Dim { @@ -591,6 +591,103 @@ fn files_that_cannot_be_denoised_fail_with_a_reason_and_never_a_panic() { let _ = std::fs::remove_dir_all(&dir); } +/// Only a Bayer pattern has a Bayer layout. 16 of X-Trans's 36 phases start with a 2 × 2 that reads as a Bayer cell +/// (rows 2 and 3 at column 1 are R G / G B), so a file whose active area began at one of them would have had its +/// X-Trans mosaic packed as Bayer. +#[test] +fn an_x_trans_phase_that_starts_like_a_bayer_cell_is_not_taken_for_one() { + use crate::denoise::layout_of; + use lcc_raw::Cfa; + let mut looks_bayer = 0; + for dy in 0..6 { + for dx in 0..6 { + let cfa = Cfa::xtrans().shifted(dx, dy); + let cell = [cfa.color_at(0, 0), cfa.color_at(1, 0), cfa.color_at(0, 1), cfa.color_at(1, 1)]; + looks_bayer += usize::from(lcc_denoise::bayer::Layout::from_cell(cell).is_some()); + assert_eq!(layout_of(&cfa), None, "X-Trans at phase ({dx}, {dy})"); + } + } + assert_eq!(looks_bayer, 16, "the phases this test is about"); + for name in ["RGGB", "GRBG", "GBRG", "BGGR"] { + assert!(layout_of(&Cfa::bayer(name).unwrap()).is_some(), "{name}"); + } +} + +/// X-Trans (and any other non-Bayer colour filter array) reaches the model through the RGGB re-mosaic: +/// the picture comes out whole and the right size, where before the file was refused outright. +#[test] +fn a_non_bayer_sensor_is_denoised_through_the_rggb_remosaic() { + let dir = temp_dir("xtrans"); + let (w, h) = (192usize, 160usize); + let data: Vec = (0..w * h).map(|i| 600 + ((i % w) * 30 + (i / w) * 35) as u16).collect(); + let f = dir.join("xtrans.dng"); + std::fs::write(&f, synthetic_dng_cfa(w, h, lcc_raw::Cfa::xtrans(), data, None, Default::default())).unwrap(); + let runs = Arc::new(AtomicUsize::new(0)); + let spec = crate::denoise::JobSpec { + path: f.to_string_lossy().into_owned(), + read: None, + product: dir.join("xtrans.lcdn"), + key: "k".into(), + manifest: manifest("stand-in"), + onnx: dir.join("model.onnx"), + model: Default::default(), + loader: dim_loader(&runs), + parallel: 2, + run_on: RunOn::Auto, + }; + assert_eq!(crate::denoise::make_product(&spec, None), Ok(true)); + let header = lcc_denoise::product::read_header_at(&spec.product).unwrap(); + assert_eq!((header.width, header.height), (w, h), "the denoised picture keeps the sensor's size"); + let rgb = lcc_denoise::product::read(&spec.product, "k", 1).unwrap(); + assert_eq!((rgb.width, rgb.height), (w, h)); + assert!(rgb.data.iter().flatten().all(|v| v.is_finite()), "no sample is left non-finite"); + assert!(rgb.data.iter().any(|p| p.iter().any(|v| *v > 0.0)), "the picture is not all black"); + assert_eq!(crate::denoise::make_product(&spec, None), Ok(false), "the product is already there"); + let _ = std::fs::remove_dir_all(&dir); +} + +/// The denoised picture of an X-Trans file is used where the photo is shown, not only made: in a preview binned 3 × 3 +/// (the only binning X-Trans allows) and at full size, from a default crop whose sides 3 does not divide. Before +/// non-Bayer sensors could be denoised nothing ever read such a product, and a twin that does not match the plain +/// picture's size is silently dropped, so a mismatch here would leave the Amount slider doing nothing in the loupe. +#[test] +fn an_x_trans_photo_shows_its_denoised_picture_binned_and_at_full_size() { + use crate::media::DenoiseSpec; + let dir = temp_dir("xtrans-twin"); + let (w, h) = (384usize, 288usize); + let data: Vec = (0..w * h).map(|i| 900 + ((i % w) * 23 + (i / w) * 31 + (i * 7919) % 401) as u16).collect(); + let mut raw = lcc_raw::decode(&synthetic_dng_cfa(w, h, lcc_raw::Cfa::xtrans(), data, None, Default::default())).unwrap(); + raw.crop = lcc_raw::Rect::new(5, 7, 371, 271); + let bytes = lcc_raw::write_dng(&raw, &Default::default()).unwrap(); + assert_eq!(lcc_raw::decode(&bytes).unwrap().crop, raw.crop, "the crop survives the DNG"); + let f = dir.join("xtrans.dng"); + std::fs::write(&f, &bytes).unwrap(); + let spec = crate::denoise::JobSpec { + path: f.to_string_lossy().into_owned(), + read: None, + product: dir.join("xtrans.lcdn"), + key: "k".into(), + manifest: manifest("stand-in"), + onnx: dir.join("model.onnx"), + model: Default::default(), + loader: dim_loader(&Arc::new(AtomicUsize::new(0))), + parallel: 2, + run_on: RunOn::Auto, + }; + assert_eq!(crate::denoise::make_product(&spec, None), Ok(true)); + let twin = DenoiseSpec { product: spec.product.clone(), key: "k".into(), make: None }; + for (max_edge, binned) in [(128, true), (100_000, false)] { + let (plain, denoised, _) = crate::files::load_vec_pair(bytes.clone(), max_edge, &twin, crate::media::LoadOptions::default()).unwrap(); + assert_eq!(plain.width < 371, binned, "max_edge {max_edge}: {}×{}", plain.width, plain.height); + let denoised = denoised.unwrap_or_else(|| panic!("max_edge {max_edge}: the denoised picture was dropped")); + assert_eq!((denoised.width, denoised.height), (plain.width, plain.height), "max_edge {max_edge}"); + // the stand-in model halves every sample: the picture shown is the denoised one, not the plain one again + let mean = |img: &lcc_raster::Rgb32f| img.data.iter().map(|p| f64::from(p[1])).sum::() / img.data.len() as f64; + assert!(mean(&denoised) < 0.75 * mean(&plain), "max_edge {max_edge}: {} vs {}", mean(&denoised), mean(&plain)); + } + let _ = std::fs::remove_dir_all(&dir); +} + #[test] fn two_threads_making_the_same_picture_make_it_once() { let dir = temp_dir("twice"); diff --git a/crates/engine/src/tests_export.rs b/crates/engine/src/tests_export.rs index 4bd895b030..d827c87983 100644 --- a/crates/engine/src/tests_export.rs +++ b/crates/engine/src/tests_export.rs @@ -2361,3 +2361,26 @@ fn an_original_never_carries_a_position_cleared_or_moved_in_the_library() { assert!(s.catalog.photo(city).unwrap().meta.gps_removed.is_some()); assert!(export_photo(&mut s, city, &original, 1).is_ok(), "the city stays: only the position was cleared"); } + +#[test] +fn preset_export_rejects_malformed_ids_without_replacing_the_output() { + let dir = temp_dir("preset-export-ids"); + let mut s = Session::with_demo(); + s.execute("develop.set", &json!({"control": "light.exposure", "value": 0.6})).unwrap(); + s.execute("preset.create", &json!({"name": "Bright", "group": "Travel"})).unwrap(); + s.execute("develop.set", &json!({"control": "effects.clarity", "value": 30})).unwrap(); + s.execute("preset.create", &json!({"name": "Crisp", "group": "Street"})).unwrap(); + let path = dir.join("selected.lcpreset"); + let prior = b"previous output"; + std::fs::write(&path, prior).unwrap(); + let path_text = path.to_string_lossy(); + + for ids in [json!("lc.warm-glow"), json!(["lc.warm-glow", 7]), json!([])] { + assert!(s.execute("preset.export", &json!({"path": path_text, "ids": ids})).is_err(), "{ids}"); + assert_eq!(std::fs::read(&path).unwrap().as_slice(), prior); + } + assert_eq!(s.execute("preset.export", &json!({"path": path_text})).unwrap()["count"], 2); + assert_eq!(s.execute("preset.export", &json!({"path": path_text, "ids": null, "group": "Travel"})).unwrap()["count"], 1); + assert_eq!(s.execute("preset.export", &json!({"path": path_text, "ids": ["lc.warm-glow"], "group": "Nope"})).unwrap()["count"], 1); + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/engine/src/tests_slideshow_export.rs b/crates/engine/src/tests_slideshow_export.rs index ce38c2a9f6..13e5c793c8 100644 --- a/crates/engine/src/tests_slideshow_export.rs +++ b/crates/engine/src/tests_slideshow_export.rs @@ -133,6 +133,7 @@ fn pdf_has_a_page_per_slide_titles_included() { let r = export(&mut s, json!({"format": "pdf", "path": path, "size": 160, "quality": 80, "ids": ids})); assert_eq!((r["pages"].as_u64(), r["slides"].as_u64(), r["width"].as_u64(), r["height"].as_u64()), (Some(5), Some(5), Some(160), Some(90))); let bytes = std::fs::read(&path).unwrap(); + assert_eq!(r["bytes"].as_u64(), Some(bytes.len() as u64)); assert!(bytes.starts_with(b"%PDF-1.4")); let pages = pdf_pages(&bytes); assert_eq!(pages.len(), 5); @@ -152,7 +153,9 @@ fn pdf_has_a_page_per_slide_titles_included() { s.execute("slideshow.layout", &json!({"aspect": "4:3"})).unwrap(); let r = export(&mut s, json!({"format": "pdf", "path": path, "size": 120, "fullScreen": false, "ids": ids})); assert_eq!((r["width"].as_u64(), r["height"].as_u64()), (Some(120), Some(90))); - assert!(!String::from_utf8_lossy(&std::fs::read(&path).unwrap()).contains("/FullScreen")); + let bytes = std::fs::read(&path).unwrap(); + assert_eq!(r["bytes"].as_u64(), Some(bytes.len() as u64)); + assert!(!String::from_utf8_lossy(&bytes).contains("/FullScreen")); } #[test] diff --git a/crates/engine/src/tests_xmp.rs b/crates/engine/src/tests_xmp.rs index 409792ea40..ea2241a2e1 100644 --- a/crates/engine/src/tests_xmp.rs +++ b/crates/engine/src/tests_xmp.rs @@ -924,8 +924,12 @@ pub(crate) fn synthetic_dng_with(xmp: Option<&str>, metadata: lcc_meta::Metadata /// A synthetic Bayer DNG for denoise and cache tests. pub(crate) fn synthetic_dng_of(w: usize, h: usize, cfa: &str, data: Vec, xmp: Option<&str>, metadata: lcc_meta::Metadata) -> Vec { + synthetic_dng_cfa(w, h, lcc_raw::Cfa::bayer(cfa).unwrap(), data, xmp, metadata) +} + +/// [`synthetic_dng_of`] for any colour filter array, Bayer or not (X-Trans). +pub(crate) fn synthetic_dng_cfa(w: usize, h: usize, cfa: lcc_raw::Cfa, data: Vec, xmp: Option<&str>, metadata: lcc_meta::Metadata) -> Vec { use lcc_raw::*; - let cfa = Cfa::bayer(cfa).unwrap(); let raw = RawImage { format: RawFormat::Dng, width: w, diff --git a/crates/engine/src/update.rs b/crates/engine/src/update.rs index 2105961de2..23d59c1304 100644 --- a/crates/engine/src/update.rs +++ b/crates/engine/src/update.rs @@ -26,6 +26,22 @@ pub const ACTIVITY_KIND: &str = "update"; /// The row's label (English; the frontend translates it). pub const ACTIVITY_LABEL: &str = "Downloading update"; +/// The variable (after the brand's env prefix) that turns every update check and prompt off. +pub const DISABLE_ENV: &str = "DISABLE_UPDATES"; + +/// Whether `_DISABLE_UPDATES` (or a legacy spelling) turns update checks off for this +/// process. Distro packages (NixOS, deb/rpm, …) set it: the package manager owns the update flow, +/// so the app's own start-up prompt and manual check would only nag. Adapted from upstream #4663. +pub fn disabled_by_env() -> bool { + disabled_by_value(lcc_brand::env(DISABLE_ENV).as_deref()) +} + +/// [`disabled_by_env`] for a known value, without reading the environment: `1`, `on`, `true` or +/// `yes` (case-insensitive, trimmed) turn updates off; anything else, or no variable, leaves them on. +pub fn disabled_by_value(value: Option<&str>) -> bool { + value.is_some_and(|v| matches!(v.trim().to_ascii_lowercase().as_str(), "1" | "on" | "true" | "yes")) +} + /// Settings file in the app's settings folder. const SETTINGS_FILE: &str = "updates.json"; /// Schema version of that file; a file from a newer build is left alone. diff --git a/crates/engine/src/update/tests.rs b/crates/engine/src/update/tests.rs index 2be11af217..f2da7c7774 100644 --- a/crates/engine/src/update/tests.rs +++ b/crates/engine/src/update/tests.rs @@ -911,3 +911,14 @@ fn a_package_install_is_sent_to_its_package_manager() { assert!(activity.list().is_empty(), "nothing started"); let _ = std::fs::remove_dir_all(&dir); } + +// upstream #4663: `_DISABLE_UPDATES` values that turn updates off, and those that don't +#[test] +fn disable_updates_values() { + for on in ["1", "on", "true", "yes", " yes ", "TRUE"] { + assert!(disabled_by_value(Some(on)), "{on:?}"); + } + for off in [None, Some(""), Some(" "), Some("0"), Some("false"), Some("off"), Some("no"), Some("2")] { + assert!(!disabled_by_value(off), "{off:?}"); + } +} diff --git a/crates/engine/src/walk.rs b/crates/engine/src/walk.rs index afffd45be3..e791b2d9d5 100644 --- a/crates/engine/src/walk.rs +++ b/crates/engine/src/walk.rs @@ -143,7 +143,7 @@ pub type NoteFolder<'a> = &'a mut dyn FnMut(&Path, Vec<(std::ffi::OsString, Entr /// at `limits` (see [`Walked::truncated`]). Unreadable folders are skipped and counted /// ([`Walked::unreadable`]), as are the files `keep` refuses ([`Walked::skipped`]). pub fn files_in(root: &Path, skip: Option<&Path>, limits: Limits, keep: impl FnMut(&Path) -> bool) -> Walked { - walk(root, skip, limits, keep, |_| true, None) + walk(root, skip, limits, keep, |_| true, None, None) } /// [`files_in`], entering a folder below `root` only when `enter` accepts it: a folder it turns @@ -156,14 +156,30 @@ pub fn files_in_entering( keep: impl FnMut(&Path) -> bool, enter: impl FnMut(&Path) -> bool, ) -> Walked { - walk(root, skip, limits, keep, enter, None) + walk(root, skip, limits, keep, enter, None, None) } /// [`files_in`], handing the listing of every folder it reads to `note`: who walks a folder to /// find its files has, with that, the answer to "is this name there" for everything in it, and /// need not ask the disk again (a round trip for each name on a network share). pub fn files_in_noting(root: &Path, skip: Option<&Path>, limits: Limits, keep: impl FnMut(&Path) -> bool, note: NoteFolder) -> Walked { - walk(root, skip, limits, keep, |_| true, Some(note)) + walk(root, skip, limits, keep, |_| true, Some(note), None) +} + +/// [`files_in`] (or [`files_in_noting`] with `note`) sharing canonical folder identities across +/// the roots of one request in `seen`: a folder already walked from an earlier root (named twice, +/// inside another root, or reached through a link) is not walked again, and the first spelling of +/// its path is the one kept. It costs one `canonicalize` per folder (not per entry), which is why +/// only multi-root requests ask for it. Adapted from upstream #1638. +pub(crate) fn files_in_with_seen( + root: &Path, + skip: Option<&Path>, + limits: Limits, + keep: impl FnMut(&Path) -> bool, + note: Option, + seen: &mut HashSet, +) -> Walked { + walk(root, skip, limits, keep, |_| true, note, Some(seen)) } fn walk( @@ -173,6 +189,7 @@ fn walk( mut keep: impl FnMut(&Path) -> bool, mut enter: impl FnMut(&Path) -> bool, mut note: Option, + mut shared: Option<&mut HashSet>, ) -> Walked { let mut out = Walked::default(); // canonical folders reached through a link, so a link loop is walked at most once @@ -200,6 +217,20 @@ fn walk( out.truncated = true; continue; } + // after the depth check: a folder too deep to be read here was not walked, so a later root + // that names it still is + if let Some(seen) = shared.as_deref_mut() { + // a folder whose canonical path can't be had (some network and virtual drives) is + // walked under its own spelling rather than left out + let real = std::fs::canonicalize(&path).unwrap_or_else(|_| path.clone()); + if seen.len() >= MAX_ENTRIES && !seen.contains(&real) { + out.truncated = true; + break; + } + if !seen.insert(real) { + continue; + } + } let Ok(rd) = std::fs::read_dir(&path) else { out.unreadable = out.unreadable.saturating_add(1); continue; @@ -525,4 +556,23 @@ mod tests { assert!(w.files.iter().any(|p| p.ends_with("a/b/p.jpg")), "{w:?}"); let _ = std::fs::remove_dir_all(&d); } + + /// Roots sharing `seen`: a folder is walked once, but one that an earlier root only passed by + /// (too deep for it: an import without subfolders) is still walked when a later root names it. + #[test] + fn shared_roots_walk_a_folder_once_but_not_one_they_only_passed() { + let d = tmp("seen"); + std::fs::create_dir_all(d.join("sub")).unwrap(); + std::fs::write(d.join("top.jpg"), b"x").unwrap(); + std::fs::write(d.join("sub/inner.jpg"), b"x").unwrap(); + let flat = Limits { max_depth: 1, ..Limits::default() }; + let mut seen = HashSet::new(); + let top = files_in_with_seen(&d, None, flat, |_| true, None, &mut seen); + assert_eq!(top.files, [d.join("top.jpg")]); + let sub = files_in_with_seen(&d.join("sub"), None, flat, |_| true, None, &mut seen); + assert_eq!(sub.files, [d.join("sub/inner.jpg")], "the subfolder named as a root of its own"); + let again = files_in_with_seen(&d.join("sub"), None, flat, |_| true, None, &mut seen); + assert!(again.files.is_empty(), "walked once: {again:?}"); + let _ = std::fs::remove_dir_all(&d); + } } diff --git a/crates/engine/tests/import_keywords.rs b/crates/engine/tests/import_keywords.rs new file mode 100644 index 0000000000..7a5ea52ee6 --- /dev/null +++ b/crates/engine/tests/import_keywords.rs @@ -0,0 +1,98 @@ +//! Keyword normalization is the same for import presets and import-dialog keywords. + +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicUsize, Ordering}; + +use lcc_engine::Session; +use serde_json::json; + +struct Input(PathBuf); + +impl Input { + fn new() -> Self { + static NEXT: AtomicUsize = AtomicUsize::new(0); + let path = std::env::temp_dir().join(format!("import-keywords-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed))); + std::fs::create_dir(&path).unwrap(); + let image = lcc_raster::Rgba8 { width: 2, height: 1, data: vec![[20, 40, 60, 255], [80, 100, 120, 255]] }; + let bytes = lcc_codecs::encode_png(&lcc_codecs::EncodeImage::rgba8(&image), &lcc_codecs::EncodeMeta::default()).unwrap(); + std::fs::write(path.join("photo.png"), bytes).unwrap(); + Self(path) + } + + fn photo(&self) -> PathBuf { + self.0.join("photo.png") + } + + fn sidecar(&self) { + std::fs::write( + self.0.join("photo.xmp"), + r#"ÉtéPortraitOriginalÉté|PortraitOriginal"#, + ) + .unwrap(); + } +} + +impl Drop for Input { + fn drop(&mut self) { + let _ = std::fs::remove_dir_all(&self.0); + } +} + +fn keywords(s: &Session) -> Vec { + assert_eq!(s.catalog.len(), 1); + s.catalog.photos().next().unwrap().meta.keywords.clone() +} + +fn import(s: &mut Session, path: &Path, mut options: serde_json::Value) { + options["paths"] = json!([path.to_string_lossy()]); + let report = s.execute("library.import", &options).unwrap(); + assert_eq!(report["imported"].as_array().unwrap().len(), 1, "{report}"); + assert_eq!(report["failed"], json!([]), "{report}"); +} + +#[test] +fn default_metadata_preset_cleans_keywords_and_ignores_unicode_duplicates() { + let input = Input::new(); + let mut s = Session::new().with_fs(); + s.execute( + "metadata.savePreset", + &json!({"name": "Default", "fields": {"creator": "Studio", "keywords": [ + " || ", " Été | Portrait ", "été|portrait", "Ärger", "ärger", "studio", "STUDIO" + ]}}), + ) + .unwrap(); + s.execute("library.preferences", &json!({"import": {"metadataPreset": "Default"}})).unwrap(); + + import(&mut s, &input.photo(), json!({})); + assert_eq!(keywords(&s), ["Été|Portrait", "Ärger", "studio"]); + assert_eq!(s.catalog.photos().next().unwrap().meta.creator, "Studio"); +} + +#[test] +fn explicit_preset_and_import_keywords_keep_first_sidecar_spellings_and_order() { + let input = Input::new(); + input.sidecar(); + let mut s = Session::new().with_fs(); + s.execute("metadata.savePreset", &json!({"name": "Import", "fields": {"keywords": [" été | portrait ", " | ", "Ärger", "ärger"]}})).unwrap(); + + import( + &mut s, + &input.photo(), + json!({"metadataPreset": "Import", "keywords": ["ÉTÉ|PORTRAIT", " ÄRGER ", " New | Child ", "new|child", " || "]}), + ); + let expected = ["Été|Portrait", "Original", "Ärger", "New|Child"]; + assert_eq!(keywords(&s), expected); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(s.catalog.is_empty(), "the whole import is one undo step"); + s.execute("edit.redo", &json!({})).unwrap(); + assert_eq!(keywords(&s), expected); +} + +#[test] +fn import_keywords_without_a_preset_use_unicode_keyword_identity() { + let input = Input::new(); + input.sidecar(); + let mut s = Session::new().with_fs(); + import(&mut s, &input.photo(), json!({"keywords": [" été | portrait ", "Ärger", "ärger", " New || Child ", "new|child", " || "]})); + assert_eq!(keywords(&s), ["Été|Portrait", "Original", "Ärger", "New|Child"]); +} diff --git a/crates/engine/tests/keyword_set_inputs.rs b/crates/engine/tests/keyword_set_inputs.rs new file mode 100644 index 0000000000..13116b5b42 --- /dev/null +++ b/crates/engine/tests/keyword_set_inputs.rs @@ -0,0 +1,61 @@ +//! Invalid keyword-set slots must not erase a set or shift its keyboard shortcuts. + +use lcc_engine::Session; +use serde_json::{Value, json}; + +fn sets(s: &mut Session) -> Value { + s.execute("keyword.sets", &json!({})).unwrap() +} + +fn named(s: &mut Session, name: &str) -> Value { + sets(s)["sets"].as_array().unwrap().iter().find(|set| set["name"] == name).unwrap()["keywords"].clone() +} + +#[test] +fn malformed_keyword_slots_leave_saved_sets_and_current_set_unchanged() { + let mut s = Session::new(); + s.execute("keyword.saveSet", &json!({"name": "Saved", "keywords": ["first", "", "third"]})).unwrap(); + s.execute("keyword.saveSet", &json!({"name": "Other", "keywords": ["other"]})).unwrap(); + let before = sets(&mut s); + for keywords in [ + json!(true), + json!(7), + json!(1.5), + json!({"name": "replacement"}), + json!(["first", null, "third"]), + json!(["first", false, "third"]), + json!(["first", 7, "third"]), + json!(["first", {}, "third"]), + json!(["first", [], "third"]), + ] { + for mut params in [json!({"name": "Saved"}), json!({"name": "Renamed", "replace": "Saved"}), json!({"name": "New", "new": true})] { + params["keywords"] = keywords.clone(); + let error = s.execute("keyword.saveSet", ¶ms).unwrap_err().to_string(); + assert!(error.contains("`keywords`"), "{params}: {error}"); + assert_eq!(sets(&mut s), before, "{params}: saved or current sets changed"); + } + } +} + +#[test] +fn valid_keyword_slot_forms_keep_their_existing_meaning() { + let mut s = Session::new(); + s.execute("keyword.saveSet", &json!({"name": "Text", "keywords": " Parent | Child "})).unwrap(); + assert_eq!(named(&mut s, "Text"), json!(["Parent|Child"]), "text stays a single slot"); + s.execute("keyword.saveSet", &json!({"name": "Slots", "keywords": [" Alpha ", "", "Été", "été", "Last", ""]})).unwrap(); + assert_eq!(named(&mut s, "Slots"), json!(["Alpha", "", "Été", "", "Last"])); + + s.execute("keyword.saveSet", &json!({"name": "Inherited"})).unwrap(); + assert_eq!(named(&mut s, "Inherited"), named(&mut s, "Slots"), "omission inherits the current slots"); + s.execute("keyword.saveSet", &json!({"name": "Renamed", "replace": "Text"})).unwrap(); + assert_eq!(named(&mut s, "Renamed"), json!(["Parent|Child"]), "rename without keywords keeps the renamed set's slots"); + + s.execute("keyword.saveSet", &json!({"name": "Slots", "keywords": null})).unwrap(); + assert_eq!(named(&mut s, "Slots"), json!([]), "explicit null still clears"); + s.execute("keyword.saveSet", &json!({"name": "Renamed", "keywords": []})).unwrap(); + assert_eq!(named(&mut s, "Renamed"), json!([]), "an empty list still clears"); + + let many: Vec = (1..=10).map(|n| n.to_string()).collect(); + s.execute("keyword.saveSet", &json!({"name": "Nine", "keywords": many})).unwrap(); + assert_eq!(named(&mut s, "Nine"), json!(many[..9]), "the nine-slot limit is unchanged"); +} diff --git a/crates/engine/tests/overlapping_roots.rs b/crates/engine/tests/overlapping_roots.rs new file mode 100644 index 0000000000..ef161c2850 --- /dev/null +++ b/crates/engine/tests/overlapping_roots.rs @@ -0,0 +1,39 @@ +//! Overlapping import roots (a folder named twice, or inside another root) are walked once and +//! keep the first path spelling; the same holds for preset imports (adapted from upstream #1638). + +use lcc_engine::Session; +use serde_json::json; + +fn temp(tag: &str) -> std::path::PathBuf { + let dir = std::env::temp_dir().join(format!("overlapping-roots-{tag}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(dir.join("real")).unwrap(); + dir +} + +#[test] +fn overlapping_photo_roots_are_walked_once_and_keep_the_first_path() { + let dir = temp("photos"); + let real = dir.join("real"); + std::fs::write(real.join("photo.jpg"), b"not really a jpeg").unwrap(); + let roots = [real.to_string_lossy().to_string(), dir.to_string_lossy().to_string(), real.to_string_lossy().to_string()]; + let (files, truncated) = lcc_engine::import::expand_within(&roots, None, lcc_engine::walk::Limits::default()); + assert!(!truncated); + assert_eq!(files, [real.join("photo.jpg").to_string_lossy().to_string()]); + std::fs::remove_dir_all(dir).unwrap(); +} + +#[test] +fn overlapping_preset_roots_import_once_and_keep_the_first_path() { + let dir = temp("presets"); + let real = dir.join("real"); + let file = real.join("look.lrtemplate"); + std::fs::write(&file, r#"return { title = "Linked Look", value = { settings = { Exposure2012 = 0.5 } } }"#).unwrap(); + let mut s = Session::new(); + let r = s.execute("preset.import", &json!({"paths": [real, dir, file], "dryRun": true})).unwrap(); + let imported = r["imported"].as_array().unwrap(); + assert_eq!(imported.len(), 1, "{r}"); + assert_eq!(imported[0]["file"], file.to_string_lossy().as_ref()); + assert_eq!(r["failed"], json!([])); + std::fs::remove_dir_all(dir).unwrap(); +} diff --git a/crates/gpu/src/wgsl/finish.wgsl b/crates/gpu/src/wgsl/finish.wgsl index 4f7f24b024..6c27aacbee 100644 --- a/crates/gpu/src/wgsl/finish.wgsl +++ b/crates/gpu/src/wgsl/finish.wgsl @@ -1230,17 +1230,24 @@ fn main(@builtin(global_invocation_id) gid: vec3) { let t = sstep(start, start + pf(F_VIG_WIDTH), dist); if (t > 0.0) { let lum = clamp(lum2020(d), 0.0, 1.0); - if (amount < 0.0) { + let style = pu(F_VIG_STYLE); + if (style == 2u) { + // Paint: a flat overlay toward black (negative) or white (positive), as the CPU's + // finish.rs; in HDR it never pulls highlights down to SDR white + let w = abs(amount) * t; + if (amount < 0.0) { + d = d * (1.0 - w); + } else if (hdr) { + d = max(d, d * (1.0 - w) + vec3(w)); + } else { + d = d * (1.0 - w) + vec3(w); + } + } else if (amount < 0.0) { var f = 1.0 + amount * t; - let style = pu(F_VIG_STYLE); if (style == 1u) { f += (1.0 - f) * pf(F_VIG_HL) * sstep(0.4, 1.0, lum); } - if (style == 2u) { - d = d * (1.0 - (-amount) * t) + 0.0; - } else { - d = d * f; - } + d = d * f; } else if (hdr) { // lighten towards SDR white; never pull HDR highlights down to it d = d + max(vec3(1.0) - d, vec3(0.0)) * amount * t * 0.85; diff --git a/crates/gpu/tests/shutdown.rs b/crates/gpu/tests/shutdown.rs index 1fc0ce7bb2..2b61139e49 100644 --- a/crates/gpu/tests/shutdown.rs +++ b/crates/gpu/tests/shutdown.rs @@ -40,7 +40,8 @@ fn nothing_renders_on_the_gpu_once_the_process_is_ending() { }) }; if has_gpu { - while rendered.load(Ordering::SeqCst) == 0 && !refused.load(Ordering::SeqCst) { + let end = std::time::Instant::now() + Duration::from_secs(120); + while rendered.load(Ordering::SeqCst) == 0 && !refused.load(Ordering::SeqCst) && std::time::Instant::now() < end { std::thread::yield_now(); } assert!(rendered.load(Ordering::SeqCst) > 0, "the GPU renders before the shutdown ({:?})", lcc_gpu::last_fallback()); diff --git a/crates/mcp/src/headless.rs b/crates/mcp/src/headless.rs index c3a2ba0441..cd38cac712 100644 --- a/crates/mcp/src/headless.rs +++ b/crates/mcp/src/headless.rs @@ -133,6 +133,9 @@ impl Headless { lcc_engine::export::set_video_hooks(&mut items, &lcc_engine::export_video::VideoHooks { cancel, progress: Some(progress) }); row }); + // a batch goes on past a photo that fails (a missing original) and lists it in `files`; + // a single-photo export that fails is an error (upstream #4737) + let stop_on_error = total == 1; let mut hook = self.progress.take(); let mut cancelled = false; let files = run_batch( @@ -141,7 +144,7 @@ impl Headless { &Destination::on_disk(dir.to_string(), exact.map(str::to_string)), write, &|path| Path::new(path).exists(), - true, + stop_on_error, &mut |done, name| { cancelled = hook.as_mut().is_some_and(|h| !h(done, total, name)); !cancelled @@ -154,8 +157,9 @@ impl Headless { return Err("cancelled".into()); } lcc_engine::export::mark_exported(&mut self.session, &files); - // Single-photo exports also report path/width/height at the top level (back-compat). - let mut out = files.first().cloned().unwrap_or_else(|| json!({})); + // Single-photo exports also report path/width/height at the top level (back-compat); a + // per-file error is never promoted to the top level. + let mut out = files.first().filter(|file| file.get("error").is_none()).cloned().unwrap_or_else(|| json!({})); if let Some(photos) = after.run(&files, false) { out["applePhotos"] = photos; } @@ -396,6 +400,38 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + /// Upstream #4737 (issue #4714): a missing original in a headless export is reported per file, and later photos still export. + #[test] + fn a_missing_original_does_not_stop_a_headless_batch_export() { + let base = std::env::temp_dir().join(format!("lc-mcp-missing-export-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&base); + let (source, output) = (base.join("source"), base.join("output")); + std::fs::create_dir_all(&source).unwrap(); + + let mut h = Headless::demo(); + let mut ids = Vec::new(); + for (i, name) in ["missing.png", "before.png", "after.png"].into_iter().enumerate() { + let img = lcc_raster::Rgba8 { width: 8, height: 8, data: vec![[20 + i as u8, 3, 9, 255]; 64] }; + let png = lcc_codecs::encode_png(&lcc_codecs::EncodeImage::rgba8(&img), &lcc_codecs::EncodeMeta::default()).unwrap(); + let path = source.join(name); + std::fs::write(&path, &png).unwrap(); + let r = crate::call_tool(&mut h, "import", &json!({"paths": [path.to_string_lossy()]})); + assert!(!r.is_error, "{r:?}"); + ids.push(h.session.catalog.photos().find(|p| p.file_name == name).unwrap().id.0); + } + std::fs::remove_file(source.join("missing.png")).unwrap(); + + let r = h.call("app.export", json!({"ids": ids, "dir": output.to_string_lossy(), "longEdge": 32, "format": "png"})).unwrap(); + let files = r["files"].as_array().unwrap(); + assert_eq!(files.len(), 3, "{r}"); + assert!(files[0]["error"].as_str().is_some_and(|e| e.contains("missing.png")), "{r}"); + assert!(r.get("error").is_none(), "{r}"); + assert!(output.join("before.png").is_file(), "{r}"); + assert!(output.join("after.png").is_file(), "{r}"); + + let _ = std::fs::remove_dir_all(&base); + } + /// The export file-name template takes the Rename Photos tokens. #[test] fn export_naming_tokens() { diff --git a/crates/mcp/src/tests.rs b/crates/mcp/src/tests.rs index 90a28370a4..e1f3ee24f0 100644 --- a/crates/mcp/src/tests.rs +++ b/crates/mcp/src/tests.rs @@ -213,6 +213,29 @@ fn export_tool_forwards_its_advertised_options() { let _ = std::fs::remove_dir_all(&base); } +/// JPEG XL options reach the export command in both selection and explicit-photo calls. +#[test] +fn export_tool_forwards_jpeg_xl_options() { + for (lossless, effort, progressive) in [(true, "fast", true), (false, "normal", false)] { + for id in [None, Some(17)] { + let params = json!({"path": "out.jxl", "format": "jxl", "jxlLossless": lossless, "jxlEffort": effort, "jxlProgressive": progressive}); + let mut args = params.clone(); + if let Some(id) = id { + args["id"] = json!(id); + } + let mut b = Recorder(vec![]); + let result = call_tool(&mut b, "export", &args); + assert!(!result.is_error, "{result:?}"); + let mut calls = vec![]; + if let Some(id) = id { + calls.push(("engine.execute".to_string(), json!({"command": "library.select", "params": {"ids": [id], "active": id}}))); + } + calls.push(("engine.execute".to_string(), json!({"command": "app.export", "params": params}))); + assert_eq!(b.0, calls, "{args}"); + } + } +} + /// Issue #236: `app.export {addToPhotos, photosAlbum}` through the headless backend (the MCP /// `export` tool, `lcc-cli run`): the files written go to Photos and the result says how /// it went; where Photos isn't (not macOS), it is refused before anything is written. A fake @@ -843,3 +866,32 @@ fn a_relative_save_path_is_checked_as_the_absolute_path_that_is_written() { assert!(std::path::Path::new(path).is_absolute(), "{path}"); assert!(path.ends_with("x.png")); } + +/// Issue #4496: the Gemini API takes only string `enum`s in a tool's parameters and refuses the whole tool list +/// (400) for one integer enum, so no helper tool declares one. +#[test] +fn every_enum_in_the_helper_tools_is_a_list_of_strings() { + fn check(at: &str, v: &Value, bad: &mut Vec) { + match v { + Value::Object(m) => { + if let Some(e) = m.get("enum") + && !e.as_array().is_some_and(|a| !a.is_empty() && a.iter().all(Value::is_string)) + { + bad.push(format!("{at}: {e}")); + } + for (k, x) in m { + check(&format!("{at}.{k}"), x, bad); + } + } + Value::Array(a) => a.iter().enumerate().for_each(|(i, x)| check(&format!("{at}[{i}]"), x, bad)), + _ => {} + } + } + let mut bad = Vec::new(); + for has_ui in [false, true] { + for t in crate::tools::helper_tools(has_ui) { + check(t["name"].as_str().unwrap_or("?"), &t["inputSchema"], &mut bad); + } + } + assert!(bad.is_empty(), "non-string enums: {bad:?}"); +} diff --git a/crates/mcp/src/tools.rs b/crates/mcp/src/tools.rs index 02270a81b7..ab97a9d351 100644 --- a/crates/mcp/src/tools.rs +++ b/crates/mcp/src/tools.rs @@ -267,7 +267,8 @@ pub fn helper_tools(has_ui: bool) -> Vec { "removeLocation": {"type": "boolean"}, "removePersonInfo": {"type": "boolean", "description": "Leave out keywords marked as a person (Lightroom's Remove Person Info)"}, "colorSpace": {"type": "string", "enum": ["srgb", "displayP3", "adobeRgb", "proPhoto", "rec2020"], "description": "Output colour space (default sRGB; AVIF is always sRGB; lossy JPEG XL writes adobeRgb/proPhoto as rec2020). adobeRgb = Adobe RGB (1998) compatible; the embedded ICC profile is generated from the published primaries"}, - "bitDepth": {"type": "integer", "enum": [8, 10, 16, 32], "description": "Bits per channel: PNG 8|16 (default 8), TIFF 8|16|32 (default 16; 32 = linear float with a linear profile), PSD 8|16 (default 16), AVIF 8|10, JPEG XL 8|16; JPEG/WebP are 8-bit"}, + // the values in words, not an `enum`: the Gemini API refuses a tool list with a non-string enum (upstream #4496) + "bitDepth": {"type": "integer", "description": "Bits per channel (8, 10, 16 or 32): PNG 8|16 (default 8), TIFF 8|16|32 (default 16; 32 = linear float with a linear profile), PSD 8|16 (default 16), AVIF 8|10, JPEG XL 8|16; JPEG/WebP are 8-bit"}, "hdr": {"type": "boolean", "description": "HDR output for photos edited in HDR (develop.hdr): JPEG as an ISO 21496-1 gain map JPEG, AVIF as 10-bit, PNG and JPEG XL as 16-bit Rec. 2020 PQ, 32-bit TIFF with highlights above 1; other formats and SDR edits export as usual"}, "hdrTransfer": {"type": "string", "enum": ["pq", "hlg"], "description": "Transfer curve of HDR AVIF output (default pq): pq = SMPTE ST 2084, hlg = ITU-R BT.2100 hybrid log-gamma"}, "pluginDestination": {"type": "object", "description": "Send the exported files on to a plug-in export destination: {plugin, destination, args?} (see plugin.exportDestinations)"}, @@ -853,6 +854,9 @@ pub fn call_tool(b: &mut dyn Backend, name: &str, args: &Value) -> ToolResult { "dontEnlarge", "ppi", "quality", + "jxlLossless", + "jxlEffort", + "jxlProgressive", "limitKb", "sharpen", "sharpenAmount", diff --git a/crates/opendocs/Cargo.toml b/crates/opendocs/Cargo.toml new file mode 100644 index 0000000000..542a9fa750 --- /dev/null +++ b/crates/opendocs/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "lcc-opendocs" +version.workspace = true +edition.workspace = true +license.workspace = true +description = "Files macOS hands the app (L0): photos opened from Finder, the Dock or another app's Open With. One of the crates allowed `unsafe` (adds one Objective-C method); does nothing elsewhere." + +# Opts out of the workspace lints only to keep `unsafe_code = "deny"` overridable for the single +# `macos` module below, as in crates/firstclick; every other crate root has `#![forbid(unsafe_code)]`. +# See AGENTS.md. +[lints.rust] +unsafe_code = "deny" + +[lints.clippy] +dbg_macro = "warn" +todo = "warn" + +[dependencies] +log = { workspace = true } + +[target.'cfg(target_os = "macos")'.dependencies] +# All already in the tree through winit and muda: no new crate, only features. +block2 = "0.6" +objc2 = { workspace = true } +objc2-app-kit = { workspace = true } +objc2-foundation = { workspace = true, features = ["block2", "NSEnumerator", "NSNotification", "NSOperation", "NSString", "NSURL"] } diff --git a/crates/opendocs/src/lib.rs b/crates/opendocs/src/lib.rs new file mode 100644 index 0000000000..2fc7a6b391 --- /dev/null +++ b/crates/opendocs/src/lib.rs @@ -0,0 +1,198 @@ +//! Files the operating system asks the app to open: on macOS, a photo opened from Finder (Open +//! With, a drop on the Dock icon), from another app (Photo Mechanic's "Open with", Files) or with +//! `open -a photo.arw`. +//! +//! macOS doesn't pass these on the command line: AppKit hands them to the application delegate's +//! `application:openURLs:`, and when the delegate has no such method it asks `NSDocumentController`, +//! which fails with " cannot open files in the … format" because the app isn't an +//! `NSDocument` app. winit 0.30's delegate doesn't implement the method, so [`install`] adds it to +//! the delegate's class when the app is about to finish launching: after winit set the delegate and +//! before AppKit delivers the files the app was launched with. The handler queues the paths and +//! calls the waker ([`set_waker`]); the app collects them with [`take`]. +//! +//! Adapted from upstream #1204 (LR-IMP-DRAGDROP, issue #506), which followed VectorCraft's +//! `open_documents.rs`; Apple's AppKit (`application(_:open:)`) and Objective-C runtime +//! (`class_addMethod`) documentation. +//! +//! Adding a method to another crate's Objective-C class has no safe API: this is one of the crates +//! allowed `unsafe` (AGENTS.md), here inside `macos`. Its API +//! is safe, and elsewhere [`install`] does nothing and [`take`] stays empty. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] + +use std::sync::{Mutex, OnceLock, PoisonError}; + +/// Paths that arrived and haven't been taken yet. +static PENDING: Mutex> = Mutex::new(Vec::new()); +/// Called when paths arrive (unset until the window exists; the app takes them on its first frame). +static WAKER: OnceLock> = OnceLock::new(); + +/// Receive the files the operating system asks the app to open from now on. Call once, before the +/// event loop runs. Does nothing except on macOS, where such files come as arguments elsewhere. +pub fn install() { + #[cfg(target_os = "macos")] + macos::install(); +} + +/// Call `wake` whenever files arrive, e.g. to repaint the window that takes them. Only the first +/// waker set is kept. +pub fn set_waker(wake: impl Fn() + Send + Sync + 'static) { + let _ = WAKER.set(Box::new(wake)); +} + +/// The paths that arrived since the last call, in order. +pub fn take() -> Vec { + std::mem::take(&mut *PENDING.lock().unwrap_or_else(PoisonError::into_inner)) +} + +/// Queue `paths` and wake the app (called by the macOS handler; elsewhere only by the tests). +#[cfg_attr(not(target_os = "macos"), allow(dead_code))] +fn arrived(paths: impl IntoIterator) { + let len = { + let mut pending = PENDING.lock().unwrap_or_else(PoisonError::into_inner); + pending.extend(paths); + pending.len() + }; + if len > 0 + && let Some(wake) = WAKER.get() + { + wake(); + } +} + +#[cfg(target_os = "macos")] +#[allow(unsafe_code)] +mod macos { + use std::ptr::NonNull; + + use block2::RcBlock; + use objc2::MainThreadMarker; + use objc2::runtime::{AnyClass, AnyObject, Imp, Sel}; + use objc2::sel; + use objc2_app_kit::{NSApplication, NSApplicationWillFinishLaunchingNotification}; + use objc2_foundation::{NSArray, NSNotification, NSNotificationCenter, NSURL}; + + /// The handler's signature, as the Objective-C runtime calls it. + type OpenUrls = extern "C-unwind" fn(&AnyObject, Sel, &AnyObject, &NSArray); + + pub fn install() { + let block = RcBlock::new(|_: NonNull| add_to_delegate()); + // SAFETY: the name is AppKit's notification constant; no object or queue filter, so the + // block runs on the posting thread (AppKit posts it on the main thread). The notification + // center keeps the registration (and the block) for the life of the app; the returned + // observer token is only needed to unregister, which we never do. + unsafe { + NSNotificationCenter::defaultCenter().addObserverForName_object_queue_usingBlock( + Some(NSApplicationWillFinishLaunchingNotification), + None, + None, + &block, + ); + } + } + + /// `application:openURLs:` on the application delegate's class (winit's). + fn add_to_delegate() { + let Some(mtm) = MainThreadMarker::new() else { return }; + let Some(delegate) = NSApplication::sharedApplication(mtm).delegate() else { + log::warn!("no application delegate: photos opened from Finder or other apps won't arrive"); + return; + }; + if !add_open_urls(AsRef::::as_ref(&*delegate).class()) { + log::warn!("the application delegate already handles open-document events"); + } + } + + /// Add [`open_urls`] to `class` as `application:openURLs:`. False when the class already has + /// that method (it is then left as it is). + pub(crate) fn add_open_urls(class: &AnyClass) -> bool { + let handler: OpenUrls = open_urls; + // SAFETY: `Imp` is the untyped form of a method implementation; the Objective-C runtime + // calls it with the arguments the type encoding declares, which match `open_urls`: no + // return value (`v`), the receiver (`@`), the selector (`:`), the application (`@`) and the + // URL array (`@`). `class_addMethod` copies the encoding string and never replaces an + // existing method; the class is a registered class, alive for the life of the process. + let added = unsafe { + let imp = std::mem::transmute::(handler); + objc2::ffi::class_addMethod(std::ptr::from_ref(class).cast_mut(), sel!(application:openURLs:), imp, c"v@:@@".as_ptr()) + }; + added.as_bool() + } + + /// Queue the files among `urls`. Never panics: it runs inside AppKit. + extern "C-unwind" fn open_urls(_delegate: &AnyObject, _cmd: Sel, _app: &AnyObject, urls: &NSArray) { + // Only file URLs: macOS 27 turns an https URL's path into a file path too. + super::arrived(urls.iter().filter(|u| u.isFileURL()).filter_map(|u| u.to_file_path()).map(|p| p.to_string_lossy().into_owned())); + } +} + +#[cfg(test)] +mod tests { + use std::sync::Mutex; + use std::sync::atomic::{AtomicUsize, Ordering}; + + use super::*; + + /// The queue is global: tests that fill it take turns. + static QUEUE: Mutex<()> = Mutex::new(()); + static WOKEN: AtomicUsize = AtomicUsize::new(0); + + fn turn() -> std::sync::MutexGuard<'static, ()> { + let guard = QUEUE.lock().unwrap_or_else(PoisonError::into_inner); + let _ = take(); + guard + } + + #[test] + fn files_wait_until_taken_and_wake_the_app() { + let _turn = turn(); + set_waker(|| { + WOKEN.fetch_add(1, Ordering::SeqCst); + }); + let before = WOKEN.load(Ordering::SeqCst); + arrived(["/tmp/a.arw".to_string(), "/tmp/b c.jpg".to_string()]); + assert_eq!(WOKEN.load(Ordering::SeqCst), before + 1); + arrived(["/tmp/d.heic".to_string()]); + assert_eq!(take(), ["/tmp/a.arw", "/tmp/b c.jpg", "/tmp/d.heic"]); + assert!(take().is_empty()); + // nothing arrived: nothing to wake the app for + let before = WOKEN.load(Ordering::SeqCst); + arrived(Vec::new()); + assert_eq!(WOKEN.load(Ordering::SeqCst), before); + } + + #[cfg(not(target_os = "macos"))] + #[test] + fn install_elsewhere_queues_nothing() { + let _turn = turn(); + install(); + assert!(take().is_empty()); + } + + /// The method `install` adds, called the way AppKit calls it: only file URLs are queued, and a + /// class that already has the method keeps its own. + #[cfg(target_os = "macos")] + #[test] + #[allow(unsafe_code)] + fn an_open_urls_message_queues_the_files() { + use objc2::rc::Retained; + use objc2::runtime::{AnyObject, ClassBuilder, NSObject}; + use objc2::{ClassType, msg_send, sel}; + use objc2_foundation::{NSArray, NSString, NSURL}; + + let _turn = turn(); + let class = ClassBuilder::new(c"LccOpenDocsTestDelegate", NSObject::class()).unwrap().register(); + assert!(!class.responds_to(sel!(application:openURLs:))); + assert!(macos::add_open_urls(class)); + assert!(!macos::add_open_urls(class), "a second add leaves the method alone"); + + let web = NSURL::URLWithString(&NSString::from_str("https://example.com/a.jpg")).unwrap(); + let urls = + NSArray::from_retained_slice(&[NSURL::from_file_path("/tmp/a b.arw").unwrap(), web, NSURL::from_file_path("/tmp/c.heic").unwrap()]); + // SAFETY: `class` is an NSObject subclass (`new` returns a retained instance), and it now + // has `application:openURLs:` with the signature the message is sent with. + let delegate: Retained = unsafe { msg_send![class, new] }; + let app = NSObject::new(); + let () = unsafe { msg_send![&*delegate, application: &*app, openURLs: &*urls] }; + assert_eq!(take(), ["/tmp/a b.arw", "/tmp/c.heic"]); + } +} diff --git a/crates/pipeline/src/finish.rs b/crates/pipeline/src/finish.rs index d5e07b7d49..2212c77c9a 100644 --- a/crates/pipeline/src/finish.rs +++ b/crates/pipeline/src/finish.rs @@ -1094,16 +1094,25 @@ pub(crate) fn finish_with( let t = smooth(v.start, v.start + v.width, dist); if t > 0.0 { let lum = luminance_2020(d).clamp(0.0, 1.0); - if v.amount < 0.0 { + if v.style == VignetteStyle::PaintOverlay { + // Paint is a flat overlay toward black (negative) or white (positive); Color and + // Highlight Priority stay a multiply or a lift, so the style tabs differ once Amount + // leaves 0. Adapted from upstream #1261. (finish.wgsl does the same.) + let w = v.amount.abs() * t; + if v.amount < 0.0 { + d = d.map(|c| c * (1.0 - w)); + } else if hdr { + // towards SDR white; never pull HDR highlights down to it + d = d.map(|c| c.max(c * (1.0 - w) + w)); + } else { + d = d.map(|c| c * (1.0 - w) + w); + } + } else if v.amount < 0.0 { let mut f = 1.0 + v.amount * t; if v.style == VignetteStyle::HighlightPriority { f += (1.0 - f) * v.highlights * smooth(0.4, 1.0, lum); } - if v.style == VignetteStyle::PaintOverlay { - d = d.map(|c| c * (1.0 - (-v.amount) * t) + 0.0); - } else { - d = d.map(|c| c * f); - } + d = d.map(|c| c * f); } else if hdr { // lighten towards SDR white; never pull HDR highlights down to it d = d.map(|c| c + (1.0 - c).max(0.0) * v.amount * t * 0.85); diff --git a/crates/pipeline/src/tests.rs b/crates/pipeline/src/tests.rs index 822dbe88f4..f9bf7b47b3 100644 --- a/crates/pipeline/src/tests.rs +++ b/crates/pipeline/src/tests.rs @@ -135,6 +135,23 @@ fn resolution_independence_of_local_contrast() { assert!(err < 9.0, "mean abs error {err}"); } +#[test] +fn paint_overlay_vignette_lifts_a_corner_toward_white() { + use lcc_develop::VignetteStyle; + let src = Rgb32f::filled(48, 48, [0.18, 0.18, 0.18]); + let mut paint = DevelopSettings::default(); + paint.vignette.amount = 100.0; + paint.vignette.midpoint = 0.0; + paint.vignette.feather = 10.0; + paint.vignette.style = VignetteStyle::PaintOverlay; + let mut color = paint.clone(); + color.vignette.style = VignetteStyle::ColorPriority; + let paint_img = render(&src, &SourceInfo::default(), &paint, &RenderRequest::fit(48, 48)).image; + let color_img = render(&src, &SourceInfo::default(), &color, &RenderRequest::fit(48, 48)).image; + let corner = |img: &lcc_raster::Rgba8| img.data[0][0]; + assert!(corner(&paint_img) > corner(&color_img) + 8, "paint {} color {}", corner(&paint_img), corner(&color_img)); +} + #[test] fn crop_and_straighten_output_size() { let mut s = DevelopSettings::default(); diff --git a/crates/preview/src/tests.rs b/crates/preview/src/tests.rs index d6d6a42f98..2c4d59d131 100644 --- a/crates/preview/src/tests.rs +++ b/crates/preview/src/tests.rs @@ -218,17 +218,13 @@ fn pool_priorities_dedupe_and_drop() { 1000, Box::new(move || { let (m, cv) = &*g; - let mut open = m.lock().unwrap(); - while !*open { - open = cv.wait(open).unwrap(); - } + let (_open, waited) = cv.wait_timeout_while(m.lock().unwrap(), std::time::Duration::from_secs(60), |open| !*open).unwrap(); + assert!(!waited.timed_out(), "the test never opened the gate"); 999 }), ); // wait until the worker took the gate job - while p.queued() > 0 { - std::thread::yield_now(); - } + assert!(eventually(30, || p.queued() == 0), "the worker never took the gate job"); p.submit(1, 1, 5, Box::new(|| 1)); // off-screen thumb p.submit(2, 1, 10, Box::new(|| 2)); // visible thumb p.submit(3, 1, 100, Box::new(|| 3)); // loupe @@ -243,13 +239,11 @@ fn pool_priorities_dedupe_and_drop() { cv.notify_all(); } let mut order = Vec::new(); - while order.len() < 4 { - if let Some(d) = p.try_recv() { - order.push((d.slot, d.key, d.result)); - } else { - std::thread::yield_now(); - } - } + let all_done = eventually(30, || { + order.extend(std::iter::from_fn(|| p.try_recv()).map(|d| (d.slot, d.key, d.result))); + order.len() >= 4 + }); + assert!(all_done, "four jobs done: {order:?}"); assert_eq!(order, vec![(999, 0, 999), (3, 1, 3), (2, 2, 22), (1, 1, 1)]); } @@ -279,7 +273,7 @@ fn pool_with_a_running_job() -> (JobPool, std::sync::mpsc::Sender<()>) { let _ = released.recv_timeout(std::time::Duration::from_secs(60)); }), ); - has_started.recv().unwrap(); + has_started.recv_timeout(std::time::Duration::from_secs(30)).expect("the job starts"); (p, release) } @@ -301,7 +295,7 @@ fn pool_drop_waits_for_running_job() { f.store(true, Ordering::SeqCst); }), ); - has_started.recv().unwrap(); + has_started.recv_timeout(std::time::Duration::from_secs(30)).expect("the job starts"); let q = queued_ran.clone(); p.submit(2, 0, 1, Box::new(move || q.store(true, Ordering::SeqCst))); drop(p); @@ -347,9 +341,7 @@ fn pool_stops_after_a_job_panicked_and_when_dropped_by_its_own_job() { // a worker that unwound is not waited for let mut p: JobPool = JobPool::new(1); p.submit(1, 0, 1, Box::new(|| panic!("a job panics (expected in this test)"))); - while p.live_workers() > 0 { - std::thread::yield_now(); - } + assert!(eventually(30, || p.live_workers() == 0), "the worker that panicked is still counted"); assert!(p.shutdown(std::time::Duration::from_secs(30))); // the last owner of a pool is one of its jobs: the worker must not wait for (or join) itself @@ -785,7 +777,7 @@ fn a_slot_runs_one_job_at_a_time() { }) }; p.submit(1, 1, 9, job(1, Some(released))); - assert_eq!(has_started.recv().unwrap(), 1); + assert_eq!(has_started.recv_timeout(std::time::Duration::from_secs(30)).expect("slot 1's first job starts"), 1); // two newer requests for the busy slot: the second replaces the first, neither starts p.submit(1, 2, 9, job(2, None)); p.submit(1, 3, 9, job(3, None)); diff --git a/crates/raw/src/demosaic/mod.rs b/crates/raw/src/demosaic/mod.rs index ee1b00d80d..423e6e66ab 100644 --- a/crates/raw/src/demosaic/mod.rs +++ b/crates/raw/src/demosaic/mod.rs @@ -16,6 +16,8 @@ //! - [`Method::Ppg`] → `xtrans::directional`: our own edge-weighted colour-difference interpolation (faster). //! - [`Method::Bilinear`] → bilinear. //! +//! [`remosaic_rggb`] goes the other way, for callers that need Bayer geometry from a sensor that has none. +//! //! Every method reproduces a constant-colour mosaic exactly. mod ahd; @@ -150,6 +152,40 @@ pub fn demosaic_with(n: &Normalized, method: Method, opts: Options) -> Rgb32f { } } +/// Adapted from upstream #1828; the fork's quality X-Trans path (`xtrans_ri`) is not used here. +/// A non-Bayer mosaic (Fujifilm X-Trans, …) rebuilt as an RGGB mosaic of the same size, so that tools +/// written around Bayer geometry can read a sensor they were not written for: the AI denoiser, whose +/// model contract is four RGGB planes. The mosaic is interpolated as `xtrans::directional` ([`Method::Ppg`]) would and one channel is +/// kept per site, the one RGGB wants there, without building the full RGB picture in between. +/// +/// Where the sensor already carries that colour at that site the interpolation returns the sample +/// itself, so those sites keep their original value and their original noise, while the rest are +/// interpolated and so already a little smoother. Anything reading the result sees noise that varies +/// from site to site, and the interpolation's own errors: this is an approximation of the sensor, not +/// the sensor. +/// +/// `None` when the mosaic is not one this can rebuild: already demosaiced data (`cpp != 1`), no CFA, a +/// CFA that is already Bayer (read that one as it is), a pattern whose size does not match its colours +/// or holding a colour that is not red, green or blue (RGBE, CYGM) or missing one of the three, or a +/// size that does not match the samples. +pub fn remosaic_rggb(n: &Normalized) -> Option { + let cfa = n.cfa.as_ref()?; + if n.cpp != 1 || cfa.is_bayer() { + return None; + } + if cfa.width == 0 || cfa.height == 0 || cfa.width.checked_mul(cfa.height) != Some(cfa.pattern.len()) { + return None; + } + if !(0..=2).all(|c| cfa.pattern.contains(&c)) || cfa.pattern.iter().any(|&c| c > 2) { + return None; + } + if n.width == 0 || n.height == 0 || n.width.checked_mul(n.height) != Some(n.data.len()) { + return None; + } + let data = xtrans::rggb(&Mosaic { w: n.width, h: n.height, data: &n.data, cfa }); + Some(Normalized { width: n.width, height: n.height, cpp: 1, data, cfa: Some(Cfa::bayer_static("RGGB")) }) +} + /// Build a mosaic from an RGB image by sampling each pixel's CFA colour (for tests and synthetic data). pub fn mosaic_from_rgb(img: &Rgb32f, cfa: &Cfa) -> Normalized { let data = (0..img.height).flat_map(|y| (0..img.width).map(move |x| (x, y))).map(|(x, y)| img.get(x, y)[cfa.color_at(x, y) as usize]).collect(); @@ -179,6 +215,13 @@ pub fn psnr(a: &Rgb32f, b: &Rgb32f, border: usize) -> f64 { mod tests { use super::*; + fn smooth_scene(w: usize, h: usize) -> Rgb32f { + Rgb32f::from_fn(w, h, |x, y| { + let (fx, fy) = (x as f32 / w as f32, y as f32 / h as f32); + [0.2 + 0.6 * fx * fy, 0.3 + 0.4 * (fx * 3.0).sin().abs() * 0.5 + 0.2 * fy, 0.1 + 0.5 * (1.0 - fx) * (0.5 + 0.5 * (fy * 5.0).cos())] + }) + } + /// A photo-like scene: sharp luminance structure (disc, stripes, diagonal edge, fine texture) modulating a /// smoothly varying colour — edges are mostly luminance edges, as in natural images. fn edgy_scene(w: usize, h: usize) -> Rgb32f { @@ -384,4 +427,172 @@ mod tests { assert_eq!(reflect(3, 1), 0); assert_eq!(reflect(-7, 2), 1); } + + /// The single-pass re-mosaic must give exactly what demosaicing and then keeping each site's RGGB + /// colour gives: every phase of the pattern, the borders, and samples with no structure to hide behind. + #[test] + fn remosaic_matches_the_demosaic_sampled_as_rggb() { + let mut seed = 2024u32; + for (dx, dy) in [(0, 0), (1, 2), (5, 3)] { + let cfa = Cfa::xtrans().shifted(dx, dy); + let (w, h) = (37, 29); + let data: Vec = (0..w * h) + .map(|_| { + seed = seed.wrapping_mul(1_664_525).wrapping_add(1_013_904_223); + (seed >> 8) as f32 / (1u32 << 24) as f32 + }) + .collect(); + let n = Normalized { width: w, height: h, cpp: 1, data, cfa: Some(cfa) }; + let want = mosaic_from_rgb(&demosaic(&n, Method::Ppg), &Cfa::bayer("RGGB").unwrap()); + let got = remosaic_rggb(&n).unwrap(); + assert_eq!((got.width, got.height, got.cpp), (w, h, 1)); + assert!(got.data.iter().zip(&want.data).all(|(a, b)| a.to_bits() == b.to_bits()), "phase ({dx}, {dy})"); + } + } + + #[test] + fn remosaic_keeps_a_constant_colour_exactly() { + let colour = [0.3f32, 0.55, 0.8]; + let n = mosaic_from_rgb(&Rgb32f::filled(19, 14, colour), &Cfa::xtrans()); + let r = remosaic_rggb(&n).unwrap(); + let cfa = r.cfa.clone().unwrap(); + assert_eq!(cfa.name(), "RGGB"); + for y in 0..r.height { + for x in 0..r.width { + let want = colour[cfa.color_at(x, y) as usize]; + assert!((r.data[y * r.width + x] - want).abs() < 1e-5, "({x}, {y})"); + } + } + } + + /// The sites where X-Trans already carries the colour RGGB wants keep their own sample, untouched. + #[test] + fn remosaic_keeps_the_samples_the_two_patterns_share() { + let img = edgy_scene(40, 32); + let xt = Cfa::xtrans(); + let n = mosaic_from_rgb(&img, &xt); + let r = remosaic_rggb(&n).unwrap(); + let rggb = r.cfa.clone().unwrap(); + let mut shared = 0; + for y in 0..32 { + for x in 0..40 { + let c = rggb.color_at(x, y); + if xt.color_at(x, y) != c { + continue; + } + shared += 1; + assert_eq!(r.data[y * 40 + x].to_bits(), img.get(x, y)[c as usize].to_bits(), "({x}, {y})"); + } + } + // about two sites in five: 20/36 greens against RGGB's half, 8/36 reds and blues against its quarters + assert!(shared > 40 * 32 / 4, "only {shared} shared sites"); + } + + /// Reading the re-mosaic back as Bayer costs a little against demosaicing the X-Trans mosaic directly, + /// but must stay close: it is the picture the denoiser's Bayer contract starts from. + #[test] + fn remosaic_round_trip_stays_close_to_the_direct_demosaic() { + for img in [smooth_scene(96, 80), edgy_scene(96, 80)] { + let n = mosaic_from_rgb(&img, &Cfa::xtrans()); + let direct = psnr(&img, &demosaic(&n, Method::Ppg), 6); // the interpolator the re-mosaic uses + let through = psnr(&img, &demosaic(&remosaic_rggb(&n).unwrap(), Method::Ahd), 6); + eprintln!("direct {direct:.1} dB, through RGGB {through:.1} dB"); + assert!(through > 24.0, "through RGGB {through:.1} dB"); + assert!(through > direct - 2.0, "through RGGB {through:.1} dB against direct {direct:.1} dB"); + } + } + + #[test] + fn remosaic_refuses_what_it_cannot_rebuild() { + let img = smooth_scene(12, 10); + let xtrans = || mosaic_from_rgb(&img, &Cfa::xtrans()); + // already Bayer: the caller reads that mosaic as it is + assert!(remosaic_rggb(&mosaic_from_rgb(&img, &Cfa::bayer("GRBG").unwrap())).is_none()); + // already demosaiced + let mut three = xtrans(); + three.cpp = 3; + assert!(remosaic_rggb(&three).is_none()); + // no colour filter array at all (a monochrome sensor) + let mut mono = xtrans(); + mono.cfa = None; + assert!(remosaic_rggb(&mono).is_none()); + // a fourth colour (RGBE), a pattern missing blue, and patterns whose size does not match their colours + // (a zero side would divide by zero when looking a colour up, a short pattern would read past its end) + for (width, height, pattern) in + [(2, 2, vec![0, 1, 1, 3]), (2, 2, vec![0, 1, 1, 1]), (0, 2, vec![0, 1, 2]), (2, 2, vec![0, 1, 2]), (6, 6, vec![])] + { + let mut odd = xtrans(); + odd.cfa = Some(Cfa { width, height, pattern }); + assert!(remosaic_rggb(&odd).is_none(), "{width}×{height}"); + } + // samples that do not match the size + let mut short = xtrans(); + short.data.pop(); + assert!(remosaic_rggb(&short).is_none()); + let mut empty = xtrans(); + (empty.width, empty.height, empty.data) = (0, 0, Vec::new()); + assert!(remosaic_rggb(&empty).is_none()); + } + + /// The re-mosaic on a real non-Bayer file, which no synthetic pattern stands in for (the active-area crop + /// moves the pattern's phase, and sensor noise is what the denoiser is given the result for): + /// `LC_XTRANS_RAW= cargo test --release -p lcc-raw --lib -- --ignored --nocapture remosaic_a_real_file` + #[test] + #[ignore = "needs LC_XTRANS_RAW pointing at a real non-Bayer raw file"] + fn remosaic_a_real_file() { + let Some(path) = std::env::var_os("LC_XTRANS_RAW") else { + lcc_testkit::skip!(Input, "set LC_XTRANS_RAW="); + return; + }; + let raw = crate::decode(&std::fs::read(&path).unwrap()).unwrap(); + let n = raw.normalized().unwrap(); + let cfa = n.cfa.clone().unwrap(); + assert!(!cfa.is_bayer(), "not a non-Bayer file"); + let t = std::time::Instant::now(); + let r = remosaic_rggb(&n).unwrap(); + let ms = t.elapsed().as_secs_f64() * 1e3; + assert_eq!((r.width, r.height), (n.width, n.height)); + assert!(r.data.iter().all(|v| v.is_finite())); + let rggb = r.cfa.clone().unwrap(); + let (mut shared, mut kept) = (0usize, 0usize); + for y in 0..n.height { + for x in 0..n.width { + if cfa.color_at(x, y) == rggb.color_at(x, y) { + shared += 1; + kept += usize::from(r.data[y * n.width + x].to_bits() == n.data[y * n.width + x].to_bits()); + } + } + } + let t = std::time::Instant::now(); + let direct = demosaic(&n, Method::Ahd); + let direct_ms = t.elapsed().as_secs_f64() * 1e3; + println!( + "{}×{}: re-mosaic {ms:.0} ms (a full demosaic {direct_ms:.0} ms), {shared} shared sites ({:.1} %), {kept} of them \ + untouched, PSNR through RGGB against the direct demosaic {:.1} dB", + n.width, + n.height, + 100.0 * shared as f64 / (n.width * n.height) as f64, + psnr(&direct, &demosaic(&r, Method::Ahd), 8) + ); + assert_eq!(kept, shared, "a shared site lost its own sample"); + } + + #[test] + #[ignore] + fn throughput() { + let (w, h) = (6000, 4000); + let img = smooth_scene(w, h); + let cfa = Cfa::bayer("RGGB").unwrap(); + let n = mosaic_from_rgb(&img, &cfa); + for m in [Method::Bilinear, Method::Ppg, Method::Ahd] { + let t = std::time::Instant::now(); + let _ = demosaic(&n, m); + let s = t.elapsed().as_secs_f64(); + println!("{m:?}: {:.1} MP/s ({:.0} ms for 24 MP)", (w * h) as f64 / 1e6 / s, s * 1e3); + } + let n = mosaic_from_rgb(&img, &Cfa::xtrans()); + let t = std::time::Instant::now(); + let _ = demosaic(&n, Method::Ahd); + println!("X-Trans directional: {:.1} MP/s", (w * h) as f64 / 1e6 / t.elapsed().as_secs_f64()); + } } diff --git a/crates/raw/src/demosaic/xtrans.rs b/crates/raw/src/demosaic/xtrans.rs index 32768ea8d6..af814f4bb4 100644 --- a/crates/raw/src/demosaic/xtrans.rs +++ b/crates/raw/src/demosaic/xtrans.rs @@ -139,6 +139,45 @@ fn green(m: &Mosaic, off: &Offsets) -> Vec { g } +/// Step 2 at an interior pixel `i` with green `gp`: green plus the edge-weighted mean colour difference of +/// the same-colour samples at `list` (precomputed offsets, no reflection). +#[inline] +fn colour_inside(m: &Mosaic, g: &[f32], i: usize, gp: f32, list: &[(isize, isize)]) -> f32 { + let w = m.w as isize; + let (mut s, mut ws) = (0.0f32, 0.0f32); + for &(dx, dy) in list { + let j = (i as isize + dy * w + dx) as usize; + let gq = g[j]; + let d2 = (dx * dx + dy * dy) as f32; + let wt = 1.0 / (d2 * (EPS + (gq - gp).abs())); + s += wt * (m.data[j] - gq); + ws += wt; + } + if ws > 0.0 { gp + s / ws } else { gp } +} + +/// Step 2 near the border, for colour `c` (0 red, 2 blue) at `(x, y)` with green `gp`: the 5×5 +/// neighbourhood read with reflection. +#[inline] +fn colour_at_border(m: &Mosaic, g: &[f32], x: isize, y: isize, gp: f32, c: usize) -> f32 { + let (w, h) = (m.w, m.h); + let gg = |x: isize, y: isize| g[super::reflect(y, h) * w + super::reflect(x, w)]; + let (mut s, mut ws) = (0.0f32, 0.0f32); + for dy in -2isize..=2 { + for dx in -2isize..=2 { + if m.color(x + dx, y + dy) as usize != c { + continue; + } + let gq = gg(x + dx, y + dy); + let d2 = (dx * dx + dy * dy) as f32; + let wt = 1.0 / (d2 * (EPS + (gq - gp).abs())); + s += wt * (m.get(x + dx, y + dy) - gq); + ws += wt; + } + } + if ws > 0.0 { gp + s / ws } else { gp } +} + pub(crate) fn directional(m: &Mosaic) -> Rgb32f { let (w, h) = (m.w, m.h); let off = Offsets::new(m); @@ -153,50 +192,50 @@ pub(crate) fn directional(m: &Mosaic) -> Rgb32f { let i = y * w + x; let own = m.cfa.color_at(x, y) as usize; let gp = g[i]; - px[1] = gp; let lists = &off.rb[off.phase(x, y)]; - for (li, c) in [0usize, 2].into_iter().enumerate() { - if c == own { - px[c] = m.data[i]; - continue; - } - let (mut s, mut ws) = (0.0f32, 0.0f32); - for &(dx, dy) in &lists[li] { - let j = (i as isize + dy * w as isize + dx) as usize; - let gq = g[j]; - let d2 = (dx * dx + dy * dy) as f32; - let wt = 1.0 / (d2 * (EPS + (gq - gp).abs())); - s += wt * (m.data[j] - gq); - ws += wt; - } - px[c] = if ws > 0.0 { gp + s / ws } else { gp }; - } + px[1] = gp; + px[0] = if own == 0 { m.data[i] } else { colour_inside(m, &g, i, gp, &lists[0]) }; + px[2] = if own == 2 { m.data[i] } else { colour_inside(m, &g, i, gp, &lists[1]) }; continue; } let x = x as isize; let own = m.color(x, yi) as usize; let gp = gg(x, yi); px[1] = gp; - for c in [0usize, 2] { - if c == own { - px[c] = m.get(x, yi); + px[0] = if own == 0 { m.get(x, yi) } else { colour_at_border(m, &g, x, yi, gp, 0) }; + px[2] = if own == 2 { m.get(x, yi) } else { colour_at_border(m, &g, x, yi, gp, 2) }; + } + }); + out +} + +/// The mosaic interpolated and read back as RGGB: sample for sample what [`directional`] followed by +/// keeping the RGGB colour of each site gives, without the full RGB picture in between — a third of the +/// memory, and one colour interpolated only at the sites that want red or blue. +pub(crate) fn rggb(m: &Mosaic) -> Vec { + let (w, h) = (m.w, m.h); + let off = Offsets::new(m); + let g = green(m, &off); + let mut out = vec![0f32; w * h]; + par_rows(&mut out, w, |y, row| { + let interior_y = y >= 2 && y + 2 < h; + let yi = y as isize; + for (x, o) in row.iter_mut().enumerate() { + let i = y * w + x; + let c = match (y % 2, x % 2) { + (0, 0) => 0, + (1, 1) => 2, + _ => { + *o = g[i]; continue; } - let (mut s, mut ws) = (0.0f32, 0.0f32); - for dy in -2isize..=2 { - for dx in -2isize..=2 { - if m.color(x + dx, yi + dy) as usize != c { - continue; - } - let gq = gg(x + dx, yi + dy); - let d2 = (dx * dx + dy * dy) as f32; - let wt = 1.0 / (d2 * (EPS + (gq - gp).abs())); - s += wt * (m.get(x + dx, yi + dy) - gq); - ws += wt; - } - } - px[c] = if ws > 0.0 { gp + s / ws } else { gp }; + }; + if interior_y && x >= 2 && x + 2 < w { + *o = if m.cfa.color_at(x, y) as usize == c { m.data[i] } else { colour_inside(m, &g, i, g[i], &off.rb[off.phase(x, y)][c / 2]) }; + continue; } + let x = x as isize; + *o = if m.color(x, yi) as usize == c { m.get(x, yi) } else { colour_at_border(m, &g, x, yi, g[i], c) }; } }); out diff --git a/crates/slideshow/src/compose.rs b/crates/slideshow/src/compose.rs index 6ea02cd2b1..89ca02bf98 100644 --- a/crates/slideshow/src/compose.rs +++ b/crates/slideshow/src/compose.rs @@ -252,6 +252,9 @@ pub fn compose_with( }); } behind(&mut out, &l); + if !has_photo { + return (out, l); + } // cast shadow: a blurred rectangle (separable: the product of two blurred steps) if let Some((r, sigma)) = l.shadow { let op = s.shadow_opacity as f32; @@ -273,9 +276,7 @@ pub fn compose_with( if l.frame != l.visible { fill(&mut out, &l.frame, s.stroke_color); } - if has_photo { - draw_image(&mut out, photo, &l.photo, &l.cell, 1.0); - } + draw_image(&mut out, photo, &l.photo, &l.cell, 1.0); (out, l) } @@ -487,6 +488,24 @@ mod tests { assert_eq!(px(&img, 100, 50), GREEN, "and the photo covers it"); } + #[test] + fn an_empty_photo_draws_the_backdrop_without_a_frame() { + let s = SlideSettings { + backdrop_color: RED, + margin_left: 0.25, + stroke_border: true, + stroke_color: GREEN, + stroke_width: 0.05, + cast_shadow: true, + shadow_opacity: 1.0, + ..SlideSettings::default() + }; + let mut drew_behind = false; + let (img, _) = compose_with(&Rgba8::new(0, 0), None, &s, 40, 24, &mut |_, _| drew_behind = true); + assert!(drew_behind); + assert!(img == solid(40, 24, RED), "photo effects changed the backdrop"); + } + #[test] fn hostile_input_never_panics() { let wild = SlideSettings { diff --git a/crates/ui-egui/locales/fork/cs.json b/crates/ui-egui/locales/fork/cs.json index 992a1e5244..ee73097159 100644 --- a/crates/ui-egui/locales/fork/cs.json +++ b/crates/ui-egui/locales/fork/cs.json @@ -3578,6 +3578,7 @@ "Update this one automatically": "Aktualizovat tento modul automaticky", "Update to Current Process Version": "Aktualizovat na aktuální verzi procesu", "Update with Current Settings…": "Aktualizovat podle aktuálního nastavení…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Aktualizace jsou vypnuté (je nastaveno {env}_DISABLE_UPDATES); aktualizace obstarává správce balíčků.", "Updates the installed version": "Aktualizuje nainstalovanou verzi", "Updates…": "Aktualizace…", "Updating the DNG previews stopped unexpectedly": "Aktualizace náhledů DNG se neočekávaně zastavila", diff --git a/crates/ui-egui/locales/fork/de.json b/crates/ui-egui/locales/fork/de.json index f6af762358..736c6c1b96 100644 --- a/crates/ui-egui/locales/fork/de.json +++ b/crates/ui-egui/locales/fork/de.json @@ -3447,6 +3447,7 @@ "Update this one automatically": "Dieses automatisch aktualisieren", "Update to Current Process Version": "Auf aktuelle Prozessversion aktualisieren", "Update with Current Settings…": "Mit aktuellen Einstellungen aktualisieren…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Updates sind ausgeschaltet ({env}_DISABLE_UPDATES ist gesetzt); Ihre Paketverwaltung kümmert sich um Updates.", "Updates the installed version": "Aktualisiert die installierte Version", "Updates…": "Aktualisierungen…", "Updating the DNG previews stopped unexpectedly": "Das Aktualisieren der DNG-Vorschauen wurde unerwartet angehalten", diff --git a/crates/ui-egui/locales/fork/es.json b/crates/ui-egui/locales/fork/es.json index 9d7c832a2a..10718af655 100644 --- a/crates/ui-egui/locales/fork/es.json +++ b/crates/ui-egui/locales/fork/es.json @@ -3710,6 +3710,7 @@ "Update to Current Process": "Actualizar al proceso actual", "Update to Current Process Version": "Actualizar a la versión de proceso actual", "Update with Current Settings…": "Actualizar con la configuración actual…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Las actualizaciones están desactivadas ({env}_DISABLE_UPDATES está definida); su gestor de paquetes se encarga de ellas.", "Updates the installed version": "Actualiza la versión instalada", "Updates…": "Actualizaciones…", "Updating the DNG previews stopped unexpectedly": "La actualización de las vistas previas DNG se detuvo inesperadamente", diff --git a/crates/ui-egui/locales/fork/fi.json b/crates/ui-egui/locales/fork/fi.json index 97a49dc908..2af5a1bce0 100644 --- a/crates/ui-egui/locales/fork/fi.json +++ b/crates/ui-egui/locales/fork/fi.json @@ -3778,6 +3778,7 @@ "Update this one automatically": "Päivitä tämä automaattisesti", "Update to Current Process Version": "Päivitä nykyiseen prosessiversioon", "Update with Current Settings…": "Päivitä nykyisillä asetuksilla…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Päivitykset ovat pois päältä ({env}_DISABLE_UPDATES on asetettu); paketinhallinta hoitaa päivitykset.", "Updates the installed version": "Päivittää asennetun version", "Updates…": "Päivitykset…", "Updating the DNG previews stopped unexpectedly": "DNG-esikatselujen päivitys pysähtyi odottamatta", diff --git a/crates/ui-egui/locales/fork/fr.json b/crates/ui-egui/locales/fork/fr.json index 6747f4c855..680bd6790c 100644 --- a/crates/ui-egui/locales/fork/fr.json +++ b/crates/ui-egui/locales/fork/fr.json @@ -3391,6 +3391,7 @@ "Update this one automatically": "Mettre à jour celui-ci automatiquement", "Update to Current Process Version": "Mettre à jour vers la version de traitement actuelle", "Update with Current Settings…": "Mettre à jour avec les réglages actuels…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Les mises à jour sont désactivées ({env}_DISABLE_UPDATES est défini) ; votre gestionnaire de paquets s’en charge.", "Updates the installed version": "Met à jour la version installée", "Updates…": "Mises à jour…", "Updating the DNG previews stopped unexpectedly": "La mise à jour des aperçus DNG s'est arrêtée de façon inattendue", diff --git a/crates/ui-egui/locales/fork/id.json b/crates/ui-egui/locales/fork/id.json index 6243d4a8bb..7d81aa7968 100644 --- a/crates/ui-egui/locales/fork/id.json +++ b/crates/ui-egui/locales/fork/id.json @@ -3791,6 +3791,7 @@ "Update this one automatically": "Perbarui yang ini secara otomatis", "Update to Current Process Version": "Perbarui ke versi proses terbaru", "Update with Current Settings…": "Perbarui dengan pengaturan saat ini…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Pembaruan dimatikan ({env}_DISABLE_UPDATES disetel); pengelola paket Anda yang menangani pembaruan.", "Updates the installed version": "Memperbarui versi yang terinstal", "Updates…": "Pembaruan…", "Updating the DNG previews stopped unexpectedly": "Pembaruan pratinjau DNG berhenti tanpa diduga", diff --git a/crates/ui-egui/locales/fork/it.json b/crates/ui-egui/locales/fork/it.json index fa57cc6071..e48d31568d 100644 --- a/crates/ui-egui/locales/fork/it.json +++ b/crates/ui-egui/locales/fork/it.json @@ -3583,6 +3583,7 @@ "Update this one automatically": "Aggiorna questo automaticamente", "Update to Current Process Version": "Aggiorna alla versione processo corrente", "Update with Current Settings…": "Aggiorna con le impostazioni attuali…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Gli aggiornamenti sono disattivati ({env}_DISABLE_UPDATES è impostata); se ne occupa il gestore di pacchetti.", "Updates the installed version": "Aggiorna la versione installata", "Updates…": "Aggiornamenti…", "Updating the DNG previews stopped unexpectedly": "L'aggiornamento delle anteprime DNG si è interrotto inaspettatamente", diff --git a/crates/ui-egui/locales/fork/ja.json b/crates/ui-egui/locales/fork/ja.json index 456f352d56..a61a010bc8 100644 --- a/crates/ui-egui/locales/fork/ja.json +++ b/crates/ui-egui/locales/fork/ja.json @@ -3712,6 +3712,7 @@ "Update to Current Process": "現在のプロセスに更新", "Update to Current Process Version": "現在のプロセスバージョンに更新", "Update with Current Settings…": "現在の設定で更新…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "アップデートはオフです({env}_DISABLE_UPDATES が設定されています)。アップデートはパッケージマネージャーが行います。", "Updates the installed version": "インストール済みのバージョンを更新します", "Updates…": "アップデート…", "Updating the DNG previews stopped unexpectedly": "DNG プレビューの更新が予期せず停止しました", diff --git a/crates/ui-egui/locales/fork/ka.json b/crates/ui-egui/locales/fork/ka.json index fb819e38e9..0ccff104c6 100644 --- a/crates/ui-egui/locales/fork/ka.json +++ b/crates/ui-egui/locales/fork/ka.json @@ -3992,6 +3992,7 @@ "Update this one automatically": "ამის ავტომატურად განახლება", "Update to Current Process Version": "მიმდინარე დამუშავების ვერსიამდე განახლება", "Update with Current Settings…": "განახლება მიმდინარე პარამეტრებით…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "განახლებები გამორთულია ({env}_DISABLE_UPDATES დაყენებულია); განახლებებს პაკეტების მმართველი უზრუნველყოფს.", "Updates the installed version": "აახლებს დაინსტალირებულ ვერსიას", "Updates…": "განახლებები…", "Updating the DNG previews stopped unexpectedly": "DNG გადახედვების განახლება მოულოდნელად შეჩერდა", diff --git a/crates/ui-egui/locales/fork/pl.json b/crates/ui-egui/locales/fork/pl.json index 1ec7a691e8..c55130d96d 100644 --- a/crates/ui-egui/locales/fork/pl.json +++ b/crates/ui-egui/locales/fork/pl.json @@ -3827,6 +3827,7 @@ "Update this one automatically": "Aktualizuj tę automatycznie", "Update to Current Process Version": "Zaktualizuj do bieżącej wersji procesu", "Update with Current Settings…": "Aktualizuj bieżącymi ustawieniami…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Aktualizacje są wyłączone (ustawiono {env}_DISABLE_UPDATES); aktualizacjami zajmuje się menedżer pakietów.", "Updates the installed version": "Aktualizuje zainstalowaną wersję", "Updates…": "Aktualizacje…", "Updating the DNG previews stopped unexpectedly": "Aktualizacja podglądów DNG nieoczekiwanie się zatrzymała", diff --git a/crates/ui-egui/locales/fork/pt-br.json b/crates/ui-egui/locales/fork/pt-br.json index 0c184417e7..414c1dbe6e 100644 --- a/crates/ui-egui/locales/fork/pt-br.json +++ b/crates/ui-egui/locales/fork/pt-br.json @@ -3709,6 +3709,7 @@ "Update to Current Process": "Atualizar para o processo atual", "Update to Current Process Version": "Atualizar para a versão do processo atual", "Update with Current Settings…": "Atualizar com as configurações atuais…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "As atualizações estão desativadas ({env}_DISABLE_UPDATES está definida); seu gerenciador de pacotes cuida delas.", "Updates the installed version": "Atualiza a versão instalada", "Updates…": "Atualizações…", "Updating the DNG previews stopped unexpectedly": "A atualização das pré-visualizações DNG parou inesperadamente", diff --git a/crates/ui-egui/locales/fork/ru.json b/crates/ui-egui/locales/fork/ru.json index 1d0c6b1f40..b9a6cad663 100644 --- a/crates/ui-egui/locales/fork/ru.json +++ b/crates/ui-egui/locales/fork/ru.json @@ -3688,6 +3688,7 @@ "Update to Current Process Version": "Обновить до текущей версии обработки", "Update with Current Settings…": "Обновить текущими настройками…", "Updated the edits saved in the external editor": "Обновлены правки, сохранённые во внешнем редакторе", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Обновления отключены (задана переменная {env}_DISABLE_UPDATES); обновлениями занимается менеджер пакетов.", "Updates the installed version": "Обновляет установленную версию", "Updates…": "Обновления…", "Updating the DNG previews stopped unexpectedly": "Обновление превью DNG неожиданно остановилось", diff --git a/crates/ui-egui/locales/fork/sv.json b/crates/ui-egui/locales/fork/sv.json index fba1a4269b..f23fbb1e70 100644 --- a/crates/ui-egui/locales/fork/sv.json +++ b/crates/ui-egui/locales/fork/sv.json @@ -3855,6 +3855,7 @@ "Update this one automatically": "Uppdatera det här automatiskt", "Update to Current Process Version": "Uppdatera till aktuell processversion", "Update with Current Settings…": "Uppdatera med aktuella inställningar…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Uppdateringar är avstängda ({env}_DISABLE_UPDATES är satt); din pakethanterare sköter uppdateringar.", "Updates the installed version": "Uppdaterar den installerade versionen", "Updates…": "Uppdateringar…", "Updating the DNG previews stopped unexpectedly": "Uppdateringen av DNG-förhandsvisningarna avbröts oväntat", diff --git a/crates/ui-egui/locales/fork/uk.json b/crates/ui-egui/locales/fork/uk.json index 5bb021e39f..93221ec80d 100644 --- a/crates/ui-egui/locales/fork/uk.json +++ b/crates/ui-egui/locales/fork/uk.json @@ -3561,6 +3561,7 @@ "Update to Current Process": "Оновити до поточного процесу", "Update to Current Process Version": "Оновити до поточної версії обробки", "Update with Current Settings…": "Оновити поточними налаштуваннями…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Оновлення вимкнено (задано змінну {env}_DISABLE_UPDATES); оновленнями опікується менеджер пакетів.", "Updates the installed version": "Оновлює встановлену версію", "Updates…": "Оновлення…", "Updating the DNG previews stopped unexpectedly": "Оновлення попередніх переглядів DNG несподівано зупинилося", diff --git a/crates/ui-egui/locales/fork/vi.json b/crates/ui-egui/locales/fork/vi.json index 278fa10004..6cd8449071 100644 --- a/crates/ui-egui/locales/fork/vi.json +++ b/crates/ui-egui/locales/fork/vi.json @@ -4032,6 +4032,7 @@ "Update this one automatically": "Tự động cập nhật plugin này", "Update to Current Process Version": "Cập nhật lên phiên bản quy trình hiện tại", "Update with Current Settings…": "Cập nhật với cài đặt hiện tại…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "Cập nhật đã bị tắt ({env}_DISABLE_UPDATES được đặt); trình quản lý gói của bạn sẽ lo việc cập nhật.", "Updates the installed version": "Cập nhật phiên bản đã cài", "Updates…": "Cập nhật…", "Updating the DNG previews stopped unexpectedly": "Việc cập nhật bản xem trước DNG đã dừng đột ngột", diff --git a/crates/ui-egui/locales/fork/zh-hans.json b/crates/ui-egui/locales/fork/zh-hans.json index e7fdb0232e..9fbcadb0f8 100644 --- a/crates/ui-egui/locales/fork/zh-hans.json +++ b/crates/ui-egui/locales/fork/zh-hans.json @@ -3649,6 +3649,7 @@ "Update to Current Process": "更新到当前处理版本", "Update to Current Process Version": "更新到当前处理版本", "Update with Current Settings…": "用当前设置更新…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "更新已关闭(已设置 {env}_DISABLE_UPDATES);更新由软件包管理器负责。", "Updates the installed version": "更新已安装的版本", "Updates…": "更新…", "Updating the DNG previews stopped unexpectedly": "更新 DNG 预览意外停止", diff --git a/crates/ui-egui/locales/fork/zh-hant.json b/crates/ui-egui/locales/fork/zh-hant.json index e077a9d66d..e94cb33ebe 100644 --- a/crates/ui-egui/locales/fork/zh-hant.json +++ b/crates/ui-egui/locales/fork/zh-hant.json @@ -3709,6 +3709,7 @@ "Update to Current Process": "更新至目前處理版本", "Update to Current Process Version": "更新至目前處理版本", "Update with Current Settings…": "以目前設定更新…", + "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates.": "更新已關閉(已設定 {env}_DISABLE_UPDATES);更新由套件管理員負責。", "Updates the installed version": "更新已安裝的版本", "Updates…": "更新…", "Updating the DNG previews stopped unexpectedly": "更新 DNG 預覽意外停止", diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index c9626e24aa..34ac825b1f 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -300,6 +300,49 @@ pub(crate) fn check_gesture_numbers(method: &str, p: &Value) -> Result<(), Strin check(method, "", p) } +/// Most synthetic events that may wait in `app.synthetic` for the frames that drain them. +/// `count` and `steps` bound one request; this bounds a script that sends requests faster than +/// the app takes them, so the queue (and the time it takes to drain) can't grow without end. +/// Room for several of the largest drags (`steps` 1000 = 1003 events). Adapted from upstream #1736. +pub const MAX_PENDING_EVENTS: usize = 4096; + +/// How many synthetic events `method` with `p` queues, and whether it is a lone release (a +/// pointer `up`, a key `up`). Invalid arguments count 0: the method's own branch refuses them. +fn queued_events(method: &str, p: &Value) -> (usize, bool) { + let n = |key: &str, default: u64, range: (u64, u64)| usize::try_from(bounded_arg(p, key, default, range).unwrap_or(0)).unwrap_or(usize::MAX); + match method { + "ui.move" | "ui.hoverWidget" | "ui.text" | "ui.scroll" | "ui.zoom" | "ui.clipboard" => (1, false), + "ui.clickWidget" | "ui.click" => (n("count", 1, CLICK_COUNT).saturating_mul(2).saturating_add(1), false), + "ui.dragWidget" | "ui.drag" => (n("steps", 10, DRAG_STEPS).saturating_add(3), false), + "ui.pointer" => { + let events = p.get("events").and_then(Value::as_array).map(Vec::as_slice).unwrap_or_default(); + let kind = |e: &Value| e.get("kind").and_then(Value::as_str).unwrap_or("move").to_string(); + let total = events.iter().fold(0usize, |t, e| t.saturating_add(if kind(e) == "down" { 2 } else { 1 })); + (total, events.len() == 1 && events.iter().all(|e| kind(e) == "up")) + } + "ui.key" => match p.get("action").and_then(Value::as_str).unwrap_or("press") { + "press" => (2, false), + "up" => (1, true), + _ => (1, false), + }, + _ => (0, false), + } +} + +/// Refuses a request whose events would take the queue past [`MAX_PENDING_EVENTS`]. A lone +/// release may go one past it, so a held button or key is never left stuck down by a full queue. +fn event_budget(pending: usize, method: &str, p: &Value) -> Result<(), String> { + let (additional, release) = queued_events(method, p); + let cap = if release { MAX_PENDING_EVENTS.saturating_add(1) } else { MAX_PENDING_EVENTS }; + if additional == 0 || pending.saturating_add(additional) <= cap { + Ok(()) + } else { + Err(format!( + "{method}: {pending} synthetic events still pending, {additional} more would pass the limit of {MAX_PENDING_EVENTS}; wait for the app to catch up" + )) + } +} + pub fn handle(app: &mut LccApp, ctx: &egui::Context, req: &ControlRequest) -> Outcome { if let Some(o) = crate::surface::handle(app, req) { return o; @@ -312,6 +355,9 @@ pub fn handle(app: &mut LccApp, ctx: &egui::Context, req: &ControlRequest) -> Ou { return err(e); } + if let Err(e) = event_budget(app.synthetic.len(), &req.method, p) { + return err(e); + } let s = |k: &str| p.get(k).and_then(Value::as_str); let f = |k: &str| p.get(k).and_then(Value::as_f64); match req.method.as_str() { @@ -964,6 +1010,37 @@ mod hostile_gesture_tests { app } + /// Adapted from upstream #1736: requests sent faster than frames drain them can't grow the + /// queue past `MAX_PENDING_EVENTS`; a lone release still gets through, once. + #[test] + fn the_synthetic_queue_is_bounded_but_a_release_gets_through() { + let mut app = app(); + app.synthetic = vec![egui::Event::PointerMoved(egui::pos2(1.0, 1.0)); MAX_PENDING_EVENTS - 1]; + for (method, params) in [ + ("ui.click", json!({"x": 1, "y": 1})), + ("ui.drag", json!({"x": 1, "y": 1, "toX": 5, "toY": 5, "steps": 1000})), + ("ui.pointer", json!({"events": [{"kind": "down"}]})), + ("ui.key", json!({"key": "A"})), + ] { + let r = reply(&mut app, method, params); + assert_eq!(r["ok"], false, "{method}: {r}"); + assert_eq!(app.synthetic.len(), MAX_PENDING_EVENTS - 1, "{method} queued past the limit"); + } + let r = reply(&mut app, "ui.scroll", json!({"dy": 1})); + assert_eq!(r["ok"], true, "{r}"); + assert_eq!(app.synthetic.len(), MAX_PENDING_EVENTS); + assert_eq!(reply(&mut app, "ui.move", json!({"x": 1, "y": 1}))["ok"], false); + let up = json!({"events": [{"kind": "up"}]}); + assert_eq!(reply(&mut app, "ui.pointer", up.clone())["ok"], true, "a lone release goes one past the limit"); + assert_eq!(app.synthetic.len(), MAX_PENDING_EVENTS + 1); + assert_eq!(reply(&mut app, "ui.pointer", up)["ok"], false, "but only one"); + assert_eq!(reply(&mut app, "ui.key", json!({"key": "A", "action": "up"}))["ok"], false); + assert_eq!(app.synthetic.len(), MAX_PENDING_EVENTS + 1); + // once the frames drain the queue, requests are taken again + app.synthetic.clear(); + assert_eq!(reply(&mut app, "ui.drag", json!({"x": 1, "y": 1, "toX": 5, "toY": 5, "steps": 1000}))["ok"], true); + } + #[test] fn invalid_pointer_events_reject_the_whole_batch() { let mut app = app(); diff --git a/crates/ui-egui/src/headless.rs b/crates/ui-egui/src/headless.rs index c83223f83a..4e962d7a2d 100644 --- a/crates/ui-egui/src/headless.rs +++ b/crates/ui-egui/src/headless.rs @@ -4625,7 +4625,9 @@ mod tests { let (g, n) = (gate.clone(), started.clone()); h.app.session.media.file_probe = Some(std::sync::Arc::new(move |_: &str| { n.fetch_add(1, std::sync::atomic::Ordering::Relaxed); - while !g.load(std::sync::atomic::Ordering::Relaxed) { + // bounded, so a test that fails before opening the gate doesn't leave the scan spinning + let end = std::time::Instant::now() + std::time::Duration::from_secs(60); + while !g.load(std::sync::atomic::Ordering::Relaxed) && std::time::Instant::now() < end { std::thread::sleep(Duration::from_millis(5)); } Ok(lcc_engine::media::ProbeInfo { format: "PNG".into(), ..Default::default() }) @@ -4751,7 +4753,9 @@ mod tests { let gate = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)); let g = gate.clone(); h.app.session.media.file_probe = Some(std::sync::Arc::new(move |_: &str| { - while !g.load(std::sync::atomic::Ordering::Relaxed) { + // bounded, so a test that fails before opening the gate doesn't leave the scan spinning + let end = std::time::Instant::now() + std::time::Duration::from_secs(60); + while !g.load(std::sync::atomic::Ordering::Relaxed) && std::time::Instant::now() < end { std::thread::sleep(Duration::from_millis(5)); } Ok(lcc_engine::media::ProbeInfo { format: "PNG".into(), ..Default::default() }) diff --git a/crates/ui-egui/src/import.rs b/crates/ui-egui/src/import.rs index c442326b18..5c69cc89cb 100644 --- a/crates/ui-egui/src/import.rs +++ b/crates/ui-egui/src/import.rs @@ -755,7 +755,7 @@ pub fn browse(app: &mut LccApp, path: &str, subfolders: Option, show: Opti if app.scan.as_ref().is_some_and(|t| !t.browse) || app.import.as_ref().is_some_and(|t| !t.browse) { return Err("an import is running".into()); } - let dir_s = dir.to_string_lossy().trim_end_matches(['/', '\\']).to_string(); + let dir_s = lcc_engine::import::browse_folder_string(&dir); // subfolders: given, it wins; left out, a re-browse of the same folder keeps the choice and a // new folder starts with subfolders in — a folder picked to import means the tree under it // (the engine's library.browse applies the same rule) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 7423b76b26..1073e237ce 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -569,6 +569,8 @@ pub type PngEncode = Box Vec>; pub type PickFolder = Box Option>; /// Reveal a file in the system file manager (Finder / Explorer / the folder on Linux). pub type RevealFn = Box Result<(), String>>; +/// Shows several files at once in the system file manager, selected in one window. +pub type RevealManyFn = Box Result<(), String>>; /// Open a URL in the user's browser. /// Starts listing (or copying) the device's camera roll; the channel answers with the photos' /// paths, or why there are none (permission denied, …). `Err` when it could not start (Android). @@ -729,6 +731,9 @@ pub struct Services { pub png: Option, /// Show a file in the system file manager (desktop only). pub reveal: Option, + /// Show several files selected in one file-manager window (Linux `FileManager1.ShowItems`); + /// None where the host reveals only one (macOS `open -R`, Windows `explorer /select`). + pub reveal_many: Option, /// The host's current log file (`/logs/.log`), which Help ▸ Open Log /// Folder reveals (#260). None where no log is kept: the web, `--memory`, `_NO_PREFS`. pub log_file: Option, diff --git a/crates/ui-egui/src/menubar.rs b/crates/ui-egui/src/menubar.rs index af27e257db..1f2f5cd4aa 100644 --- a/crates/ui-egui/src/menubar.rs +++ b/crates/ui-egui/src/menubar.rs @@ -130,6 +130,9 @@ pub fn native_menu_structure(bar: &[(String, Vec)], keymap: &crate::sh s } +/// Hover text of Help ▸ Check for Updates… when `_DISABLE_UPDATES` turned it off. +const UPDATES_DISABLED_HINT: &str = "Updates are turned off ({env}_DISABLE_UPDATES is set); your package manager handles updates."; + /// The Library module's menus in order (the macOS app menu is added by the host); [`menus`] gives /// the module on screen's. pub const MENUS: &[&str] = &["File", "Edit", "Library", "Photo", "Metadata", "View", "Window", "Help"]; @@ -1605,6 +1608,10 @@ pub(crate) fn nodes_ui( if crate::lrc_menus::is_coming_soon(id) { r = r.on_disabled_hover_text(crate::i18n::tr(crate::lrc_menus::COMING_SOON_HINT)); } + // Check for Updates turned off by the environment says why (upstream #4663) + if id == "app.checkForUpdates" && crate::menus::updates_disabled_by_env() { + r = r.on_disabled_hover_text(crate::i18n::tr(UPDATES_DISABLED_HINT)); + } crate::widgets::register(ui.ctx(), format!("menuitem:{id}"), r.rect); if *checked == Some(true) { let t = crate::theme::Tokens::get(ui.ctx()); @@ -2222,6 +2229,50 @@ mod tests { assert_eq!(run_item(&mut app, "app.openLogFolder", Value::Null).unwrap_err(), "no file manager"); } + /// Upstream #4653: Show in Finder reveals the whole selection where the host selects several + /// files at once (`reveal_many`), and the active photo where it reveals one. + #[test] + fn show_in_finder_reveals_the_selection() { + let dir = lcc_testkit::TempDir::new("lc-ui-reveal"); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + let o = lcc_engine::export::ExportOptions { format: lcc_engine::export::ExportFormat::Png, ..Default::default() }; + for (name, base) in [("one.png", 0usize), ("two.png", 40)] { + let img = lcc_raster::Rgba8::from_fn(16, 12, |x, y| [(x * 7 + base) as u8, (y * 11) as u8, 50, 255]); + std::fs::write(dir.join(name), lcc_engine::export::encode_image(&img, &o).unwrap()).unwrap(); + } + let mut photos = LccApp::new(lcc_engine::Session::new().with_fs(), Default::default()); + photos.session.execute("library.import", &json!({"paths": [dir.to_string_lossy()]})).unwrap(); + let ids: Vec = photos.session.catalog.photos().map(|p| p.id.0).collect(); + assert_eq!(ids.len(), 2); + photos.session.execute("library.select", &json!({"ids": ids})).unwrap(); + // a demo scene has no file to reveal + let mut demo = app(); + assert!(run_item(&mut demo, "app.showInFinder", Value::Null).is_err()); + assert!(!crate::menus::ui_enabled(&demo, "app.showInFinder")); + // several files at once where the host supports it + let shown = std::sync::Arc::new(std::sync::Mutex::new(Vec::::new())); + let captured = shown.clone(); + photos.services.reveal_many = Some(Box::new(move |paths: &[String]| { + captured.lock().unwrap().extend(paths.iter().cloned()); + Ok(()) + })); + assert!(crate::menus::ui_enabled(&photos, "app.showInFinder")); + let r = run_item(&mut photos, "app.showInFinder", Value::Null).unwrap(); + assert_eq!(shown.lock().unwrap().len(), 2, "{r}"); + assert_eq!(r["paths"].as_array().map(Vec::len), Some(2)); + // without it, one photo is revealed, as before + let single = std::sync::Arc::new(std::sync::Mutex::new(Vec::::new())); + let one = single.clone(); + photos.services.reveal_many = None; + photos.services.reveal = Some(Box::new(move |p: &str| { + one.lock().unwrap().push(p.to_string()); + Ok(()) + })); + run_item(&mut photos, "app.showInFinder", Value::Null).unwrap(); + assert_eq!(single.lock().unwrap().len(), 1); + } + #[test] fn find_missing_and_locate() { let dir = lcc_testkit::TempDir::new("lc-ui-missing"); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index de28c120ac..fb0f3ce97d 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -15,6 +15,7 @@ pub type UiCommand = (&'static str, &'static str, Option<&'static str>, &'static /// The fork's UI commands and their dispatch (fork-owned). #[path = "menus_fork.rs"] mod fork; +pub(crate) use fork::updates_disabled_by_env; /// The "Edit → Language" entries, one per language in [`crate::i18n::Locale::ALL`], so a language /// has a matching menu command (also listed through the control channel). Tests check coverage. @@ -1962,7 +1963,7 @@ pub fn run_ui_command(app: &mut LccApp, id: &str, p: &Value) -> Option { // a folder kept in Local's sidebar (saved with the UI state); nothing on disk changes let Some(path) = p.get("path").and_then(Value::as_str) else { return Some(Err("local.addRoot needs a path".into())) }; - let abs = std::path::absolute(path).map(|a| a.to_string_lossy().trim_end_matches(['/', '\\']).to_string()).unwrap_or(path.into()); + let abs = std::path::absolute(path).map(|a| lcc_engine::import::browse_folder_string(&a)).unwrap_or(path.into()); let abs = if abs.is_empty() { path.to_string() } else { abs }; if !std::path::Path::new(&abs).is_dir() { return Some(Err(format!("{path}: not a folder"))); @@ -3731,7 +3732,7 @@ pub fn run_ui_command(app: &mut LccApp, id: &str, p: &Value) -> Option crate::control::export_active(app, p), "photo.renderToDng" => return crate::render_dng_task::start(app, p), "photo.updateDngPreview" => return crate::dng_update_task::start(app, p), - "app.showInFinder" => show_in_finder(app), + "app.showInFinder" => show_in_finder(app, p), "app.showInFolders" => show_in_folders(app, p.get("id").and_then(Value::as_u64).map(lcc_catalog::PhotoId)), "app.openLogFolder" => open_log_folder(app), "app.website" | "app.github" | "app.help" | "app.feedback" | "app.discord" => { @@ -3820,12 +3821,12 @@ pub fn ui_enabled(app: &LccApp, id: &str) -> bool { }) } "app.showInFinder" => { - app.services.reveal.is_some() + (app.services.reveal.is_some() || app.services.reveal_many.is_some()) && app .session - .active() - .and_then(|id| app.session.catalog.photo(id)) - .is_some_and(|p| matches!(p.source, lcc_engine::catalog::Source::File { .. })) + .selected() + .iter() + .any(|id| app.session.catalog.photo(*id).is_some_and(|p| matches!(p.source, lcc_engine::catalog::Source::File { .. }))) } "app.showInFolders" => show_in_folders_enabled(app, None), "app.openSamModelFolder" => app.session.segmenter.dir.is_some() && app.services.open_with.is_some(), @@ -4008,13 +4009,33 @@ fn open_log_folder(app: &mut LccApp) -> Result { Ok(json!({"path": path})) } -/// Reveal the active photo's original in the system file manager. -fn show_in_finder(app: &mut LccApp) -> Result { - let id = app.session.active().ok_or("no photo selected")?; - let path = match app.session.catalog.photo(id).map(|p| p.source.clone()) { - Some(lcc_engine::catalog::Source::File { path }) => path, - _ => return Err("this photo has no file (demo scene)".into()), +/// Reveal the selected photos' originals (`ids`/`id`, or the selection) in the system file +/// manager. Where the host selects several files in one window (`reveal_many`, Linux) every file +/// is shown; otherwise the active photo, or the first with a file (adapted from upstream #4653). +fn show_in_finder(app: &mut LccApp, p: &Value) -> Result { + let ids = app.session.targets(p).map_err(|e| e.to_string())?; + if ids.is_empty() { + return Err("no photo selected".into()); + } + let file_of = |app: &LccApp, id: lcc_catalog::PhotoId| match app.session.catalog.photo(id).map(|photo| &photo.source) { + Some(lcc_engine::catalog::Source::File { path }) => Some(path.clone()), + _ => None, }; + let paths: Vec = ids.iter().filter_map(|id| file_of(app, *id)).collect(); + if paths.is_empty() { + return Err("this photo has no file (demo scene)".into()); + } + if let Some(reveal_many) = app.services.reveal_many.as_mut() { + reveal_many(&paths)?; + return Ok(json!({"path": paths.first(), "paths": paths})); + } + let path = app + .session + .active() + .and_then(|id| file_of(app, id)) + .filter(|active| paths.contains(active)) + .or_else(|| paths.into_iter().next()) + .ok_or("no photo selected")?; let reveal = app.services.reveal.as_mut().ok_or("not available here")?; reveal(&path)?; Ok(json!({"path": path})) diff --git a/crates/ui-egui/src/menus_fork.rs b/crates/ui-egui/src/menus_fork.rs index 88e8d139b2..e3cf1f4666 100644 --- a/crates/ui-egui/src/menus_fork.rs +++ b/crates/ui-egui/src/menus_fork.rs @@ -332,11 +332,27 @@ pub(super) fn run(app: &mut LccApp, id: &str, p: &Value) -> Option_DISABLE_UPDATES` turned the updater off; the web build has no updater, so never. +pub(crate) fn updates_disabled_by_env() -> bool { + #[cfg(not(target_arch = "wasm32"))] + { + lcc_engine::update::disabled_by_env() + } + #[cfg(target_arch = "wasm32")] + { + false + } +} + /// Enabled state of the fork's modules' commands. pub(super) fn enabled(app: &LccApp, id: &str) -> Option { if crate::lrc_menus::is_coming_soon(id) { return Some(false); } + // a distro package turned updates off (`_DISABLE_UPDATES`, upstream #4663) + if id == "app.checkForUpdates" && updates_disabled_by_env() { + return Some(false); + } crate::module::enabled(app, id) .or_else(|| crate::catalog_ui::enabled(app, id)) .or_else(|| crate::timelapse_ui::enabled(app, id)) diff --git a/crates/ui-egui/src/panels/detail.rs b/crates/ui-egui/src/panels/detail.rs index f30138fec1..8dbf8d75a7 100644 --- a/crates/ui-egui/src/panels/detail.rs +++ b/crates/ui-egui/src/panels/detail.rs @@ -4977,7 +4977,7 @@ fn mask_overlay(app: &mut LccApp, ui: &mut egui::Ui, resp: &egui::Response, map: app.ui.tool.clear(); } if resp.drag_started() && d.masks.iter().find(|m| m.id == mid).and_then(|m| m.components.get(ci)).is_some() { - let _ = app.run("develop.beginInteraction", json!({"label": "Edit Mask"})); + let _ = app.run("develop.beginInteraction", json!({"label": crate::region::SHARP_DRAG})); if let Some(original_shape) = current_shape(app, mid, ci) .or_else(|| d.masks.iter().find(|m| m.id == mid).and_then(|m| m.components.get(ci)).map(|c| c.shape.clone())) { @@ -5162,7 +5162,7 @@ fn mask_overlay(app: &mut LccApp, ui: &mut egui::Ui, resp: &egui::Response, map: let _ = app.run("mask.select", json!({"id": mask})); } app.ui.active_mask_component = Some(comp); - let _ = app.run("develop.beginInteraction", json!({"label": "Edit Mask"})); + let _ = app.run("develop.beginInteraction", json!({"label": crate::region::SHARP_DRAG})); // (read after it begins: an old mask is on the photo from then on, in its coordinates) if let Some(original_shape) = current_shape(app, mask, comp) .or_else(|| d.masks.iter().find(|m| m.id == mask).and_then(|m| m.components.get(comp)).map(|c| c.shape.clone())) @@ -5421,7 +5421,7 @@ fn mask_keys(app: &mut LccApp, ui: &mut egui::Ui, map: &CanvasMap, d: &DevelopSe if app.session.active_mask != Some(mid) { let _ = app.run("mask.select", json!({"id": mid})); } - let _ = app.run("develop.beginInteraction", json!({"label": "Edit Mask"})); + let _ = app.run("develop.beginInteraction", json!({"label": crate::region::SHARP_DRAG})); // (read after it begins: an old mask is on the photo from then on, in its coordinates) let (shape, map) = match (current_shape(app, mid, ci), current_on_photo(app, mid)) { (Some(s), Some(on)) => (s, map.for_mask(on)), diff --git a/crates/ui-egui/src/panels/dialogs.rs b/crates/ui-egui/src/panels/dialogs.rs index f8ab02db8f..6c36fcc2f4 100644 --- a/crates/ui-egui/src/panels/dialogs.rs +++ b/crates/ui-egui/src/panels/dialogs.rs @@ -1383,7 +1383,8 @@ pub fn show(app: &mut LccApp, ctx: &egui::Context) { let n = app.session.selected().len(); ui.label(crate::i18n::tr_format!("{n} selected photos · {pages} pages", n = n, pages = n.div_ceil(options.columns * options.rows))); field(ui, "Paper", |ui| { - crate::widgets::combo_box("contactSheetPaper").selected_text(&options.paper).show_ui(ui, |ui| { + let shown = if options.paper == "letter" { crate::i18n::tr("Letter") } else { "A4" }; + crate::widgets::combo_box("contactSheetPaper").selected_text(shown).show_ui(ui, |ui| { ui.selectable_value(&mut options.paper, "a4".into(), "A4"); ui.selectable_value(&mut options.paper, "letter".into(), crate::i18n::tr("Letter")); }); diff --git a/crates/ui-egui/src/region.rs b/crates/ui-egui/src/region.rs index 1d25618e49..49744953b2 100644 --- a/crates/ui-egui/src/region.rs +++ b/crates/ui-egui/src/region.rs @@ -100,6 +100,12 @@ pub struct LoupePlan { /// it, or full-size drafts of this drag went over [`DRAFT_BUDGET_MS`]), against the render at rest. pub const CPU_DRAFT_SCALE: f32 = 0.6; +/// The interaction label of a mask edit on the photo (moving, resizing or turning a gradient or +/// pin). Its drafts are always full size, on the CPU too, and never drop to [`CPU_DRAFT_SCALE`]: +/// the edit changes part of the photo, and a smaller draft blurred the whole photo for it +/// (adapted from upstream #4444). A slow machine shows fewer drafts instead. +pub const SHARP_DRAG: &str = "Edit Mask"; + /// The slider budget (ms): a drag whose full-size drafts take longer gets smaller drafts next time. /// A draft's time is its render plus the frame that shows it (the texture upload is part of it). pub const DRAFT_BUDGET_MS: f64 = 16.0; @@ -187,7 +193,7 @@ impl DragScale { } let key = (photo, control.to_string()); let small = matches!(self.verdict(&key), Some(Verdict::Slow { until, .. }) if now < until); - let s = if gpu && !small { 1.0 } else { CPU_DRAFT_SCALE }; + let s = if control == SHARP_DRAG || (gpu && !small) { 1.0 } else { CPU_DRAFT_SCALE }; self.current = Some((key, s)); self.seen = shown; Some(s) @@ -211,7 +217,8 @@ impl DragScale { } if self.samples.len() > GIVE_UP_AFTER && median_after_first(&self.samples).is_some_and(|m| m > DRAFT_BUDGET_MS * GIVE_UP_FACTOR) - && let Some((_, s)) = self.current.as_mut() + && let Some(((_, control), s)) = self.current.as_mut() + && control != SHARP_DRAG { *s = CPU_DRAFT_SCALE; return; @@ -1102,6 +1109,28 @@ mod tests { assert_eq!(d.scale(drag, false, None, 0.0), Some(1.0)); } + // Given a mask edit on the photo (a gradient's handle or pin dragged), its drafts are full size + // even on the CPU, after slow drags, and when they are far over budget: the photo stays sharp + // (upstream #4444) + #[test] + fn a_mask_edit_always_drafts_at_full_size() { + use lcc_catalog::PhotoId; + let mut d = DragScale::default(); + let mask = Some((PhotoId(1), SHARP_DRAG)); + assert_eq!(d.scale(mask, false, None, 0.0), Some(1.0), "on the CPU too"); + d.scale(None, false, None, 0.0); + for i in 0..3 { + assert_eq!(timed_drag(&mut d, mask, 400.0, f64::from(i)), Some(1.0), "drag {i}: slow drags don't shrink the next"); + } + assert_eq!(d.scale(mask, true, None, 10.0), Some(1.0)); + for key in 100..110 { + d.observe(key, 400.0, None); + } + assert_eq!(d.scale(mask, true, None, 10.0), Some(1.0)); + d.scale(None, true, None, 10.0); + assert_eq!(d.scale(Some((PhotoId(1), "Exposure")), false, None, 10.0), Some(CPU_DRAFT_SCALE)); + } + /// One whole drag of `drag` at full size whose drafts all take `ms` to show, ending at `now`. fn timed_drag(d: &mut DragScale, drag: Option<(lcc_catalog::PhotoId, &str)>, ms: f64, now: f64) -> Option { let scale = d.scale(drag, true, None, now); diff --git a/crates/ui-egui/src/tests_print.rs b/crates/ui-egui/src/tests_print.rs index 4c8ac6ae80..5a2a761a41 100644 --- a/crates/ui-egui/src/tests_print.rs +++ b/crates/ui-egui/src/tests_print.rs @@ -569,3 +569,18 @@ fn print_module_follows_the_filmstrip_selection() { cmd(&mut h, "library.select", json!({"ids": []})); assert!(crate::print_ui::job_photos(&mut h.app, false).len() >= ids.len()); } + +// upstream #4484: the contact sheet's Paper box shows the label (A4 / Letter), not the stored id +#[test] +fn contact_sheet_paper_box_shows_the_label() { + let mut h = demo(Services::default()); + h.app.ui.language = crate::i18n::Locale::En; + for (paper, label) in [("a4", "A4"), ("letter", "Letter")] { + let options = lcc_engine::contact_sheet::Options { paper: paper.into(), ..Default::default() }; + h.app.ui.dialog = Some(Dialog::ContactSheet { options }); + h.settle(T); + let text = h.painted_text(); + assert!(text.iter().any(|t| t == label), "{paper} not shown as {label}"); + assert!(!text.iter().any(|t| t == paper), "{paper} shown raw"); + } +} diff --git a/crates/ui-egui/src/tests_sync.rs b/crates/ui-egui/src/tests_sync.rs index 8182616388..4236dde8dc 100644 --- a/crates/ui-egui/src/tests_sync.rs +++ b/crates/ui-egui/src/tests_sync.rs @@ -492,7 +492,9 @@ fn the_folders_scan_shows_a_row_and_its_cross_closes_the_dialog() { let gate = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)); let g = gate.clone(); h.app.session.media.file_probe = Some(std::sync::Arc::new(move |_: &str| { - while !g.load(std::sync::atomic::Ordering::Relaxed) { + // bounded, so a test that fails before opening the gate doesn't leave the scan spinning + let end = std::time::Instant::now() + std::time::Duration::from_secs(60); + while !g.load(std::sync::atomic::Ordering::Relaxed) && std::time::Instant::now() < end { std::thread::sleep(Duration::from_millis(5)); } Ok(lcc_engine::media::ProbeInfo { format: "PNG".into(), ..Default::default() }) diff --git a/docs/changelog/unreleased/2026-11-29-macos-open-from-finder.md b/docs/changelog/unreleased/2026-11-29-macos-open-from-finder.md new file mode 100644 index 0000000000..3f030dcc30 --- /dev/null +++ b/docs/changelog/unreleased/2026-11-29-macos-open-from-finder.md @@ -0,0 +1,3 @@ +## Library + +- macOS: photos opened from Finder (Open With, the Dock icon) or another app are imported; before, macOS said the app could not open them. diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 08dc8eb070..d3c80222eb 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -120,7 +120,7 @@ filmstrip is visible. | `ui.inspect` | — | UI state, window, `loupe` (`source`, `pending`, `failed` = why its render failed, else `null`, and `region: {full, window, pending}` when a zoomed view also renders the window on screen at no more than 100 % — `full` is the frame it is cut from, `window` its `[x, y, w, h]` — and `regionBefore` for the Before side of a Before/After view), canvas/image rects, `scroll: {grid, filmstrip}` (scroll offsets in points, `null` until drawn), active photo, selection, perf (`frameMs` = layout, `logicMs` = per-frame logic before it, `updateMs` = both, `maxUpdateMs`, `frameGaps: {hostFrameMs, gapMs, maxGapMs, maxGapHostMs}` = wall time between frames while the window had work to show (renders on their way, input), the longest since start and the host's frame time before it — a long gap with a short host frame waited outside the UI thread, e.g. presenting behind GPU work, `fps`, render queue …, `gpu` = adapter in use, `gpuReason` = why renders don't use the GPU, `gpuFallback` = latest render redone on the CPU and why, `gpuWindowDevice` / `screenTextures` / `mainOnGpu` = renders run on the window's device / can be drawn from the GPU / the loupe shows one now — see `docs/gpu-pipeline.md`, `adjustQuality` = what a slider drag renders with high quality adjustment previews on: `idle` (no drag, or the setting is off), `full`, `draft` (too slow at full quality and the slider is moving) or `settled` (too slow, but the slider holds still) — see `docs/high-quality-adjustment-previews.md`; `loupeSteps` = how the loupe showed each photo it was stepped to, measured on the frames it drew: `{steps: [{photo, anyMs, anySource, fullMs, fullSource, sharpMs, dwellMs}], current}` — ms from the step to the first frame with anything of the photo, with a full-size picture (`embedded` camera JPEG, `last` / `draft` / `cached` or `render`), and with the app's own render; `dwellMs` is how long it stayed, the latest 256 steps), status, memory (bytes per cache, see `library.memory`; plus stage caches — `budgetBytes`, `trimmed`, `sharedSourceBytes` (the one device copy of a big original) — and textures), `export: {running: {total, done, current} \| null, last}`, `notices` (warnings waiting to be shown, e.g. a damaged settings file; OK = `button:noticeOk`), `quitPrompt` (why quitting was stopped: tasks that would be cut short are running — `button:quitAnyway` cancels them and quits, `button:quitCancel` keeps working — or unsaved changes: `button:quitRetry` / `button:quitAnyway` / `button:quitCancel`), `import: {done, total, imported, cancelled} \| null` (an import runs on a worker thread), `tasks` (other background work: `Find Missing Photos`, `Auto Import`), `activity` (every long-running task in flight as the activity stack shows it, same shape as `activity.list`; a task shows once it is 0.5 s old. Classic: in the module bar in the identity plate's place, `activity:plate`, with ✕ = `activity:cancel:` for a single task and thin bars `activity:bar:` for several; a click there or `view.activityList` opens the list `activity:list` with rows `activity:row:` and their ✕. Modern: a floating card of rows `activity:row:`, `activity:more` expands past 3. Compact: as Classic; see `docs/background-tasks.md`), `activityList` (Classic and Compact: the list of tasks is open), `fileDialogs` (commands waiting on a native file dialog, which runs off the UI thread; they run again with the answer when it closes), `copied` (the text the UI last put on the clipboard, `null` until something is copied), `toasts` (the messages at the bottom centre still showing, oldest first: `{text, kind, secsLeft}`; `kind` is `message`, `error`, `action` or `sticky`; a sticky one has a `key` and no `secsLeft`), `toastAction` (the message with a button: `{text, button, command, secsLeft}`, else `null`), `osd` (the on-screen overlay pill, as `osd.state` returns it: `settings`, `shown` = `{title, value, caption, icon, ageS}` or `null`, `held`)) | | `ui.widgets` | `{filter?}` | On-screen widgets `{id, rect: [x, y, w, h]}` (screen points) | | `ui.clickWidget` / `ui.dragWidget` / `ui.hoverWidget` | `{id, count?, button?, fx?, fy?}` (`button: "right"` right-clicks) / `{id, toX?, toY?, dx?, dy?, steps?}` / `{id, fx?, fy?}` | Real egui input on a widget (hover: the pointer rests on it, e.g. for preset/profile previews) | -| `ui.move` / `ui.click` / `ui.drag` | `{x, y, count?, button?}` / `{x, y, toX, toY, steps?}` | Raw pointer input, screen points. In every pointer and scroll gesture (also `ui.clickWidget`, `ui.dragWidget`, `ui.hoverWidget`, `ui.pointer`, `ui.scroll`) a number other than `count` and `steps` must lie between −1,000,000 and 1,000,000, or the request is refused and queues nothing | +| `ui.move` / `ui.click` / `ui.drag` | `{x, y, count?, button?}` / `{x, y, toX, toY, steps?}` | Raw pointer input, screen points. In every pointer and scroll gesture (also `ui.clickWidget`, `ui.dragWidget`, `ui.hoverWidget`, `ui.pointer`, `ui.scroll`) a number other than `count` and `steps` must lie between −1,000,000 and 1,000,000, or the request is refused and queues nothing. At most 4096 synthetic events (pointer, key, text, scroll, zoom) wait for the frames that take them; a request that would queue past that is refused (wait and retry), except one lone release (`ui.pointer` `up`, `ui.key` `up`) so a held button or key is never left down | | `ui.pointer` | `{events: [{kind: down\|drag\|up, x, y}], alt?, shift?, cmd?}` | Gesture in normalized image coordinates (Detail view) | | `ui.key` | `{key, action?: press\|down\|repeat\|up, cmd?, shift?, alt?, ctrl?}` | Key press (default), or the key going `down` and staying held until an `up` (Space held over a `ui.pointer` drag); `repeat` is an auto-repeat while held (Space's are ignored: it is a modifier) | | `ui.text` | `{text}` | Text input | @@ -136,7 +136,7 @@ filmstrip is visible. | `ui.dropFiles` | `{paths: [..], hover?}` | Files dragged from the file manager. `hover: true` makes every following frame report `paths` as hovered over the window (the drop card appears, `ui.widgets` lists `dropOverlay`) until another `ui.dropFiles` replaces them; `{paths: [], hover: true}` ends the hover. Without `hover` the files are dropped: the hover ends and the next frame receives them as dropped files, exactly as an OS drop arrives (photos and folders open the import review, or import at once with Settings ▸ Import ▸ Import dropped files without review). An empty path stands for a file whose path the platform doesn't tell | | `ui.zoomFactor` | `{factor}` | Set the interface scale (0.5–3; egui's zoom keys are off, Cmd+= / Cmd+- zoom the photo) | | `ui.screenshot` | `{path?, headless?}` | `{path, width, height}` once the frame (with finished renders) is captured. `headless: true` draws the UI on the CPU (no compositor needed); a windowed capture that gets no frame within 2 s falls back to headless automatically. While the loupe still waits for a render, `ui.widgets {filter: "loupe:rendering"}` lists its "Rendering…" pill; `loupe:renderFailed` is the pill saying a render failed behind a stand-in; Compare and Reference panes have their own (`compare:rendering:`, `compare:renderFailed:`) | -| `engine.execute {command: "app.export", params}` | export params (see `docs/mcp.md`), plus `preset`, `dir` / `path`, `ids`, `background`; `destinationMode: "sameAsOriginal"` writes each photo into its original's folder (+ `subfolder`) instead of `dir`; `destinationMode: "chooseLater"` without `dir` opens the folder dialog and exports once a folder is chosen (nothing when it is cancelled; an error where there is no folder dialog) | Writes the files and returns `{files}` (one `{path, width, height, bytes, sidecars}` per file, plus `gpuFallback` — why that render fell back from the GPU to the CPU — when it did; see `docs/gpu-pipeline.md` — and `quality`, the JPEG quality a `limitKb` file-size limit settled on, when a limit was set); with `background: true` (what the Export dialog and menus use) it returns `{background: true, total}` at once and the batch runs on a worker thread — poll `ui.inspect` → `export` | +| `engine.execute {command: "app.export", params}` | export params (see `docs/mcp.md`), plus `preset`, `dir` / `path`, `ids`, `background`; `destinationMode: "sameAsOriginal"` writes each photo into its original's folder (+ `subfolder`) instead of `dir`; `destinationMode: "chooseLater"` without `dir` opens the folder dialog and exports once a folder is chosen (nothing when it is cancelled; an error where there is no folder dialog) | Writes the files and returns `{files}` (one `{path, width, height, bytes, sidecars}` per file, plus `gpuFallback` — why that render fell back from the GPU to the CPU — when it did; see `docs/gpu-pipeline.md` — and `quality`, the JPEG quality a `limitKb` file-size limit settled on, when a limit was set). A headless batch continues after a failed photo and lists it as `{photo, file, error}` in `files`; a failed single-photo export is an error. With `background: true` (what the Export dialog and menus use) it returns `{background: true, total}` at once and the batch runs on a worker thread — poll `ui.inspect` → `export` | | `engine.execute {command: "activity.list"}` | — | The long-running tasks in flight (imports, exports, preview builds, downloads, the face scan…), oldest first: `{tasks: [{id, kind, label, done, total, unit, detail, cancellable, cancelling, ageMs}]}`; `total` 0 = not known yet; `unit` is `count`, `bytes` or `percent`; `label` is English (the app shows it translated) | | `engine.execute {command: "activity.cancel"}` | `{id}` or `{all: true}` | Asks the task (or every cancellable one) to stop at its next file or photo → `{cancelled: n}`; an unknown id (it may have just finished) or a task that can't be cancelled is an error | | `ui.render` | `{id?, size?, path?, inline?}` | Render a photo (PNG to `path`), `{width, height}`; `inline: true` without `path` puts the PNG in the reply as base64 `png` (for a client on another machine) | diff --git a/docs/denoise.md b/docs/denoise.md index 22880ccd32..75df74f97c 100644 --- a/docs/denoise.md +++ b/docs/denoise.md @@ -370,7 +370,18 @@ Native apps enable inference through their `denoise` feature. A build without it the web build report inference unavailable. Manifest/cache primitives still compile for WASM. Settings and models remain opt-in; nothing is downloaded on launch. -This implementation supports **Bayer RAW only**. X-Trans, Foveon, demosaiced DNG and -non-RAW images remain unsupported by this model contract. No measured quality parity -with Lightroom is claimed. Apple/Metal and wider hardware verification, model policy, +The model contract itself is **Bayer only**. A non-Bayer colour filter array — Fujifilm's +X-Trans, and any other pattern laid out in red, green and blue — reaches it through a +re-mosaic: the sensor is interpolated and read back as an RGGB mosaic of the same size +(`remosaic_rggb`, `crates/raw/src/demosaic`), so the picture keeps its resolution and every +step after the model is unchanged. It interpolates only the colour each site needs, without +the full RGB picture in between: on a 26 MP X-Trans frame it takes ~65 ms (a full demosaic +~80 ms) and holds three planes at once, the mosaic, its green and the RGGB copy, under its +own share of the working-memory gate. 39 % of the frame's sites already carry the colour +RGGB wants there and keep the sensor's own sample, and reading the result back as RGB comes +within 42 dB (PSNR) of demosaicing the X-Trans mosaic directly. The rest reach the model +already interpolated, so it sees noise that varies from site to site: this is an +approximation of an X-Trans sensor, not a model trained on one, and its quality is +unmeasured. Foveon, demosaiced DNG and non-RAW +images remain unsupported. No measured quality parity with Lightroom is claimed. Apple/Metal and wider hardware verification, model policy, a linear-RGB contract and a side-by-side fidelity suite remain future work. diff --git a/docs/gaps.md b/docs/gaps.md index 9ffda1d8a6..acfba239bb 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -2,7 +2,7 @@ - 2026-10-12: Print colour management (G15): printer ICC profile, Perceptual / Relative with black point compensation, Print Adjustment, 16-bit PDF output. -> **Last updated:** 2026-11-29 · **Change:** patch (gap 36 narrows: the file-name templates shared by Export, Rename Photos and import take every stored metadata field as a token — caption, headline, category, keywords, copyright, job title, location fields, camera serial, alt text, long description, caption writer, shutter, aperture, focal — #1584); patch (gap 41 narrows: a Lightroom import is committed and saved in parts, #1361); patch (gap 41 narrows: a large step is saved as many small log records, #1361); imported photos' metadata status compares their sidecars with the catalog, in step or a conflict, #1312); patch (gap 41 narrows: no row cap on Lightroom import tables, a memory budget from the computer instead, #1361); patch (gaps 13 and 41 narrow: cached-XMP records over 64 MiB and packets over 16 MiB are read without their camera-profile tables, #1311); patch (gap 39: ONNX Runtime on the GPU exists, #491; the aesthetic model is what is left); patch (gap 41 narrows: the recovery archive and the history settings budget follow the drive, the catalog and the memory, newest steps first, #1312); patch (feature-freeze parity pass: CF-PROCESS-RECIPES row restored, gap 43 cites the skin-uniformity row; no ranked gap closes); patch (#1360: scoped, cancellable face maintenance and confirmed reset; no ranked gap closes); patch (gap 42 narrows: OpenEXR scene-linear export, plan 7.5); minor (gap 11: Lens Blur renders from the depth model or the subject, focus picker and bokeh shapes, plan 7.1); patch (gap 16: plug-in publish services get the account, collection, photo metadata and remote comments, plan 7.14); patch (gap 43 narrows: skin-tone uniformity on Point Color, plan 7.9); patch (gap 43: Match Look, Capture One's Smart Adjustments, plan 7.6); minor (gap 18 narrows: lens corrections, Upright and Transform on video frames, poster frame picked, plan 7.11); patch (gap 43 narrows: process recipes, several export presets in one run with one decode per photo, plan 7.4); minor (gap 42 narrows: Tone Equalizer ported from darktable, plan 7.10); minor (gap 42 narrows: inpaint opposed and guided Laplacian highlight reconstruction, ported from darktable, plan 7.2); minor (adaptive presets, plan 7.8; no gap change: P2 rows without a gap entry; adaptive profiles left); patch (the Export screen previews the first photo as its file will be, with an SDR / HDR choice; minor (HDR export: gain map files for AVIF and JPEG XL with `hdrMode: gainMap`, LR-HDR-EXPORT; no ranked gap closes); patch (gap 37: OS folder notifications, single-instance hand-off, URL scheme on Windows and Linux, plan 5.9); patch (gap 43 narrows: speed-edit keys, hold a key and drag or scroll to move a Develop slider, plan 5.10); patch (gap 23: the brush by keyboard; Library and Develop core widgets checked in the AccessKit tree, plan 5.8); patch (gap 26: 100k wheel-scroll frame timed frame by frame, 3–5 ms median, within budget, plan 4.8); minor (gap 2 narrows: CRX partial subbands, multi-tile 0x200 and adaptive low-frequency gains decode, ported from LibRaw `crx.cpp`, synthetic tests only); patch (gap 1: LibRaw matrices for about 400 newer bodies; every body with a pinned sample has colour matrices; SIL ΔE cross-check; no chart shots yet); patch (gap 8: lensfun's database fetched on first run, picked lens written to XMP, plan 3.9); minor (gap 10: SRF and S200 EXR RAF decode, 47 Olympus / OM bodies verified: 645 verified, 89% on a verified body; target not met); minor (gap 19: the plug-in marketplace — search, install, update, remove and opt-in automatic updates from an index of each plug-in's newest release, vetted and community tiers); patch (gap 9: weekly model-reference job for SAM 2.1, BiRefNet, EoMT and MediaPipe); patch (gap 1: LibRaw matrices for six newer bodies that used the neutral matrix, #451; no chart shots yet); patch (gap 3: render-fidelity reference suite with ΔE2000 / SSIM tolerances and a synthetic ColorChecker check, plan 3.5); patch (gap 3: process V10 applies the Tone Curve in a wide working space, #1142); patch (gap 1: one ranked colour-source order, a Lightroom calibration that loses to the per-photo JPEG fit serves converted DNGs only, #1119; Adobe Standard DNGs without a tone curve get their BaselineExposure once more, #1174); minor (gaps 41–43: Lightroom migration limits left from #1311 / #1312, darktable raw-processing depth, Capture One workflow features); patch (gap 9: PRs run changed-crate tests; the nightly full run covers macOS and Windows, files an issue when red, and blocks releases); patch (gap 40 closed: `apps/android` denies `indexing_slicing`, clippy runs on it in the Android check); patch (never-crash tooling: pure-Rust fuzz targets with a nightly long run; no gap change); patch (gap 40: `apps/cli` and the chart-profile dialog converted); patch (tests only: loopback mock servers for generative fill errors, publish uploads while the server is down and misbehaving IPP printers; slideshow export in SIL; no gap changes); patch (gap 9: nightly corpus + fonts run with a skip gate, GPU equivalence on software adapters); patch (gap 37: folder polling notices new dated folders in a photo tree); minor (gap 38 closed: mixed metadata across a selection, `photo.sharedMeta`); patch (gap 9: timing probes and benchmarks are opt-in `probe` skips, not `#[ignore]`); patch (gap 9: engine import → export → re-import SIL scenario); minor (gap 40 added: checked indexing in the UI; unconverted modules carry a tracked allow); patch (gap 31: the sync merge rules are property-tested in the SIL run); patch (gap 13: required-table record losses always warned; remaining Lightroom size limits listed, #1311); patch (gap 13: the Lightroom import index is no longer capped at 16 MiB, #1312); patch (gap 13: one bad Lightroom record costs only itself; keyword assignments streamed, #1311); minor (gap 19: signed plug-ins find updates in their author's feed, checked when the Plug-in Manager opens and installed by the user); minor (gap 19: plug-in author signatures pin a plug-in's signer, #1271); minor (People: the People view sorts faces into Unknown, Suggested and Confirmed, and reviews the suggested ones a person at a time, #1050); minor (gap 20: Nikon NEFX, NX Studio's merged pixel-shift images, decodes; ARQ pixel shift is what is left of pixel shift); minor (gap 13: Capture One develop settings — exposure, orientation, crop, flips, white balance); minor (gap 13: saved prints in Lightroom catalogs import as Saved Prints with their layout); minor (gap 33 closed: the translation coverage check reads `trf!` and the helpers that translate; gap 21 re-measured: every language has every interface message); minor (gap 19: plug-ins look at a photo's pixels, set its crop and make virtual copies, #891); minor (gap 5: AI mask edges follow the photo's, no outline under a raised Exposure, upstream #3298); minor (gap 11 narrows: AI Super Resolution and AI Sharpen with an opt-in upscaler, upstream #3493); minor (gap 11 narrows: AI Denoise for finished pictures, upstream #3279); patch (gap 36: the ISO country code is carried over in preset save and import, #784); minor (gap 5: AI masks as recipes computed on the AI worker, Update AI Mask, masks under geometry, a Color Mixer per mask); patch (gap 26: smoother edits and lasting previews); minor (gap 5: Object masks can run on SAM 2.1, an open model, ported from OneSlips); minor (gap 12: generative remove through cloud providers with your own key, from OneSlips); minor (gap 36: the IPTC Content fields — headline, description writer, category, supplemental categories, subject codes — are stored, so Lightroom metadata presets carry them); minor (gap 19: plug-ins add a tool's files to the library, stacked or in the source album); minor (gap 19: plug-ins start installed programs; plug-in work no longer on hold); minor (gap 11: AI Denoise works out of the box with a built-in BM3D denoiser, upstream #2982); minor (gap 1: colour-chart calibration); patch (gap 1: calibrations matched to other editors); minor (gap 11 shrinks: the upstream project's own AI Denoise model is a download in the desktop app); patch (gap 3: probe DNGs and slider sweeps); minor (gap 1: dcraw's colour matrices replace the neutral fallback for about 550 models); patch (gap 3: `calibrate-lightroom verify`, edited raws against edited exports); patch (gap 3: ` compare`, ΔE00 between renders from any editor); minor (gaps 1 and 3: Lightroom-matched calibration tool, 0 cameras calibrated yet); minor (upstream merge: gap 13: before a Lightroom catalog import the app asks merge or new library, #2672; gap 28: grid-cycle key shown in View, #2500; gap 21: Thai glyphs in export text, #2052; gap 15: Japanese photo and postcard paper sizes); patch (HDR zoom: recent windows kept, encoded off the UI thread); patch (HDR adjustment previews: review follow-up); minor (upstream merge: gap 38 added: multi-select metadata editing UI, upstream's gap 30; XMP foreign namespaces and PSD/PSB embedded metadata, no gap change); patch (HDR adjustment previews keep float HDR output during slider drags); minor (opt-in Windows VRR compositor workaround); minor (gap 37 added: folder watching leftovers after issue #123's polling); minor (gap 36 added: what preset import doesn't carry over); minor (M15 decisions: CMYK won't do; Flickr / SmugMug and tethering blocked); minor (gap 11: the Enhance dialog); minor (gap 14 closed: HDR renders on the GPU; X11 SDR is a platform limit); minor (gap 14 narrows: zoomed, Before/After, Compare and second window show HDR, HDR Preview toggle); minor (gap 11 narrows: Raw Details and Super Resolution; gap 18: M14 closed, interlaced H.264 and faster AV1); minor (full audit 2026-10-20: rows refreshed against code; gaps 8 and 2 no longer beta blockers; gaps 34–35 added: Android camera roll and built-in camera; gap 34 narrows: picked folders rescanned); minor (gap 29 narrows: JPEG response curves and half-float frames) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 +> **Last updated:** 2026-11-29 · **Change:** patch (gap 11 narrows: X-Trans reaches AI denoise through an RGGB re-mosaic, upstream #1828); patch (gap 36 narrows: the file-name templates shared by Export, Rename Photos and import take every stored metadata field as a token — caption, headline, category, keywords, copyright, job title, location fields, camera serial, alt text, long description, caption writer, shutter, aperture, focal — #1584); patch (gap 41 narrows: a Lightroom import is committed and saved in parts, #1361); patch (gap 41 narrows: a large step is saved as many small log records, #1361); imported photos' metadata status compares their sidecars with the catalog, in step or a conflict, #1312); patch (gap 41 narrows: no row cap on Lightroom import tables, a memory budget from the computer instead, #1361); patch (gaps 13 and 41 narrow: cached-XMP records over 64 MiB and packets over 16 MiB are read without their camera-profile tables, #1311); patch (gap 39: ONNX Runtime on the GPU exists, #491; the aesthetic model is what is left); patch (gap 41 narrows: the recovery archive and the history settings budget follow the drive, the catalog and the memory, newest steps first, #1312); patch (feature-freeze parity pass: CF-PROCESS-RECIPES row restored, gap 43 cites the skin-uniformity row; no ranked gap closes); patch (#1360: scoped, cancellable face maintenance and confirmed reset; no ranked gap closes); patch (gap 42 narrows: OpenEXR scene-linear export, plan 7.5); minor (gap 11: Lens Blur renders from the depth model or the subject, focus picker and bokeh shapes, plan 7.1); patch (gap 16: plug-in publish services get the account, collection, photo metadata and remote comments, plan 7.14); patch (gap 43 narrows: skin-tone uniformity on Point Color, plan 7.9); patch (gap 43: Match Look, Capture One's Smart Adjustments, plan 7.6); minor (gap 18 narrows: lens corrections, Upright and Transform on video frames, poster frame picked, plan 7.11); patch (gap 43 narrows: process recipes, several export presets in one run with one decode per photo, plan 7.4); minor (gap 42 narrows: Tone Equalizer ported from darktable, plan 7.10); minor (gap 42 narrows: inpaint opposed and guided Laplacian highlight reconstruction, ported from darktable, plan 7.2); minor (adaptive presets, plan 7.8; no gap change: P2 rows without a gap entry; adaptive profiles left); patch (the Export screen previews the first photo as its file will be, with an SDR / HDR choice; minor (HDR export: gain map files for AVIF and JPEG XL with `hdrMode: gainMap`, LR-HDR-EXPORT; no ranked gap closes); patch (gap 37: OS folder notifications, single-instance hand-off, URL scheme on Windows and Linux, plan 5.9); patch (gap 43 narrows: speed-edit keys, hold a key and drag or scroll to move a Develop slider, plan 5.10); patch (gap 23: the brush by keyboard; Library and Develop core widgets checked in the AccessKit tree, plan 5.8); patch (gap 26: 100k wheel-scroll frame timed frame by frame, 3–5 ms median, within budget, plan 4.8); minor (gap 2 narrows: CRX partial subbands, multi-tile 0x200 and adaptive low-frequency gains decode, ported from LibRaw `crx.cpp`, synthetic tests only); patch (gap 1: LibRaw matrices for about 400 newer bodies; every body with a pinned sample has colour matrices; SIL ΔE cross-check; no chart shots yet); patch (gap 8: lensfun's database fetched on first run, picked lens written to XMP, plan 3.9); minor (gap 10: SRF and S200 EXR RAF decode, 47 Olympus / OM bodies verified: 645 verified, 89% on a verified body; target not met); minor (gap 19: the plug-in marketplace — search, install, update, remove and opt-in automatic updates from an index of each plug-in's newest release, vetted and community tiers); patch (gap 9: weekly model-reference job for SAM 2.1, BiRefNet, EoMT and MediaPipe); patch (gap 1: LibRaw matrices for six newer bodies that used the neutral matrix, #451; no chart shots yet); patch (gap 3: render-fidelity reference suite with ΔE2000 / SSIM tolerances and a synthetic ColorChecker check, plan 3.5); patch (gap 3: process V10 applies the Tone Curve in a wide working space, #1142); patch (gap 1: one ranked colour-source order, a Lightroom calibration that loses to the per-photo JPEG fit serves converted DNGs only, #1119; Adobe Standard DNGs without a tone curve get their BaselineExposure once more, #1174); minor (gaps 41–43: Lightroom migration limits left from #1311 / #1312, darktable raw-processing depth, Capture One workflow features); patch (gap 9: PRs run changed-crate tests; the nightly full run covers macOS and Windows, files an issue when red, and blocks releases); patch (gap 40 closed: `apps/android` denies `indexing_slicing`, clippy runs on it in the Android check); patch (never-crash tooling: pure-Rust fuzz targets with a nightly long run; no gap change); patch (gap 40: `apps/cli` and the chart-profile dialog converted); patch (tests only: loopback mock servers for generative fill errors, publish uploads while the server is down and misbehaving IPP printers; slideshow export in SIL; no gap changes); patch (gap 9: nightly corpus + fonts run with a skip gate, GPU equivalence on software adapters); patch (gap 37: folder polling notices new dated folders in a photo tree); minor (gap 38 closed: mixed metadata across a selection, `photo.sharedMeta`); patch (gap 9: timing probes and benchmarks are opt-in `probe` skips, not `#[ignore]`); patch (gap 9: engine import → export → re-import SIL scenario); minor (gap 40 added: checked indexing in the UI; unconverted modules carry a tracked allow); patch (gap 31: the sync merge rules are property-tested in the SIL run); patch (gap 13: required-table record losses always warned; remaining Lightroom size limits listed, #1311); patch (gap 13: the Lightroom import index is no longer capped at 16 MiB, #1312); patch (gap 13: one bad Lightroom record costs only itself; keyword assignments streamed, #1311); minor (gap 19: signed plug-ins find updates in their author's feed, checked when the Plug-in Manager opens and installed by the user); minor (gap 19: plug-in author signatures pin a plug-in's signer, #1271); minor (People: the People view sorts faces into Unknown, Suggested and Confirmed, and reviews the suggested ones a person at a time, #1050); minor (gap 20: Nikon NEFX, NX Studio's merged pixel-shift images, decodes; ARQ pixel shift is what is left of pixel shift); minor (gap 13: Capture One develop settings — exposure, orientation, crop, flips, white balance); minor (gap 13: saved prints in Lightroom catalogs import as Saved Prints with their layout); minor (gap 33 closed: the translation coverage check reads `trf!` and the helpers that translate; gap 21 re-measured: every language has every interface message); minor (gap 19: plug-ins look at a photo's pixels, set its crop and make virtual copies, #891); minor (gap 5: AI mask edges follow the photo's, no outline under a raised Exposure, upstream #3298); minor (gap 11 narrows: AI Super Resolution and AI Sharpen with an opt-in upscaler, upstream #3493); minor (gap 11 narrows: AI Denoise for finished pictures, upstream #3279); patch (gap 36: the ISO country code is carried over in preset save and import, #784); minor (gap 5: AI masks as recipes computed on the AI worker, Update AI Mask, masks under geometry, a Color Mixer per mask); patch (gap 26: smoother edits and lasting previews); minor (gap 5: Object masks can run on SAM 2.1, an open model, ported from OneSlips); minor (gap 12: generative remove through cloud providers with your own key, from OneSlips); minor (gap 36: the IPTC Content fields — headline, description writer, category, supplemental categories, subject codes — are stored, so Lightroom metadata presets carry them); minor (gap 19: plug-ins add a tool's files to the library, stacked or in the source album); minor (gap 19: plug-ins start installed programs; plug-in work no longer on hold); minor (gap 11: AI Denoise works out of the box with a built-in BM3D denoiser, upstream #2982); minor (gap 1: colour-chart calibration); patch (gap 1: calibrations matched to other editors); minor (gap 11 shrinks: the upstream project's own AI Denoise model is a download in the desktop app); patch (gap 3: probe DNGs and slider sweeps); minor (gap 1: dcraw's colour matrices replace the neutral fallback for about 550 models); patch (gap 3: `calibrate-lightroom verify`, edited raws against edited exports); patch (gap 3: ` compare`, ΔE00 between renders from any editor); minor (gaps 1 and 3: Lightroom-matched calibration tool, 0 cameras calibrated yet); minor (upstream merge: gap 13: before a Lightroom catalog import the app asks merge or new library, #2672; gap 28: grid-cycle key shown in View, #2500; gap 21: Thai glyphs in export text, #2052; gap 15: Japanese photo and postcard paper sizes); patch (HDR zoom: recent windows kept, encoded off the UI thread); patch (HDR adjustment previews: review follow-up); minor (upstream merge: gap 38 added: multi-select metadata editing UI, upstream's gap 30; XMP foreign namespaces and PSD/PSB embedded metadata, no gap change); patch (HDR adjustment previews keep float HDR output during slider drags); minor (opt-in Windows VRR compositor workaround); minor (gap 37 added: folder watching leftovers after issue #123's polling); minor (gap 36 added: what preset import doesn't carry over); minor (M15 decisions: CMYK won't do; Flickr / SmugMug and tethering blocked); minor (gap 11: the Enhance dialog); minor (gap 14 closed: HDR renders on the GPU; X11 SDR is a platform limit); minor (gap 14 narrows: zoomed, Before/After, Compare and second window show HDR, HDR Preview toggle); minor (gap 11 narrows: Raw Details and Super Resolution; gap 18: M14 closed, interlaced H.264 and faster AV1); minor (full audit 2026-10-20: rows refreshed against code; gaps 8 and 2 no longer beta blockers; gaps 34–35 added: Android camera roll and built-in camera; gap 34 narrows: picked folders rescanned); minor (gap 29 narrows: JPEG response curves and half-float frames) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 Every known shortfall, one entry each, ranked by user impact (how many Lightroom users hit it, and how hard it blocks them), then by effort. **Agents pick work from the top** (the first entry nobody is @@ -27,7 +27,7 @@ Hours are Opus 5.5 agent wall-clock hours (see [target-app-parity.md](target-app | 8 | **No lens profile database of our own** (LR-EDIT-OPTICS-PROFILE): DNG opcodes, RW2 in-file distortion and Sony ILCE-7RM4A, ILCE-7RM6 and ZV-E10 distortion (`docs/sony-ilce7rm6-lens-corrections.md`), Nikon Z 6II / Z 8 / Z f in-file distortion (`docs/nikon-lens-corrections.md`), plus lensfun's database, fetched once on the desktop app's first run (activity stack) or set up / downloaded from Settings ▸ Lens profiles (CC-BY-SA, not bundled in the binary; a picked lens is written to XMP as `optics.lens`; profiles unverified against Lightroom) | Adobe ships 3,635 lens profiles; we never use them | distortion / vignetting correction is a default step for many | 40–80 + calibration shots | [raw-parity](raw-parity.md#lens-profiles) | | 9 B | **Full tests in CI not yet green on macOS, Windows and Linux x64**: pushes to main run fmt / clippy / build on all three OSes (green); full tests run only on `release` or a manual dispatch. The manual full run was green 2026-10-18 (run 39114677868); release 0.9.5 (run 39371069655) failed on macOS, Windows and Linux in four deterministic test groups: lcc-publish full-disk publish, ui-egui i18n catalog coverage (2 tests), empty-library icon layout, engine Immich album publish. Also left: real-disk sidecar-repair fixtures skip on case-insensitive volumes (FakeFs models them); CPU/GPU equivalence runs nightly on software adapters (lavapipe, WARP; `nightly.yml`, wider bounds), and a nightly corpus + fonts run fails when skips exceed `ci/skip-allowlist.toml`, both not yet seen green on CI (#1050); a weekly model-reference job (`models.yml`) runs SAM 2.1, BiRefNet, EoMT and the MediaPipe TFLite models from their pinned, sha256-checked downloads against stored numeric summaries of our own outputs; SAM 3 (SAM License, gated) and YuNet (retired, CC BY-NC-ND training data) are left out (docs/ci.md → Model references) | `.github/workflows/ci.yml`, runs 39114677868 / 39371069655 | regressions reach users on the main platforms until the full suite is green | 2–6 | [target-app-parity](target-app-parity.md#by-dimension) | | 10 B | **Per-model verification still partial**: 645 of 1,446 Adobe models verified (45%, measured 2026-11-24), ~89% of photographers on a verified body (plan target: 60% of models or 95% of photographers — not met); per maker in raw-parity.md. The cheap per-body fixes landed (Z 6II packed NEF #769, ARW version 1 for the A100 and A200…A390, A850, Z 8 and Z 9 lossless verified, pre-X FinePix SuperCCD RAF decoded); S200 EXR upright RAF and SRF decode, Olympus / OM bulk-checked (2026-11-24); left: phones (DNG, few public samples), the older / niche tail per maker, a four-colour path for the F828, and samples for the 90D, 250D, X-H2S, Z 6III, OM-1, OM-5 (none on raw.pixls.us) | measured: [raw/coverage.tsv](raw/coverage.tsv) | per-body bugs (levels, crops, WB) surface only from users | 15–30 | [raw-parity](raw-parity.md#by-maker-measured) | -| 11 | **Enhance: AI denoise without shippable weights or X-Trans; Raw Details and Super Resolution are classical** (Photo ▸ Enhance ▸ Raw Details / Super Resolution landed 2026-10-20: edge-aware residual demosaic and 2× iterative back-projection, each a new linear DNG stacked with the source, in the activity stack; no learned model, Raw Details Bayer only; the Enhance Preview dialog, Photo ▸ Enhance…, landed 2026-10-21) | ENH rows 🟡; denoise: Bayer raws, and finished pictures (JPEG / PNG / TIFF) once a model for them is installed (own model slot; opt-in NIND U-Net, GPL-3.0 weights, upstream #3279); a built-in classical denoiser (block-matching collaborative filtering, GPU-accelerated) works out of the box; the upstream project's own model (MIT OR Apache-2.0, CC0 training data, 0.1.0; [denoise.md](denoise.md#the-upstream-projects-own-model)) is a download in the desktop app, from the upstream release asset, else radfilms.com.au (same SHA-256); RawNIND weights dual-licensed GPL-3.0 and CC BY 4.0, offered under CC BY 4.0, and opt-in (#1760) (Lens Blur renders since 2026-11-25 from the depth model, else from the Subject selection: LR-EDIT-LENSBLUR 🟡, no depth refine brushes) | Fujifilm users get no AI denoise; classical Super Resolution recovers less texture than an AI model, and AI Super Resolution / AI Sharpen (an installed upscaler, upstream #3493) bake the photo's edits into an sRGB TIFF (Lightroom keeps an editable raw) | 20–45 + model decision | [raw-parity](raw-parity.md#demosaic-levels-crops-and-lens-metadata) | +| 11 | **Enhance: AI denoise without shippable weights (X-Trans only through an RGGB re-mosaic, 2026-11-29); Raw Details and Super Resolution are classical** (Photo ▸ Enhance ▸ Raw Details / Super Resolution landed 2026-10-20: edge-aware residual demosaic and 2× iterative back-projection, each a new linear DNG stacked with the source, in the activity stack; no learned model, Raw Details Bayer only; the Enhance Preview dialog, Photo ▸ Enhance…, landed 2026-10-21) | ENH rows 🟡; denoise: Bayer raws, X-Trans through an RGGB re-mosaic (`remosaic_rggb`, upstream #1828; unmeasured with a model trained on Bayer sensors), and finished pictures (JPEG / PNG / TIFF) once a model for them is installed (own model slot; opt-in NIND U-Net, GPL-3.0 weights, upstream #3279); a built-in classical denoiser (block-matching collaborative filtering, GPU-accelerated) works out of the box; the upstream project's own model (MIT OR Apache-2.0, CC0 training data, 0.1.0; [denoise.md](denoise.md#the-upstream-projects-own-model)) is a download in the desktop app, from the upstream release asset, else radfilms.com.au (same SHA-256); RawNIND weights dual-licensed GPL-3.0 and CC BY 4.0, offered under CC BY 4.0, and opt-in (#1760) (Lens Blur renders since 2026-11-25 from the depth model, else from the Subject selection: LR-EDIT-LENSBLUR 🟡, no depth refine brushes) | Fujifilm users get AI denoise only through a re-mosaic the model was not trained on; classical Super Resolution recovers less texture than an AI model, and AI Super Resolution / AI Sharpen (an installed upscaler, upstream #3493) bake the photo's edits into an sRGB TIFF (Lightroom keeps an editable raw) | 20–45 + model decision | [raw-parity](raw-parity.md#demosaic-levels-crops-and-lens-metadata) | | 12 | **Generative remove, detect distractions, reflections removal** (content-aware Remove exists: PatchMatch Fill spots, LR-REM-CONTENTAWARE 🟡) | REM rows 75%; generative remove works through cloud providers with the user's own key (LR-REM-GEN 🟡, ported from OneSlips; no on-device model), remove people stays out of scope (LR-REM-PEOPLE 🚫); open work is detect distractions and reflections | cleanup work goes back to Photoshop | 25–45 (+ generative model) | [target-app-parity](target-app-parity.md#ai) | | 13 | **Lightroom catalog migration is one-way and approximate**: unsupported Adobe profiles / AI settings archived; smart collections with unmappable rules (metadata status) stay static; 6 of 113 public flat `crs:` fields have no equivalent (Upright tool options, lens profile setup…) (most smart rules (rule mapping still being finished, 8296786e), stacks, develop history as History, snapshots as Versions, collection / capture / edit date rules incl. today / this week / month / year now import, G13); offline record counts and destination are shown in a lasting import result; before an import the app asks whether the catalog merges into the open library or goes into a new library (opt-out in Settings, #2672); video records classified, records without files skipped, large catalogs read in bounded pages; one oversized or damaged record is left out and counted instead of its table, keyword assignments are streamed past a million (#1311, #1312) — oversized cached-XMP records and packets are read without their camera-profile tables (#1311); imported photos start in step with their sidecars, or as a conflict where a sidecar disagrees (#1312); the recovery archive and the history budget grow with the catalog, the drive and the memory (#1312); the import index grows past 16 MiB so large re-imports add nothing twice; saved prints import as Saved Prints with their layout; Capture One catalogs (`.cocatalogdb`) import through the same path (photos, variants as virtual copies, ratings, colour tags but orange / pink, IPTC fields, keywords, albums in their projects and groups, capture time and camera of offline originals; develop settings: exposure, contrast, brightness, saturation, High Dynamic Range, clarity and structure, levels, the RGB / red / green / blue curves, orientation and straighten, crop, flips and white balance, every other setting named in the result window; not yet the colour editor, layers (as masks), the luma curve or smart albums, C1-IMPORT, C1-DEVELOP) | lightroom-catalog-import.md | switching users lose some looks | 6–10 | [file-format-parity](file-format-parity.md) | | 14 | ~~**HDR display leftovers**~~ — **closed 2026-10-21**: HDR display output (EDR / scRGB surface through a vendored egui-wgpu patch, UI at paper white, HDR edits above SDR white in every view, View ▸ HDR Preview `view.hdrPreview`), and HDR renders run on the GPU (float HDR tone map and output in `finish.wgsl`, CPU as oracle; HDR views, HDR exports and gain maps). X11 has no HDR surface (no colour-management protocol carries headroom or HDR metadata there; a platform limit, not planned): on Linux the app runs native Wayland whenever an output reports HDR headroom, else XWayland / X11 in SDR; slider drags show live HDR drafts too, zoomed in as well (2026-10-22); zoomed panes keep their recent HDR windows (2026-10-24) | HDR rows 85%; LR-HDR-EDIT ✅; LR-VIEW-HDR-DISPLAY 🟡 only for X11 (platform limit); `hdr_renders_match` in `crates/gpu/tests/it/equivalence.rs` | 6 MP HDR render CPU ~200 ms → GPU ~50–70 ms | 0 | [hardware-parity](hardware-parity.md) | diff --git a/docs/manual-site/src/content/docs/ai/denoise.mdx b/docs/manual-site/src/content/docs/ai/denoise.mdx index 2b3848a467..b49b22bc42 100644 --- a/docs/manual-site/src/content/docs/ai/denoise.mdx +++ b/docs/manual-site/src/content/docs/ai/denoise.mdx @@ -13,7 +13,7 @@ import { Aside } from '@astrojs/starlight/components'; - **Where**: Edit ▸ **Detail** ▸ under **AI Denoise**, the **Enable** switch and **Amount** (0 to 100). Turning it on starts at 50. - **Works out of the box**: a built-in denoiser (block matching and collaborative filtering after measuring the photo's noise). No download and no weights. It is a classical filter, not a trained network. -- **Raw only by default**: Bayer raw files. A JPEG, PNG or TIFF is denoised only with a model for finished pictures. X-Trans, Foveon and demosaiced DNG are not supported. The panel says so on photos it cannot handle. +- **Raw only by default**: raw files with a colour filter array. Bayer raws go to the model as they are; X-Trans (and other red/green/blue patterns) are first rebuilt as a Bayer mosaic, an approximation the model was not trained on. A JPEG, PNG or TIFF is denoised only with a model for finished pictures. Foveon, monochrome and demosaiced DNG are not supported. The panel says so on photos it cannot handle. - **Non-destructive**: the cleaned picture is cached data, made in the background and shown in previews and exports. Your file is never changed. Exports make it if it is missing. - **Manual noise reduction** (Luminance, Color) stays separate and works on every photo. diff --git a/docs/manual-site/src/content/docs/develop/effects.mdx b/docs/manual-site/src/content/docs/develop/effects.mdx index c935308a46..8b8cfa1dc2 100644 --- a/docs/manual-site/src/content/docs/develop/effects.mdx +++ b/docs/manual-site/src/content/docs/develop/effects.mdx @@ -12,7 +12,7 @@ import { Aside } from '@astrojs/starlight/components'; - **Texture**, **Clarity**, **Dehaze**: in Basic and in the Effects dock card. -- **Vignette**: **Vignette** amount, **Midpoint**, **Roundness**, **Feather**, **Highlights**; style **Highlight**, **Color**, **Paint**. Post-crop: it follows the crop. +- **Vignette**: **Vignette** amount, **Midpoint**, **Roundness**, **Feather**, **Highlights**; style **Highlight**, **Color**, **Paint** (Paint blends the corners toward flat black when negative, toward flat white when positive). Post-crop: it follows the crop. - **Glow**: the bright parts of the picture, spread as a halo over it (beyond Lightroom, after DaVinci Resolve's Glow effect). **Glow** is the strength; **Threshold** picks how bright a part must be to glow; **Radius** sets the halo's width (relative to the frame, so a preview matches an export); **H/V Ratio** stretches the halo one way (50 is even); **Gain** and **Gamma** shape the glow's brightness and falloff; the composite is **Screen** (gentler, the default) or **Add** (hotter); **Recovery** brings the bright regions' own detail back through the glow. - **Grain**: amount, **Size**, **Size Variation**, **Roughness**, **Clumping**, **Color**, **Response**, **Seed**. From process V7, irregular particles that do not change with the picture's size. See [Process versions](../process-versions/). - Dehaze from V3 keeps shadows from going black. diff --git a/docs/manual-site/src/content/docs/library/import.mdx b/docs/manual-site/src/content/docs/library/import.mdx index 259bab27f1..c5483ea2ee 100644 --- a/docs/manual-site/src/content/docs/library/import.mdx +++ b/docs/manual-site/src/content/docs/library/import.mdx @@ -19,6 +19,7 @@ import Shot from '../../../components/Shot.astro'; - **Rename** with a template and live example; the **Tags** picker inserts `{name}`, `{seq:4}`, `{date:…}`, `{camera}`, `{lens}`, `{iso}` and more. - **Apply on import**: develop preset, metadata preset (copyright, creator), keywords, a collection, and **Batch edits** sliders (Light, Vibrance, Clarity, Sharpening, Grain, Vignette) as one History step. - **Drag and drop**: files or folders dropped on the window open the review (or import at once with **Settings ▸ Import ▸ Import dropped photos without review**). A card says what the drop will do. +- **From Finder or another app (macOS)**: a photo opened with **Open With ▸ **, dropped on the app's Dock icon, or opened with `open -a` from another app arrives like a file dropped on the window, whether the app was running or not. The app is offered for camera raws and the image types it imports, but never becomes the default app for them. - **Import presets**: save and reuse the dialog's settings (**Save as Preset**). - **Raw defaults** (**Settings**): built-in, a preset, or per camera model; applied to new photos. - Raw, JPEG, TIFF, PNG, WebP, JPEG XL, PSD and DNG are read. Unreadable files are reported, never crash the import; a batch the library couldn't add (a save that failed) is reported as "not added", with the reason, not as unreadable. Images over 512 megapixels are refused with a message giving their size and the limit. Previews are built in the background after import. diff --git a/docs/manual-site/src/content/docs/platforms/desktop.mdx b/docs/manual-site/src/content/docs/platforms/desktop.mdx index ceac7e1746..e416d389bf 100644 --- a/docs/manual-site/src/content/docs/platforms/desktop.mdx +++ b/docs/manual-site/src/content/docs/platforms/desktop.mdx @@ -16,6 +16,7 @@ import { Aside } from '@astrojs/starlight/components'; | FreeBSD | `.tar.gz`; the release job is currently disabled | | RISC-V | not shipped | +- **Photo ▸ File ▸ Show in Finder** (`Ctrl+R`) shows the original in the file manager. On Linux it selects the file in the window (every selected photo at once) through the desktop's file-manager service, and where there is none it opens the folder; the app keeps working while that window is open. - Linux packages install a desktop entry, file types and a camera (PTP) udev rule. AppImage and Flatpak users add the rule by hand for tethering. - Flatpak can reach the network and the Pictures folder only; widen with a Flatpak override if you keep photos elsewhere. @@ -26,6 +27,7 @@ import { Aside } from '@astrojs/starlight/components'; ## Updates - **Help ▸ Check for Updates…** reads the release feed, shows the notes and how long ago it last checked ("Last checked 5 minutes ago"), then **Download** fetches the file for your platform, verifies that it was signed by the Chromaforge authors, and offers to install it over this version (where the app can't install itself, it opens the file's folder instead). When the download is ready, **Install and Relaunch** is highlighted and has the keyboard focus, so Return presses it. The notes show `code`, **bold** and links as such; a link opens in your browser. +- Installed from a distro package (the Nix package, for example), the package manager handles updates: when the environment variable `_DISABLE_UPDATES` is `1`, `on`, `true` or `yes`, the start-up check never runs and **Help ▸ Check for Updates…** is greyed out; hovering it says why. - **Help ▸ What's New** lists the changes under a heading for each date, newest first. The newest date is open; click a date's arrow, or focus it and press Space or Enter, to open or close it. Older dates are added as you scroll to them. Its text is formatted like the update notes. - A download is installed only when the release's checksum list carries a valid signature; it is checked again before install. - Installing an update restarts the app. On Windows the app quits, the installer runs, and the app starts again when it is done (after a restart the installer asked for, if it needs one). If the installer fails or its permission prompt is declined, the old version stays and the next start logs why (the installer's own log is `update-install.log` beside the download); Start-menu shortcuts, and taskbar entries pinned from them, keep working across updates. macOS, AppImage and portable-zip copies swap the new version in and start it once the app has quit. On a Mac, a release that needs a newer macOS than the Mac runs is not installed, and the previous app is kept beside the new one (hidden, as `..app.old`) until the new version has started. An AppImage update replaces only the AppImage this copy runs from: a copy installed another way that was started from another AppImage's terminal is told to install it the way it was installed. diff --git a/docs/manual/import-export.md b/docs/manual/import-export.md index 566409bf50..a2331cbda2 100644 --- a/docs/manual/import-export.md +++ b/docs/manual/import-export.md @@ -15,6 +15,9 @@ File → Import Photos… (`Cmd+Shift+I`) or Import from Folder… (`library.imp memory held by a drive that stopped responding, a failed conversion) is imported as its raw copy and listed by reason in File → More Imports → Import Warnings…; Convert Photo to DNG… converts it later. - Apply a develop preset, a metadata preset, keywords, and add the photos to a collection. +- On macOS, photos opened from Finder (Open With, a drop on the Dock icon) or another app arrive like files dropped + on the window, at launch or while the app runs. The app is offered for camera raws and the image types it imports, + never as their default app. - Files on several drives, cards or shares are read side by side. Each drive starts with as many readers as before and then finds its own number: it gets more while more readers read it faster (an SSD, a RAID or a fast card), fewer when they slow it down (a hard drive seeking between files), one drive trying a change at a time, never fewer than diff --git a/docs/manual/troubleshooting.md b/docs/manual/troubleshooting.md index add240c2aa..0cff7b8b4d 100644 --- a/docs/manual/troubleshooting.md +++ b/docs/manual/troubleshooting.md @@ -82,7 +82,9 @@ Library → Validate DNG Files checks the selected DNGs' raw data against their Help → Check for Updates… reads the project's release feed and, when something newer exists, offers to download it for this system and install it; the app restarts afterwards. The dialog says how long ago it last checked ("Last checked 5 minutes ago"). When the download is ready, "Install and Relaunch" is highlighted and has -the keyboard focus, so Return presses it. Things that can go wrong: +the keyboard focus, so Return presses it. When `_DISABLE_UPDATES` is `1`, `on`, `true` or `yes` (distro packages +such as the Nix package set it), Check for Updates… is greyed out and the start-up check never runs: the package +manager handles updates. Things that can go wrong: - "Could not reach the release server" or "the release server answered 403": no internet, a proxy, or GitHub's rate limit. The check uses the release's `latest.json` first, which usually still works; try again later. diff --git a/docs/mcp.md b/docs/mcp.md index c34bd2ebf5..c8bd57eeec 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -378,7 +378,9 @@ until the export ends. EOF lets a pending export finish and preserves queued req photo, suppressing its response. Unknown/completed request ids are ignored. A photo already being processed finishes first: completed photos remain, each written with the existing atomic file writer, and there are no partial files to delete. Unrelated outputs and earlier exports -are untouched. A failed export is an `isError` tool result. Transport mutexes recover poisoning. +are untouched. In a headless batch export, a failed photo is listed as `{photo, file, error}` in +`files` and later photos continue exporting. A failed single-photo export is an `isError` tool +result. Transport mutexes recover poisoning. If a protocol write or flush fails, the CLI reports the output error and shuts down without waiting for stdin to close. Output failures are observable only when writing. An active direct diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 8127a4b16d..3123f20903 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -145,7 +145,7 @@ under the UI command that wraps it (a no-op error); the UI command now wins. | LR-HDR-EDIT | HDR editing | P2 | ✅ | `cmd:develop.hdr`, `crates/pipeline/src/tone.rs` (`ToneMap::hdr`), `crates/pipeline/src/tests_hdr.rs`, `crates/gpu/src/wgsl/finish.wgsl` | HDR tone map (SDR curve through the midtones, highlights up to the headroom limit) and float HDR render, on the GPU too (linear float output up to the peak, the CPU as oracle: `hdr_renders_match` in `crates/gpu/tests/it/equivalence.rs`; gap 14); shown on HDR displays in every view (LR-VIEW-HDR-DISPLAY); `crs:HDREditMode`, `HDRMaxValue`, `SDRBlend` and the SDR sliders are read from XMP | | LR-IMP-ADD-DIALOG | Add photos/folders | P0 | ✅ | `cmd:dialog.import`, `cmd:file.addPhotos`, `cmd:library.importPreview`, `cmd:library.import` (`mode`, `album`, `albumName`, `preset`, `keywords`), `crates/ui-egui/src/import.rs` | review dialog (Import Photos): the scanned source (a scanned folder is not added to Local), candidate grid with thumbnails and checkboxes (duplicates by path/content marked and unchecked; with several file types, a toggle per type checks or unchecks all of its files, e.g. the raws without the JPEGs beside them, issue #344) filling a resizable window (issue #337), transfer mode (add in place / copy / move, each explained), album (existing/new), preset, keywords; the folder scan runs on a background thread with a progress window and Cancel (a NAS folder no longer freezes the window); the import itself (probing, sidecars, copying / moving files) runs on a worker thread and its batches join the library between frames, with a progress window and Cancel; one undo step. Drag-and-drop goes through the same background import. File dialogs list the importable extensions (`lcc_engine::import::EXTENSIONS`) in any letter case on Linux, where GTK and the desktop portal match globs case-sensitively (`apps/app/src/dialog_filter.rs`, issue #342; 0.4.0 hid `.JPG` / `.NEF`, issue #705). The folder scan, Browse Folder, drag-and-drop and the sidecar lookup match extensions in any case (`crates/engine/src/tests_import.rs`); a rating, reject flag and colour label embedded in the file (XMP / EXIF) are kept on import, a sidecar still winning (`crates/engine/src/tests_import.rs`); the review (and `library.importPreview`: `truncated`, `skipped {unreadable, unsupported}`) says when its folder scan stopped at the walk limit, could not read folders or skipped files that are not a supported photo type (XMP sidecars not counted; upstream #2944); `library.import` returns the same `skipped` counts (upstream #4321) | | 2026-10-12 | minor | LR-IMP-FORMATS: Mamiya MEF decodes from sensor data and is imported (`vendor/mef.rs`) | -| LR-IMP-DRAGDROP | Drop files/folders to import | P0 | ✅ | `crates/ui-egui/src/lib.rs` (dropped files → the import review), `crates/ui-egui/src/drop_overlay.rs`, `crates/ui-egui/src/tests_drop_import.rs` | while files are dragged over the window a veil and a card say what dropping does (import N items, review a folder for import, import N presets, open the face model; a note to close the open dialog first when one is open); dropped photo files and folders open the import review as File ▸ Import does, or, with Settings ▸ Import ▸ Import dropped photos without review (off by default; from OneSlips), are added at once on a worker thread with the library's import settings (the web build imports both at once); with no library open on the desktop (the launch list, a library that couldn't open) photos wait for the library opened and presets are refused, and the card says so; a drop while a dialog is open (also in the web build) or while an import is running is refused with a toast, and the card says so; a finished scan waits for an open dialog to close before its review opens; the control channel's `ui.dropFiles` hovers or drops files for scripts; dropping onto a specific album not supported | +| LR-IMP-DRAGDROP | Drop files/folders to import | P0 | ✅ | `crates/ui-egui/src/lib.rs` (dropped files → the import review), `crates/ui-egui/src/drop_overlay.rs`, `crates/ui-egui/src/tests_drop_import.rs`, `crates/opendocs/src/lib.rs`, `packaging/macos/Info.plist.in` | while files are dragged over the window a veil and a card say what dropping does (import N items, review a folder for import, import N presets, open the face model; a note to close the open dialog first when one is open); dropped photo files and folders open the import review as File ▸ Import does, or, with Settings ▸ Import ▸ Import dropped photos without review (off by default; from OneSlips), are added at once on a worker thread with the library's import settings (the web build imports both at once); with no library open on the desktop (the launch list, a library that couldn't open) photos wait for the library opened and presets are refused, and the card says so; a drop while a dialog is open (also in the web build) or while an import is running is refused with a toast, and the card says so; a finished scan waits for an open dialog to close before its review opens; the control channel's `ui.dropFiles` hovers or drops files for scripts; macOS: photos opened from Finder (Open With, a drop on the Dock icon), from another app or with `open -a` arrive as dropped files (upstream #1204; the bundle offers the app for camera raws and the image types it imports, never as the default app); dropping onto a specific album not supported | | LR-IMP-DUPES | Skip duplicates by content | P1 | ✅ | `crates/engine/src/import.rs`, `crates/engine/src/tests_import.rs`, `crates/ui-egui/src/import.rs`, `crates/ui-egui/src/headless.rs` | Only library records (including Recently Deleted) count as existing content; a copy merely browsed in Local does not block importing another path. A browsed file at the same path is offered by the scan (not "In library") and promoted with its edits, unless a library match or an earlier promotion already has its content; background import batches deduplicate promoted files too. The review offers such a file only when adding in place (copy and move would add it where it is), and notes that keywords and presets apply to new files only. | | LR-IMP-RECIPE | Batch edits during import | P2 | ✅ | `cmd:library.import` (`recipe`), `cmd:preset.saveRecipe`, `crates/ui-egui/src/import.rs`, `crates/ui-egui/src/import_screen.rs` | an optional Batch edits section in the import review: sliders for everyday adjustments (Light, Vibrance and Saturation, Clarity, Texture and Dehaze, Sharpening, Grain, Vignette) whose values are set on every photo the import adds, after its XMP sidecar, camera default and the chosen preset, as one extra History step (`Import adjustments`) after the preset's own; a photo the library already has (a duplicate, one restored from Recently Deleted, one joined from a browsed folder) is not changed; a summary beside the section counts the adjustments, it does not list them; Save as Preset stores only the settings the recipe names (`preset.saveRecipe`) so it can be reused from the Preset list; the recipe lives only in the dialog until the import runs, so Cancel changes neither the catalog nor the preset collections. The command takes any plain develop control, not only the ones the dialog offers, and refuses white balance, geometry and crop controls, per-photo controls and unknown ids before anything is imported. Not a second editor: white balance is not offered (a temperature means something else on a raw than on a rendered photo, so the command refuses it too), and neither are crop, masks, curve or point colour; a slider left at its default names nothing, so setting a control to its default for the whole batch is only possible through the command | | LR-IMP-DEVICE | Import from camera/card | P1 | ✅ | `cmd:library.devices`, `cmd:file.addFromDevice`, `crates/engine/src/devices.rs` | mounted volumes with a DCIM folder (macOS /Volumes, Linux /media and /run/media, Windows drive letters); File → Import from Device → the import review, copying into the library by default; menus serve the last scan and rescan in the background (never blocking a frame; hot-plugs repaint); copies are verified (a new file, synced, checked against the content hash the scan computed — byte compare with the source when there is none, issue #134; a bad copy is removed and reported as failed, never counted as imported; taken names get -1, -2…, never replaced — issue #96, `crates/engine/src/import_move.rs`); no PTP/MTP (cameras that don't mount as a disk); Settings → Import → Cameras and Cards can open the import review when a camera or card is connected (off by default; a card that was already in doesn't ask, and an open dialog or running import is finished first; `crates/ui-egui/src/import.rs`) | @@ -293,7 +293,7 @@ under the UI command that wraps it (a no-op error); the UI command now wins. | LR-EDIT-DETAIL-NR | Luminance noise reduction | P0 | ✅ | `ctl:detail.nrLuminance`, `ctl:detail.nrDetail`, `ctl:detail.nrContrast` | radii in the original's pixels, so grid, loupe and smaller exports look like the full-size render scaled down (`local::nr_params`, `Plan::detail_scale`, #960) | | LR-EDIT-DETAIL-CNR | Colour noise reduction | P0 | ✅ | `ctl:detail.nrColor`, `ctl:detail.nrColorDetail`, `ctl:detail.nrColorSmoothness` | preview-size independent like luminance NR (#960). From process V8 the joint method (adapted from upstream #1348, `docs/nr-color-joint.md`): linear R−Y / B−Y, edge-aware weights from a denoised guide, a speck brake; acts clearly at the default 25 and keeps colour edges at 100. CPU and GPU within 1/255 | | LR-EDIT-DETAIL-HOTPIXELS | Hot pixel removal | P1 | ✅ | `check:detail.nrOutliers`, `crates/raw/src/hotpixel.rs`, `crates/engine/src/files.rs` (`load_bytes_now`) | Lightroom has no control for this. A box under Noise Reduction (raws only), on for newly imported raws and off for edits saved before it existed (upstream #1345): isolated photosites far above their same-colour neighbours are replaced in the mosaic before demosaicing; stars and sparks spread over neighbours are kept | -| LR-EDIT-DETAIL-DENOISE | AI denoise | P2 | 🟡 | cmd:denoise.toggle, cmd:denoise.models.install, cmd:denoise.queue, cmd:denoise.models.select, ctl:enhance.denoise, `crates/denoise/`, `docs/denoise.md` | non-destructive Bayer RAW and finished pictures (JPEG/PNG/TIFF with a model for finished pictures, chosen separately: `rgbModel`, `kind: rgb`; the built-in denoiser stays raw-only; opt-in NIND U-Net `nind-rgb`, GPL-3.0 weights, under `rawnind-model`; upstream #3279), opt-in RawNIND weights (dual-licensed GPL-3.0 and CC BY 4.0, upstream #1760; offered under CC BY 4.0 with credit), pure-Rust CPU/GPU; GPU convolution uses independently written shared scalars (Metal equivalence regression, issue #479); tiles can also run on another computer's graphics card (`lcc-cli denoise-serve`, `crates/denoise/src/remote.rs`); X-Trans/linear RGB, model policy and Lightroom fidelity remain; closing the model setup without installing turns the switch back off (#922); with no model installed Settings ▸ AI Denoise says so plainly (this version has none and none can be downloaded from here yet; Luminance and Color under Detail meanwhile; Install from file for a model you have) instead of a file prompt, and the Detail panel note answers Why?; the desktop app offers the upstream project's own model (MIT OR Apache-2.0, `own-model` feature, `known::own_bayer`) from its release asset, else radfilms.com.au; works out of the box with a built-in classical denoiser (BM3D-style block matching and collaborative filtering after a per-plane noise fit, `crates/denoise-core/src/builtin.rs`, GPU kernels in `crates/gpu/src/bm3d.rs` checked against the CPU; id `builtin`, no weights), so turning AI Denoise on needs no set-up; a model of one's own stays optional (upstream #2982); the switch follows Auto Sync (every selected raw in one undo step), Settings ▸ Import ▸ AI Denoise from (ISO) switches it on at import, and a job over many photos is one batch row with the time left and its failures (upstream #2932); from process V6 the Amount eases in (`1 − (1 − a)³`, 50 leaves ~0.17 of the noise σ; not yet compared with Lightroom on a real high-ISO raw) | +| LR-EDIT-DETAIL-DENOISE | AI denoise | P2 | 🟡 | cmd:denoise.toggle, cmd:denoise.models.install, cmd:denoise.queue, cmd:denoise.models.select, ctl:enhance.denoise, `crates/denoise/`, `docs/denoise.md` | non-destructive Bayer RAW, X-Trans and other non-Bayer layouts through an RGGB re-mosaic (`remosaic_rggb`, unmeasured: the model is trained on Bayer sensors), and finished pictures (JPEG/PNG/TIFF with a model for finished pictures, chosen separately: `rgbModel`, `kind: rgb`; the built-in denoiser stays raw-only; opt-in NIND U-Net `nind-rgb`, GPL-3.0 weights, under `rawnind-model`; upstream #3279), opt-in RawNIND weights (dual-licensed GPL-3.0 and CC BY 4.0, upstream #1760; offered under CC BY 4.0 with credit), pure-Rust CPU/GPU; GPU convolution uses independently written shared scalars (Metal equivalence regression, issue #479); tiles can also run on another computer's graphics card (`lcc-cli denoise-serve`, `crates/denoise/src/remote.rs`); X-Trans/linear RGB, model policy and Lightroom fidelity remain; closing the model setup without installing turns the switch back off (#922); with no model installed Settings ▸ AI Denoise says so plainly (this version has none and none can be downloaded from here yet; Luminance and Color under Detail meanwhile; Install from file for a model you have) instead of a file prompt, and the Detail panel note answers Why?; the desktop app offers the upstream project's own model (MIT OR Apache-2.0, `own-model` feature, `known::own_bayer`) from its release asset, else radfilms.com.au; works out of the box with a built-in classical denoiser (BM3D-style block matching and collaborative filtering after a per-plane noise fit, `crates/denoise-core/src/builtin.rs`, GPU kernels in `crates/gpu/src/bm3d.rs` checked against the CPU; id `builtin`, no weights), so turning AI Denoise on needs no set-up; a model of one's own stays optional (upstream #2982); the switch follows Auto Sync (every selected raw in one undo step), Settings ▸ Import ▸ AI Denoise from (ISO) switches it on at import, and a job over many photos is one batch row with the time left and its failures (upstream #2932); from process V6 the Amount eases in (`1 − (1 − a)³`, 50 leaves ~0.17 of the noise σ; not yet compared with Lightroom on a real high-ISO raw) | | LR-EDIT-DETAIL-RAWDETAILS | Improved demosaic toggle | P2 | 🟡 | `cmd:enhance.rawDetails`, `crates/raw/src/demosaic/detail.rs` | Photo ▸ Enhance ▸ Raw Details: a new linear DNG (`-Enhanced-RD.dng`) demosaiced by gradient-weighted Hamilton–Adams green and edge-aware residual red/blue (own design after GBTF 2010 and residual interpolation 2013); +13 dB over bilinear, +1.5 dB over AHD, ¼ of bilinear's false colour on the procedural edge scene; Bayer only (X-Trans keeps the directional method); not a learned model, no fidelity check against Lightroom; no dialog | | LR-EDIT-DETAIL-SUPERRES | Super resolution | P2 | 🟡 | `cmd:enhance.superResolution`, `crates/merge/src/superres.rs` | Photo ▸ Enhance ▸ Super Resolution: Raw Details, then 2× per side by iterative back-projection (Irani & Peleg 1991) with a 3×3 range guard against ringing, into `-Enhanced-SR.dng`; raws and other photos; +3 dB over bicubic on a downsampled procedural scene; ≤ 400 MP out. With an installed upscaler (Real-ESRGAN General v3, BSD-3-Clause, opt-in `realesrgan-model` download, or any `rgbToRgb4x` ONNX; upstream #3493) the dialog also offers AI Super Resolution (`method: ai`, 2× or 4×, pure-Rust CPU/GPU, tiled, cancellable): the photo rendered as an export renders it (edits, crop and masks baked in) to sRGB, Display P3 or Adobe RGB (`space`), into a new 16-bit `-Enhanced-SR.tif` stacked with it, ≤ 110 MP out; the result is not an editable raw (Lightroom keeps a raw a raw) | | LR-EDIT-DETAIL-AISHARPEN | AI sharpen | OOS | 🟡 | `cmd:enhance.aiSharpen`, `crates/engine/src/enhance.rs`, `docs/super-resolution.md` | beyond Lightroom (upstream #3493): Photo ▸ Enhance… ▸ AI Sharpen, the installed upscaler's 4× answer averaged back to the photo's size (finer detail and slight defocus, not motion blur), rendered with the photo's edits into a new 16-bit TIFF stacked with it; needs an upscaler (`realesrgan-model` or one's own `rgbToRgb4x` ONNX) | diff --git a/docs/raw-parity.md b/docs/raw-parity.md index 597d65a9e1..1620fb766b 100644 --- a/docs/raw-parity.md +++ b/docs/raw-parity.md @@ -1,6 +1,6 @@ # RAW parity: cameras, formats, demosaic, colour and lens profiles -> **Last updated:** 2026-11-25 · **Change:** minor (highlight reconstruction: inpaint opposed and guided Laplacian from darktable, `sensor.highlightMode`); minor (CRX partial subbands, multi-tile 0x200 and adaptive low-frequency gains decode, ported from LibRaw `crx.cpp`; synthetic tests only; CR3 0.6 → 0.7); minor (ARW6 12-bit mode decodes when its tile headers match the verified variant; synthetic files only); minor (verification drive, plan 3.8: Sony SRF (DSC-F828 verified, DSC-V3) and the upright FinePix S200 EXR RAF decode; 47 more Olympus / OM bodies verified by a bulk check: 645 verified (45%), 89% of photographers on a verified body; the 60% / 95% verification target is not met); minor (Nikon NEFX, the merged pixel-shift image from NX Studio, decodes: five 16-shot Z 8 files; other shot counts and bodies unverified); minor (CR2 in-camera aspect crop from `AspectInfo`); patch (upstream #3097: CR3 white level at the sensor's saturation point, #2053); minor (upstream #2926: X-Trans demosaic, classified LMMSE green + residual interpolation); minor (Kelvin white balance for Canon ColorData presets and the Nikon Z5II; upstream: integration batch 36 and the camera-coverage sweep #1327, 545 models verified upstream; re-measured after the merge: 596 verified; Canon EOS R6 verified: 315 verified, use-weighted ~90%; Canon CRW decoded, 15 bodies verified; Epson ERF and Mamiya MEF decoded, 4 bodies verified: 314 verified, use-weighted ~90%; compressed ORF decoded: E-M1 and E-M10 Mark III verified; use-weighted 85% → 87%; compressed Samsung SRW 32770 / 32772 / 32773 decoded, 7 bodies checked; Minolta MRW decoded, 6 bodies verified; ARW version 1 and the Z 6II's packed NEF decode, 31 popular bodies verified: use-weighted 87% → 89%, 57% on verified bodies; Z 8 and Z 9 lossless verified: 280 verified, 59% on verified bodies; pre-X FinePix SuperCCD RAF decoded (`raf_superccd.rs`), 15 FinePix bodies verified: 295 verified, Fujifilm 93% → 99%, 60% on verified bodies); upstream: lossy JPEG XL DNG tiles with a non-linear declared transfer curve decode; X-Trans CMOS 4 bodies take the X-T3's spectral matrices · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 (Camera Raw 18.7) +> **Last updated:** 2026-11-29 · **Change:** minor (AI denoise reaches X-Trans through an RGGB re-mosaic, upstream #1828); minor (highlight reconstruction: inpaint opposed and guided Laplacian from darktable, `sensor.highlightMode`); minor (CRX partial subbands, multi-tile 0x200 and adaptive low-frequency gains decode, ported from LibRaw `crx.cpp`; synthetic tests only; CR3 0.6 → 0.7); minor (ARW6 12-bit mode decodes when its tile headers match the verified variant; synthetic files only); minor (verification drive, plan 3.8: Sony SRF (DSC-F828 verified, DSC-V3) and the upright FinePix S200 EXR RAF decode; 47 more Olympus / OM bodies verified by a bulk check: 645 verified (45%), 89% of photographers on a verified body; the 60% / 95% verification target is not met); minor (Nikon NEFX, the merged pixel-shift image from NX Studio, decodes: five 16-shot Z 8 files; other shot counts and bodies unverified); minor (CR2 in-camera aspect crop from `AspectInfo`); patch (upstream #3097: CR3 white level at the sensor's saturation point, #2053); minor (upstream #2926: X-Trans demosaic, classified LMMSE green + residual interpolation); minor (Kelvin white balance for Canon ColorData presets and the Nikon Z5II; upstream: integration batch 36 and the camera-coverage sweep #1327, 545 models verified upstream; re-measured after the merge: 596 verified; Canon EOS R6 verified: 315 verified, use-weighted ~90%; Canon CRW decoded, 15 bodies verified; Epson ERF and Mamiya MEF decoded, 4 bodies verified: 314 verified, use-weighted ~90%; compressed ORF decoded: E-M1 and E-M10 Mark III verified; use-weighted 85% → 87%; compressed Samsung SRW 32770 / 32772 / 32773 decoded, 7 bodies checked; Minolta MRW decoded, 6 bodies verified; ARW version 1 and the Z 6II's packed NEF decode, 31 popular bodies verified: use-weighted 87% → 89%, 57% on verified bodies; Z 8 and Z 9 lossless verified: 280 verified, 59% on verified bodies; pre-X FinePix SuperCCD RAF decoded (`raf_superccd.rs`), 15 FinePix bodies verified: 295 verified, Fujifilm 93% → 99%, 60% on verified bodies); upstream: lossy JPEG XL DNG tiles with a non-linear declared transfer curve decode; X-Trans CMOS 4 bodies take the X-T3's spectral matrices · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 (Camera Raw 18.7) Raw processing is the deepest single dimension of Lightroom parity: a photographer whose camera does not decode, or decodes with the wrong colour, cannot switch. This document measures it model by @@ -216,7 +216,7 @@ sample files. A pointer for contributors, not legal advice. | Crop masks and aspect | ✅ | DefaultCrop, Sony recorded size, Canon AspectInfo, Panasonic in-camera crops, Nikon CropArea, measured Nikon bodies without it (D4, D90, D5000, D600, D610) | 🟡 7RM3 / 7RM4 crop origin 8–32 px off (cosmetic) | | Lens metadata | ✅ read for profile selection | EXIF lens fields read; used only for the in-file corrections below | 🟡 | | Highlight reconstruction | ✅ | neutral clip, chromaticity diffusion (`highlight.rs`); inpaint opposed and guided Laplacian from darktable (`highlight/opposed.rs`, `highlight/laplacian.rs`, `sensor.highlightMode`) | 🟡 tuned by eye | -| AI denoise | ✅ Bayer and X-Trans, model bundled | Bayer only, user-installed weights, pure-Rust CPU / GPU | 🟡 no X-Trans, no shippable weights | +| AI denoise | ✅ Bayer and X-Trans, model bundled | Bayer natively; X-Trans and other non-Bayer layouts through an RGGB re-mosaic; user-installed weights, pure-Rust CPU / GPU | 🟡 no shippable weights; the model is trained on Bayer sensors and unmeasured on a re-mosaiced one | | Super Resolution | ✅ | — | ⬜ | | HDR / panorama merge to raw DNG | ✅ | linear DNG (float16 HDR) with the source's colour tags | ✅ | | Convert to DNG | ✅ | uncompressed or LJ92 tiles (`dngwrite.rs`) | ✅ (no lossy DNG) | diff --git a/docs/upstream-pr-reviews/ledger.md b/docs/upstream-pr-reviews/ledger.md index 56f68d810a..dbf2e30df1 100644 --- a/docs/upstream-pr-reviews/ledger.md +++ b/docs/upstream-pr-reviews/ledger.md @@ -45,6 +45,8 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | #1048 | open | chore: add bug, feature, and performance issue forms | SKIP | - | Upstream's GitHub issue forms (their product name and triage flow); Chromaforge has no ISSUE_TEMPLATE and uses CONTRIBUTING.md. | ``f9549e9093`` | 2026-11-08 @ de096566ff | - | | #1063 | open | LR-PROF-IMPORT: import the user's own DNG camera profiles (.dcp) | SKIP | - | Chromaforge already imports a person's own .dcp (fork 344a04f7a, camera.listDcp, crates/raw/src/dcp.rs, camprof dcp writer); 45 files overlap fork-owned engine/UI; its D750 CC0 Lightroom comparison corpus is not needed | ``408636ab5fd5`` | 2026-11-05 @ 0b5e6c7a06 | - | | #1065 | merged | GPU-FULL: more of the render on the GPU, loupe drafts from GPU textures | SKIP | - | Already in Chromaforge: its author (OneSlips) ported the whole GPU-FULL series into the fork as the OS-gpu-perf / OS-gpu-window commits (v26.45.2) and closed the upstream PR saying so (2026-11-05 01:02); the maintainer merged it 3 h later unchanged. | ``9bfc34733b`` | 2026-11-06 @ 8a0b91a95c | - | +| #1069 | open | Normalize DNG black levels per plane with finite-range guards | PENDING | fork numbers; #1068 | Changes pixels on DNGs with non-uniform blacks (per-plane max instead of mean); needs a corpus measurement and a render-cache bump; sil has no such DNG. Upstream says #1068 first. | `e211776001` | 2026-11-29 @ 2d62488dd2 | - | +| #1079 | open | Reject stale mask results and disclose approximate selections | PENDING | split port | 684 lines over ~23 files mixing Rust 1.95 clippy fixes with stale-segment rejection and a new Masking notice string; port by concern. | `9922a180f5` | 2026-11-29 @ 2d62488dd2 | - | | #1095 | open | Import: what the photos themselves carry can be left in the files | PENDING | upstream approval | Useful per-kind import read choice (keywords, ratings, titles, location, develop settings), but CONFLICTING, 1.2k lines across fork-owned catalog/ui-egui/import, unresolved AlexChambers (sync read choices must stay fixed per import) and CodeRabbit findings, no maintainer review; revisit as an own-design port once settled. | ``7227ccb9bf`` | 2026-11-08 @ de096566ff | - | | #1115 | open | LR-EDIT-OPTICS-PROFILE: Sony ILCE-7RM6 lateral CA corrected on the raw mosaic before demosaic | PENDING | undrafted / ready | Sony ILCE-7RM6 lateral CA corrected on the raw mosaic before demosaic (red/blue sites resampled from same-colour taps; applied only to lenses measured to improve, CA_IMPROVES); approved by FredApps and CI green, but still a draft, and it changes every ARW render (cache bump) and the fork's own decision (8c64c467f) kept the Sony CA planes off by default. | ``4420b0b5330e`` | 2026-11-08 @ de096566ff | - | | #1117 | open | Auto Import: option to include subfolders of the watched folder (#1109) | ADOPT | - | Taken in the fork's own form: Settings ▸ Import ▸ Auto Import gains Include subfolders (off by default), listed through the bounded folder walk (16 levels, 200,000 entries, hidden entries and the library folder skipped, folder links entered once so loops end, unreadable subfolders skipped; subfolders list supported photo types only, the top level lists every file as before). The fork's own `auto_options` setting and the walk replace upstream's `listingWarnings` and `prefs.json` key; the same change adds file naming, develop preset, metadata preset and keywords for arriving photos. | `edef73d86a` | 2026-11-11 @ a974417dc | (this PR) | @@ -56,12 +58,14 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | #1159 | open | test(gpu): preserve active markers across nested panics | ADOPT | - | Adds the missing nested-panic regression test for the GPU init marker (inner scope panics while an outer scope is active); no product code. Adapted to the fork's slot-based with_marker_in; passes. | ``7c70fb74da`` | 2026-11-08 @ de096566ff | `985c64662` | | #1162 | closed | M11: decode lossless Olympus and OM System ORF | SKIP | - | Closed 2026-11-08: its author split it into #3944, #3939 and #3964 (see their rows); #3939 is ported, the decoder part is still the competing Olympus decoder. | `d0b966a0fe` | 2026-11-09 @ 7e2b8a6b27 | - | | #1181 | open | LR-BEHAV-RENDER-FIDELITY: tools/render_fidelity.py measures single-slider responses against your own Lightroom exports | PENDING | upstream approval + a maintainer wanting a second Lightroom-comparison tool | Stand-alone 4k-line Python tool and docs (no product change): pairs a person's own Lightroom exports with raws and scores slider responses. Overlaps the fork's `calibrate-lightroom` fit/add flow, drives upstream's CLI name, and has no maintainer review; not read line by line, so not taken. 2026-11-17: head moved (main merges / follow-ups), decision unchanged. | `a3d1698b34` | 2026-11-17 @ aa08a77060 | - | +| #1204 | open | LR-IMP-DRAGDROP: photos opened from Finder or other apps reach LightCraft on macOS (#506) | ADOPT | - | Fork had no CFBundleDocumentTypes and no openURLs handler. Hand-ported as the new unsafe helper crate crates/opendocs (named in AGENTS.md), reusing objc2 already in Cargo.lock; files go through the fork's drop path. Clippy cross-checked for aarch64-apple-darwin; not run on a Mac. Upstream's library-problem commits not needed (fork's hold_dropped). | `48d4a4332f` | 2026-11-29 @ 2d62488dd2 | `589ae0254` | | #1206 | open | LR-PROF-CAMERACOLOR: dark, muted scenes learn their matrix | PENDING | #784 lands | Merges only; stacked on unapproved #784 2026-11-25: head moved (re-read by the monitor; main merges or follow-ups), decision unchanged. | `1f6cc72b91` | 2026-11-25 @ ddc0eef377 | - | | #1208 | open | LR-META-EXIF-FULL: HEIC/HEIF/AVIF EXIF and XMP | ADOPT | - | Merges only; own commits unchanged; fork port complete | `ea5416d2e92a09f98e5231da5411e426affc72d2` | 2026-11-15 @ 80de5f8fae | `456ec0cca` | | #1221 | open | HDR display: show HDR edits in HDR on HDR displays (Linux; macOS EDR next) | PENDING | CI green and egui pin in storytold/egui | Red CI (Git dependencies job): pins every egui crate to a personal fork (JordyUSA/egui) for prefer_hdr, a supply-chain item FredApps would not approve; Chromaforge already ships HDR (crates/hdrmeta, all 3 OSes); only the loupe HDR rendition idea might be worth comparing later. Re-read 2026-11-11: head moved by a merge of main only; CHANGES_REQUESTED and the egui pin question stand. 2026-11-25: head moved (re-read by the monitor; main merges or follow-ups), decision unchanged. | `342cbc0bf1` | 2026-11-25 @ ddc0eef377 | - | | #1209 | open | Show Fujifilm film-simulation settings from the MakerNote | PENDING | own-design port with a catalog format bump | Useful (Info panel and CLI/MCP show film simulation, DR, Copy recipe; crates/meta/fuji.rs is portable), but storing the recipe needs a catalog format bump and changes in crates/catalog and ui-egui, which the fork owns (upstream format 13 vs the fork's 16); open AlexChambers cache-key finding. The parser alone has no consumer. | ``35ad3a1f9f`` | 2026-11-08 @ de096566ff | - | | #1243 | open | LRC-LIB-LIBFOLDERS: Folders skips the folders that only lead to your photos, with Show Parent Folder to list them | SKIP | - | Fork already draws Folders without the lead-only chain (sidebar_folders in ui-egui left.rs: a folder with no photo, no label and one child gives its row to the child) and has Show Parent Folder (switches the source to the parent); only the persisted Hide This Parent list is missing, a UI nicety on fork-owned paths. | ``59944f6e9beb`` | 2026-11-05 @ 0b5e6c7a06 | - | | #1244 | open | Sidebar: the row of what is shown has a bar, and a folded section says what it holds | SKIP | - | Only crates/ui-egui panels and locale catalogs: fork-owned UI (the Modern layout sidebar was rewritten); no shared logic | ``77b0863f1f`` | 2026-11-05 @ 0b5e6c7a06 | - | +| #1261 | open | Make a positive paint vignette blend toward white. | ADOPT | - | Fork's positive Paint overlay equalled the Color lift. Hand-ported in pipeline finish.rs: blends toward white (0.18 grey at amount 100 in the corner: 0.877 -> 1.0 linear); other styles and signs unchanged; sil 9 passed. #980 not touched. | `41ebe6dd08` | 2026-11-29 @ 2d62488dd2 | `027178033` | | #1348 | merged | Colour noise reduction: joint linear chroma filter with speck brake, CPU and GPU (#815) | ADOPT | - | merged 3943279105; joint chroma NR; fix NRV2_GPU_BAND_MB prefix, use lcc-gpumem not nvidia-smi, measure first. Ported in the next PR, Process V8 (#1348, #3783 and #3509 change existing renders together under one process version) | ``f2d051cbee`` | 2026-11-06 @ 8a0b91a95c | `0a99b96be` | | #1374 | open | LR-PREF-INTERFACE: text sizes have names, the seven type roles of the theme | SKIP | - | Only crates/ui-egui (Settings dialogs, panels, theme); upstream-owned paths the fork rewrote. | ``b341826e11`` | 2026-11-04 @ 03e03f382e | - | | #1384 | closed | LR-EDIT-OPTICS-PROFILE: enable Sony ILCE-7M3 (A7 III) embedded distortion correction | SKIP | - | Closed as superseded by #3144; already in the fork as c98908977 (ILCE-7M3 in DISTORTION_MODELS). | ``ede4eb70dd8f`` | 2026-11-05 @ 0b5e6c7a06 | - | @@ -79,14 +83,19 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | #1626 | open | LR-BEHAV-SIDEBAR-COLLAPSE: the sidebar's trees open as they were left | SKIP | - | Only crates/ui-egui sidebar/state; the fork has its own sidebar. Idea (persist tree open state) noted, no trapped shared fix. | ``3d28e091ef`` | 2026-11-04 @ 03e03f382e | - | | #1631 | open | LR-BEHAV-SIDEBAR-SECTIONS: Option-click on a triangle opens or folds the whole branch (stacked on #1626) | SKIP | - | Only `crates/ui-egui` left panel (upstream-owned paths), stacked on unmerged #1626, +1863 lines; Chromaforge's panel is its own design | ``0d0456315d`` | 2026-11-04 @ 03e03f382e | - | | #1635 | open | LR-IMP-DEVICE: import from PTP cameras on Windows and macOS (#1005, includes #1169) | WATCH | upstream approval | One new commit fixing a CodeRabbit finding (a staged camera file always leaves the temp folder on Copy/Move, `camera_import::is_staged`, job.rs guard, test `a_staged_camera_file_leaves_the_temp_folder`); nothing changes the ledger's blockers (3.4k lines, ~95 unsafe in new crates/cameras, includes open #1169, no approval). Re-read 2026-11-08: head moved (refresh); decision unchanged. Re-read 2026-11-11: unchanged. | `1288a2923f6b30cf93328d827fbf09bf6e3e162d` | 2026-11-11 @ c2e9c456c9 | - | +| #1638 | open | Avoid rescanning overlapping photo and preset import roots | ADOPT | - | Adapted onto the fork's walk.rs: opt-in walk::files_in_with_seen with a shared canonical-folder set, used by import expansion and preset.import. Portable nested-root tests instead of upstream's Unix symlink CLI tests. | `29d7283572` | 2026-11-29 @ 2d62488dd2 | `d30dfd4f3` | | #1639 | open | Preserve Survey groups and make photo removal reliably clickable | ADOPT | - | Filmstrip half ported (plain Survey filmstrip clicks add or activate, keeping the group; headless test). The remove-button half was already in the fork (contains_pointer, surveyRemove widget) | ``1c0d090260`` | 2026-11-04 @ 03e03f382e | `c0c67b307` | | #1649 | open | LR-BEHAV-BG-TASKS: an export or import that ended stays in the list under the bell (stacked on #1642 and #3151) | SKIP | - | stack on fork-owned bell/locales; the fork's activity stack already keeps finished-batch summaries (`Activity::finished`) and has its own panel | ``8c2311c6c9`` | 2026-11-04 @ 03e03f382e | - | | #1674 | open | [agent] Top bar and sidebar buttons show hover feedback and the pointing hand | ADOPT | - | icon_button shows the pointing hand and the full hover fill (hand port, fork commit 32cde9305) | ``b4feea9d43`` | 2026-11-04 @ 03e03f382e | ``32cde9305`` | | #1700 | open | LR-VIEW-HDR-DISPLAY: HDR edits show in HDR on HDR displays | SKIP | - | Already in Chromaforge (hdrmeta crate, apps/app/src/hdr_display.rs, Wayland metadata; fork commit 5ceee3327 fixed follow-ups; HDR confirmed on all 3 OSes); upstream PR is conflicting and unchanged in intent. | ``de0bd390c5`` | 2026-11-05 @ 0b5e6c7a06 | - | +| #1704 | open | Export: Original and DNG follow the metadata setting (#1505) | SKIP | upstream changes what an Original's own file may carry | Already the case in the fork: FX-137 (`export_packet`) makes the Original sidecar and the DNG packet follow the Metadata choice, keyword export options included. Not adopted: refusing an Original whose own file embeds excluded metadata; the fork copies the file as it is and says so in the manual (a camera original would be refused under every choice but All). A hand-port (`fd1730607`) was made on `main` and dropped when the round was merged onto `staging`. | `711a90e6fc` | 2026-11-29 @ 2d62488dd2 | - | | #1711 | open | LR-BEHAV-BG-TASKS: a background task says how it ended; the engine's own jobs do (part 1 of 3) | PENDING | upstream approval | Unchanged head; conflicting, unapproved, part 1 of 3 and must be read against the fork's activity stack (TaskGuard rule, shared AI backend row) | ``1233e35b2035`` | 2026-11-08 @ de096566ff | - | | #1735 | open | LRC-LIB-CATALOG-IMPORT: catalogs import in batches | LEARN | - | Merges only; approval stands; hand-port plan unchanged | `346d500136d54aa1519ea4aefca1a5d2749de752` | 2026-11-15 @ 80de5f8fae | - | +| #1736 | open | fix(control): bound synthetic UI events and protect input queue | ADOPT | - | Fork already bounds count/steps per request (bounded_arg); ported only a cap on the whole pending queue (4096; a lone release may pass) with a hostile-input test. | `3700d257c8` | 2026-11-29 @ 2d62488dd2 | `d423abe82` | | #1775 | open | LR-IMP-MOVE: Sync the copy's folder before removing the original (#1501) | SKIP | - | Already in Chromaforge: ccbe8b6e3 ported it (sync_dir, create_dir_durable in import_move.rs; sync before removal in rename.rs move_across_volumes). Upstream head still has unresolved blockers (per-photo sync cost, failing gate). | ``1ff734e9cc`` | 2026-11-05 @ 0b5e6c7a06 | - | | #1812 | open | LR-EDIT-DETAIL-DENOISE: RawNIND weights under CC BY 4.0, offered by default (#1760) | ADOPT | - | RawNIND weights dual-licensed CC BY 4.0; ported the licence metadata, provenance and tests. The `rawnind-model` default flip was withheld — upstream calls it a maintainer decision and so does the fork | `46f4596465` | 2026-11-16 @ a4676b1249 | d4f2f0d10 | +| #1828 | open | Denoise X-Trans raws through an RGGB re-mosaic | ADOPT | - | Fork's AI denoise refused X-Trans. Cherry-picked with conflicts resolved: re-mosaic tests compare with Method::Ppg, fork's repair_pixels kept. Bayer renders unchanged; RGGB round-trip PSNR 56-57 dB smooth / 33 dB edgy. Gap 11 narrowed. | `19c4c6d76b` | 2026-11-29 @ 2d62488dd2 | `e3b59f20c` | +| #1837 | open | macOS: open photos from Finder, the Dock and Open With | SKIP | - | Superseded by #1204's port: it needs the external fmv-macos-events crate for its unsafe code, which AGENTS.md doesn't allow; its quit-event handling is not ported. | `719bf0c952` | 2026-11-29 @ 2d62488dd2 | - | | #1907 | closed | LR-META-XMP: Write automatic XMP sidecars off the UI thread in the desktop app | LEARN | - | already in ledger (archive LEARN): background sidecar writer keeps saves off the UI thread; fork still writes inline (no `sidecar_writer`). Now closed unmerged upstream | ``78efb8f791`` | 2026-11-02 | - | | #1938 | closed | Files on an SMB share: imports, moves and sidecar backups use the fsync fallback too | SKIP | - | already in ledger (archive SKIP): duplicate, fork has it (fork #375, `crates/sysmem` fsync fallback). Closed as draft | ``4529335dd9`` | 2026-11-02 | - | | #1995 | open | Import: preserve embedded rating, flag and label from file metadata | SKIP | - | The Rating 65535 read fix (rejected, not five stars) is ported from craft-libs #967 (9b501b761); writing Rating stays out. Earlier: already in Chromaforge: e4daa22ff carries the first version (rating, flag, label from embedded metadata on import). The PR head (now APPROVED) was reworked to drop embedded develop settings of rendered files and merge partial sidecars, which contradicts adopted #3607 (embedded develop in a JPEG applies). | `52d9ca0ea4` | 2026-11-16 @ a4676b1249 | - | @@ -158,7 +167,7 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | #2653 | open | Detail view: zoom to 1600 % (#2652) | SKIP | - | UI-only (state::MAX_ZOOM, detail panel, bottom bar): ui-egui is fork-owned (Modern layout); the fork picks its own zoom limits. | `22ecbd25a3` | 2026-11-16 @ a4676b1249 | - | | #2659 | open | LR-META-LOCATION: place names always download into the settings folder (#2575) | SKIP | - | already ported | ``9a2aa7c471`` | 2026-11-04 @ 03e03f382e | ec5296285 | | #2661 | merged | LR-EDIT-LENSBLUR: camera-like Lens Blur with AI subject focus and per-mask bokeh | LEARN | - | Read in full at the squash `1a301fc2d` and ported whole in fork PR #1500, which was closed unmerged: the fork's own depth-based Lens Blur (PR #1498: depth model or Subject fallback, focus picker, bokeh shapes) had landed first under the same `DevelopSettings.lens_blur`, `lensBlur.*` controls and `lens_blur.rs`, and its depth map replaces upstream's two-depth focus (subject / focus mask / fixed shapes, Transition, Find Subject). Taken in the fork's form, onto the depth renderer: Boost (highlight gain before the spread), Focus / Blur brush refinement (strokes overrule the depth) and the per-mask Lens Blur block (Selection / Outside, Blur Amount, Boost; without upstream's per-mask Transition). No catalog format bump | `eb23b178c6` | 2026-11-25 @ ea033fbe1c | `0e45c1889` | -| #2675 | open | LR-PROF-CAMERACOLOR: align lens-corrected camera JPEG training pairs | WATCH | upstream approval | Author merged main several times and then narrowed the PR (bd3ee7ea8d "narrow standalone color geometry scope"): the activity-totals UI commit fbb318a83a was reverted out, diff vs main is now 18 files in engine (camera_preview colour/proxy, camera_profiles, cmd/previews +344, lens_profiles +210, smart.rs lens_db header field + marker), merge/src/frame.rs (lens opcodes stripped after the colour callback) and a pipeline tests_light constant fix. Still bumps LOOK 13->14 and render cache 76->77, still unapproved, no before/after numbers. Re-read 2026-11-08: head unchanged, no approval or merge since; Recheck stands. 2026-11-17: new head adds DNG colour fits in stored sample space (8d45e43cf3); still needs fork numbers. 2026-11-25: head moved (re-read by the monitor; main merges or follow-ups), decision unchanged. | `344ac41e09` | 2026-11-25 @ ddc0eef377 | - | +| #2675 | merged | LR-PROF-CAMERACOLOR: align lens-corrected camera JPEG training pairs | PENDING | fork numbers | Merged 2026-11-27 (`c5eff6b2d6`); still a render change bumping LOOK/RENDER_CACHE (upstream 27/88, fork 29/94) with no before/after numbers. | `25a43773dc` | 2026-11-29 @ 2d62488dd2 | - | | #2676 | open | LR-EDIT-OPTICS-PROFILE: preserve unknown crop factors in lens profiles | ADOPT | - | Option crop factors were already carried (fork #536); ported the remaining tie-break: an exact score tie prefers the profile with a known calibration crop, with a test. | ``be6a90064f`` | 2026-11-08 @ b3b49987d4 | 0c9e63f91 | | #2707 | closed | LR-BEHAV-MULTISELECT: the model for choosing several sidebar rows with Cmd/Ctrl+click and Shift+click | SKIP | - | Closed with an empty diff, restacked as #3106, #3107, #3108 and #2757; model lives in `ui-egui`, which the fork rewrote (Classic sidebar) | ``ebe2477108`` | 2026-11-04 @ 03e03f382e | - | | #2733 | merged | LR-EDIT-OPTICS-PROFILE: Sigma 10-18 mm exception on the ILCE-6700 | SKIP | - | Already in the fork: ported with fork PR #529 (commit 3ef7db7ae, 'upstream PRs 2835, 2664, 2777, 2733'); LENS_EXCEPTIONS and Sigma 10-18 present in crates/raw/src/vendor/arw_lens_rm6.rs on origin/main. Upstream landed it via merge b4757824b (commits c1a1896d3, d1b272e49 docs). | ``b4757824b`` | 2026-11-05 @ 0b5e6c7a06 | - | @@ -443,7 +452,7 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | #3400 | merged | Never crash: a Samsung encryption key past i64::MAX doesn't overflow keyed() | ADOPT | - | Already in the fork (`wrapping_mul(sign)` in `crates/raw/src/vendor/srw.rs`, with its typed-entry test); the ledger row was stale | ``7597810299`` | 2026-11-04 @ 03e03f382e | 6f4a69b9b | | #3402 | merged | RAW.colour: fit the per-file look on the vignetting-corrected sensor | ADOPT | - | Fit the per-file look on the vignetting-corrected sensor. LOOK_VERSION 20->21, RENDER_CACHE_VERSION 76->77; unmeasured on the fork (upstream X-S10 dE00 2.71->2.55). | ``cabc9a3d21b8`` | 2026-11-05 @ 0b5e6c7a06 | 5bc88f079 | | #3403 | merged | LRC-LIB-CATALOG-SWITCH: files waiting for a library wait for a running import instead of being dropped (#2779) | ADOPT | - | Ported by hand: LccApp.waiting_import keeps the files while an import or Synchronize Folder runs and retries each frame; one test. Not ported: the toast, the quit prompt and library-switch guards. | ``a2d3698333`` | 2026-11-04 @ 03e03f382e | `352a140b7` | -| #3407 | open | fix: Fade deep shadows to grey when Blacks lifts the toe | WATCH | upstream merge (and #3266 V3 numbering) | Unchanged head; approved but a new process version (fork V3-V7 taken, would be V8 in sidecars) and a reviewer found no change on 34 public Sony raws; wait for upstream numbering Re-read 2026-11-11: unchanged. | `d19658e60d5c54161862d6c2de5b7d1cc49dd66a` | 2026-11-11 @ c2e9c456c9 | - | +| #3407 | open | fix: Fade deep shadows to grey when Blacks lifts the toe | WATCH | upstream merge (and process-version numbering) | One comment-only commit (7492729c5e); review now CHANGES_REQUESTED; still a new process version without fork numbers. | `7492729c5e` | 2026-11-29 @ 2d62488dd2 | - | | #3408 | merged | Control: pointer and scroll gestures refuse numbers past any screen instead of queueing NaN positions | SKIP | - | Control gestures refusing huge numbers already ported. | ``8d256db7a0`` | 2026-11-04 @ 03e03f382e | 9a9aac96f | | #3409 | merged | Issue #3405: Auto Import waits for an import that starts during its listing | SKIP | - | merged upstream but upstream-only (CI/packaging/docs/i18n) or fork-owned paths only | `2910705fa2` | 2026-11-02 @ 5a09d07530 | - | | #3410 | merged | Issue #3406: Auto Import says when it can't read the watched folder | SKIP | - | merged upstream but upstream-only (CI/packaging/docs/i18n) or fork-owned paths only | `b9ba9d4640` | 2026-11-02 @ 5a09d07530 | - | @@ -943,7 +952,7 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | #2645 | open | Zoom past 100% shows pixels, not a blur (#2643) | WATCH | upstream approval | Useful; owned ui-egui, a hand-port once vetted | `526fde2fa0b71326c2072af8d48a89b09883a4ae` | 2026-11-15 @ 80de5f8fae | - | | #2777 | merged | Fujifilm X-S20 lens corrections and matrices | SKIP | - | Already ported (3ef7db7ae) | `8ffe73cc3cef8019aa3571c639b17f98c09c1e87` | 2026-11-15 @ 80de5f8fae | - | | #2896 | merged | Preset Amount blends curves and profiles (#2669) | ADOPT | - | Core already in the fork (76c7abcdc: a new choice's strength fades in from 0, white balance on another scale taken whole; curve blending, the HDR blend base and the shared preview path came earlier). 2026-11-27: merged upstream (`95ada217da`); the remaining delta adopted: importing with a preset and the import default preset go through the same apply as `preset.apply` and the previews (a one-field white balance preset is prepared on the photo's scale, issue #2910), and Amount 0 without an import state returns before that preparation, so As Shot stays. Not taken: monotone-cubic evaluation in the curve blend (the fork blends piecewise-linear at the union of points; it changes the curves written at partial amounts, and there are no numbers). | `b2e8d74977` | 2026-11-27 @ 5973d956df | `d21affb32` | -| #4215 | open | Choose a raw's lens profile by hand (#1049) | WATCH | upstream approval | Large, unreviewed; real parity gain once vetted | `786330533ecf3d58cd7b1eba9de329298351e2cb` | 2026-11-15 @ 80de5f8fae | - | +| #4215 | open | Choose a raw's lens profile by hand (#1049) | LEARN | - | The fork has its own lens.choose / lens.db.photo (issue #307); porting would duplicate it. Borrow: the Lens field/column naming the chosen profile. | `202209aebf` | 2026-11-29 @ 2d62488dd2 | - | | #4216 | open | First edit lists an Import History step (#4203) | ADOPT | - | Ported early: the first edit lists an Import History step (Lightroom behaviour); history-group/headless tests adjusted | `e096283b47` | 2026-11-17 @ aa08a77060 | `04ddf14b7` | | #4222 | closed | codecs: shared GIF decoder | SKIP | - | craft-libs move (landed via #4231); nothing separable | `1666a8dd244863284cec63b92d1067593dcc3847` | 2026-11-15 @ 80de5f8fae | - | | #4223 | open | Validate album rule ids exactly | LEARN | - | Same f64 rounding in fork album_rule_id, only above 2^53; a 120-line exact parser not worth it now | `adb5da20e8619bceda669237692411b17f9a3de3` | 2026-11-15 @ 80de5f8fae | - | @@ -1025,14 +1034,14 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | #2381 | open | #2284: date files and the session clock in the host's time zone | LEARN | numbers | New time-zone dependency and an import-dating default change with no numbers | `bf20027304` | 2026-11-16 @ a4676b1249 | - | | #4283 | open | feat(library): stack RAW + JPG pairs automatically | PENDING | upstream picks #4046 or #4283 | Was unready (WIP); touches catalog/local.rs, fork-owned UI and the frozen whats-new.md 2026-11-25: marked ready for review, head unchanged; decision unchanged (no review, fork-owned paths). | `f13d25f618` | 2026-11-25 @ ddc0eef377 | - | | #4284 | open | cli: collect every calibration raw format (#4061) | ADOPT | - | Ported early: shared CALIBRATION_EXTENSIONS (adds rwl, crw, mrw; no dng); calibrate_lightroom keeps its own list | `bdc4faa835` | 2026-11-17 @ aa08a77060 | `ba869ddac` | -| #4285 | open | develop: keep a preset's white balance on one scale across amounts (#3917) | PENDING | threads resolved, numbers | Two real unresolved CodeRabbit threads; render change at amounts below 100 % with no numbers 2026-11-17: head moved (main merges / follow-ups), decision unchanged. | `9635119092` | 2026-11-17 @ aa08a77060 | - | +| #4285 | closed | develop: keep a preset's white balance on one scale across amounts (#3917) | SKIP | - | Closed by its author as covered by main's preset interpolation; the fork's scale_patch already takes white balance on another scale whole (#2896, 76c7abcdc). | `9635119092` | 2026-11-29 @ 2d62488dd2 | - | | #4286 | open | engine: faces.add and faces.remove commands (#4118) | PENDING | threads resolved | Unresolved: near-zero rect makes an empty region; remove on an unsearched photo lets the next search re-add it without undo 2026-11-17: head moved; check whether the near-zero rect and re-add threads are fixed (S/M candidate). | `d3c2c1e6fa` | 2026-11-17 @ aa08a77060 | - | | #4287 | open | tests: wait for the drive's reads before counting them (#3823) | SKIP | - | Test-only fix to a test Chromaforge does not have | `98b9c196e9` | 2026-11-16 @ a4676b1249 | - | | #4293 | open | LRC-LIB-CATALOG-IMPORT: captions come from AgLibraryIPTC too (#4043) | ADOPT | - | Hand-ported: the AgLibraryIPTC caption wins over the cached XMP packet's; test ported, docs + notes | `cf4027be34` | 2026-11-17 @ aa08a77060 | `8ea42505e` | | #4321 | open | LR-IMP-ADD-DIALOG: library.import reports what its folder walk skipped (#4319) | ADOPT | - | Ported early: library.import reports unreadable/unsupported files its folder walk skipped | `1169f1e847` | 2026-11-17 @ aa08a77060 | `14b97c6e6` | | #4323 | merged | Use coverage-aware deadlines for asynchronous UI checks | LEARN | - | Merged; test-deadline plumbing in upstream ui-egui. Idea only: coverage-aware deadlines if fork UI tests flake | `3a616261e3` | 2026-11-17 @ aa08a77060 | - | | #4329 | open | LR-FILT-TYPE: photo types from metadata (selfie, panorama, long exposure, screenshot, drone) | PENDING | upstream merge | Large catalog-model and query feature, unmerged; base of #4345 | `911c3fcace` | 2026-11-16 @ a4676b1249 | - | -| #4338 | open | Issue #3050: report non-rendering XMP bookkeeping apart from adjustments | PENDING | #4272 lands | Stacked on unmerged #4272; ui-egui part needs a hand-port | `3511bce5fc` | 2026-11-16 @ a4676b1249 | - | +| #4338 | open | Issue #3050: report non-rendering XMP bookkeeping apart from adjustments | PENDING | #4272 lands | Rebased (adds a singleton field-cap test); still stacked on open #4272. | `c5adc1583e` | 2026-11-29 @ 2d62488dd2 | - | | #4342 | open | LR-IMP-FORMATS: mark photos that have recorded depth (has_depth) | PENDING | upstream merge | Catalog-format field, unmerged; base of the Portrait/depth stack | `c215724db3` | 2026-11-16 @ a4676b1249 | - | | #4343 | open | LR-IMP-FORMATS: read the aperture chosen on the phone from iPhone Portrait photos | PENDING | #4342 lands | Stacked on #4342 | `66988a3cc2` | 2026-11-16 @ a4676b1249 | - | | #4344 | closed | LR-IMP-FORMATS: a HEIC's own XMP is read, not its depth map's or gain map's | SKIP | replacement PR | Closed unmerged (stacked, CodeRabbit red); look again at the aux-image XMP bug if a replacement appears | `1d636a186c` | 2026-11-16 @ a4676b1249 | - | @@ -1074,11 +1083,35 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | #2018 | merged | Workspace: rust-version 1.95 | SKIP | - | Empty diff when merged; the fork's workspace already declares `rust-version = "1.95"`. | `3f4ef77159` | 2026-11-27 @ 5973d956df | - | | #2194 | merged | MENU-BAR: every command has a place in the menus, and View drops from 63 rows | LEARN | - | Menu layout in upstream's menubar plus menu-path edits in engine command specs and 17 locales; the fork owns its menus (`menus.rs`, `lrc_menus.rs`). Idea: give every command a slot and keep the end-of-menu fallback empty with a test. | `4f2150f97f` | 2026-11-27 @ 5973d956df | - | | #2838 | merged | Lightroom import: keep compressed history-step and snapshot settings in the archive | SKIP | - | Already in the fork as its own change: fork #632 (d08f388ee) decodes compressed history steps and snapshots, with `tests_lightroom_history.rs` and `lightroom_fixture.rs`. | `93baba5a67` | 2026-11-27 @ 5973d956df | `d08f388ee` | +| #4444 | open | LR-VIEW-ZOOM: dragging a mask keeps the photo sharp (#1679) | ADOPT | - | region::SHARP_DRAG; the fork has three call sites in panels/detail.rs. Test brought over. | `3efa9c8cfd` | 2026-11-29 @ 2d62488dd2 | `4fc144152` | +| #4482 | open | Unbounded waits in preview, gpu and ui-egui tests get a time limit | ADOPT | - | Fork already had the preview and gpu halves; only three file_probe waits got the 60 s limit. | `7ad2873f56` | 2026-11-29 @ 2d62488dd2 | `9468923d8` | +| #4484 | open | LRC-PRINT-PAGE: the contact sheet's Paper box shows A4 / Letter, not a4 / letter | ADOPT | - | Hand-ported into panels/dialogs.rs with a test. | `e35ef9cf60` | 2026-11-29 @ 2d62488dd2 | `cb32ba309` | +| #4490 | open | body_corpus compares the X100VI mosaic with its camera JPEG unrotated | SKIP | - | Already so in the fork: body_corpus decodes the camera JPEG with zune_jpeg, which never applies orientation. | `7127eb77e8` | 2026-11-29 @ 2d62488dd2 | - | +| #4497 | merged | MCP: export's bitDepth has no integer enum, which Gemini refuses (#4496) | ADOPT | - | Integer enum removed, values in the description; upstream's strings-only enum test ported. | `c498a457dd` | 2026-11-29 @ 2d62488dd2 | `2291eae7b` | +| #4528 | open | #4527: preserve JPEG XL options in MCP export | ADOPT | - | The forwarded-key list lacked jxlLossless/jxlEffort/jxlProgressive; upstream test ported. | `29ed08e4b7` | 2026-11-29 @ 2d62488dd2 | `acc72a1a9` | +| #4535 | open | 4534: fix Rust 1.95 Clippy in camera-profile lookup | SKIP | - | The negated is_some_and line doesn't exist in the fork's camera_profiles.rs; clippy clean. | `58e8bbc7c1` | 2026-11-29 @ 2d62488dd2 | - | +| #4538 | open | `lightcraft-cli mcp FOLDER` keeps serving when the folder has no photos | ADOPT | - | Fork's apps/cli/src/lib.rs sent an empty path list to library.import and quit. Hand-ported with the e2e test (apps/cli/tests/mcp_empty_folder.rs). | `f36066e591` | 2026-11-29 @ 2d62488dd2 | `be29ce402` | +| #4565 | open | fix(import): normalize preset and import keywords | ADOPT | - | Hand-ported into the fork's import.rs apply_settings; upstream's import_keywords integration test ported. | `7513c92765` | 2026-11-29 @ 2d62488dd2 | `8421e3969` | +| #4568 | open | fix(keywords): reject malformed saved-set slots | ADOPT | - | Cherry-picked both commits; test renamed to lcc_. | `463e2c4fcd` | 2026-11-29 @ 2d62488dd2 | `0519c8df8` | +| #4572 | open | fix(print): report oversized cell pages without overflow | ADOPT | - | Fork had c.page + 1 on a u32 in print/layout.rs. Hand-ported with upstream's page_overflow_tests. | `6b61d0ef9a` | 2026-11-29 @ 2d62488dd2 | `71e926cec` | | #4608 | merged | deps: update candle to 0.11.1 to move zip past GHSA-m665-v7pm-7grj | ADOPT | - | The fork already avoids the critical zip 7 advisory: its vendored candle-core 0.9.2 uses zip 9 (`vendor/candle-core`). But the lockfile had zip 9.2.2, still under the two later zip advisories the PR names (GHSA-h5xf-qc2v-94w6, fixed 9.2.0; GHSA-fpwh-q2m5-vfm2, fixed 9.2.3). Taken: `cargo update -p zip` to 9.8.2 (adds constant_time_eq 0.6.2). The candle 0.11.1 bump itself is not taken; the vendored patch stays. | `76bcfaae45` | 2026-11-27 @ 5973d956df | `88a4038e0` | +| #4622 | open | Slideshow: skip photo effects when there is no photo | ADOPT | - | Applied cleanly with its test. | `6a381bddad` | 2026-11-29 @ 2d62488dd2 | `9ddf4c3d5` | +| #4627 | open | Reject malformed preset IDs before exporting | ADOPT | - | Hand-ported into preset_files.rs export(): an explicit ids must be an array of strings. Test in tests_export.rs. | `d07606c65b` | 2026-11-29 @ 2d62488dd2 | `c7fa4cad0` | +| #4628 | open | Preserve absolute filesystem roots in Local browse | ADOPT | - | Trimming turned C:\ and / into broken roots. Hand-ported import::browse_folder_string with unit tests, used in cmd/browse.rs and two ui-egui call sites. | `e13354cb52` | 2026-11-29 @ 2d62488dd2 | `c224702d1` | +| #4633 | open | fix(proof): preserve the selected ICC profile path | ADOPT | - | Cherry-picked: proof::load no longer trims the picked path. | `24f5683eb8` | 2026-11-29 @ 2d62488dd2 | `530afa632` | +| #4653 | open | fix(#4652, #4658): Select revealed photos in the Linux file manager | ADOPT | - | Hand-ported into apps/app/src/reveal.rs (zbus already a Linux dep): FileManager1.ShowItems with a 2 s timeout, xdg-open spawned without waiting (the freeze), Services::reveal_many. Not run on Linux. | `0b2744eddb` | 2026-11-29 @ 2d62488dd2 | `79f41fbdf` | +| #4663 | open | feat(#4662): Add LIGHTCRAFT_DISABLE_UPDATES opt-out for update checks | ADOPT | - | _DISABLE_UPDATES via lcc_brand::env: update.check refuses, start-up check skipped, Help > Check for Updates greyed with a reason (17 fork catalogs). Nix wrapper sets it (not evaluated). | `0ee1391957` | 2026-11-29 @ 2d62488dd2 | `da85582c9` | +| #4684 | open | Expand subfolder tokens for each exported photo | PENDING | fork token subfolders | Makes upstream's {token} subfolders expand per photo; the fork's export subfolder is one plain name without tokens (subfolder_problem). Token subfolders first. | `801c76bf21` | 2026-11-29 @ 2d62488dd2 | - | | #4695 | merged | ui-egui, catalog: name the camera above the Edit header | LEARN | - | Edit panel shows a cleaned-up camera name (maker words dropped, maker not said twice). The edit panel is fork-owned ui-egui; the name cleanup in `crates/catalog/src/model.rs` would need its own home in the fork. A feature to port by hand if wanted. | `339b0d72e4` | 2026-11-27 @ 5973d956df | - | +| #4716 | open | engine: move a shared stem XMP sidecar only with the photo that owns it (#4713) | PENDING | dedicated hand-port | About 590 lines assuming upstream's split rename/{moves,plan,sidecar}.rs; the fork still has one rename.rs, and it changes undo entries. Real raw+JPEG data bug: needs its own port. | `21dbfee808` | 2026-11-29 @ 2d62488dd2 | - | | #4720 | merged | UI: export watermark Position is a 3x3 grid | ADOPT | - | The fork's Edit Watermarks dialog had the same single row of nine arrows (`choices`). Hand-ported as a 3 x 3 grid in `panels/dialogs.rs`, same widget ids, checked in a headless screenshot. | `94b2e94744` | 2026-11-27 @ 5973d956df | `5b0ec87be` | | #4723 | merged | packaging(linux): support co-installable nightly packages | SKIP | - | Upstream's nightly packaging, signing and launcher (apps, workflows, assets); the fork has its own nightly channel and packaging. | `5a20f060c9` | 2026-11-27 @ 5973d956df | - | +| #4729 | open | LR-META-XMP: an older process version's untouched defaults are not an edit | ADOPT | - | Cherry-picked; an import-time read only, existing catalog renders unchanged. | `cae6cf087f` | 2026-11-29 @ 2d62488dd2 | `0a4024ad0` | +| #4730 | open | engine: report final slideshow PDF bytes (#4715) | ADOPT | - | Hand-ported: bytes read from file metadata after the fork's sync_file; upstream asserts added. | `6e99e5e8b3` | 2026-11-29 @ 2d62488dd2 | `d5b22ebc0` | +| #4737 | open | mcp: continue exports after missing originals (#4714) | ADOPT | - | Hand-ported in mcp/headless.rs (stop_on_error only for a single photo); docs/mcp.md and control-protocol.md updated. | `ede1546d23` | 2026-11-29 @ 2d62488dd2 | `9f57e59e6` | | #4740 | merged | Use the shared nightly launcher template | SKIP | - | Upstream nightly Linux launcher scripts only. | `10c12418ac` | 2026-11-27 @ 5973d956df | - | +| #4741 | open | engine: skip image probes for linked catalog videos | ADOPT | - | Adapted: added is_catalog_video (the fork had none), used in lightroom_job::original_paths; test uses .MOV. | `3fc7494697` | 2026-11-29 @ 2d62488dd2 | `ef74a81ed` | +| #4747 | open | engine: skip warnings for inactive legacy XMP fields | ADOPT | - | Final state of both commits hand-applied; the fork's develop_field_coverage test loses AutoWhiteVersion from its unmapped list. | `03d61a7f6d` | 2026-11-29 @ 2d62488dd2 | `964f12827` | | #4749 | merged | Switch on supervised nightlies on the nightly-signer branch | SKIP | - | Upstream nightly signing workflows and policy only. | `564e85a522` | 2026-11-27 @ 5973d956df | - | | #4752 | merged | Nightly: stop blocking a refused launch on macOS | SKIP | - | Fixes upstream's nightly launch-profile refusal dialog (#4723), which the fork does not have. | `e5aaa4cffe` | 2026-11-27 @ 5973d956df | - | | #4811 | merged | SAM 3: reduce DX12 attention pipeline startup time | SKIP | - | Smaller attention tiles in upstream's `crates/gpu` SAM 3 kernels; the fork has no SAM 3 GPU path (the #2533-#2537 stack is SKIP). | `d0a13f3587` | 2026-11-27 @ 5973d956df | - | @@ -1146,3 +1179,4 @@ PR head or commit SHA. A pipe inside a cell is escaped with a backslash. | round 11 (#2661 settled) | 2026-11-25 | `ea033fbe1c` | 1: the carried PENDING row #2661, re-read in full (squash commit, PR reviews and threads) | 1 part: Boost `0e45c1889` onto the fork's depth-based Lens Blur | #2661 now LEARN: its full port (fork PR #1500) duplicated fork PR #1498 and was closed; brush refinement and per-mask Lens Blur ported after it onto the depth renderer; #4349 (Lens Blur on iPhone Portrait depth) stays PENDING | upstream intake 2026-11-25 | | monitor 2026-11-27 | 2026-11-27 | `5973d956df` (craft-libs `0ebc5915b0`) | upstream: 8 of 148 waiting rows moved (6 merged, 2 heads moved by main merges only); craft-libs: 0 of 5 waiting rows moved, 11 PRs on tracked paths since 2026-11-25, 2 merged (#3536 next into main: test sizing, a craft-cms split the fork does not use; #3578 jpeg-encoder 0.7, already in the fork), the rest open drafts, refactors or features: SKIP unlisted | 1: #2896 remainder `d21affb32` | #2378 WATCH; #3141, #3943, #1958 PENDING though merged upstream; #2584 SKIP; #2822, #3429 PENDING | upstream intake 2026-11-27 | | monitor 2026-11-27 (unlogged merges) | 2026-11-27 | `5973d956df` | 13 PRs merged upstream since 2026-11-25 that had no ledger row (most from the 2026-11-26 backlog merge) | 3: #4816 fork fix `c73d05733`, #4608 zip lockfile bump `88a4038e0`, #4720 watermark grid `5b0ec87be` | LEARN #1900 #2194 #4695; SKIP #2018 #2838 (already in the fork) #4723 #4740 #4749 #4752 #4811 | upstream intake 2026-11-27 | +| round 12 (backlog triage) | 2026-11-29 | `2d62488dd2` (craft-libs `857784e6b1`) | upstream: 10 of 146 waiting rows moved; 275 PRs updated since 2026-11-25 with no ledger or archive row triaged in 5 batches (35 ADOPT NOW candidates, the rest PENDING/LEARN/SKIP, kept in the round report, not as rows); craft-libs: 0 of 5 waiting rows moved, 12 merged PRs on tracked paths all SKIP (#3900 joins the #534 rev-bump decision) | 25: #1828 #4538 #4628 #1638 #4565 #4741 #4730 #4627 #4622 #4572 #4568 #4633 #1204 #1736 #4747 #4729 #1261 #4653 #4663 #4482 #4444 #4484 #4737 #4528 #4497 | PENDING #4716 #4684 #1079 #1069 #2675; SKIP #1837 #4490 #4535 #4285 #1704 (FX-137 already does it); LEARN #4215; OpenFill: no such upstream PR found | upstream intake 2026-11-29 | diff --git a/docs/whats-new/2026-11-29-disable-updates.md b/docs/whats-new/2026-11-29-disable-updates.md new file mode 100644 index 0000000000..67961a123d --- /dev/null +++ b/docs/whats-new/2026-11-29-disable-updates.md @@ -0,0 +1,2 @@ +### Distro packages can turn the updater off +- Setting `_DISABLE_UPDATES=1` turns off the start-up update check and greys out **Help ▸ Check for Updates…**, which says why when you hover it. Package managers (the Nix package sets it) own updates there. diff --git a/docs/whats-new/2026-11-29-linux-reveal-selects.md b/docs/whats-new/2026-11-29-linux-reveal-selects.md new file mode 100644 index 0000000000..557e6f95ac --- /dev/null +++ b/docs/whats-new/2026-11-29-linux-reveal-selects.md @@ -0,0 +1,2 @@ +### Show in Finder selects the files on Linux +- On Linux, **Show in Finder** now selects the photo in the file manager, and every selected photo at once, instead of only opening its folder. Where the file manager can't do that, the folder opens as before, and the app no longer freezes until that window is closed. diff --git a/docs/whats-new/2026-11-29-local-browse-drive-roots.md b/docs/whats-new/2026-11-29-local-browse-drive-roots.md new file mode 100644 index 0000000000..49bc60742d --- /dev/null +++ b/docs/whats-new/2026-11-29-local-browse-drive-roots.md @@ -0,0 +1,2 @@ +### Local browse keeps drive roots +- Browsing or adding a whole drive or share in Local (`/`, `C:\`, a network share) now keeps its root, instead of turning it into an empty or relative path. diff --git a/docs/whats-new/2026-11-29-macos-open-from-finder.md b/docs/whats-new/2026-11-29-macos-open-from-finder.md new file mode 100644 index 0000000000..c664d4dc3b --- /dev/null +++ b/docs/whats-new/2026-11-29-macos-open-from-finder.md @@ -0,0 +1,4 @@ +### Open photos from Finder on macOS + +- Open With, a drop on the Dock icon, or `open -a` from another app now hands the photos to the app, which imports them like files dropped on its window, at launch or while it runs. Before, macOS said the app couldn't open files in that format. +- The app is offered for camera raws and the image types it imports, but never becomes their default app. diff --git a/docs/whats-new/2026-11-29-mcp-batch-export-missing-originals.md b/docs/whats-new/2026-11-29-mcp-batch-export-missing-originals.md new file mode 100644 index 0000000000..395a08351c --- /dev/null +++ b/docs/whats-new/2026-11-29-mcp-batch-export-missing-originals.md @@ -0,0 +1,3 @@ +### MCP batch exports go on past a missing original + +- A headless export of several photos (the MCP `export` tool, ` run`) no longer stops at a photo whose original is missing: it is listed with its error in `files` and the other photos are still written. A single-photo export that fails is still an error. diff --git a/docs/whats-new/2026-11-29-mcp-empty-folder.md b/docs/whats-new/2026-11-29-mcp-empty-folder.md new file mode 100644 index 0000000000..be269614e8 --- /dev/null +++ b/docs/whats-new/2026-11-29-mcp-empty-folder.md @@ -0,0 +1,3 @@ +### ` mcp FOLDER` serves an empty folder + +- Starting the MCP server on a folder with no photos yet no longer exits with an import error: it says nothing was imported and serves, and photos can come later through `import`. diff --git a/docs/whats-new/2026-11-29-older-process-defaults.md b/docs/whats-new/2026-11-29-older-process-defaults.md new file mode 100644 index 0000000000..8f729ab8b6 --- /dev/null +++ b/docs/whats-new/2026-11-29-older-process-defaults.md @@ -0,0 +1,3 @@ +### Untouched photos from older Lightroom process versions stay unedited + +- A photo saved under process version 2003/2010 and never edited there no longer comes in as edited: its "Medium Contrast" curve and a raw's default sharpening of 25 are read as that version's defaults, so it keeps the import look. diff --git a/docs/whats-new/2026-11-29-overlapping-import-roots.md b/docs/whats-new/2026-11-29-overlapping-import-roots.md new file mode 100644 index 0000000000..517f58125f --- /dev/null +++ b/docs/whats-new/2026-11-29-overlapping-import-roots.md @@ -0,0 +1,2 @@ +### Overlapping import folders are read once +- Importing photos or presets from folders that overlap (a folder and one inside it, or a link to another chosen folder) reads each folder once and keeps the first path, so nothing is offered twice. diff --git a/docs/whats-new/2026-11-29-paint-vignette-white.md b/docs/whats-new/2026-11-29-paint-vignette-white.md new file mode 100644 index 0000000000..15e7efae48 --- /dev/null +++ b/docs/whats-new/2026-11-29-paint-vignette-white.md @@ -0,0 +1,2 @@ +### Paint vignette lightens toward white +- A positive **Paint** post-crop vignette now blends the corners toward flat white, as a negative one blends toward black. Before, it lifted the corners exactly like **Color**, so the two styles looked the same. diff --git a/docs/whats-new/2026-11-29-xtrans-ai-denoise.md b/docs/whats-new/2026-11-29-xtrans-ai-denoise.md new file mode 100644 index 0000000000..c579d58408 --- /dev/null +++ b/docs/whats-new/2026-11-29-xtrans-ai-denoise.md @@ -0,0 +1,2 @@ +### AI denoise for Fujifilm X-Trans raws +- AI denoise no longer refuses X-Trans raws: the mosaic is rebuilt as a Bayer mosaic of the same size and handed to the installed Bayer model. The model was not trained on X-Trans, so results are an approximation. diff --git a/docs/xmp-interop.md b/docs/xmp-interop.md index 20d244a03c..d9240e9007 100644 --- a/docs/xmp-interop.md +++ b/docs/xmp-interop.md @@ -199,11 +199,12 @@ application's renderer and is ignored: the photo keeps the app's own process, th | `ParametricShadowSplit`, `ParametricMidtoneSplit`, `ParametricHighlightSplit` | `curve.split_shadows/split_mid/split_highlights` | | | `CurveRefineSaturation` | `curve.refine_saturation` | 0..100 (100 = curve saturation unchanged) | | `ToneCurvePV2012`, `ToneCurvePV2012Red/Green/Blue` | `curve.master/red/green/blue` | `"x, y"` points in 0..255 → 0..1; a straight 0→255 line = no curve; the red / green / blue curves are read only when `ToneCurvePV2012` and all three channel curves are present (Lightroom Classic ignores them otherwise: a master + red-only packet renders without the red curve) | +| `ToneCurve` (older process versions) | `curve.master` | as `ToneCurvePV2012`, read only when the packet has no `ToneCurvePV2012`; a curve named `Medium Contrast` (`ToneCurveName`) is the older process versions' untouched default, like their Contrast 25, Blacks 5 and Brightness 50, and comes in as no curve (see `Sharpness` for the other older default that isn't an edit), so an unedited photo keeps its import look | | `SplitToningShadowHue/Saturation`, `SplitToningHighlightHue/Saturation` | `grading.shadows/highlights.hue/sat` | | | `ColorGradeShadowLum`, `ColorGradeHighlightLum` | `grading.shadows/highlights.lum` | | | `ColorGradeMidtoneHue/Sat/Lum`, `ColorGradeGlobalHue/Sat/Lum` | `grading.midtones/global.*` | | | `ColorGradeBlending`, `SplitToningBalance` | `grading.blending`, `grading.balance` | | -| `Sharpness`, `SharpenRadius`, `SharpenDetail`, `SharpenEdgeMasking` | `detail.sharpen_*` | | +| `Sharpness`, `SharpenRadius`, `SharpenDetail`, `SharpenEdgeMasking` | `detail.sharpen_*` | a raw's `Sharpness` of 25 under an older process version (no `…2012` fields) is that version's untouched default and leaves our raw default in place; anywhere else 25 is read as written | | `LuminanceSmoothing`, `LuminanceNoiseReductionDetail`, `LuminanceNoiseReductionContrast` | `detail.nr_luminance/nr_detail/nr_contrast` | | | `ColorNoiseReduction`, `ColorNoiseReductionDetail`, `ColorNoiseReductionSmoothness` | `detail.nr_color/nr_color_detail/nr_color_smoothness` | | | `PostCropVignetteAmount/Midpoint/Roundness/Feather/HighlightContrast` | `vignette.amount/midpoint/roundness/feather/highlights` | | diff --git a/nix/package.nix b/nix/package.nix index 3d796e7401..d777e60f98 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -209,7 +209,10 @@ rustPlatform.buildRustPackage { $out/share/metainfo/${appId}.metainfo.xml # makeWrapper keeps the program working when the libs above are only dlopen'd. - wrapProgram $out/bin/${brand.binary} --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}" + # NixOS owns the update flow (the system state updates the software), so the app's own + # start-up prompt and manual check are turned off (upstream #4663). + wrapProgram $out/bin/${brand.binary} --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeLibs}" \ + --set ${brand.env_prefix}_DISABLE_UPDATES 1 '' # The CLI: a link to the program (its wrapper on Linux, which starts it under the name it was # started by), so it runs as the CLI. diff --git a/packaging/macos/Info.plist.in b/packaging/macos/Info.plist.in index 750ca8240c..e4050782ae 100644 --- a/packaging/macos/Info.plist.in +++ b/packaging/macos/Info.plist.in @@ -72,6 +72,49 @@ NSHumanReadableCopyright Copyright © {{vendor}}. MIT. + + CFBundleDocumentTypes + + + CFBundleTypeName + Camera Raw Image + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + public.camera-raw-image + + + + CFBundleTypeName + Image + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + public.jpeg + public.heic + public.heif + public.avif + public.tiff + public.png + org.webmproject.webp + public.jpeg-xl + com.adobe.photoshop-image + com.compuserve.gif + com.microsoft.bmp + + + + UTExportedTypeDeclarations diff --git a/xtask/src/layers.rs b/xtask/src/layers.rs index 8d0f33a3b1..423e7cdf26 100644 --- a/xtask/src/layers.rs +++ b/xtask/src/layers.rs @@ -48,6 +48,7 @@ pub const TABLE: &[(&str, Class)] = &[ ("winmsi", Class::Layer(0)), ("winjob", Class::Layer(0)), ("firstclick", Class::Layer(0)), + ("opendocs", Class::Layer(0)), // LibRaw (C++, opt-in) behind a C shim: the raw mosaic for `lcc_engine::raw_decoder` ("libraw", Class::Layer(0)), ("android-host", Class::Layer(0)),