From c10673254be785d132ca00eaf3c892da2b4774dc Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 14 Nov 2026 05:58:12 +0100 Subject: [PATCH 01/42] WIP: Artboards to Files: reference file type list (#13635) From ff60e13c5038fb7a68af6b2314fbbeca5d0dca3d Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 14 Nov 2026 06:19:27 +0100 Subject: [PATCH 02/42] Artboards to Files: the File Type list matches the reference application (#13635) The dialog's list is now File Type: BMP, JPEG, PDF, PSD, Targa, TIFF, PNG-8, PNG-24, with PSD chosen on open. The command learns png8 (indexed PNG), png24 (truecolour PNG), targa and pdf (one multi-page .pdf, bottom artboard first, pages at 72 ppi, through Artboards to PDF's writer). Scripts still default to png; Layer Comps to Files keeps its list. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/artboard_cmds.rs | 106 ++++++++++--- .../src/cmd/artboard_cmds/file_types_tests.rs | 145 ++++++++++++++++++ .../src/artboards_to_files_types_tests.rs | 98 ++++++++++++ crates/ui-egui/src/export_quality_tests.rs | 2 +- crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/menus/view_cmds/dialogs.rs | 20 ++- 6 files changed, 346 insertions(+), 27 deletions(-) create mode 100644 crates/engine/src/cmd/artboard_cmds/file_types_tests.rs create mode 100644 crates/ui-egui/src/artboards_to_files_types_tests.rs diff --git a/crates/engine/src/cmd/artboard_cmds.rs b/crates/engine/src/cmd/artboard_cmds.rs index 00b0f7e37f..810a102488 100644 --- a/crates/engine/src/cmd/artboard_cmds.rs +++ b/crates/engine/src/cmd/artboard_cmds.rs @@ -675,7 +675,30 @@ fn chosen_artboards(doc: &Document, p: &Value) -> Vec { } } -/// File › Export › Artboards to Files: `__.` per board. +/// What an Artboards to Files `format` writes (the dialog's File Type list). +enum FileType { + /// One file per board through the format's encoder, with this extension. + Save(String), + /// One indexed (palette) PNG per board, as PNG-8. + Png8, + /// One multi-page PDF, a page per board, bottom artboard first. + Pdf, +} + +impl FileType { + fn of(format: &str) -> Self { + match format { + "png8" | "png-8" => FileType::Png8, + "png24" | "png-24" => FileType::Save("png".into()), + "targa" => FileType::Save("tga".into()), + "pdf" => FileType::Pdf, + ext => FileType::Save(ext.into()), + } + } +} + +/// File › Export › Artboards to Files: `__.` per board, +/// or for PDF one `.pdf`. fn artboards_to_files(s: &mut Session, p: &Value) -> Result { let cmd = "file.export.artboardsToFiles"; let dir = str_param(p, "dir", cmd).or_else(|_| str_param(p, "output", cmd))?.to_string(); @@ -684,20 +707,69 @@ fn artboards_to_files(s: &mut Session, p: &Value) -> Result { let d = s.active().ok_or(EngineError::NoDocument)?; let prefix = p.get("prefix").and_then(Value::as_str).map(str::to_string).unwrap_or_else(|| stem(&d.doc.name)); let doc = d.doc.clone(); - let mut files = Vec::new(); - for (i, one) in chosen_documents(&doc, p)?.into_iter().enumerate() { - // Names may be identical, or collide after sanitizing or filesystem case folding. - let name = if prefix.is_empty() { format!("{i:04}_{}", sanitize(&one.name)) } else { format!("{}_{i:04}_{}", sanitize(&prefix), sanitize(&one.name)) }; - let path = join(&dir, &format!("{name}.{format}")); - save_doc(&one, &path, save)?; - files.push(path); - } - if files.is_empty() { + let boards = chosen_documents(&doc, p)?; + if boards.is_empty() { return Err(bad(cmd, "no matching artboards")); } + let ext = match FileType::of(&format) { + FileType::Pdf => { + // The reference application's Multi-Page Document: the bottom artboard is page 1, and + // each page is the board's pixel size at 72 ppi. + let mut pages = Vec::new(); + for one in boards.iter().rev() { + pages.push((one.size.width, one.size.height, 72.0, jpeg_page(one, save.quality.or(Some(10.0)))?)); + } + let name = if prefix.is_empty() { stem(&doc.name) } else { prefix }; + let path = join(&dir, &format!("{}.pdf", sanitize(&name))); + write_file(&path, &raster_pdf(&pages))?; + return Ok(json!({"files": [path]})); + } + FileType::Png8 => None, + FileType::Save(ext) => Some(ext), + }; + let mut files = Vec::new(); + for (i, one) in boards.into_iter().enumerate() { + // Names may be identical, or collide after sanitizing or filesystem case folding. + let name = if prefix.is_empty() { format!("{i:04}_{}", sanitize(&one.name)) } else { format!("{}_{i:04}_{}", sanitize(&prefix), sanitize(&one.name)) }; + let path = join(&dir, &format!("{name}.{}", ext.as_deref().unwrap_or("png"))); + match &ext { + Some(_) => { + save_doc(&one, &path, save)?; + } + None => write_file(&path, &png8(&one)?)?, + } + files.push(path); + } Ok(json!({"files": files})) } +/// `one` as an indexed PNG: Generate Assets' PNG-8 (selective palette, no dither, transparency kept). +fn png8(one: &Document) -> Result> { + use crate::web_cmds::{WebFormat, WebMetadata, WebSettings, optimize, web_document}; + let st = WebSettings { + format: WebFormat::Png8, + dither: photocraft_algo::quantize::Dither::None, + matte: None, + metadata: WebMetadata::None, + ..WebSettings::default() + }; + let (wdoc, _, _) = web_document(one, &json!({}), &st)?; + let buf = photocraft_compose::flatten(&wdoc); + Ok(optimize(&buf.px, wdoc.size.width as usize, wdoc.bounds(), &st, None, None, None, wdoc.resolution_dpi, false)?.bytes) +} + +/// `one` flattened over white as a JPEG, for a PDF page. +fn jpeg_page(one: &Document, quality: Option) -> Result> { + let buf = photocraft_compose::flatten(one).over_background([1.0, 1.0, 1.0]); + let fmt = PixelFormat::new(ColorMode::Rgb, SampleType::U8, true); + let mut flat = Document::new(&one.name, one.size, ColorMode::Rgb, SampleType::U8); + let mut surf = Surface::new(fmt); + let vals: Vec = buf.px.iter().flat_map(|px| photocraft_raster::from_rgba(&fmt, *px)).collect(); + surf.write_region(one.bounds(), &vals); + flat.layers.push(Layer::new("Background", LayerContent::Raster(surf))); + Ok(encode(&flat, "page.jpg", quality)?.0) +} + /// A minimal PDF with one page per JPEG image: (width px, height px, dpi, JPEG bytes). /// Pages are sized so the image prints at its resolution. pub fn raster_pdf(pages: &[(u32, u32, f32, Vec)]) -> Vec { @@ -753,14 +825,7 @@ fn artboards_to_pdf(s: &mut Session, p: &Value) -> Result { let quality = f64_param(p, "quality").or(Some(10.0)); let mut pages = Vec::new(); for one in chosen_documents(&doc, p)? { - let buf = photocraft_compose::flatten(&one).over_background([1.0, 1.0, 1.0]); - let fmt = PixelFormat::new(ColorMode::Rgb, SampleType::U8, true); - let mut flat = Document::new(&one.name, one.size, ColorMode::Rgb, SampleType::U8); - let mut surf = Surface::new(fmt); - let vals: Vec = buf.px.iter().flat_map(|px| photocraft_raster::from_rgba(&fmt, *px)).collect(); - surf.write_region(one.bounds(), &vals); - flat.layers.push(Layer::new("Background", LayerContent::Raster(surf))); - let (jpeg, _) = encode(&flat, "page.jpg", quality)?; + let jpeg = jpeg_page(&one, quality)?; pages.push((one.size.width, one.size.height, doc.resolution_dpi, jpeg)); } if pages.is_empty() { @@ -829,7 +894,7 @@ pub fn specs() -> Vec { "file.export.artboardsToFiles", "Artboards to Files…", &["File", "Export"], - r##"{"dir":folder,"format":"png|jpg|psd|tiff|…"="png","prefix":str=document name ("" = none),"artboards":[id]? (default all),"quality":0..12?} → {files}"##, + r##"{"dir":folder,"format":"png|png24|png8|jpg|bmp|tga|tiff|psd|pdf|…"="png" (png24 = truecolour .png, png8 = indexed .png, tga = Targa; pdf = one multi-page .pdf, bottom artboard first, pages at 72 ppi),"prefix":str=document name ("" = none),"artboards":[id]? (default all),"quality":0..12?} → {files}"##, export_artboards, artboards_to_files ), @@ -844,6 +909,9 @@ pub fn specs() -> Vec { ] } +#[cfg(test)] +#[path = "artboard_cmds/file_types_tests.rs"] +mod file_types_tests; #[cfg(test)] #[path = "artboard_cmds/first_board_background_tests.rs"] mod first_board_background_tests; diff --git a/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs b/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs new file mode 100644 index 0000000000..9788e98d33 --- /dev/null +++ b/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs @@ -0,0 +1,145 @@ +//! Artboards to Files writes each of the File Type list's types (#13635): PNG-8 an indexed +//! PNG, PNG-24 a truecolour one, Targa a `.tga`, PDF one multi-page file with the bottom +//! artboard first and each page the board's pixel size at 72 ppi. +use super::*; + +/// The issue's test document: 800 x 400, transparent, Red Board 200 x 150 at the bottom of the +/// Layers panel, then Blue Board 200 x 200, then an empty transparent board on top. 300 ppi, so +/// a page sized from the document resolution would not be 72 ppi. +fn boards() -> Session { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 800, "height": 400, "name": "abfiles-test", "background": "transparent"})).unwrap(); + for (name, rect, bg) in [ + ("Red Board", [0, 0, 200, 150], json!({"background": "custom", "color": "#ff0000"})), + ("Blue Board", [300, 0, 200, 200], json!({"background": "custom", "color": "#0000ff"})), + ("Empty Board", [600, 0, 100, 100], json!({"background": "transparent"})), + ] { + let mut p = json!({"rect": rect, "name": name}); + p.as_object_mut().unwrap().extend(bg.as_object().unwrap().clone()); + s.execute("layer.new.artboard", p).unwrap(); + } + s.edit("ppi", |doc, _| { + doc.resolution_dpi = 300.0; + Ok(()) + }) + .unwrap(); + s +} + +fn out_dir(tag: &str) -> String { + let dir = std::env::temp_dir().join(format!("photocraft-13635-{tag}-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + dir.to_string_lossy().into_owned() +} + +fn export(s: &mut Session, dir: &str, format: &str) -> Vec { + let r = s.execute("file.export.artboardsToFiles", json!({"dir": dir, "format": format})).unwrap(); + r["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_string()).collect() +} + +/// The PNG IHDR colour type: 2 truecolour, 3 indexed, 6 truecolour with alpha. +fn png_color_type(path: &str) -> u8 { + let bytes = std::fs::read(path).unwrap(); + assert!(bytes.starts_with(b"\x89PNG\r\n\x1a\n"), "{path} is not a PNG"); + assert_eq!(&bytes[12..16], b"IHDR"); + bytes[25] +} + +fn size_of(path: &str, ext: &str) -> (u32, u32) { + let d = photocraft_io::import(&format!("x.{ext}"), &std::fs::read(path).unwrap()).unwrap().document; + (d.size.width, d.size.height) +} + +#[test] +fn png8_writes_indexed_pngs() { + let mut s = boards(); + let dir = out_dir("png8"); + let files = export(&mut s, &dir, "png8"); + assert_eq!(files.len(), 3); + for f in &files { + assert!(f.ends_with(".png"), "{f}"); + assert_eq!(png_color_type(f), 3, "{f} is not indexed"); + } + assert!(files[2].ends_with("abfiles-test_0002_Red Board.png"), "{files:?}"); + assert_eq!(size_of(&files[2], "png"), (200, 150)); + // Red stays red through the palette. + let red = photocraft_io::import("x.png", &std::fs::read(&files[2]).unwrap()).unwrap().document; + let px = photocraft_compose::flatten(&red).px.clone(); + assert!(px[0][0] > 0.99 && px[0][1] < 0.01 && px[0][2] < 0.01, "{:?}", px[0]); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn png24_writes_truecolour_pngs_with_alpha_where_transparent() { + let mut s = boards(); + let dir = out_dir("png24"); + let files = export(&mut s, &dir, "png24"); + assert_eq!(files.len(), 3); + for f in &files { + assert!(f.ends_with(".png"), "{f}"); + assert!(matches!(png_color_type(f), 2 | 6), "{f} is not truecolour"); + } + // The empty board is transparent: the file keeps its alpha. + assert!(files[0].ends_with("abfiles-test_0000_Empty Board.png"), "{files:?}"); + assert_eq!(png_color_type(&files[0]), 6); + assert_eq!(size_of(&files[1], "png"), (200, 200)); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn targa_writes_tga_files() { + let mut s = boards(); + let dir = out_dir("tga"); + for format in ["tga", "targa"] { + let files = export(&mut s, &dir, format); + assert_eq!(files.len(), 3); + assert!(files.iter().all(|f| f.ends_with(".tga")), "{files:?}"); + assert_eq!(size_of(&files[2], "tga"), (200, 150)); + } + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn pdf_writes_one_multi_page_file_bottom_artboard_first_at_72_ppi() { + let mut s = boards(); + let dir = out_dir("pdf"); + let files = export(&mut s, &dir, "pdf"); + assert_eq!(files, vec![join(&dir, "abfiles-test.pdf")]); + let entries: Vec<_> = std::fs::read_dir(&dir).unwrap().collect(); + assert_eq!(entries.len(), 1, "one file, not one per board"); + let bytes = std::fs::read(&files[0]).unwrap(); + assert!(bytes.starts_with(b"%PDF-")); + let text = String::from_utf8_lossy(&bytes); + assert_eq!(text.matches("/Type /Page ").count(), 3); + assert_eq!(text.matches("/DCTDecode").count(), 3); + // Page order: Red Board (bottom of the Layers panel), Blue Board, the empty board. + let boxes: Vec<&str> = text.match_indices("/MediaBox [").map(|(i, _)| &text[i + 11..i + 11 + text[i + 11..].find(']').unwrap()]).collect(); + assert_eq!(boxes, vec!["0 0 200.000 150.000", "0 0 200.000 200.000", "0 0 100.000 100.000"]); + // A prefix names the file. + let r = s.execute("file.export.artboardsToFiles", json!({"dir": dir, "format": "pdf", "prefix": "pre_"})).unwrap(); + assert_eq!(r["files"], json!([join(&dir, "pre_.pdf")])); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn scripts_still_default_to_png() { + let mut s = boards(); + let dir = out_dir("default"); + let r = s.execute("file.export.artboardsToFiles", json!({"dir": dir})).unwrap(); + let files: Vec<&str> = r["files"].as_array().unwrap().iter().filter_map(Value::as_str).collect(); + assert_eq!(files.len(), 3); + assert!(files.iter().all(|f| f.ends_with(".png")), "{files:?}"); + let _ = std::fs::remove_dir_all(&dir); +} + +#[test] +fn unknown_format_is_an_error_and_writes_nothing() { + let mut s = boards(); + let dir = out_dir("unknown"); + for format in ["xyz", "png9", ""] { + assert!(s.execute("file.export.artboardsToFiles", json!({"dir": dir, "format": format})).is_err(), "{format}"); + } + assert_eq!(std::fs::read_dir(&dir).unwrap().count(), 0); + let _ = std::fs::remove_dir_all(&dir); +} diff --git a/crates/ui-egui/src/artboards_to_files_types_tests.rs b/crates/ui-egui/src/artboards_to_files_types_tests.rs new file mode 100644 index 0000000000..7b411641db --- /dev/null +++ b/crates/ui-egui/src/artboards_to_files_types_tests.rs @@ -0,0 +1,98 @@ +//! #13635: File › Export › Artboards to Files has the reference application's File Type list: +//! BMP, JPEG, PDF, PSD, Targa, TIFF, PNG-8, PNG-24 in that order, PSD chosen when it opens. +//! Layer Comps to Files keeps its own list. +use crate::PhotocraftApp; +use egui::accesskit::Role; +use egui::vec2; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use serde_json::json; + +const ARTBOARDS: &str = "file.export.artboardsToFiles"; +const NAMES: [&str; 8] = ["BMP", "JPEG", "PDF", "PSD", "Targa", "TIFF", "PNG-8", "PNG-24"]; + +fn harness() -> Harness<'static, PhotocraftApp> { + let mut h = Harness::builder().with_size(vec2(1440.0, 900.0)).with_max_steps(64).build_eframe(|cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); + PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()) + }); + let app = h.state_mut(); + app.run("file.new", json!({"width": 400, "height": 200, "background": "transparent"})).unwrap(); + app.run("layer.new.artboard", json!({"rect": [0, 0, 100, 50], "name": "Red Board", "background": "custom", "color": "#ff0000"})).unwrap(); + app.run("layer.new.artboard", json!({"rect": [200, 0, 80, 80], "name": "Blue Board", "background": "custom", "color": "#0000ff"})).unwrap(); + app.run("layerComp.new", json!({"name": "Comp"})).unwrap(); + app.sync_views(); + h +} + +fn open(h: &mut Harness<'_, PhotocraftApp>, id: &str) -> u64 { + let ctx = h.ctx.clone(); + let dialog = crate::menus::invoke(h.state_mut(), &ctx, id, json!({})).unwrap()["dialog"].as_u64().unwrap(); + h.run_steps(4); + dialog +} + +#[test] +fn file_type_list_is_the_reference_list_with_psd_chosen() { + let mut h = harness(); + let dialog = open(&mut h, ARTBOARDS); + let fields = h.state_mut().ui.dialog_mut(dialog).unwrap().fields.clone(); + assert_eq!(fields["format"], json!("psd"), "PSD on first open"); + assert_eq!(fields["__choices"]["format"], json!(["bmp", "jpg", "pdf", "psd", "tga", "tiff", "png8", "png24"])); + // The row reads "File Type:" and the closed dropdown shows PSD. + let combo = h.query_all_by_role(Role::ComboBox).find(|n| n.accesskit_node().label().as_deref() == Some("File Type:")).expect("a File Type: dropdown"); + assert_eq!(combo.accesskit_node().value().as_deref(), Some("PSD")); + let at = combo.rect().center(); + h.hover_at(at); + h.run_steps(1); + for pressed in [true, false] { + h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }); + h.run_steps(2); + } + h.run_steps(2); + // Opened, the list shows the eight names top to bottom in the reference order. + let ys: Vec = NAMES + .iter() + .map(|name| { + let tops: Vec = h.query_all_by_label(name).map(|n| n.rect().min.y).collect(); + assert!(!tops.is_empty(), "the list shows {name}"); + tops.into_iter().fold(f32::MIN, f32::max) + }) + .collect(); + assert!(ys.windows(2).all(|w| w[0] < w[1]), "{NAMES:?} at {ys:?}"); +} + +#[test] +fn ok_with_png8_writes_indexed_pngs_and_pdf_one_file() { + let mut h = harness(); + let t = tempfile::tempdir().unwrap(); + let dir = t.path().to_string_lossy().into_owned(); + for (format, files) in [("png8", 2), ("pdf", 1), ("psd", 2)] { + let dialog = open(&mut h, ARTBOARDS); + let fields = &mut h.state_mut().ui.dialog_mut(dialog).unwrap().fields; + fields.insert("dir".into(), json!(dir)); + fields.insert("prefix".into(), json!(format)); + fields.insert("format".into(), json!(format)); + h.run_steps(2); + let r = crate::dialogs::confirm(h.state_mut(), dialog).unwrap(); + let written: Vec = r["files"].as_array().unwrap().iter().map(|v| v.as_str().unwrap().to_string()).collect(); + assert_eq!(written.len(), files, "{format}: {written:?}"); + for f in &written { + let bytes = std::fs::read(f).unwrap(); + match format { + "png8" => assert_eq!(bytes[25], 3, "{f} is an indexed PNG"), + "pdf" => assert!(f.ends_with("pdf.pdf") && bytes.starts_with(b"%PDF-"), "{f}"), + _ => assert!(f.ends_with(".psd") && bytes.starts_with(b"8BPS"), "{f}"), + } + } + } +} + +#[test] +fn layer_comps_to_files_keeps_its_list() { + let mut h = harness(); + let dialog = open(&mut h, "file.export.layerCompsToFiles"); + let fields = h.state_mut().ui.dialog_mut(dialog).unwrap().fields.clone(); + assert_eq!(fields["format"], json!("png")); + assert_eq!(fields["__choices"]["format"], json!(["png", "jpg", "psd", "tiff", "webp", "bmp"])); +} diff --git a/crates/ui-egui/src/export_quality_tests.rs b/crates/ui-egui/src/export_quality_tests.rs index 1f1bfd88ae..4cb4227604 100644 --- a/crates/ui-egui/src/export_quality_tests.rs +++ b/crates/ui-egui/src/export_quality_tests.rs @@ -219,7 +219,7 @@ fn alt_reset_restores_the_custom_quality() { alt_reset(&mut h); assert!(h.state().ui.dialogs.iter().any(|d| d.id == dialog), "Reset keeps the dialog open"); let p = params(&mut h, dialog); - assert_eq!((&p["format"], &p["quality"]), (&json!("png"), &Value::Null), "the opening format, no quality"); + assert_eq!((&p["format"], &p["quality"]), (&json!("psd"), &Value::Null), "the opening format, no quality"); assert!(!custom_ticked(&h) && !quality_enabled(&h), "Custom is off again"); assert_eq!(shown_quality(&h), Some(10.0), "the field shows the opening quality"); // Choosing JPEG again still sends no quality until Custom is ticked. diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 7928bf442c..4e0905e91d 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1056,6 +1056,8 @@ mod polygon_lasso_tests; #[cfg(test)] mod window_frame_tests; +#[cfg(test)] +mod artboards_to_files_types_tests; #[cfg(test)] mod browse_field_tests; #[cfg(test)] diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index 51c67b83e5..f1e23b6063 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -500,17 +500,23 @@ pub(super) fn front(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, para json!({"format": ["png", "jpg", "psd", "tiff", "webp", "bmp"]}), ) } - "file.export.layerCompsToFiles" | "file.export.artboardsToFiles" => { + "file.export.layerCompsToFiles" => { let (_, _, name) = doc?; let prefix = name.rsplit_once('.').map_or(name.as_str(), |(a, _)| a).to_string(); - let fields = if id == "file.export.layerCompsToFiles" { - json!({"dir": dir, "prefix": prefix, "format": "png", "quality": null, JPEG_CUSTOM: false, JPEG_QUALITY: 10, "selectedOnly": false, - "__order": ["dir", "prefix", "selectedOnly", "format", "quality"]}) - } else { - json!({"dir": dir, "prefix": prefix, "format": "png", "quality": null, JPEG_CUSTOM: false, JPEG_QUALITY: 10, "__order": ["dir", "prefix", "format", "quality"]}) - }; + let fields = json!({"dir": dir, "prefix": prefix, "format": "png", "quality": null, JPEG_CUSTOM: false, JPEG_QUALITY: 10, "selectedOnly": false, + "__order": ["dir", "prefix", "selectedOnly", "format", "quality"]}); dialog(app, fields, json!({"format": ["png", "jpg", "psd", "tiff", "webp", "bmp"]})) } + // The reference application's File Type list, in its order, PSD first chosen (#13635). + "file.export.artboardsToFiles" => { + let (_, _, name) = doc?; + let prefix = name.rsplit_once('.').map_or(name.as_str(), |(a, _)| a).to_string(); + let fields = json!({"dir": dir, "prefix": prefix, "format": "psd", "quality": null, JPEG_CUSTOM: false, JPEG_QUALITY: 10, + "__order": ["dir", "prefix", "format", "quality"], + "__labels": {"format": tl!("File Type:"), "bmp": "BMP", "jpg": "JPEG", "pdf": "PDF", "psd": "PSD", "tga": "Targa", "tiff": "TIFF", + "png8": "PNG-8", "png24": "PNG-24"}}); + dialog(app, fields, json!({"format": ["bmp", "jpg", "pdf", "psd", "tga", "tiff", "png8", "png24"]})) + } "file.export.artboardsToPdf" => { let (_, _, name) = doc?; let stem = name.rsplit_once('.').map_or(name.as_str(), |(a, _)| a).to_string(); From 806b851e547f71c13610b38d51ba9532b28500b4 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 14 Nov 2026 08:19:13 +0100 Subject: [PATCH 03/42] Artboards to Files: PNG-24 writes truecolour for non-RGB documents A Grayscale (or other non-RGB) board is converted to RGB for PNG-24, keeping its depth, layers and transparency; plain png keeps writing it as before. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/artboard_cmds.rs | 15 +++++++++++++- .../src/cmd/artboard_cmds/file_types_tests.rs | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/artboard_cmds.rs b/crates/engine/src/cmd/artboard_cmds.rs index 810a102488..381369a702 100644 --- a/crates/engine/src/cmd/artboard_cmds.rs +++ b/crates/engine/src/cmd/artboard_cmds.rs @@ -681,6 +681,8 @@ enum FileType { Save(String), /// One indexed (palette) PNG per board, as PNG-8. Png8, + /// One truecolour PNG per board, as PNG-24: a Grayscale or other non-RGB board becomes RGB. + Png24, /// One multi-page PDF, a page per board, bottom artboard first. Pdf, } @@ -689,7 +691,7 @@ impl FileType { fn of(format: &str) -> Self { match format { "png8" | "png-8" => FileType::Png8, - "png24" | "png-24" => FileType::Save("png".into()), + "png24" | "png-24" => FileType::Png24, "targa" => FileType::Save("tga".into()), "pdf" => FileType::Pdf, ext => FileType::Save(ext.into()), @@ -725,14 +727,19 @@ fn artboards_to_files(s: &mut Session, p: &Value) -> Result { return Ok(json!({"files": [path]})); } FileType::Png8 => None, + FileType::Png24 => Some("png".to_string()), FileType::Save(ext) => Some(ext), }; + let truecolour = matches!(FileType::of(&format), FileType::Png24); let mut files = Vec::new(); for (i, one) in boards.into_iter().enumerate() { // Names may be identical, or collide after sanitizing or filesystem case folding. let name = if prefix.is_empty() { format!("{i:04}_{}", sanitize(&one.name)) } else { format!("{}_{i:04}_{}", sanitize(&prefix), sanitize(&one.name)) }; let path = join(&dir, &format!("{name}.{}", ext.as_deref().unwrap_or("png"))); match &ext { + Some(_) if truecolour && one.mode != ColorMode::Rgb => { + save_doc(&rgb_copy(&one)?, &path, save)?; + } Some(_) => { save_doc(&one, &path, save)?; } @@ -758,6 +765,12 @@ fn png8(one: &Document) -> Result> { Ok(optimize(&buf.px, wdoc.size.width as usize, wdoc.bounds(), &st, None, None, None, wdoc.resolution_dpi, false)?.bytes) } +/// `one` converted to RGB (its depth, layers and transparency kept), for a truecolour file. +fn rgb_copy(one: &Document) -> Result { + use crate::web_cmds::{WebSettings, web_document}; + Ok(web_document(one, &json!({}), &WebSettings { convert_to_srgb: false, ..WebSettings::default() })?.0) +} + /// `one` flattened over white as a JPEG, for a PDF page. fn jpeg_page(one: &Document, quality: Option) -> Result> { let buf = photocraft_compose::flatten(one).over_background([1.0, 1.0, 1.0]); diff --git a/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs b/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs index 9788e98d33..3e30ef0620 100644 --- a/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs +++ b/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs @@ -87,6 +87,26 @@ fn png24_writes_truecolour_pngs_with_alpha_where_transparent() { let _ = std::fs::remove_dir_all(&dir); } +/// A Grayscale document's boards are still truecolour as PNG-24 (and keep their alpha), while +/// plain `png` keeps writing Grayscale as before. +#[test] +fn png24_is_truecolour_for_a_grayscale_document() { + let mut s = boards(); + s.execute("image.mode.grayscale", json!({})).unwrap(); + let dir = out_dir("png24-gray"); + let files = export(&mut s, &dir, "png24"); + assert_eq!(files.len(), 3); + for f in &files { + assert!(matches!(png_color_type(f), 2 | 6), "{f} is not truecolour"); + } + assert_eq!(png_color_type(&files[0]), 6, "the transparent board keeps its alpha"); + assert_eq!(size_of(&files[2], "png"), (200, 150)); + assert_eq!(s.active().unwrap().doc.mode, ColorMode::Grayscale, "the document itself is unchanged"); + let files = export(&mut s, &dir, "png"); + assert!(files.iter().all(|f| matches!(png_color_type(f), 0 | 4)), "plain png stays Grayscale"); + let _ = std::fs::remove_dir_all(&dir); +} + #[test] fn targa_writes_tga_files() { let mut s = boards(); From bdc76f44d91345a6b0fddedfae883d4f89ff7a57 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:21:44 +0100 Subject: [PATCH 04/42] fix(paint): wrap procedural pattern seed hashing Use explicit wrapping seed arithmetic in checked builds and cover boundary/high u32 seeds across all four texture styles. --- crates/paint/src/procedural.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/paint/src/procedural.rs b/crates/paint/src/procedural.rs index 5469dacebc..57662dbe0d 100644 --- a/crates/paint/src/procedural.rs +++ b/crates/paint/src/procedural.rs @@ -37,7 +37,8 @@ fn fbm(x: f32, y: f32, size: f32, cells: i32, octaves: u32, salt: u64) -> f32 { pub fn pattern(style: PatternStyle, size: u32, seed: u32) -> PatternImage { let n = size.clamp(8, 1024) as usize; let s = n as f32; - let salt = u64::from(seed) * 0x0100_0000_01B3 + 17; + // Seed hashing wraps so every u32 seed also works in checked builds. + let salt = u64::from(seed).wrapping_mul(0x0100_0000_01B3).wrapping_add(17); let mut data = vec![0.0f32; n * n]; for y in 0..n { for x in 0..n { @@ -281,6 +282,18 @@ mod tests { assert!(seam < 0.08, "{seam}"); } + #[test] + fn patterns_accept_full_seed_range() { + for seed in [0, 1, (1 << 24) - 1, 1 << 24, u32::MAX] { + for style in [PatternStyle::Noise, PatternStyle::Paper, PatternStyle::Canvas, PatternStyle::Dots] { + let p = pattern(style, 8, seed); + assert_eq!((p.width, p.height, p.data.len()), (8, 8, 64)); + assert!(p.data.iter().all(|v| (0.0..=1.0).contains(v)), "{style:?} seed {seed}"); + assert_eq!(p.data, pattern(style, 8, seed).data); + } + } + } + #[test] fn tips_have_paint() { for t in [ From 05092c4fa8e0f2b8e66f3320d8dbe97a36f8cc86 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 15 Nov 2026 22:30:19 +0100 Subject: [PATCH 05/42] cargo fmt after merging main Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/artboard_cmds.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/artboard_cmds.rs b/crates/engine/src/cmd/artboard_cmds.rs index 248eabc7da..61740c4214 100644 --- a/crates/engine/src/cmd/artboard_cmds.rs +++ b/crates/engine/src/cmd/artboard_cmds.rs @@ -977,13 +977,13 @@ pub fn specs() -> Vec { ] } -#[cfg(test)] -#[path = "artboard_cmds/file_types_tests.rs"] -mod file_types_tests; #[cfg(test)] #[path = "artboard_cmds/file_names_tests.rs"] mod file_names_tests; #[cfg(test)] +#[path = "artboard_cmds/file_types_tests.rs"] +mod file_types_tests; +#[cfg(test)] #[path = "artboard_cmds/first_board_background_tests.rs"] mod first_board_background_tests; #[cfg(test)] From 2f0ac3215f75af77dbdb4d08052c26f4aeefaf99 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 16 Nov 2026 01:22:45 +0100 Subject: [PATCH 06/42] Address CodeRabbit review: refuse compound file types, unreadable scratch tiles and oversized boards in artboard exports - A format token must be one plain extension: `unknown.png` named `.unknown.png` and wrote PNGs, and a `/` could leave the folder. - Artboards to Files and Artboards to PDF capture the scratch read generation before the boards are built and check it, and the document's own scratch health, before each file is written: building the boards copies their pixels (and the PNG-8 and PDF paths flatten them) before the encoder's own check sees them, so placeholder pixels from a failed read reached files. - The PNG-8 and PDF page paths refuse a board past the compositor's render limit as a bad parameter instead of panicking on the empty flatten. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/artboard_cmds.rs | 74 +++++++++++++----- .../src/cmd/artboard_cmds/file_types_tests.rs | 29 ++++++- .../engine/tests/artboard_export_scratch.rs | 76 +++++++++++++++++++ 3 files changed, 157 insertions(+), 22 deletions(-) create mode 100644 crates/engine/tests/artboard_export_scratch.rs diff --git a/crates/engine/src/cmd/artboard_cmds.rs b/crates/engine/src/cmd/artboard_cmds.rs index 61740c4214..fa6452ee7a 100644 --- a/crates/engine/src/cmd/artboard_cmds.rs +++ b/crates/engine/src/cmd/artboard_cmds.rs @@ -16,7 +16,7 @@ use photocraft_raster::Surface; use serde_json::{Value, json}; use crate::commands::{CommandSpec, color_param, int, int_i32}; -use crate::file_cmds::{SaveOpts, encode, f64_param, join, native_doc, sanitize, save_doc, stem, str_param, write_file}; +use crate::file_cmds::{SaveOpts, encode, f64_param, join, native_doc, sanitize, stem, str_param, write_file}; use crate::{EngineError, Result, Session}; /// Artboard size presets (name, width, height) in pixels, Photoshop's common devices and pages. @@ -690,14 +690,17 @@ enum FileType { } impl FileType { - fn of(format: &str) -> Self { - match format { + /// Any other token is an extension for the encoder to pick by. It must be one plain extension: + /// `unknown.png` would name `.unknown.png` and write a PNG, and a `/` would leave `dir`. + fn of(format: &str, cmd: &str) -> Result { + Ok(match format { "png8" | "png-8" => FileType::Png8, "png24" | "png-24" => FileType::Png24, "targa" => FileType::Save("tga".into()), "pdf" => FileType::Pdf, - ext => FileType::Save(ext.into()), - } + ext if !ext.is_empty() && ext.bytes().all(|b| b.is_ascii_alphanumeric()) => FileType::Save(ext.into()), + other => return Err(bad(cmd, format!("unknown file type `{other}`"))), + }) } } @@ -761,20 +764,24 @@ fn artboards_to_files(s: &mut Session, p: &Value) -> Result { let d = s.active().ok_or(EngineError::NoDocument)?; let prefix = p.get("prefix").and_then(Value::as_str).map(str::to_string).unwrap_or_else(|| stem(&d.doc.name)); let doc = d.doc.clone(); + let guard = ScratchGuard::new(&doc)?; let boards = chosen_documents(&doc, p)?; if boards.is_empty() { return Err(bad(cmd, "no matching artboards")); } - let ext = match FileType::of(&format) { + let file_type = FileType::of(&format, cmd)?; + let truecolour = matches!(file_type, FileType::Png24); + let ext = match file_type { FileType::Pdf => { // The reference application's Multi-Page Document: the bottom artboard is page 1, and // each page is the board's pixel size at 72 ppi. let mut pages = Vec::new(); for one in boards.iter().rev() { - pages.push((one.size.width, one.size.height, 72.0, jpeg_page(one, save.quality.or(Some(10.0)))?)); + pages.push((one.size.width, one.size.height, 72.0, jpeg_page(one, save.quality.or(Some(10.0)), cmd)?)); } let name = if prefix.is_empty() { stem(&doc.name) } else { prefix }; let path = join(&dir, &format!("{}.pdf", sanitize(&name))); + guard.check()?; write_file(&path, &raster_pdf(&pages))?; return Ok(json!({"files": [path]})); } @@ -782,29 +789,49 @@ fn artboards_to_files(s: &mut Session, p: &Value) -> Result { FileType::Png24 => Some("png".to_string()), FileType::Save(ext) => Some(ext), }; - let truecolour = matches!(FileType::of(&format), FileType::Png24); let extension = ext.as_deref().unwrap_or("png"); let names: Vec<&str> = boards.iter().map(|one| one.name.as_str()).collect(); let stems = artboard_file_stems(&prefix, &names, HYPHENATED_FORMATS.contains(&extension)); let mut files = Vec::new(); for (one, name) in boards.iter().zip(stems) { let path = join(&dir, &format!("{name}.{extension}")); - match &ext { - Some(_) if truecolour && one.mode != ColorMode::Rgb => { - save_doc(&rgb_copy(one)?, &path, save)?; - } - Some(_) => { - save_doc(one, &path, save)?; - } - None => write_file(&path, &png8(one)?)?, - } + let bytes = match &ext { + Some(_) if truecolour && one.mode != ColorMode::Rgb => encode(&rgb_copy(one)?, &path, save)?.0, + Some(_) => encode(one, &path, save)?.0, + None => png8(one, cmd)?, + }; + guard.check()?; + write_file(&path, &bytes)?; files.push(path); } Ok(json!({"files": files})) } +/// The scratch state an artboard export starts from. Building the boards copies their pixels +/// (and the PNG-8 and PDF paths flatten them) before the encoder's own scratch check sees them, +/// and a tile that fails to read gives placeholder pixels: [`ScratchGuard::check`] refuses them +/// before a file is written, as the export pipeline does for a document it reads itself. +struct ScratchGuard<'a> { + doc: &'a Document, + generation: u64, +} + +impl<'a> ScratchGuard<'a> { + fn new(doc: &'a Document) -> Result { + photocraft_compose::discard_unreadable_pixel_caches(); + doc.scratch_health().map_err(EngineError::Other)?; + Ok(Self { doc, generation: photocraft_raster::spill::read_error_generation() }) + } + + /// An error when a scratch read failed since [`ScratchGuard::new`], or the document's own + /// pixels are unreadable. + fn check(&self) -> Result<()> { + photocraft_raster::spill::check_since(self.generation).and_then(|()| self.doc.scratch_health()).map_err(EngineError::Other) + } +} + /// `one` as an indexed PNG: Generate Assets' PNG-8 (selective palette, no dither, transparency kept). -fn png8(one: &Document) -> Result> { +fn png8(one: &Document, cmd: &str) -> Result> { use crate::web_cmds::{WebFormat, WebMetadata, WebSettings, optimize, web_document}; let st = WebSettings { format: WebFormat::Png8, @@ -813,6 +840,7 @@ fn png8(one: &Document) -> Result> { metadata: WebMetadata::None, ..WebSettings::default() }; + crate::file_cmds::check_flattenable(one, cmd)?; let (wdoc, _, _) = web_document(one, &json!({}), &st)?; let buf = photocraft_compose::flatten(&wdoc); Ok(optimize(&buf.px, wdoc.size.width as usize, wdoc.bounds(), &st, None, None, None, wdoc.resolution_dpi, false)?.bytes) @@ -824,8 +852,10 @@ fn rgb_copy(one: &Document) -> Result { Ok(web_document(one, &json!({}), &WebSettings { convert_to_srgb: false, ..WebSettings::default() })?.0) } -/// `one` flattened over white as a JPEG, for a PDF page. -fn jpeg_page(one: &Document, quality: Option) -> Result> { +/// `one` flattened over white as a JPEG, for a PDF page. A board past the compositor's render +/// limit is refused before it is flattened (the flatten would be empty). +fn jpeg_page(one: &Document, quality: Option, cmd: &str) -> Result> { + crate::file_cmds::check_flattenable(one, cmd)?; let buf = photocraft_compose::flatten(one).over_background([1.0, 1.0, 1.0]); let fmt = PixelFormat::new(ColorMode::Rgb, SampleType::U8, true); let mut flat = Document::new(&one.name, one.size, ColorMode::Rgb, SampleType::U8); @@ -889,16 +919,18 @@ fn artboards_to_pdf(s: &mut Session, p: &Value) -> Result { let d = s.active().ok_or(EngineError::NoDocument)?; let doc = d.doc.clone(); let quality = f64_param(p, "quality").or(Some(10.0)); + let guard = ScratchGuard::new(&doc)?; let mut pages = Vec::new(); // Pages go bottom artboard of the Layers panel first, as in the reference application (#13643); // `chosen_documents` lists them top first, the order Artboards to Files keeps. for one in chosen_documents(&doc, p)?.into_iter().rev() { - let jpeg = jpeg_page(&one, quality)?; + let jpeg = jpeg_page(&one, quality, cmd)?; pages.push((one.size.width, one.size.height, doc.resolution_dpi, jpeg)); } if pages.is_empty() { return Err(bad(cmd, "no matching artboards")); } + guard.check()?; write_file(&path, &raster_pdf(&pages))?; Ok(json!({"path": path, "pages": pages.len()})) } diff --git a/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs b/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs index 0ac435e4fc..7ca2b2b4e9 100644 --- a/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs +++ b/crates/engine/src/cmd/artboard_cmds/file_types_tests.rs @@ -157,9 +157,36 @@ fn scripts_still_default_to_png() { fn unknown_format_is_an_error_and_writes_nothing() { let mut s = boards(); let dir = out_dir("unknown"); - for format in ["xyz", "png9", ""] { + // A token with a second extension or a path in it is not a file type either: `unknown.png` + // used to name `.unknown.png` and write PNGs. + for format in ["xyz", "png9", "", "unknown.png", "x.jpg", "../png", "png/x", "png "] { assert!(s.execute("file.export.artboardsToFiles", json!({"dir": dir, "format": format})).is_err(), "{format}"); } assert_eq!(std::fs::read_dir(&dir).unwrap().count(), 0); let _ = std::fs::remove_dir_all(&dir); } + +/// A board past the compositor's render limit flattens to an empty buffer; the PNG-8 and PDF +/// paths flatten it themselves, so they refuse it as a bad parameter instead of panicking on the +/// empty buffer (`region data length mismatch`). +#[test] +fn oversized_board_is_a_bad_params_error_for_png8_and_pdf() { + let mut s = Session::new(); + let mut doc = Document::new("huge", Size::new(40_000, 40_000), ColorMode::Rgb, SampleType::U8); + let mut board = Layer::group("Huge Board", Vec::new()); + if let LayerContent::Group(g) = &mut board.content { + g.artboard = Some(Artboard { rect: Rect::new(0, 0, 40_000, 40_000), background: ArtboardBackground::Transparent, preset: String::new() }); + } + doc.layers.push(board); + s.add_document(doc, None); + let dir = out_dir("huge"); + for format in ["png8", "pdf"] { + let r = s.execute("file.export.artboardsToFiles", json!({"dir": dir, "format": format})); + assert!(matches!(r, Err(EngineError::BadParams { .. })), "{format}: {r:?}"); + } + let path = join(&dir, "huge.pdf"); + let r = s.execute("file.export.artboardsToPdf", json!({"path": path})); + assert!(matches!(r, Err(EngineError::BadParams { .. })), "artboardsToPdf: {r:?}"); + assert_eq!(std::fs::read_dir(&dir).unwrap().count(), 0); + let _ = std::fs::remove_dir_all(&dir); +} diff --git a/crates/engine/tests/artboard_export_scratch.rs b/crates/engine/tests/artboard_export_scratch.rs new file mode 100644 index 0000000000..da0443310b --- /dev/null +++ b/crates/engine/tests/artboard_export_scratch.rs @@ -0,0 +1,76 @@ +//! Artboards to Files and Artboards to PDF never write a board whose scratch tiles can't be read: +//! the PNG-8 and PDF paths flatten the board themselves, outside the checked export pipeline, so +//! the placeholder pixels a failed read gives would otherwise be encoded as real pixels. +use photocraft_color::{ColorMode, PixelFormat, SampleType}; +use photocraft_doc::{Artboard, ArtboardBackground, Document, Layer, LayerContent}; +use photocraft_engine::Session; +use photocraft_geom::{Rect, Size, TileCoord}; +use photocraft_raster::spill; +use serde_json::json; +use std::io::{Read, Seek, SeekFrom, Write}; + +#[test] +fn artboard_exports_refuse_unreadable_scratch_tiles() { + let root = std::env::temp_dir().join(format!("photocraft-artboard-scratch-{}", std::process::id())); + let scratch = root.join("scratch"); + let out = root.join("out"); + let _ = std::fs::remove_dir_all(&root); + std::fs::create_dir_all(&out).unwrap(); + let mut session = Session::new(); + session.edit_prefs(|p| { + p.scratch_disks.disks = vec![photocraft_engine::prefs::ScratchDisk { path: scratch.to_string_lossy().into(), enabled: true }]; + p.performance.memory_usage_mb = 1; + }); + assert!(spill::enabled()); + let mut doc = Document::new("Scratch boards", Size::new(2048, 256), ColorMode::Rgb, SampleType::U8); + let mut pixels = Layer::raster("Pixels", PixelFormat::RGBA8); + for i in 0..8 { + let mut bytes = pixels.surface_mut().unwrap().tile_mut(TileCoord::new(i, 0)).bytes_mut(); + for (j, b) in bytes.iter_mut().enumerate() { + *b = (j as u32).wrapping_mul(17).wrapping_add(i as u32 * 43) as u8; + } + } + let mut board = Layer::group("Board", vec![pixels]); + if let LayerContent::Group(g) = &mut board.content { + g.artboard = Some(Artboard { rect: Rect::new(0, 0, 2048, 256), background: ArtboardBackground::Transparent, preset: String::new() }); + } + doc.layers.push(board); + session.add_document(doc, None); + let dir = out.to_string_lossy().into_owned(); + // Readable: every path writes. + for format in ["png8", "pdf"] { + session.execute("file.export.artboardsToFiles", json!({"dir": dir, "format": format})).unwrap(); + } + let pdf = out.join("whole.pdf").to_string_lossy().into_owned(); + session.execute("file.export.artboardsToPdf", json!({"path": pdf})).unwrap(); + for entry in std::fs::read_dir(&out).unwrap() { + std::fs::remove_file(entry.unwrap().path()).unwrap(); + } + + // Force every tile to disk, then damage only this test's scratch file. + spill::configure(Some(&scratch), 1).unwrap(); + spill::settle(); + assert_eq!(spill::stats().resident_bytes, 0); + let mut file = spill::scratch_handle_for_tests().unwrap(); + file.seek(SeekFrom::Start(0)).unwrap(); + let mut good = Vec::new(); + file.read_to_end(&mut good).unwrap(); + file.seek(SeekFrom::Start(0)).unwrap(); + file.write_all(&vec![0; good.len()]).unwrap(); + file.sync_all().unwrap(); + + for format in ["png8", "pdf", "png24", "png"] { + let r = session.execute("file.export.artboardsToFiles", json!({"dir": dir, "format": format})); + assert!(r.is_err(), "{format} wrote a board with unreadable tiles: {r:?}"); + } + assert!(session.execute("file.export.artboardsToPdf", json!({"path": pdf})).is_err(), "Artboards to PDF wrote unreadable tiles"); + let written: Vec<_> = std::fs::read_dir(&out).unwrap().map(|e| e.unwrap().path()).collect(); + assert!(written.is_empty(), "{written:?}"); + + file.seek(SeekFrom::Start(0)).unwrap(); + file.write_all(&good).unwrap(); + file.sync_all().unwrap(); + drop((session, file)); + spill::configure(None, 0).unwrap(); + let _ = std::fs::remove_dir_all(root); +} From ad131b391ec096563494cab65250182fa91829bf Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 16 Nov 2026 02:41:29 +0100 Subject: [PATCH 07/42] Address CodeRabbit review: keep the scratch test's one-byte budget through eviction The session's memory worker refreshes the tile budget from the preferences every two seconds; a refresh between configure and settle could leave tiles resident. Set the budget again until a settle has emptied memory (bounded). Co-Authored-By: Claude Opus 5.5 --- crates/engine/tests/artboard_export_scratch.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/engine/tests/artboard_export_scratch.rs b/crates/engine/tests/artboard_export_scratch.rs index da0443310b..38f0e71e6c 100644 --- a/crates/engine/tests/artboard_export_scratch.rs +++ b/crates/engine/tests/artboard_export_scratch.rs @@ -47,9 +47,17 @@ fn artboard_exports_refuse_unreadable_scratch_tiles() { std::fs::remove_file(entry.unwrap().path()).unwrap(); } - // Force every tile to disk, then damage only this test's scratch file. - spill::configure(Some(&scratch), 1).unwrap(); - spill::settle(); + // Force every tile to disk, then damage only this test's scratch file. The session's memory + // worker refreshes the budget from the preferences every two seconds; a refresh between + // `configure` and `settle` would leave tiles resident, so set the one-byte budget again until + // a settle has emptied memory (bounded). + for _ in 0..20 { + spill::configure(Some(&scratch), 1).unwrap(); + spill::settle(); + if spill::stats().resident_bytes == 0 { + break; + } + } assert_eq!(spill::stats().resident_bytes, 0); let mut file = spill::scratch_handle_for_tests().unwrap(); file.seek(SeekFrom::Start(0)).unwrap(); From c30a5bfbd7c16665ed229da785b54a6a0dcbe7da Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 19 Nov 2026 18:36:29 +0100 Subject: [PATCH 08/42] Tests: the artboard export scratch test joins the global_state binary `cargo xtask test-binaries` refuses single-file test binaries under crates/*/tests. The test sets the scratch disk and the memory budget for the whole process, so it moves next to scratch_disk.rs in tests/global_state and takes the same process lock and test volume. Co-Authored-By: Claude Opus 5.5 --- .../engine/tests/{ => global_state}/artboard_export_scratch.rs | 2 ++ crates/engine/tests/global_state/main.rs | 1 + 2 files changed, 3 insertions(+) rename crates/engine/tests/{ => global_state}/artboard_export_scratch.rs (97%) diff --git a/crates/engine/tests/artboard_export_scratch.rs b/crates/engine/tests/global_state/artboard_export_scratch.rs similarity index 97% rename from crates/engine/tests/artboard_export_scratch.rs rename to crates/engine/tests/global_state/artboard_export_scratch.rs index 38f0e71e6c..cb2d21be19 100644 --- a/crates/engine/tests/artboard_export_scratch.rs +++ b/crates/engine/tests/global_state/artboard_export_scratch.rs @@ -11,6 +11,8 @@ use std::io::{Read, Seek, SeekFrom, Write}; #[test] fn artboard_exports_refuse_unreadable_scratch_tiles() { + photocraft_raster::spill::use_test_volume_space(); + let _scratch = crate::lock(&crate::PROCESS); let root = std::env::temp_dir().join(format!("photocraft-artboard-scratch-{}", std::process::id())); let scratch = root.join("scratch"); let out = root.join("out"); diff --git a/crates/engine/tests/global_state/main.rs b/crates/engine/tests/global_state/main.rs index fa3f08a3d1..4d78ec0606 100644 --- a/crates/engine/tests/global_state/main.rs +++ b/crates/engine/tests/global_state/main.rs @@ -2,6 +2,7 @@ //! spill configuration, simulated memory, global caches, compositor settings). They live apart from //! `it` so plain `cargo test` runs them without the rest of the suite. +mod artboard_export_scratch; mod lut_row_cache_purge; mod mask_cache_purge; mod memory_gate; From 20ff6bc6052a3e7285ca103e5b1285a2e7bad5de Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:25:38 +0100 Subject: [PATCH 09/42] Validate palette size for exact transparency handling Reject Exact conversion if the opaque palette uses every slot and the image needs a transparent entry. Leave the edit transaction uncommitted in that case. --- crates/engine/src/cmd/mode_cmds.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/engine/src/cmd/mode_cmds.rs b/crates/engine/src/cmd/mode_cmds.rs index 4d75962e96..6e24019b2e 100644 --- a/crates/engine/src/cmd/mode_cmds.rs +++ b/crates/engine/src/cmd/mode_cmds.rs @@ -360,6 +360,10 @@ fn indexed_color(s: &mut Session, p: &Value) -> Result { } let has_clear = transparency && px.iter().any(|q| q[3] < 0.5); let mut pal = quantize::build_palette(&px, kind, if has_clear { colors.saturating_sub(1).max(2) } else { colors }, forced).map_err(|e| bad(CMD, e))?; + // Exact must reserve one palette slot for clear pixels. + if kind == PaletteKind::Exact && has_clear && pal.len() >= 256 { + return Err(bad(CMD, "Exact with transparency needs 255 or fewer opaque palette colours plus one transparent entry")); + } let transparent = if has_clear && pal.len() < 256 { pal.push([255, 255, 255]); Some(pal.len() - 1) From 65b3b20b24b833eb05a2270cfeaeba9f8fd8e88a Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:26:31 +0100 Subject: [PATCH 10/42] test(engine): cover Exact indexed transparency capacity Cover unchanged document state after refusal and successful conversion on both valid palette boundaries. --- crates/engine/src/cmd/mode_cmds/tests.rs | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/crates/engine/src/cmd/mode_cmds/tests.rs b/crates/engine/src/cmd/mode_cmds/tests.rs index 7e49ee5f8f..f32584a5a5 100644 --- a/crates/engine/src/cmd/mode_cmds/tests.rs +++ b/crates/engine/src/cmd/mode_cmds/tests.rs @@ -439,6 +439,47 @@ fn indexed_matte_without_transparency_fills_clear_pixels_and_rejects_bad_input_a assert_eq!(doc(&s).color_table.as_ref().unwrap().transparent, None); } +#[test] +fn indexed_exact_rejects_full_opaque_palette_with_clear_pixels_atomically() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 257, "height": 1, "background": "transparent"})).unwrap(); + paint(&mut s, |x, _| if x < 256 { [x as f32 / 255.0, x as f32 / 255.0, x as f32 / 255.0, 1.0] } else { [0.0; 4] }); + let before = doc(&s).layers[0].surface().unwrap().to_interleaved(doc(&s).bounds()); + let history = s.active().unwrap().history.past_len(); + let revision = s.active().unwrap().revision; + let error = s.execute("image.mode.indexedColor", json!({"palette": "exact", "forced": "none", "dither": "none", "transparency": true})).unwrap_err(); + let message = error.to_string(); + assert!(message.contains("255") && message.contains("transparent entry"), "{message}"); + assert_eq!(doc(&s).mode, ColorMode::Rgb); + assert!(doc(&s).color_table.is_none()); + assert_eq!(doc(&s).layers[0].surface().unwrap().to_interleaved(doc(&s).bounds()), before); + assert_eq!(s.active().unwrap().history.past_len(), history); + assert_eq!(s.active().unwrap().revision, revision); +} + +#[test] +fn indexed_exact_reserves_transparency_only_when_needed_and_available() { + for (opaque, clear) in [(255u32, true), (256, false)] { + let mut s = Session::new(); + s.execute("file.new", json!({"width": opaque + u32::from(clear), "height": 1, "background": "transparent"})).unwrap(); + paint(&mut s, |x, _| if x < opaque as i32 { [x as f32 / 255.0, x as f32 / 255.0, x as f32 / 255.0, 1.0] } else { [0.0; 4] }); + let result = s.execute("image.mode.indexedColor", json!({"palette": "exact", "forced": "none", "dither": "none", "transparency": true})).unwrap(); + assert_eq!(doc(&s).mode, ColorMode::Indexed); + let table = doc(&s).color_table.as_ref().unwrap(); + assert_eq!(table.colors.len(), 256); + assert_eq!(table.transparent, if clear { Some(255) } else { None }); + assert_eq!(result["transparentIndex"], if clear { json!(255) } else { Value::Null }); + let surface = doc(&s).layers[0].surface().unwrap(); + for x in 0..opaque as i32 { + let gray = x as f32 / 255.0; + assert_eq!(surface.rgba(x, 0), [gray, gray, gray, 1.0]); + } + if clear { + assert_eq!(surface.rgba(opaque as i32, 0)[3], 0.0); + } + } +} + #[test] fn indexed_exact_transparency_and_sources() { // Two colours + transparency: exact palette with a transparent entry. From d57b7b2ff13231642211904f6e8480f187a56b20 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:47:11 +0100 Subject: [PATCH 11/42] Implement checkpoint for Exact conversion failures Restore the active document state and action history on a rejected Exact conversion that auto-drops a floating selection. Keep the normal command, drop, and history sequence on success. --- crates/engine/src/jobs.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/engine/src/jobs.rs b/crates/engine/src/jobs.rs index d4870e52f6..86fb590a5c 100644 --- a/crates/engine/src/jobs.rs +++ b/crates/engine/src/jobs.rs @@ -1721,6 +1721,29 @@ impl Session { // authorization, validation, floating-selection and admission failures. let live_commit = self.live_commit.take(); self.sync_scratch_state(); + // A refused Exact conversion must also undo its automatic floating-selection drop. + let checkpoint = if id == "image.mode.indexedColor" && params.get("palette").and_then(Value::as_str) == Some("exact") { + self.active.and_then(|index| { + self.docs + .get(index) + .filter(|state| crate::float_cmds::floating(state).is_some()) + .map(|state| (index, state.clone(), self.action_history.clone())) + }) + } else { + None + }; + let result = self.dispatch_with_commit(id, params, background, live_commit); + if result.is_err() + && let Some((index, state, action_history)) = checkpoint + && self.docs.get(index).is_some_and(|current| current.doc.id == state.doc.id) + { + self.docs[index] = state; + self.action_history = action_history; + } + result + } + + fn dispatch_with_commit(&mut self, id: &str, params: Value, background: bool, live_commit: Option) -> Result { let spec = crate::commands::find(id).ok_or_else(|| EngineError::UnknownCommand(id.to_string()))?; // Params are named fields: anything but an object (or null, meaning none) is a caller // mistake, not "use every default". From 923dbadade2a7c8cbb679ab694c0101d689484d6 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:47:20 +0100 Subject: [PATCH 12/42] test(engine): cover Exact conversion with a floating selection Reproduce failure after a partial clear-pixel fill, preserving the floating copy and redo. Exercise successful conversion after filling the last clear pixel. --- crates/engine/src/cmd/mode_cmds/tests.rs | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/crates/engine/src/cmd/mode_cmds/tests.rs b/crates/engine/src/cmd/mode_cmds/tests.rs index f32584a5a5..4bb0ddc91c 100644 --- a/crates/engine/src/cmd/mode_cmds/tests.rs +++ b/crates/engine/src/cmd/mode_cmds/tests.rs @@ -480,6 +480,64 @@ fn indexed_exact_reserves_transparency_only_when_needed_and_available() { } } +#[test] +fn indexed_exact_failure_restores_a_floating_copy_and_redo() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 258, "height": 1, "background": "transparent"})).unwrap(); + paint(&mut s, |x, _| if x < 256 { [x as f32 / 255.0, x as f32 / 255.0, x as f32 / 255.0, 1.0] } else { [0.0; 4] }); + s.execute("select.rect", json!({"x": 0, "y": 0, "width": 1, "height": 1})).unwrap(); + s.edit("redo marker", |doc, _| { + doc.name.push_str(" changed"); + Ok(()) + }) + .unwrap(); + assert!(s.undo()); + s.execute("select.float", json!({"dx": 256, "copy": true})).unwrap(); + let before = s.active().unwrap().clone(); + assert!(before.history.can_redo()); + let piece = crate::float_cmds::floating(&before).unwrap(); + let pixels = before.doc.layers[0].surface().unwrap().to_interleaved(before.doc.bounds()); + + let error = s.execute("image.mode.indexedColor", json!({"palette": "exact", "forced": "none", "dither": "none", "transparency": true})).unwrap_err(); + assert!(error.to_string().contains("255"), "{error}"); + let after = s.active().unwrap(); + let restored = crate::float_cmds::floating(after).unwrap(); + assert_eq!(after.doc.id, before.doc.id); + assert_eq!(after.doc.mode, ColorMode::Rgb); + assert!(std::sync::Arc::ptr_eq(&after.doc, &before.doc)); + assert_eq!(after.doc.layers[0].surface().unwrap().to_interleaved(after.doc.bounds()), pixels); + assert_eq!((restored.layer, restored.offset, restored.revision, restored.moved), (piece.layer, piece.offset, piece.revision, piece.moved)); + assert!(std::sync::Arc::ptr_eq(&restored.parts, &piece.parts)); + assert_eq!(after.revision, before.revision); + assert_eq!(after.history.past_len(), before.history.past_len()); + assert!(after.history.can_redo()); + assert_eq!(after.active_layer, before.active_layer); + assert_eq!(after.selected_layers, before.selected_layers); +} + +#[test] +fn indexed_exact_success_drops_the_floating_copy_before_counting_colours() { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 257, "height": 1, "background": "transparent"})).unwrap(); + paint(&mut s, |x, _| if x < 256 { [x as f32 / 255.0, x as f32 / 255.0, x as f32 / 255.0, 1.0] } else { [0.0; 4] }); + s.execute("select.rect", json!({"x": 0, "y": 0, "width": 1, "height": 1})).unwrap(); + s.execute("select.float", json!({"dx": 256, "copy": true})).unwrap(); + let history = s.active().unwrap().history.past_len(); + let result = s.execute("image.mode.indexedColor", json!({"palette": "exact", "forced": "none", "dither": "none", "transparency": true})).unwrap(); + assert_eq!(doc(&s).mode, ColorMode::Indexed); + assert_eq!(doc(&s).color_table.as_ref().unwrap().colors.len(), 256); + assert_eq!(result["transparentIndex"], Value::Null); + assert!(crate::float_cmds::floating(s.active().unwrap()).is_none()); + assert_eq!(doc(&s).layers[0].surface().unwrap().rgba(256, 0), [0.0, 0.0, 0.0, 1.0]); + assert_eq!(s.active().unwrap().history.past_len(), history + 2, "drop and conversion remain separate history steps"); + assert!(s.undo()); + assert_eq!(doc(&s).mode, ColorMode::Rgb); + assert_eq!(doc(&s).layers[0].surface().unwrap().rgba(256, 0)[3], 1.0); + assert!(s.undo()); + assert_eq!(doc(&s).layers[0].surface().unwrap().rgba(256, 0)[3], 0.0); + assert_eq!(s.active().unwrap().history.past_len(), history); +} + #[test] fn indexed_exact_transparency_and_sources() { // Two colours + transparency: exact palette with a transparent entry. From 1fba8d090f1a2fc6cafc30b4a4296580656c9e2f Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:06:47 +0100 Subject: [PATCH 13/42] fix(xtask): run corpus tests for changes to the current ATN module Point the changed-path trigger at the current engine command module and share the predicate with regression tests. --- xtask/src/corpus.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xtask/src/corpus.rs b/xtask/src/corpus.rs index 0be1f83625..871a9e1c2c 100644 --- a/xtask/src/corpus.rs +++ b/xtask/src/corpus.rs @@ -24,7 +24,12 @@ const HEIF_CRATES: &[&str] = &["photocraft-io"]; /// Paths whose changes make `test-corpus --changed` run (the file-format and rendering crates, /// and the engine's `.atn` import and export). -const CRITICAL: &[&str] = &["crates/io/", "crates/compose/", "crates/gpu/", "crates/text/", "crates/format/", "crates/raw/", "crates/engine/src/atn_cmds"]; +const CRITICAL: &[&str] = &["crates/io/", "crates/compose/", "crates/gpu/", "crates/text/", "crates/format/", "crates/raw/", "crates/engine/src/cmd/atn_cmds"]; + +fn is_critical(path: &str) -> bool { + CRITICAL.iter().any(|prefix| path.starts_with(prefix)) +} + /// `cargo xtask corpus [--all | --pngsuite | --download | --psd | --psd-tools | --heif | --exr | --pixls | --affinity | --atn | --photoshop [--local] | --gimp [--local]] [--update-manifest]` pub fn cmd(args: &[&str]) -> Result<(), String> { let update = args.contains(&"--update-manifest"); @@ -417,7 +422,7 @@ pub fn test_cmd(args: &[&str]) -> Result<(), String> { let mut raw_changed = false; if ours.contains(&"--changed") { let changed = changed_files()?; - let hits: Vec<&String> = changed.iter().filter(|f| CRITICAL.iter().any(|c| f.starts_with(c))).collect(); + let hits: Vec<&String> = changed.iter().filter(|f| is_critical(f)).collect(); if hits.is_empty() { println!("test-corpus --changed: nothing under {} changed since origin/main; skipping", CRITICAL.join(", ")); return Ok(()); From 3c1043a87b1a56e5571e596431ca80247a194a93 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Thu, 19 Nov 2026 23:07:29 +0100 Subject: [PATCH 14/42] test(xtask): cover ATN corpus trigger paths Exercise the ATN root and nested modules, all existing corpus prefixes, and unrelated engine paths. --- xtask/src/corpus/tests.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/xtask/src/corpus/tests.rs b/xtask/src/corpus/tests.rs index b1c7b515a9..0b187445e2 100644 --- a/xtask/src/corpus/tests.rs +++ b/xtask/src/corpus/tests.rs @@ -1,5 +1,38 @@ use super::*; +#[test] +fn changed_atn_root_triggers_corpus_tests() { + assert!(is_critical("crates/engine/src/cmd/atn_cmds.rs")); +} + +#[test] +fn changed_atn_modules_trigger_corpus_tests() { + for path in ["crates/engine/src/cmd/atn_cmds/steps_render.rs", "crates/engine/src/cmd/atn_cmds/tests.rs"] { + assert!(is_critical(path), "{path}"); + } +} + +#[test] +fn existing_critical_sources_still_trigger_corpus_tests() { + for path in [ + "crates/io/src/ora.rs", + "crates/compose/src/lib.rs", + "crates/gpu/src/lib.rs", + "crates/text/src/lib.rs", + "crates/format/src/lib.rs", + "crates/raw/src/lib.rs", + ] { + assert!(is_critical(path), "{path}"); + } +} + +#[test] +fn unrelated_sources_do_not_trigger_corpus_tests() { + for path in ["crates/engine/src/jobs.rs", "crates/engine/src/cmd/layer_cmds.rs", "docs/actions.md", "apps/photocraft-web/src/main.rs"] { + assert!(!is_critical(path), "{path}"); + } +} + /// The flags each pinned corpus is fetched with by `fetch_all(local, update)`. fn calls(local: bool, update: bool) -> Vec<(&'static str, bool)> { let mut seen = Vec::new(); From 2a3fae44ef62bd7c7b833a1acf0d3ea940781b39 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:45:42 +0100 Subject: [PATCH 15/42] fix(xtask): limit ATN corpus trigger to real module paths Updated the CRITICAL paths to include a trailing slash for consistency and modified the is_critical function to check for a specific path. --- xtask/src/corpus.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xtask/src/corpus.rs b/xtask/src/corpus.rs index 871a9e1c2c..3d217c9f78 100644 --- a/xtask/src/corpus.rs +++ b/xtask/src/corpus.rs @@ -24,10 +24,10 @@ const HEIF_CRATES: &[&str] = &["photocraft-io"]; /// Paths whose changes make `test-corpus --changed` run (the file-format and rendering crates, /// and the engine's `.atn` import and export). -const CRITICAL: &[&str] = &["crates/io/", "crates/compose/", "crates/gpu/", "crates/text/", "crates/format/", "crates/raw/", "crates/engine/src/cmd/atn_cmds"]; +const CRITICAL: &[&str] = &["crates/io/", "crates/compose/", "crates/gpu/", "crates/text/", "crates/format/", "crates/raw/", "crates/engine/src/cmd/atn_cmds/"]; fn is_critical(path: &str) -> bool { - CRITICAL.iter().any(|prefix| path.starts_with(prefix)) + path == "crates/engine/src/cmd/atn_cmds.rs" || CRITICAL.iter().any(|prefix| path.starts_with(prefix)) } /// `cargo xtask corpus [--all | --pngsuite | --download | --psd | --psd-tools | --heif | --exr | --pixls | --affinity | --atn | --photoshop [--local] | --gimp [--local]] [--update-manifest]` From 9de261912872a901ab0005ecd185156accc0ac8f Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:46:09 +0100 Subject: [PATCH 16/42] test(xtask): exclude similarly named ATN sibling paths --- xtask/src/corpus/tests.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xtask/src/corpus/tests.rs b/xtask/src/corpus/tests.rs index 0b187445e2..921bdc24e9 100644 --- a/xtask/src/corpus/tests.rs +++ b/xtask/src/corpus/tests.rs @@ -12,6 +12,18 @@ fn changed_atn_modules_trigger_corpus_tests() { } } +#[test] +fn similarly_named_atn_siblings_do_not_trigger_corpus_tests() { + for path in [ + "crates/engine/src/cmd/atn_cmds_extra.rs", + "crates/engine/src/cmd/atn_cmds_old/tests.rs", + "crates/engine/src/cmd/atn_cmds.rs.bak", + "crates/engine/src/cmd/atn_cmds", + ] { + assert!(!is_critical(path), "{path}"); + } +} + #[test] fn existing_critical_sources_still_trigger_corpus_tests() { for path in [ From e39dfb94552f2d697333a538dc42508cd4bb3083 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 21 Nov 2026 07:24:26 +0000 Subject: [PATCH 17/42] Appearance and Language menu picks change the theme and the language A theme or language row is a fired command (app.theme, app.language) with the choice in its parameters. The drain's dispatch refused both ids (no enable rule, so the engine's rule answered: not available) and passed invoke empty parameters. Both rows are enabled with or without a document, and dispatch passes the fired command's parameters to invoke. Trials run the whole app with and without a document: a theme fired as the macOS menu fires it, a theme clicked in Window > Appearance, and a language row. --- crates/ui-egui/src/input/shortcut_dispatch.rs | 16 ++- crates/ui-egui/src/menus.rs | 3 + .../src/menus/appearance_menu_trials.rs | 118 ++++++++++++++++++ crates/ui-egui/src/menus/state.rs | 4 + 4 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 crates/ui-egui/src/menus/appearance_menu_trials.rs diff --git a/crates/ui-egui/src/input/shortcut_dispatch.rs b/crates/ui-egui/src/input/shortcut_dispatch.rs index f0af34bbdf..1d0c5189b7 100644 --- a/crates/ui-egui/src/input/shortcut_dispatch.rs +++ b/crates/ui-egui/src/input/shortcut_dispatch.rs @@ -709,17 +709,20 @@ fn run_pressed(app: &mut PhotocraftApp, ctx: &egui::Context, f: &Fired) { // The Delete key is Edit › Clear, or deletes the layers when nothing is selected (`delete_key_command`). let id = if id == EditCommands::Delete.id() { "edit.clear" } else { id }; let id = clip_key_command(app, delete_key_command(app, id.to_string())); - dispatch_as(app, ctx, &id, f.alt_variant); + // A key that runs another command (Delete, the clip keys) runs it without the fired command's parameters. + let command = if id == f.command.id { f.command.clone() } else { CommandRef::new(id) }; + dispatch_as(app, ctx, &command, f.alt_variant); } /// Run a shortcut's command like its menu item (dialogs included), or say why it can't run. pub fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str) { - dispatch_as(app, ctx, id, false); + dispatch_as(app, ctx, &CommandRef::new(id), false); } -/// [`dispatch`]; with `last`, an adjustment dialog opens at its last confirmed settings and New Layer makes the -/// layer without its dialog. -fn dispatch_as(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, last: bool) { +/// [`dispatch`] of a fired command, its parameters included (an Appearance or Language row's choice); with `last`, an +/// adjustment dialog opens at its last confirmed settings and New Layer makes the layer without its dialog. +fn dispatch_as(app: &mut PhotocraftApp, ctx: &egui::Context, command: &CommandRef, last: bool) { + let id = command.id.as_str(); let action = id.strip_prefix(crate::actions::SHORTCUT_PREFIX); let command_id = if action.is_some() { "actions.play" } else { id }; // A key saved for an action that was since deleted or renamed names no action. @@ -748,7 +751,8 @@ fn dispatch_as(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, last: boo let opened = if last { crate::adjust_dialog::open_last(app, id) } else { crate::adjust_dialog::open(app, id) }; opened.map(|_| serde_json::Value::Null) } else { - crate::menus::invoke(app, ctx, id, json!({})) + let params = if command.params.is_null() { json!({}) } else { command.params.clone() }; + crate::menus::invoke(app, ctx, id, params) }; match r { Ok(_) => Outcome::Ran, diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 4df91e6dc1..2b3ccdd3f1 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -104,6 +104,9 @@ pub(crate) const DOCUMENT_ITEM: &str = "window.document."; #[cfg(test)] mod tests; +#[cfg(test)] +mod appearance_menu_trials; + #[cfg(test)] mod open_recent_position_tests; diff --git a/crates/ui-egui/src/menus/appearance_menu_trials.rs b/crates/ui-egui/src/menus/appearance_menu_trials.rs new file mode 100644 index 0000000000..bdff4c3900 --- /dev/null +++ b/crates/ui-egui/src/menus/appearance_menu_trials.rs @@ -0,0 +1,118 @@ +//! The Appearance and Language menus in the whole app: a pick changes the theme the framework draws with and the +//! language, whether it comes from a click on the in-window bar or from the macOS menu, which fires the row's command. +//! Both menus work with or without a document open. + +use craft::keymap::CommandRef; +use craft::menu::{LANGUAGE_COMMAND, ThemeChoice}; +use craft::ui::runtime::commands::{FireSource, fire}; +use egui::accesskit::Role; +use egui_kittest::Harness; +use egui_kittest::kittest::{AccessKitNode, Queryable}; + +use crate::PhotocraftApp; +use crate::theme::AppTheme; + +/// The whole app, empty or with one document open. +fn harness(document: bool) -> Harness<'static, Box> { + let mut session = photocraft_engine::Session::new(); + if document { + session.execute("file.new", serde_json::json!({"width": 64, "height": 48})).unwrap(); + } + crate::shortcut_dispatch::tests::app_harness(PhotocraftApp::new(session, crate::Services::default())) +} + +/// The theme the framework's root takes each frame (`frame_input`) and the panel fill the theme installs. +fn shown(h: &Harness<'_, Box>) -> (String, bool, egui::Color32) { + let theme = &h.state().ui.theme; + (theme.id().as_str().to_string(), theme.is_dark(), h.ctx.global_style().visuals.panel_fill) +} + +/// Classic in light mode: a light theme of its own row, unlike the dark theme the app starts with. +fn classic() -> (AppTheme, ThemeChoice) { + let theme = AppTheme::classic(); + let choice = ThemeChoice::theme(theme.id().clone(), false); + (theme, choice) +} + +/// Runs the frames that take a fired command and show its result. +fn settle(h: &mut Harness<'_, Box>) { + h.run_steps(6); +} + +/// The centre of the top-most menu title or row labelled `label`. +fn top(h: &Harness<'_, Box>, label: &str) -> egui::Pos2 { + let named = |node: &AccessKitNode<'_>| { + node.label().as_deref() == Some(label) && matches!(node.role(), Role::MenuItem | Role::MenuItemRadio | Role::MenuItemCheckBox) + }; + let node = h.get_all_by(named).min_by(|a, b| a.rect().min.y.total_cmp(&b.rect().min.y)).unwrap_or_else(|| panic!("no menu row {label}")); + node.rect().center() +} + +/// Moves the pointer over the top-most node labelled `label`. +fn hover_top(h: &mut Harness<'_, Box>, label: &str) { + let at = top(h, label); + h.event(egui::Event::PointerMoved(at)); + settle(h); +} + +/// Clicks the top-most node labelled `label` with the pointer, a frame for the press and one for the release. +fn click_top(h: &mut Harness<'_, Box>, label: &str) { + let at = top(h, label); + h.event(egui::Event::PointerMoved(at)); + h.step(); + for pressed in [true, false] { + h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }); + h.step(); + } + settle(h); +} + +/// Asserts the app shows Classic light after a pick, with the panel fill it installs. +fn assert_classic(h: &Harness<'_, Box>, before: &(String, bool, egui::Color32), document: bool) { + let (theme, _) = classic(); + let after = shown(h); + assert_eq!((after.0.as_str(), after.1), (theme.id().as_str(), false), "document {document}; status: {}", h.state().ui.status); + assert_ne!(after.2, before.2, "document {document}: the panels take the theme's fill"); + assert_eq!(after.2, theme.tokens().chrome, "document {document}"); +} + +#[test] +fn a_theme_fired_from_the_menu_shows_it() { + for document in [true, false] { + let mut h = harness(document); + let (theme, choice) = classic(); + let before = shown(&h); + assert_ne!(before.0, theme.id().as_str(), "the app starts on another theme"); + assert!(fire(&h.ctx.clone(), choice.command(), FireSource::Menu), "the runtime takes the menu's theme row"); + settle(&mut h); + assert_classic(&h, &before, document); + } +} + +#[test] +fn a_theme_clicked_in_the_window_menu_shows_it() { + for document in [true, false] { + let mut h = harness(document); + let (theme, _) = classic(); + let before = shown(&h); + click_top(&mut h, "Window"); + hover_top(&mut h, "Appearance"); + let name = h.state().framework.theme_name(theme.id(), false); + click_top(&mut h, &name); + assert_classic(&h, &before, document); + } +} + +#[test] +fn a_language_fired_from_the_menu_is_saved() { + // A language other than English where the build has the catalogs; English (from Automatic) where it has only that. + let code = crate::i18n::Lang::all().map(crate::i18n::Lang::code).find(|code| *code != "en").unwrap_or("en"); + for document in [true, false] { + let mut h = harness(document); + assert_eq!(h.state().session.prefs().interface.language, "auto"); + let row = CommandRef::with_params(LANGUAGE_COMMAND, serde_json::json!({"lang": code})); + assert!(fire(&h.ctx.clone(), row, FireSource::Menu), "the runtime takes the menu's language row"); + settle(&mut h); + assert_eq!(h.state().session.prefs().interface.language, code, "document {document}; status: {}", h.state().ui.status); + } +} diff --git a/crates/ui-egui/src/menus/state.rs b/crates/ui-egui/src/menus/state.rs index b391038165..7831ae9382 100644 --- a/crates/ui-egui/src/menus/state.rs +++ b/crates/ui-egui/src/menus/state.rs @@ -1,3 +1,5 @@ +use craft::menu::{LANGUAGE_COMMAND, THEME_COMMAND}; + use super::invoke::{panel_alias, proof_preset, workspace_id}; use super::{DOCUMENT_ITEM, PhotocraftApp, Value}; @@ -72,6 +74,8 @@ pub fn is_enabled(app: &PhotocraftApp, id: &str) -> bool { i if crate::links::url_for(i).is_some() => true, // Interface brightness works with or without a document, as in Photoshop. "view.darkenInterface" | "view.lightenInterface" => true, + // Appearance and Language rows: the theme and the language change with or without a document. + THEME_COMMAND | LANGUAGE_COMMAND => true, "file.save" | "file.saveAs" | "file.export.exportAs" | "file.export.quickExportAsPng" => { app.session.active().is_some() && app.services.export.is_some() } From f0a1b7c9c38c255bbdd17a6942da7728c9f758c7 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 10:39:20 +0100 Subject: [PATCH 18/42] Tests: cut duplicate bevel thread cases (#15935) --- crates/compose/src/effects/tests.rs | 67 +++++++++++++++-------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/crates/compose/src/effects/tests.rs b/crates/compose/src/effects/tests.rs index e546ece5bf..3654dd78fc 100644 --- a/crates/compose/src/effects/tests.rs +++ b/crates/compose/src/effects/tests.rs @@ -700,49 +700,52 @@ fn chisel_fields_do_not_depend_on_the_threads() { #[test] fn bevel_maps_do_not_depend_on_the_threads() { - // Every style and technique, softened or not, and a texture; one thread (in order) is the reference. - let mut patchy = aa_disc(101, 101, 40.0); + // Compact anti-aliased fixtures keep curved, rounded, clipped oblique and patchy edges. + // Dimensions above 16 and below 64 exercise multi-row groups with 2 threads and + // one row per group with 8. Odd extents also leave a short final group. + let mut patchy = aa_disc(51, 51, 18.0); + let patchy_width = patchy.w; for (i, v) in patchy.v.iter_mut().enumerate() { - if (i % 101 / 13 + i / 101 / 17) % 5 == 0 { + if (i % patchy_width / 7 + i / patchy_width / 9) % 5 == 0 { *v *= 0.6; } } - let shapes = [aa_disc(97, 83, 30.0), aa_round_rect(131, 77, 9.0, 11.0, 120.0, 66.0, 14.0), aa_bar(90, 130, 60.0, 150.0, 25.0), patchy]; + let shapes = [aa_disc(49, 47, 13.0), aa_round_rect(61, 47, 10.0, 9.0, 51.0, 38.0, 8.0), aa_bar(47, 63, 60.0, 74.0, 15.0), patchy]; let mut sf = photocraft_raster::Surface::new(photocraft_color::PixelFormat::RGBA8); sf.fill_rect(Rect::new(0, 0, 4, 2), &[0.0, 0.0, 0.0, 1.0]); sf.fill_rect(Rect::new(0, 2, 4, 4), &[1.0, 1.0, 1.0, 1.0]); let pats = [Pattern::new("stripes", sf, 4, 4)]; let light = GlobalLight::default(); let styles = [BevelStyle::InnerBevel, BevelStyle::OuterBevel, BevelStyle::Emboss, BevelStyle::PillowEmboss, BevelStyle::StrokeEmboss]; - for (k, shape) in shapes.iter().enumerate() { + let techniques = [BevelTechnique::Smooth, BevelTechnique::ChiselHard, BevelTechnique::ChiselSoft]; + let settings = [(5.0, 0.0, false), (12.0, 2.0, false), (8.0, 0.0, true)]; + for (shape_index, shape) in shapes.iter().enumerate() { let tex = TextureCtx { rect: Rect::new(3, 5, 3 + shape.w as i32, 5 + shape.h as i32), patterns: &pats, anchor: (0.0, 0.0) }; - for style in styles { - for technique in [BevelTechnique::Smooth, BevelTechnique::ChiselHard, BevelTechnique::ChiselSoft] { - for (size, soften, textured) in [(5.0, 0.0, false), (12.0, 2.0, false), (8.0, 0.0, true)] { - let mut b = bevel_of(style, technique); - (b.size, b.soften) = (size, soften); - if textured { - b.texture = Some(photocraft_doc::BevelTexture { - name: "stripes".into(), - id: String::new(), - scale: 1.0, - depth: 1.0, - invert: false, - link: true, - phase: (0.0, 0.0), - }); - } - let run = || bevel_maps(shape, &b, &light, &tex, &PreparedPatterns::new(&pats, PREPARED_PATTERN_BYTES)).0; - let one = with_threads(1, run); - // 2 threads give groups of several units with a short last one, 16 one unit a group: the two ways `par_units` splits work (#15652). - for threads in [2, 16] { - let many = with_threads(threads, run); - assert_eq!(one.len(), many.len()); - for (j, (a, m)) in one.iter().zip(&many).enumerate() { - assert_eq!(bits(&a.v), bits(&m.v), "shape {k}, {style:?} {technique:?} size {size} map {j} on {threads} threads"); - } - } - } + for (style_index, style) in styles.into_iter().enumerate() { + // Rotate each set through shapes. Stepping the settings twice as fast as + // the techniques across styles also gives every technique each setting. + let technique = techniques[(shape_index + style_index) % techniques.len()]; + let (size, soften, textured) = settings[(shape_index + 2 * style_index) % settings.len()]; + let threads = [2, 8][(shape_index + style_index) % 2]; + let mut b = bevel_of(style, technique); + (b.size, b.soften) = (size, soften); + if textured { + b.texture = Some(photocraft_doc::BevelTexture { + name: "stripes".into(), + id: String::new(), + scale: 1.0, + depth: 1.0, + invert: false, + link: true, + phase: (0.0, 0.0), + }); + } + let run = || bevel_maps(shape, &b, &light, &tex, &PreparedPatterns::new(&pats, PREPARED_PATTERN_BYTES)).0; + let one = with_threads(1, run); + let many = with_threads(threads, run); + assert_eq!(one.len(), many.len()); + for (j, (a, m)) in one.iter().zip(&many).enumerate() { + assert_eq!(bits(&a.v), bits(&m.v), "shape {shape_index}, {style:?} {technique:?} size {size} map {j} on {threads} threads"); } } } From 56050cf13b1ad5d2e0aa188d6bc59c81217225c1 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 10:49:32 +0100 Subject: [PATCH 19/42] Credit MMexicann as mexicann --- contributors/people.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index 9b7ed5a52e..e86ee8a01a 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -355,3 +355,6 @@ real_name = "Sven Lafebre" [people.kirubhakaran12] sync_github_name = true + +[people.MMexicann] +display_name = "mexicann" From ba53b470489edd457d61abf9ab6e1425a34abf44 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 10:54:15 +0100 Subject: [PATCH 20/42] Use the standard divisibility check in the bevel fixture --- crates/compose/src/effects/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/compose/src/effects/tests.rs b/crates/compose/src/effects/tests.rs index 3654dd78fc..6291cb393b 100644 --- a/crates/compose/src/effects/tests.rs +++ b/crates/compose/src/effects/tests.rs @@ -706,7 +706,7 @@ fn bevel_maps_do_not_depend_on_the_threads() { let mut patchy = aa_disc(51, 51, 18.0); let patchy_width = patchy.w; for (i, v) in patchy.v.iter_mut().enumerate() { - if (i % patchy_width / 7 + i / patchy_width / 9) % 5 == 0 { + if (i % patchy_width / 7 + i / patchy_width / 9).is_multiple_of(5) { *v *= 0.6; } } From e19e864a843e58f1d9bafe0bcce7aeee9f2af0be Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:06:47 +0100 Subject: [PATCH 21/42] Audit coverage removed by the shared UI framework port Added documentation for tests affected by the shared UI port, including an inventory of removed tests and their successors. The document tracks changes related to the UI rework and provides details on test coverage and assertions. --- .../framework-port-test-map.md | 305 ++++++++++++++++++ 1 file changed, 305 insertions(+) create mode 100644 docs/integration-testing/framework-port-test-map.md diff --git a/docs/integration-testing/framework-port-test-map.md b/docs/integration-testing/framework-port-test-map.md new file mode 100644 index 0000000000..72a59060b7 --- /dev/null +++ b/docs/integration-testing/framework-port-test-map.md @@ -0,0 +1,305 @@ +# Tests affected by the shared UI port + +Tracking issue [#15466](https://github.com/storytold/photocraft/issues/15466), part of the [UI rework](https://github.com/storytold/photocraft/issues/15476). + +This inventory compares the PhotoCraft parent [`01b79958a7`](https://github.com/storytold/photocraft/commit/01b79958a7b73c3d840b76492069e9635f9f7394) with the framework port [`ed14e1c413`](https://github.com/storytold/photocraft/commit/ed14e1c413ebea61dcb54abda3d388b33a29a4af). Successors were checked in PhotoCraft [`42c853396d`](https://github.com/storytold/photocraft/commit/42c853396d147a554f540c9723b90e1179080a79) and its pinned craft-libs [`683fe06031`](https://github.com/storytold/craft-libs/commit/683fe06031224725b913c8ad3697d8e8bfec6c90). + +The scan found **226 whole-file removals** with **1,659 recognized test declarations**. 215 paths belonged to `ui-egui`. The scan includes inline tests in implementation files and counts whole paths, so its file total uses a different scope from the original issue’s test-file count. Declarations removed from files that stayed in place are outside this inventory. + +The source scan recognized Rust functions marked `#[test]`, namespaced `#[…::test]` and `#[trial]`. 121 declarations have at least one same-name candidate. The inventory also records bodies with identical Rust tokens after dropping comments and whitespace. Names and body matches identify places to inspect. The behavior notes below come from reading assertions. No tests were run for this audit. + +## Reviewed successors + +| Removed PhotoCraft source | Current test | Assertions retained and scope | +| --- | --- | --- | +| [`crates/ui-egui/src/canvas/rectangle_click_in_shape_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/rectangle_click_in_shape_tests.rs#L41) | [PhotoCraft rectangle input](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/vector_ui/rectangle_click_in_shape_tests.rs#L41) | Inside-click and one-pixel motion leave the live shape alone. Rounded corners use the outline, and path and pixel modes retain their distinct behavior. | +| [`crates/ui-egui/src/canvas/canvas_autoscroll.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/canvas_autoscroll.rs#L140) | [Autoscroll edges](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/navigate.rs#L734) | Checks edge clamping, fitting and overscrolled images, a rotated view with pixel aspect, and an oblique screen axis. The old HiDPI, flip and negative quarter-turn cases need separate review. | +| [`crates/ui-egui/src/canvas/rotate_view/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/rotate_view/tests.rs#L163) | [Rotate View drag](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/tools.rs#L312) | Checks pointer movement in both flip states and 15-degree Shift steps. PhotoCraft history and key routing are outside this fixture. | +| [`crates/ui-egui/src/canvas/zoom_hold.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/zoom_hold.rs#L139) | [Zoom hold and scrub](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/tools.rs#L381) | Checks the anchor, 30 and 120 Hz holds, an animation-off step, quick clicks and drag scrubbing. Nonfinite input, limits and history still need review. | +| [`crates/ui-egui/src/canvas/pixel_grid.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/pixel_grid.rs#L194) | [Grid line colour](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas_controls/grid.rs#L76), [Canvas grid](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/tests/it/gpu_tests/checker_canvas.rs#L169) | Checks transparency, adaptive contrast and the 500% threshold in the app. Exact 501% behavior and panning-cache bounds remain open. | +| [`crates/ui-egui/tests/it/crop_shift_corner.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/tests/it/crop_shift_corner.rs#L100) | [Crop corner diagonal](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/crop.rs#L756) | Checks the ratio, reachable guide snap and distant-guide rejection in pending geometry. PhotoCraft’s committed result is a separate assertion. | +| [`crates/ui-egui/tests/it/crop_turn_keeps_frame_inside.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/tests/it/crop_turn_keeps_frame_inside.rs#L152) | [Turned crop fit](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/crop.rs#L667) | Checks fit, shrink, restore, corner movement and the Command override. Committed pixels and a modifier changed during a turn remain open. | +| [`crates/ui-egui/src/tools/crop_mode/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/crop_mode/tests.rs#L519) | [Dropped crop on document switch](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/crop_mode_tests.rs#L92) | Switching away drops the pending crop and returns the original view upright. The old test repeated the scenario in both document orders. | +| [`crates/ui-egui/src/input/control_click.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/input/control_click.rs#L45) | [macOS Control-click](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-contract/tests/it/runtime/control_click.rs#L39), [PhotoCraft menus](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/canvas_menu_tests.rs#L88) | Checks secondary click through release, other modifiers and platforms, re-entry and the next primary click. PhotoCraft also checks that the right menus open. | +| [`crates/ui-egui/src/menus/menu_keys/harness_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/menus/menu_keys/harness_tests.rs#L397) | [Command shortcut focus](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/menu/pick_focus.rs#L131) | A command dispatches once, closes the menu and restores its prior focus. | +| [`crates/ui-egui/src/menus/menu_nav/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/menus/menu_nav/tests.rs#L453) | [Popup clearance](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/menu/overflow.rs#L169) | The menu and submenu clear the bar and stay in the window. The original ran across more display and menu configurations. | +| [`crates/ui-egui/src/menus/menu_nav/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/menus/menu_nav/tests.rs#L832) | [Submenu pointer path](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/menu/submenus.rs#L42) | Moving toward the open submenu over a competing row keeps it open, then a rested pointer switches it. The legacy path matrix was broader. | +| [`crates/ui-egui/src/widgets/type_ahead.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/widgets/type_ahead.rs#L129) | [Localized type-ahead](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/pickers/select_list.rs#L118) | Checks Azerbaijani dotted and dotless I, combining dot and Greek. The old split composing sequence needs separate review. | +| [`crates/ui-egui/src/widgets/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/widgets/tests.rs#L629) | [Text event limits](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-contract/tests/it/text/input_cap.rs#L110) | Checks Unicode character limits for text, paste and IME and removes an out-of-bounds preedit range. | +| [`crates/ui-egui/src/widgets/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/widgets/tests.rs#L916) | [Numeric expression stepping](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/text/number.rs#L614) | Arrow keys evaluate `5+5`, reach 11 then 10, and keep focus in the field. | +| [`crates/ui-egui/src/widgets/task_bar.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/widgets/task_bar.rs#L203) | [Task bar placement](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs#L185) | Checks anchoring, manual placement, pin/reset, clamping and nonfinite input. Exact spacing and a fixed left edge during content growth need separate review. | +| [`crates/ui-egui/src/panels/layer_row_ui/edit_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/panels/layer_row_ui/edit_tests.rs#L161) | [Invalid type edits](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/layers_thumbnail_tests.rs#L146) | A rejected type edit keeps the active tool and leaves text editing inactive. | +| [`crates/ui-egui/src/panels/layer_row_ui/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/panels/layer_row_ui/tests.rs#L804) | [Masked artboard retargeting](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/layers_thumbnail_tests.rs#L164) | Clicking an artboard thumbnail exits mask view and retargets the artboard. | +| [`crates/ui-egui/src/panels/props_layout/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/panels/props_layout/tests.rs#L338) | [Background plus another layer](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/panels/properties.rs#L165) | A single Background hides alignment actions. A multiple selection keeps them and horizontal alignment moves only x. | +| [`crates/ui-egui/src/panels/titlebar/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/panels/titlebar/tests.rs#L278) | [Dirty window close](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/panels/title_bar/tests.rs#L50) | Checks the unsaved-work prompt for a drawable window and direct closing after device loss. The former no-document case needs separate review. | +| [`crates/ui-egui/src/panels/layer_reveal/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/panels/layer_reveal/tests.rs#L69) | [Layer reveal and group behavior](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/layers/tests/it/panel_reveal.rs#L136), [Per-document scroll](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/layers/tests/it/panel_reveal.rs#L188) | Checks group expansion, row visibility, stable visible rows, optional group preservation and retained scroll. PhotoCraft’s undo-triggered reveal still needs a fixture. | +| [`crates/ui-egui/src/dialogs/export_dialog/enter_key_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/export_dialog/enter_key_tests.rs#L51) | [Explicit export button](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L265), [Scale field Enter](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L348), [Escape cancellation](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L104) | Bare Enter keeps Export As open. Enter in Scale commits the field, only the button requests a path, and Escape reaches the host as Cancel. | +| [`crates/ui-egui/src/dialogs/image_size_readout_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/image_size_readout_tests.rs#L43) | [Flat image size](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/dialogs/sizing/tests.rs#L159), [Bitmap row padding and previous size](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L385) | Checks channel and depth calculations, whole-byte bitmap rows and when the previous size appears. Localized formatting and same-byte changes remain open. | +| [`crates/ui-egui/src/dialogs/image_size_resample_shortcuts_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/image_size_resample_shortcuts_tests.rs#L74) | [Alt-digit resampling](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L404) | Checks two picks, ignored chords, typing in the field and unavailable choices. Full key position coverage, same-frame ordering and applying the choice remain open. | + +The Magnetic Lasso cursor-preference matrix returned in [PhotoCraft #15805](https://github.com/storytold/photocraft/pull/15805). The removed Alt+Tab case has a draft in [craft-libs #2805](https://github.com/storytold/craft-libs/pull/2805). Customized-workspace Properties coverage is tracked in [#15791](https://github.com/storytold/photocraft/issues/15791). + +## Coverage still to review + +These assertions have no equivalent identified in the reviewed successors. The gaps concern test coverage based on these snapshots. + +- Selection outline paint order above guides across zoom and DPI and drawing in a secondary view. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/guide_ants_tests.rs#L49) +- Escape and Enter routing while the crop ratio list owns the keyboard, with the crop remaining pending. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/tests/it/crop_popup_keys.rs#L72) +- The pointer-driven third and fourth corner and hover grid. The current app tests cover committed quad input. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/perspective_crop_click_preview_tests.rs#L31) +- Perspective Crop hover hit zones and keeping the drag cursor while moving. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/perspective_crop_cursor_tests.rs#L45) +- Native pinch and Ctrl-wheel in the same frame coalesce into one zoom. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/wheel_nav/tests.rs#L770) +- Non-US physical bracket fallback, the Dvorak exception and leaving the German plus key alone. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/input/layout_keys.rs#L142) +- Off-field diagonal selection follows x on single-line fields and preserves multiline movement. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/input/single_line_drag.rs#L157) +- Field-local rejection before parsing, including Unicode, IME, undo and same-frame Tab. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/widgets/numeric_input_tests.rs#L52) +- Fit Image validation and undo across field editing and programmatic input. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/fit_image_range_tests.rs#L59) +- Camera Raw anchored zoom, clamped panning, snap limits and fitting after tiny or nonfinite resize. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/camera_raw_preview_ui.rs#L299) +- Dialog-specific undo isolation for Filter Gallery and Vanishing Point. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/edit_history.rs#L197) + +## Identical body matches + +Each row links the first matched declaration at a destination and counts matching bodies at that path. The inventory counts unique legacy declarations, so a test at more than one destination is counted once there. + +| Removed source | Candidate location | Matched bodies | +| --- | --- | ---: | +| [`apps/photocraft/src/icon_theme.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/apps/photocraft/src/icon_theme.rs#L280) | [`crates/window/src/desktop/icon_theme.rs`](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/window/src/desktop/icon_theme.rs#L253) | 4 | +| [`apps/photocraft/src/portal_save/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/apps/photocraft/src/portal_save/tests.rs#L5) | [`crates/dialogs/src/portal/tests.rs`](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/dialogs/src/portal/tests.rs#L23) | 1 | +| [`crates/ui-egui/src/canvas/rectangle_click_in_shape_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/canvas/rectangle_click_in_shape_tests.rs#L54) | [`crates/ui-egui/src/tools/vector_ui/rectangle_click_in_shape_tests.rs`](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/vector_ui/rectangle_click_in_shape_tests.rs#L54) | 2 | +| [`crates/ui-egui/src/dialogs/adjust_editors/curves.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/adjust_editors/curves.rs#L545) | [`crates/ui-egui/src/dialogs/adjust_editors/curves.rs`](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/dialogs/adjust_editors/curves.rs#L546) | 13 | +| [`crates/ui-egui/src/shape_bounds_box_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/shape_bounds_box_tests.rs#L86) | [`crates/ui-egui/src/tools/shape_controls/box_tests.rs`](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/shape_controls/box_tests.rs#L71) | 2 | +| [`crates/ui-egui/src/tools/analysis_ui/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/analysis_ui/tests.rs#L147) | [`crates/ui-egui/src/tools/analysis/tests.rs`](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/analysis/tests.rs#L134) | 2 | +| [`crates/ui-egui/src/widgets/point_curve.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/widgets/point_curve.rs#L229) | [`crates/ui-egui/src/widgets/point_curve.rs`](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/widgets/point_curve.rs#L262) | 6 | +| [`crates/ui-egui/src/widgets/tone.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/widgets/tone.rs#L582) | [`crates/ui-egui/src/tone.rs`](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tone.rs#L533) | 13 | +| [`crates/ui-egui/tests/it/custom_print_paper.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/tests/it/custom_print_paper.rs#L234) | [`crates/ui-egui/src/dialogs/file_ui/custom_paper_tests.rs`](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/dialogs/file_ui/custom_paper_tests.rs#L200) | 1 | + +## Whole-file inventory + +A dash means no same-name candidate or identical body surfaced in the scanned snapshots. Current tests can cover a behavior under a different name. The assertion comparisons above record reviewed examples, including renamed tests. + +| Removed path | Cases | Same-name leads | Identical bodies | +| --- | ---: | ---: | ---: | +| `apps/photocraft/src/agent_link.rs` | 6 | 1 | — | +| `apps/photocraft/src/appearance.rs` | 3 | — | — | +| `apps/photocraft/src/caption_style.rs` | 7 | — | — | +| `apps/photocraft/src/control_server.rs` | 8 | 1 | — | +| `apps/photocraft/src/file_dialog_probe.rs` | 7 | 2 | — | +| `apps/photocraft/src/icon_theme.rs` | 9 | 8 | 4 | +| `apps/photocraft/src/mac_menu.rs` | 2 | — | — | +| `apps/photocraft/src/portal_save/tests.rs` | 11 | 1 | 1 | +| `apps/photocraft/src/screen_color.rs` | 6 | — | — | +| `crates/engine/src/cmd/updates_cmds.rs` | 4 | — | — | +| `crates/engine/src/kys.rs` | 10 | 1 | — | +| `crates/ui-egui/examples/cursor_bench/args.rs` | 1 | — | — | +| `crates/ui-egui/src/background_eraser_alt_click_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/background_eraser_bar_angle_tests.rs` | 13 | 1 | — | +| `crates/ui-egui/src/background_eraser_brush_popup_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/background_eraser_digit_keys_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/blend_dropdown_groups_tests.rs` | 2 | — | — | +| `crates/ui-egui/src/blend_dropdown_keys_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/blend_dropdown_wheel_tests.rs` | 9 | — | — | +| `crates/ui-egui/src/blur_strength_alert_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/brush_alt_digit_smoothing_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/brush_hud_rate_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/brush_opacity_minimum_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/brush_options_tooltips_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/brush_picker_angle_widget_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/bucket_bitmap_alert_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/burn_bar_tooltips_tests.rs` | 10 | — | — | +| `crates/ui-egui/src/burn_default_tip_tests.rs` | 3 | 2 | — | +| `crates/ui-egui/src/burn_exposure_field_tests.rs` | 10 | — | — | +| `crates/ui-egui/src/cam_options_bar_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/cam_reset_tool_mode_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/canvas/ants.rs` | 7 | — | — | +| `crates/ui-egui/src/canvas/canvas_autoscroll.rs` | 10 | — | — | +| `crates/ui-egui/src/canvas/canvas_popup.rs` | 2 | — | — | +| `crates/ui-egui/src/canvas/canvas_tool_menu/hand_menu_entries_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/canvas/canvas_tool_menu/zoom_menu_anchor_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/canvas/guide_ants_tests.rs` | 2 | — | — | +| `crates/ui-egui/src/canvas/paint.rs` | 5 | — | — | +| `crates/ui-egui/src/canvas/pattern_preview.rs` | 6 | — | — | +| `crates/ui-egui/src/canvas/perspective_crop_cursor_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/canvas/pixel_grid.rs` | 16 | — | — | +| `crates/ui-egui/src/canvas/rectangle_click_in_shape_tests.rs` | 6 | 6 | 2 | +| `crates/ui-egui/src/canvas/remove_cursor_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/canvas/rotate_view/tests.rs` | 21 | — | — | +| `crates/ui-egui/src/canvas/sampler_cursor_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/canvas/scrollbars.rs` | 11 | — | — | +| `crates/ui-egui/src/canvas/tool_cursor/add_anchor_cursor_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/canvas/tool_cursor/count_tests.rs` | 5 | 1 | — | +| `crates/ui-egui/src/canvas/tool_cursor/ruler_tests.rs` | 9 | — | — | +| `crates/ui-egui/src/canvas/tool_cursor/tests.rs` | 50 | — | — | +| `crates/ui-egui/src/canvas/wheel_nav/scroll_step_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/canvas/wheel_nav/tests.rs` | 52 | — | — | +| `crates/ui-egui/src/canvas/zoom_field.rs` | 6 | — | — | +| `crates/ui-egui/src/canvas/zoom_hold.rs` | 9 | — | — | +| `crates/ui-egui/src/canvas/zoom_levels.rs` | 6 | — | — | +| `crates/ui-egui/src/canvas/zoom_window_fit.rs` | 14 | — | — | +| `crates/ui-egui/src/clone_stamp_reset_tip_tests.rs` | 4 | 2 | — | +| `crates/ui-egui/src/color_replacement_alt_click_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/color_replacement_blend_keys_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/color_replacement_tolerance_field_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/dialogs/adjust_editors/curves.rs` | 13 | 13 | 13 | +| `crates/ui-egui/src/dialogs/camera_raw_preview_ui.rs` | 6 | — | — | +| `crates/ui-egui/src/dialogs/camera_raw_ui/controls.rs` | 2 | — | — | +| `crates/ui-egui/src/dialogs/credits/ui_tests.rs` | 12 | — | — | +| `crates/ui-egui/src/dialogs/dialog_alt_reset.rs` | 3 | — | — | +| `crates/ui-egui/src/dialogs/edit_history.rs` | 4 | — | — | +| `crates/ui-egui/src/dialogs/export_dialog/enter_key_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/dialogs/fit_image_range_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/dialogs/image_size_readout_tests.rs` | 13 | — | — | +| `crates/ui-egui/src/dialogs/image_size_resample_shortcuts_tests.rs` | 9 | — | — | +| `crates/ui-egui/src/dialogs/label_column_tests.rs` | 1 | — | — | +| `crates/ui-egui/src/dialogs/layer_style/bevel_modes_tests.rs` | 1 | — | — | +| `crates/ui-egui/src/dialogs/rgb_histogram.rs` | 7 | — | — | +| `crates/ui-egui/src/dialogs/select_mask_ui/cycle_tool_mode_tests.rs` | 9 | — | — | +| `crates/ui-egui/src/dialogs/shape_dialog/create_triangle_range_alert_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/dodge_default_tip_tests.rs` | 3 | 2 | — | +| `crates/ui-egui/src/dropdown_press_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/empty_workspace_tests.rs` | 2 | — | — | +| `crates/ui-egui/src/eraser_range_alert_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/i18n/casing.rs` | 1 | — | — | +| `crates/ui-egui/src/input/control_click.rs` | 4 | — | — | +| `crates/ui-egui/src/input/layout_keys.rs` | 3 | — | — | +| `crates/ui-egui/src/input/page_keys.rs` | 2 | — | — | +| `crates/ui-egui/src/input/scrub_wrap.rs` | 2 | — | — | +| `crates/ui-egui/src/input/single_line_drag.rs` | 4 | — | — | +| `crates/ui-egui/src/layer_shortcut_tests.rs` | 10 | — | — | +| `crates/ui-egui/src/layer_via_label_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/layers_empty_area_menu_tests.rs` | 10 | — | — | +| `crates/ui-egui/src/marquee_press_mods_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/menu_item_labels_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/menus/menu_keys.rs` | 4 | — | — | +| `crates/ui-egui/src/menus/menu_keys/harness_tests.rs` | 23 | 1 | — | +| `crates/ui-egui/src/menus/menu_nav/tests.rs` | 24 | — | — | +| `crates/ui-egui/src/mixer_cursor_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/new_doc_pixel_aspect_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/new_doc_save_preset_icon_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/new_doc_web_artboards_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/new_group_button_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/options_hit_area_tests.rs` | 11 | — | — | +| `crates/ui-egui/src/panels/brushes_tab/tests.rs` | 12 | — | — | +| `crates/ui-egui/src/panels/compact_visual_regressions.rs` | 12 | — | — | +| `crates/ui-egui/src/panels/layer_filter_ui/effect_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/panels/layer_filter_ui/group_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/panels/layer_menu_ui/color_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/panels/layer_pct_slider_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/panels/layer_reveal/tests.rs` | 3 | — | — | +| `crates/ui-egui/src/panels/layer_row_ui/edit_tests.rs` | 7 | 1 | — | +| `crates/ui-egui/src/panels/layer_row_ui/rename_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/panels/layer_row_ui/tests.rs` | 25 | 1 | — | +| `crates/ui-egui/src/panels/layer_tree_ui/tests.rs` | 7 | — | — | +| `crates/ui-egui/src/panels/options_bar/hand_tooltips_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/panels/options_bar/zoom_buttons_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/panels/panel_state.rs` | 1 | — | — | +| `crates/ui-egui/src/panels/props_layout/tests.rs` | 13 | 1 | — | +| `crates/ui-egui/src/panels/titlebar/tests.rs` | 25 | — | — | +| `crates/ui-egui/src/pen_path_visual_tests.rs` | 1 | — | — | +| `crates/ui-egui/src/pencil_auto_erase_tooltip_tests.rs` | 1 | — | — | +| `crates/ui-egui/src/pencil_shift_digit_opacity_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/polygon_lasso_step_snap_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/prefs/flick_pan.rs` | 4 | — | — | +| `crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs` | 10 | — | — | +| `crates/ui-egui/src/profile_prompt_tests.rs` | 2 | — | — | +| `crates/ui-egui/src/shape_bounds_box_tests.rs` | 18 | 6 | 2 | +| `crates/ui-egui/src/sharpen_refusal_alert_tests.rs` | 7 | 4 | — | +| `crates/ui-egui/src/sharpen_strength_alert_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/smoothing_options_greyed_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/smudge_default_tip_tests.rs` | 4 | 2 | — | +| `crates/ui-egui/src/smudge_mode_bar_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/smudge_strength_alert_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/sponge_default_tip_tests.rs` | 4 | 2 | — | +| `crates/ui-egui/src/sponge_flow_field_tests.rs` | 9 | — | — | +| `crates/ui-egui/src/sponge_refusal_alert_tests.rs` | 6 | 5 | — | +| `crates/ui-egui/src/state/type_default_size_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/status_bar_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/text/bidi_text.rs` | 1 | — | — | +| `crates/ui-egui/src/text/egui_fonts.rs` | 3 | — | — | +| `crates/ui-egui/src/text/font_filters.rs` | 3 | — | — | +| `crates/ui-egui/src/text/font_preview.rs` | 5 | — | — | +| `crates/ui-egui/src/tool_options_theme_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/toolbar_more_slot_flyout_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/tools/analysis_ruler_click_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/tools/analysis_ruler_escape_tests.rs` | 2 | — | — | +| `crates/ui-egui/src/tools/analysis_ruler_move_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/tools/analysis_ruler_shift_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/tools/analysis_ruler_visibility_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/tools/analysis_ui/sampler_drag_tests.rs` | 11 | — | — | +| `crates/ui-egui/src/tools/analysis_ui/sampler_extras_tests.rs` | 2 | — | — | +| `crates/ui-egui/src/tools/analysis_ui/sampler_menu_tests.rs` | 8 | 2 | — | +| `crates/ui-egui/src/tools/analysis_ui/tests.rs` | 14 | 9 | 2 | +| `crates/ui-egui/src/tools/anchor_tools/delete_anchor_shown_anchors_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/tools/corner_radius/tests.rs` | 13 | 5 | — | +| `crates/ui-egui/src/tools/crop_mode/tests.rs` | 26 | — | — | +| `crates/ui-egui/src/tools/crop_options_labels_tests.rs` | 10 | — | — | +| `crates/ui-egui/src/tools/crop_overlay.rs` | 13 | — | — | +| `crates/ui-egui/src/tools/crop_shield.rs` | 14 | 1 | — | +| `crates/ui-egui/src/tools/crop_size.rs` | 18 | — | — | +| `crates/ui-egui/src/tools/crop_straighten.rs` | 9 | — | — | +| `crates/ui-egui/src/tools/direct_select/alt_drag_duplicate_tests.rs` | 7 | — | — | +| `crates/ui-egui/src/tools/direct_select/convert_point_tolerance_tests.rs` | 9 | — | — | +| `crates/ui-egui/src/tools/direct_select/shift_angle_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/tools/ellipse_center_mark_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/tools/gradient_refusal_messages_tests.rs` | 4 | 2 | — | +| `crates/ui-egui/src/tools/lasso_ui/tests.rs` | 21 | 6 | — | +| `crates/ui-egui/src/tools/line_live_handles_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/tools/magnetic_lasso_ui/caps_lock_cursor_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/tools/perspective_crop_click_preview_tests.rs` | 9 | — | — | +| `crates/ui-egui/src/tools/perspective_crop_modifiers_tests.rs` | 11 | — | — | +| `crates/ui-egui/src/tools/perspective_crop_shield_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/tools/remove_default_size_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/tools/remove_locked_alert_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/tools/shape_stroke_ui/shortcut_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/tools/transform_tex.rs` | 5 | 1 | — | +| `crates/ui-egui/src/tools/transform_tool/warp_handles_visible_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/tools/transform_tool/warp_options_bar_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/tools/transform_tool/warp_split_one_shot_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/tools/type_tool/fonts_loading_tests.rs` | 1 | — | — | +| `crates/ui-egui/src/tools/type_tool/options_tooltips_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/tools/type_tool/size_presets_tests.rs` | 13 | — | — | +| `crates/ui-egui/src/tools/vector_ui/add_anchor_options_bar_tests.rs` | 1 | — | — | +| `crates/ui-egui/src/tools/vector_ui/delete_anchor_options_bar_tests.rs` | 2 | — | — | +| `crates/ui-egui/src/tools/vector_ui/pen_alt_drag_segment_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/tools/vector_ui/pen_mode_menu_tests.rs` | 5 | — | — | +| `crates/ui-egui/src/tools/vector_ui/rectangle_path_make_tests.rs` | 1 | — | — | +| `crates/ui-egui/src/tools/warp_preview.rs` | 4 | — | — | +| `crates/ui-egui/src/tools/zoom_tool/tests.rs` | 12 | 1 | — | +| `crates/ui-egui/src/tools/zoom_tool/zoom_out_mode_tests.rs` | 8 | — | — | +| `crates/ui-egui/src/transform_corner_projection_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/transform_reference_point_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/transform_relative_position_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/transform_rotate_snap_tests.rs` | 3 | — | — | +| `crates/ui-egui/src/widgets/angle_dial.rs` | 4 | — | — | +| `crates/ui-egui/src/widgets/color_button_tests.rs` | 4 | — | — | +| `crates/ui-egui/src/widgets/color_count.rs` | 3 | — | — | +| `crates/ui-egui/src/widgets/field_tab.rs` | 4 | — | — | +| `crates/ui-egui/src/widgets/field_wheel.rs` | 20 | — | — | +| `crates/ui-egui/src/widgets/numeric_expression.rs` | 5 | — | — | +| `crates/ui-egui/src/widgets/numeric_input_tests.rs` | 6 | — | — | +| `crates/ui-egui/src/widgets/point_curve.rs` | 6 | 6 | 6 | +| `crates/ui-egui/src/widgets/press_menu.rs` | 9 | — | — | +| `crates/ui-egui/src/widgets/swap_arrow.rs` | 3 | — | — | +| `crates/ui-egui/src/widgets/tab_strip.rs` | 5 | — | — | +| `crates/ui-egui/src/widgets/task_bar.rs` | 4 | — | — | +| `crates/ui-egui/src/widgets/tests.rs` | 82 | — | — | +| `crates/ui-egui/src/widgets/text_field_menu.rs` | 2 | — | — | +| `crates/ui-egui/src/widgets/tone.rs` | 15 | 13 | 13 | +| `crates/ui-egui/src/widgets/type_ahead.rs` | 8 | — | — | +| `crates/ui-egui/tests/it/actions_record_again.rs` | 4 | 4 | — | +| `crates/ui-egui/tests/it/background_eraser_reset_tip.rs` | 4 | 2 | — | +| `crates/ui-egui/tests/it/camera_raw_localization.rs` | 1 | — | — | +| `crates/ui-egui/tests/it/camera_raw_zoom.rs` | 6 | — | — | +| `crates/ui-egui/tests/it/crop_beyond_canvas.rs` | 1 | — | — | +| `crates/ui-egui/tests/it/crop_default_mode.rs` | 6 | — | — | +| `crates/ui-egui/tests/it/crop_frame_look.rs` | 10 | — | — | +| `crates/ui-egui/tests/it/crop_overlay_icons.rs` | 5 | — | — | +| `crates/ui-egui/tests/it/crop_popup_keys.rs` | 2 | — | — | +| `crates/ui-egui/tests/it/crop_shift_corner.rs` | 9 | — | — | +| `crates/ui-egui/tests/it/crop_turn_grid.rs` | 10 | — | — | +| `crates/ui-egui/tests/it/crop_turn_keeps_frame_inside.rs` | 8 | — | — | +| `crates/ui-egui/tests/it/custom_print_paper.rs` | 6 | 5 | 1 | +| `crates/ui-egui/tests/it/export_as_scaling.rs` | 2 | — | — | +| `crates/ui-egui/tests/it/eyedropper_ring.rs` | 2 | — | — | +| `crates/ui-egui/tests/it/marching_ants_pixels.rs` | 2 | — | — | +| `crates/ui-egui/tests/it/marquee_autoscroll.rs` | 3 | — | — | +| `crates/ui-egui/tests/it/transform_readout_units.rs` | 1 | — | — | +| `crates/ui-egui/tests/magnetic_lasso_spacing.rs` | 11 | — | — | +| `crates/ui-egui/tests/magnetic_lasso_width_keys.rs` | 5 | — | — | From 2134254ad59d5d7455eecb1c67624199a5b8ba46 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:09:03 +0100 Subject: [PATCH 22/42] Restore crop ratio popup keyboard regression coverage --- crates/ui-egui/tests/it/crop_task_bar.rs | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/crates/ui-egui/tests/it/crop_task_bar.rs b/crates/ui-egui/tests/it/crop_task_bar.rs index 14a391c1db..30bbe4d907 100644 --- a/crates/ui-egui/tests/it/crop_task_bar.rs +++ b/crates/ui-egui/tests/it/crop_task_bar.rs @@ -176,6 +176,41 @@ fn the_bars_preset_dropdown_is_the_options_bars() { assert_eq!(h.get_all_by_value("1 : 1 (Square)").count(), 2, "the options bar shows the same preset"); } +#[test] +fn the_options_bar_ratio_list_takes_escape_and_enter_before_the_crop() { + let mut h = harness(); + control(&mut h, "ui.set", json!({"panels": {"context_task_bar": false}})); + draw_frame(&mut h, [100.0, 50.0], [300.0, 250.0]); + assert!(pending(h.state()), "the drawn square crop is pending"); + let before = frame_rect(&h).expect("the pending frame"); + let size = |h: &Harness| h.state().session.active().map(|s| (s.doc.size.width, s.doc.size.height)); + let square = "1 : 1 (Square)"; + + // Escape dismisses the list. Enter accepts its first row, the selected free Ratio. + // Neither key should reach the pending crop while the list is open (#7386). + for key in [egui::Key::Escape, egui::Key::Enter] { + assert!(!has(&h, square), "the square row is only in the open list"); + let at = h.get_by_value("Ratio").rect().center(); + click_at(&mut h, at); + assert!(has(&h, square), "the options bar ratio list opened"); + h.key_press(key); + h.run_steps(12); + assert!(!has(&h, square), "{key:?} closed the ratio list"); + assert!(pending(h.state()), "{key:?} left the crop pending"); + assert_eq!(frame_rect(&h), Some(before), "{key:?} left the frame alone"); + assert_eq!(size(&h), Some((400, 300)), "{key:?} did not crop the document"); + } + + // A closed dropdown still has focus. Click inside the frame to return focus to the canvas. + let at = h.state().last_canvas_rect.center(); + click_at(&mut h, at); + assert_eq!(frame_rect(&h), Some(before), "the click only moved focus"); + h.key_press(egui::Key::Enter); + h.run_steps(6); + assert_eq!(size(&h), Some((200, 200)), "Enter on the canvas commits the pending crop"); + assert!(!pending(h.state())); +} + #[test] fn inspect_reports_a_bar_hidden_before_the_next_draw_as_hidden() { let mut h = harness(); From b94787a48d45bd41d431d127b48957f96004884a Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:11:40 +0100 Subject: [PATCH 23/42] Record additional reviewed framework successors --- docs/integration-testing/framework-port-test-map.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/integration-testing/framework-port-test-map.md b/docs/integration-testing/framework-port-test-map.md index 72a59060b7..9f913b5045 100644 --- a/docs/integration-testing/framework-port-test-map.md +++ b/docs/integration-testing/framework-port-test-map.md @@ -21,6 +21,8 @@ The source scan recognized Rust functions marked `#[test]`, namespaced `#[…::t | [`crates/ui-egui/tests/it/crop_turn_keeps_frame_inside.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/tests/it/crop_turn_keeps_frame_inside.rs#L152) | [Turned crop fit](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/crop.rs#L667) | Checks fit, shrink, restore, corner movement and the Command override. Committed pixels and a modifier changed during a turn remain open. | | [`crates/ui-egui/src/tools/crop_mode/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/crop_mode/tests.rs#L519) | [Dropped crop on document switch](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/crop_mode_tests.rs#L92) | Switching away drops the pending crop and returns the original view upright. The old test repeated the scenario in both document orders. | | [`crates/ui-egui/src/input/control_click.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/input/control_click.rs#L45) | [macOS Control-click](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-contract/tests/it/runtime/control_click.rs#L39), [PhotoCraft menus](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/canvas_menu_tests.rs#L88) | Checks secondary click through release, other modifiers and platforms, re-entry and the next primary click. PhotoCraft also checks that the right menus open. | +| [`crates/ui-egui/src/input/scrub_wrap.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/input/scrub_wrap.rs#L75) | [Scrub wrap](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/label/mod.rs#L44) | Checks that a warp landing and the next move preserve a continuous value. Movement coalesced with the landing event and both logical edges remain open. | +| [`crates/ui-egui/src/input/page_keys.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/input/page_keys.rs#L116) | [Canvas page navigation](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/navigate.rs#L62) | Checks vertical Page Down and horizontal Cmd or Ctrl Page Down. The legacy zoom-scaled amount, Shift step and Home or End corner assertions still need review. | | [`crates/ui-egui/src/menus/menu_keys/harness_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/menus/menu_keys/harness_tests.rs#L397) | [Command shortcut focus](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/menu/pick_focus.rs#L131) | A command dispatches once, closes the menu and restores its prior focus. | | [`crates/ui-egui/src/menus/menu_nav/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/menus/menu_nav/tests.rs#L453) | [Popup clearance](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/menu/overflow.rs#L169) | The menu and submenu clear the bar and stay in the window. The original ran across more display and menu configurations. | | [`crates/ui-egui/src/menus/menu_nav/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/menus/menu_nav/tests.rs#L832) | [Submenu pointer path](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/menu/submenus.rs#L42) | Moving toward the open submenu over a competing row keeps it open, then a rested pointer switches it. The legacy path matrix was broader. | @@ -36,6 +38,7 @@ The source scan recognized Rust functions marked `#[test]`, namespaced `#[…::t | [`crates/ui-egui/src/dialogs/export_dialog/enter_key_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/export_dialog/enter_key_tests.rs#L51) | [Explicit export button](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L265), [Scale field Enter](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L348), [Escape cancellation](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L104) | Bare Enter keeps Export As open. Enter in Scale commits the field, only the button requests a path, and Escape reaches the host as Cancel. | | [`crates/ui-egui/src/dialogs/image_size_readout_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/image_size_readout_tests.rs#L43) | [Flat image size](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/dialogs/sizing/tests.rs#L159), [Bitmap row padding and previous size](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L385) | Checks channel and depth calculations, whole-byte bitmap rows and when the previous size appears. Localized formatting and same-byte changes remain open. | | [`crates/ui-egui/src/dialogs/image_size_resample_shortcuts_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/image_size_resample_shortcuts_tests.rs#L74) | [Alt-digit resampling](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L404) | Checks two picks, ignored chords, typing in the field and unavailable choices. Full key position coverage, same-frame ordering and applying the choice remain open. | +| [`crates/ui-egui/src/dialogs/camera_raw_preview_ui.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/camera_raw_preview_ui.rs#L299) | [Leaving Fit](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/full_window_parts.rs#L27), [Pointer anchor](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/full_window_parts.rs#L107), [Shift+Alt zoom ladder](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/navigate.rs#L555) | Shared canvas tests cover the core navigation. The Camera Raw input wiring and its pan and snap limits still need app-level coverage. | The Magnetic Lasso cursor-preference matrix returned in [PhotoCraft #15805](https://github.com/storytold/photocraft/pull/15805). The removed Alt+Tab case has a draft in [craft-libs #2805](https://github.com/storytold/craft-libs/pull/2805). Customized-workspace Properties coverage is tracked in [#15791](https://github.com/storytold/photocraft/issues/15791). @@ -52,7 +55,7 @@ These assertions have no equivalent identified in the reviewed successors. The g - Off-field diagonal selection follows x on single-line fields and preserves multiline movement. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/input/single_line_drag.rs#L157) - Field-local rejection before parsing, including Unicode, IME, undo and same-frame Tab. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/widgets/numeric_input_tests.rs#L52) - Fit Image validation and undo across field editing and programmatic input. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/fit_image_range_tests.rs#L59) -- Camera Raw anchored zoom, clamped panning, snap limits and fitting after tiny or nonfinite resize. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/camera_raw_preview_ui.rs#L299) +- Camera Raw-specific clamped panning, snap limits and fitting after tiny or nonfinite resize. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/camera_raw_preview_ui.rs#L299) - Dialog-specific undo isolation for Filter Gallery and Vanishing Point. [Original assertion](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/edit_history.rs#L197) ## Identical body matches From d23c5957b1353e7b2e66725d1be0e6d5f94e86f6 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 10:48:32 +0000 Subject: [PATCH 24/42] Map additional framework regression tests --- .../framework-port-test-map.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/integration-testing/framework-port-test-map.md b/docs/integration-testing/framework-port-test-map.md index 9f913b5045..9c2d1ee6b0 100644 --- a/docs/integration-testing/framework-port-test-map.md +++ b/docs/integration-testing/framework-port-test-map.md @@ -39,6 +39,34 @@ The source scan recognized Rust functions marked `#[test]`, namespaced `#[…::t | [`crates/ui-egui/src/dialogs/image_size_readout_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/image_size_readout_tests.rs#L43) | [Flat image size](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/dialogs/sizing/tests.rs#L159), [Bitmap row padding and previous size](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L385) | Checks channel and depth calculations, whole-byte bitmap rows and when the previous size appears. Localized formatting and same-byte changes remain open. | | [`crates/ui-egui/src/dialogs/image_size_resample_shortcuts_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/image_size_resample_shortcuts_tests.rs#L74) | [Alt-digit resampling](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/hosted.rs#L404) | Checks two picks, ignored chords, typing in the field and unavailable choices. Full key position coverage, same-frame ordering and applying the choice remain open. | | [`crates/ui-egui/src/dialogs/camera_raw_preview_ui.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/camera_raw_preview_ui.rs#L299) | [Leaving Fit](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/full_window_parts.rs#L27), [Pointer anchor](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/full_window_parts.rs#L107), [Shift+Alt zoom ladder](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-canvas/tests/it/canvas/navigate.rs#L555) | Shared canvas tests cover the core navigation. The Camera Raw input wiring and its pan and snap limits still need app-level coverage. | +| [`apps/photocraft/src/icon_theme.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/apps/photocraft/src/icon_theme.rs#L250) | [Desktop icon themes](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/window/src/desktop/icon_theme.rs#L220), [Caption masks](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-shell/tests/it/shell/caption_button.rs#L51) | Theme lookup follows the child, parent and hicolor order, honors icon size and XDG paths, and handles cyclic indexes. Caption tests cover mask dimensions and pixels, refused renders and images producing no coverage. | +| [`apps/photocraft/src/file_dialog_probe.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/apps/photocraft/src/file_dialog_probe.rs#L140) | [File chooser backend probe](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/dialogs/src/probe/tests.rs#L11) | Retains no-backend diagnostics, exact FileChooser interface matching, and the distinction between missing-interface errors and inconclusive access errors. The former executable PATH lookup has no assertion in this group. | +| [`apps/photocraft/src/portal_save/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/apps/photocraft/src/portal_save/tests.rs#L134) | [Portal URI and file type tests](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/dialogs/src/portal/tests.rs#L23) | Checks local URI decoding and when the chosen type supplies or replaces an extension. The successor uses a pure filename helper. The former mocked portal handle, overwrite and cancel sequences need separate coverage. | +| [`crates/ui-egui/tests/it/actions_record_again.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/tests/it/actions_record_again.rs#L47) | [Record Again tests](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/panels/actions/record_again_tests.rs#L89) | Retains seeded dimensions, cancellation, a single-step update with its flags, preservation on stale or denied edits, cross-dialog isolation and preview authorization. The hosted dialog test reads fields through the current control route. | +| [`crates/ui-egui/tests/it/custom_print_paper.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/tests/it/custom_print_paper.rs#L177) | [Custom paper tests](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/dialogs/file_ui/custom_paper_tests.rs#L144) | Retains custom dimensions across units, presets and reopening, preview and PDF orientation, postcard aliases and rejection without document or output changes. The old standard- and Retina-scale drag fixture is outside these five cases. | +| [`crates/ui-egui/src/background_eraser_alt_click_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/background_eraser_alt_click_tests.rs#L127) | [Brush resize and Alt sampling](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/brush_resize/tests.rs#L155) | Retains foreground sampling without a paint or history step, plain erase dispatch, and the Ctrl+Alt and Alt+right resize routes. The former per-pixel and in-flight assertions still need mapping. | +| [`crates/ui-egui/src/background_eraser_bar_angle_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/background_eraser_bar_angle_tests.rs#L134) | [Background Eraser angle and pressure](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/background_eraser_tolerance_field_tests.rs#L91) | Brush and Background Eraser retain separate angle and pressure settings after tool switches. Visible angle text is a separate legacy assertion. | +| [`crates/ui-egui/src/background_eraser_bar_angle_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/background_eraser_bar_angle_tests.rs#L66) | [Options bar range alerts](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/background_eraser_tolerance_field_tests.rs#L53) | The hosted field clamps angles to −180° or 180° and retains the accepted value after dismissing one alert. Fractional angles still need a successor. | +| [`crates/ui-egui/src/brush_picker_angle_widget_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/brush_picker_angle_widget_tests.rs#L88) | [Brush-picker angle drag](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/brush_picker_escape_tests.rs#L75) | A drag in the real popup reaches 135° with one brush command. The old panel helper and simultaneous roundness check still need a mapping. | +| [`crates/ui-egui/src/background_eraser_digit_keys_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/background_eraser_digit_keys_tests.rs#L63) | [Tool-specific digit values](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/input/opacity_keys.rs#L195), [Double-zero dispatch](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/input/opacity_keys.rs#L252) | Preserves unrelated brush, layer and tool values, leaves Background Eraser tolerance alone on Shift digits, and sets it to 100% on double-zero. The new plain-digit case starts at the expected value, so it establishes isolation rather than a nondefault change. | +| [`crates/ui-egui/src/brush_alt_digit_smoothing_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/brush_alt_digit_smoothing_tests.rs#L44) | [Tool smoothing dispatch](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/input/opacity_keys.rs#L293) | Preserves other smoothing preferences, interrupts a pending opacity pair and ignores smoothing on Move. Actual Alt-key routing still needs an end-to-end case. | +| [`crates/ui-egui/src/brush_opacity_minimum_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/brush_opacity_minimum_tests.rs#L77) | [Brush and Pencil double-zero](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/input/opacity_keys.rs#L252), [Digit-pair timing](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/input/opacity_keys.rs#L275) | Checks Brush and Pencil opacity at 100%, Brush flow at 1% and the digit pairing window. The legacy leading-zero and build-up-specific cases still need mapping. | +| [`crates/ui-egui/src/sponge_flow_field_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/sponge_flow_field_tests.rs#L88) | [Sponge range alert](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/background_eraser_tolerance_field_tests.rs#L53), [Retouch dab parameters](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/retouch_ui/tests.rs#L249) | Covers upper-bound clamping with one alert and checks that dabs send the bar value, including rounding a restored 33.7 to 34. Lower-bound typing and the painted-pixel check need separate cases. | +| [`crates/ui-egui/src/dialogs/camera_raw_ui/controls.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/camera_raw_ui/controls.rs#L603) | [Restoring the active Camera Raw modal](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-contract/tests/it/runtime/windows.rs#L177), [Modal activation across window systems](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-contract/tests/it/runtime/windows.rs#L129) | Checks that regaining main-window focus restores and raises a Camera Raw modal, with platform-specific attention requests. The already-focused dimmed click is a separate legacy path. | +| [`crates/ui-egui/src/dialogs/rgb_histogram.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/rgb_histogram.rs#L189) | [Typical histogram scale](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/imaging/tests/it/histogram.rs#L34), [Overlapping color channels](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/imaging/tests/it/histogram.rs#L48) | Checks that spikes can clip while typical detail remains visible, and that crossing channels retain their overlap color. The old mask, theme and geometry matrices still need mapping. | +| [`crates/ui-egui/src/dialogs/edit_history.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/edit_history.rs#L175) | [Dialog-local undo and drag](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/dialog.rs#L31), [Redo truncation](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/behavior/src/edit_history.rs#L155), [Undo routing to the dialog](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-shell/tests/it/commands/board.rs#L112) | Covers a drag as one undo step, dropping redo after a new edit and routing undo to the modal instead of the application. Lens Correction and Vanishing Point still need case-specific mapping. | +| [`crates/ui-egui/src/dialogs/edit_history.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/edit_history.rs#L225) | [Filter Gallery undo and selection](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/imaging/tests/it/filter_gallery.rs#L181) | The shared workspace reduces two effects to one on Command-Z, clamps the selection and reports it once. PhotoCraft document-history isolation was a separate legacy assertion. | +| [`crates/ui-egui/src/dialogs/credits/ui_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/credits/ui_tests.rs#L101) | [Contributor sorting](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/about.rs#L235), [Generic table alignment and scroll](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-widgets/tests/it/table.rs#L323) | Checks actual About header sorting and undated rows staying last. Shared table tests cover numeric alignment and header scrolling. About-specific column widths and resize persistence remain open. | +| [`crates/ui-egui/src/dialogs/shape_dialog/create_triangle_range_alert_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/shape_dialog/create_triangle_range_alert_tests.rs#L59) | [Triangle and Rectangle range alerts](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/draw/tests/it/shape_drag.rs#L344), [Creating a Triangle in PhotoCraft](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/dialogs/shape_dialog/tests.rs#L79) | Checks out-of-range Triangle and Rectangle dimensions clamping with one alert on Tab, in-range input without an alert, and valid Triangle confirmation creating a layer. Rectangle now alerts too. Confirm while alerting, Cancel and comma-locale cases still need mapping. | +| [`crates/ui-egui/src/dialogs/fit_image_range_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/fit_image_range_tests.rs#L59) | [Hosted integer field validation](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/dialog.rs#L765), [Escape during a dialog draft](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/dialog.rs#L563), [Fit Image staging and confirmation](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/menus/view_cmds/tests.rs#L156) | The shared field exercises the same integer bounds and verifies clamping with one alert on Tab. Nonnumeric text now retains the value without an alert. The app test checks staging and valid confirmation. Invalid Fit Image submission and its undo behavior still need app-level cases. | +| [`crates/ui-egui/src/dialogs/dialog_alt_reset.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/dialogs/dialog_alt_reset.rs#L81) | [Alt changes Cancel to Reset](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/ui-patterns/tests/it/form_dialogs/dialog.rs#L586) | The hosted footer retains a deliberate in-place reset to opening or explicit values. The old JSON marker has been replaced by typed opt-in, whose opt-out path still needs a matching assertion. | +| [`crates/ui-egui/src/tools/analysis_ui/sampler_drag_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/analysis_ui/sampler_drag_tests.rs#L63) | [Color Sampler press and release](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/color-ui/tests/it/sampling.rs#L78) | Retains adding and moving on release, cancelling placement with Escape, refusing an off-canvas addition, removing by dragging out or using Alt, and refusal at the point limit. Live PhotoCraft marker painting and numbering still need coverage. | +| [`crates/ui-egui/src/tools/analysis_ui/sampler_menu_tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/analysis_ui/sampler_menu_tests.rs#L120) | [Stale sampler menu](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs#L31) | A stale point index or document cannot delete another sample. The successor checks the menu helper directly and closes the stale menu. The former control-channel refusal and menu painting are separate paths. | +| [`crates/ui-egui/src/tools/analysis_ui/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/analysis_ui/tests.rs#L106) | [Count Tool transactions](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/analysis/tests.rs#L52), [Note defaults and panel state](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/analysis/tests.rs#L115) | Retains Count Tool placement, movement and Alt-removal, including one history entry for a real move. Note tests verify selection, the panel opening, drag movement, sampled author and color, and reuse for a new note. | +| [`crates/ui-egui/src/tools/corner_radius/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/corner_radius/tests.rs#L45) | [Corner radius handle](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/shape_controls/corner_tests.rs#L87), [Corner radius across selected shapes](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/shape_controls/corner_tests.rs#L100) | Retains all-corner and multi-target drags as one history step, skips an unselected shape and honors per-shape limits. Alt for a single corner and live cursor and readout still need mapping. | +| [`crates/ui-egui/src/tools/lasso_ui/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/lasso_ui/tests.rs#L29) | [Straight lasso segments](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/imaging/tests/it/select.rs#L551), [Latched lasso operation](https://github.com/storytold/craft-libs/blob/683fe06031224725b913c8ad3697d8e8bfec6c90/crates/imaging/tests/it/select.rs#L640) | Checks straight vertices while Alt is held, closing on release and initial Subtract surviving later modifier changes. The old final mask, undo and initial Shift/Add and Alt+Shift/Intersect cases still need mapping. | +| [`crates/ui-egui/src/tools/lasso_ui/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/lasso_ui/tests.rs#L174) | [Pasteboard click and drag](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/lasso_click_tests.rs#L21) | Retains the click modifier matrix, one undo step and the actual mask sample from a drag that starts on the pasteboard. | +| [`crates/ui-egui/src/tools/lasso_ui/tests.rs`](https://github.com/storytold/photocraft/blob/01b79958a7b73c3d840b76492069e9635f9f7394/crates/ui-egui/src/tools/lasso_ui/tests.rs#L231) | [Freeform Pen owned paths](https://github.com/storytold/photocraft/blob/42c853396d147a554f540c9723b90e1179080a79/crates/ui-egui/src/tools/vector_ui/freeform_pen_tests.rs#L60) | Retains the old subpath, straight controls, one history step and undo, and rejects a changed target, source, revision or document. The old same-press Alt release case still needs mapping. | The Magnetic Lasso cursor-preference matrix returned in [PhotoCraft #15805](https://github.com/storytold/photocraft/pull/15805). The removed Alt+Tab case has a draft in [craft-libs #2805](https://github.com/storytold/craft-libs/pull/2805). Customized-workspace Properties coverage is tracked in [#15791](https://github.com/storytold/photocraft/issues/15791). From a7948b7a3ad5ddc22665f15a8ad1783e1aaeef2a Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:56:46 +0100 Subject: [PATCH 25/42] Restore Fit Image dialog validation coverage --- crates/ui-egui/src/menus/view_cmds/tests.rs | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/crates/ui-egui/src/menus/view_cmds/tests.rs b/crates/ui-egui/src/menus/view_cmds/tests.rs index 89b022749f..cf88596d58 100644 --- a/crates/ui-egui/src/menus/view_cmds/tests.rs +++ b/crates/ui-egui/src/menus/view_cmds/tests.rs @@ -211,6 +211,40 @@ fn command_dialogs_open_and_refuse() { assert!(app.ui.views.is_empty() && app.session.documents().is_empty()); } +/// Fit Image's dialog bounds apply before the command, where a zero side would mean unconstrained. +#[test] +fn fit_image_validates_dialog_bounds_before_one_undoable_resize() { + let (mut app, ctx) = app_with(1); + let id = open_form(&mut app, &ctx, "file.automate.fitImage"); + let opening = fields(&app, id); + let original = app.session.active().unwrap(); + let (size, steps, revision) = (original.doc.size, original.history.past_len(), original.revision); + + for key in ["width", "height"] { + for value in [json!(0), json!(300_001), json!("abc")] { + assert!(app.framework.dialogs.set_json_field(&ctx, id, key, value.clone()).is_err(), "{key} accepted {value}"); + assert_eq!(fields(&app, id), opening); + } + } + + set(&mut app, &ctx, id, "width", json!(1)); + set(&mut app, &ctx, id, "height", json!(300_000)); + let accepted = fields(&app, id); + assert_eq!(accepted["width"].as_f64(), Some(1.0)); + assert_eq!(accepted["height"].as_f64(), Some(300_000.0)); + let staged = app.session.active().unwrap(); + assert_eq!((staged.doc.size, staged.history.past_len(), staged.revision), (size, steps, revision)); + + confirm(&mut app, &ctx, id).unwrap(); + let resized = app.session.active().unwrap(); + assert_eq!((resized.doc.size.width, resized.doc.size.height), (1, 1)); + assert_eq!(resized.history.past_len(), steps + 1); + assert_eq!(resized.history.undo_label(), Some("Image Size")); + + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(app.session.active().unwrap().doc.size, size); +} + #[test] fn data_sets_as_files_enablement_respects_target_platform() { let (app, _) = app_with(1); From c05add970c466917febc01cabcf8187523ce0027 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:04:14 +0000 Subject: [PATCH 26/42] Cover Color Sampler menu routing and point deletion --- .../src/tools/analysis/sampler_menu_tests.rs | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs b/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs index 2389fd03e4..ad1c6ee0ad 100644 --- a/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs +++ b/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs @@ -25,6 +25,59 @@ fn samplers(app: &PhotocraftApp) -> Vec<[f64; 2]> { app.session.active().unwrap().color_samplers.clone() } +/// The mouse opens the same ordered menu the control channel sees, and only a hit can be deleted. +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn the_sampler_menu_only_deletes_the_point_under_the_pointer() { + use crate::canvas::testing::{control, key}; + + let (mut app, _) = app(); + app.run("view.colorSamplers.add", json!({"x": 180, "y": 90})).unwrap(); + let before = samplers(&app); + let expected_rows = [ + SAMPLER_DELETE, + "colorSampler.readout.actual", + "colorSampler.readout.proof", + "colorSampler.readout.gray", + "colorSampler.readout.rgb", + "colorSampler.readout.web", + "colorSampler.readout.hsb", + "colorSampler.readout.hsl", + "colorSampler.readout.cmyk", + "colorSampler.readout.lab", + "colorSampler.readout.gray16", + "colorSampler.readout.rgb16", + "colorSampler.readout.cmyk16", + "colorSampler.readout.lab16", + "colorSampler.readout.totalInk", + ]; + + for ((x, y), can_delete) in [((70.0, 40.0), false), ((120.0, 60.0), true)] { + right_click(&mut app, x, y); + assert_eq!(samplers(&app), before, "a right-click never places a sampler"); + let inspected = control(&mut app, "ui.inspect", json!({})); + let rows = inspected.pointer("/result/canvasToolMenu/entries").and_then(serde_json::Value::as_array).expect("the open sampler menu"); + let ids: Vec<_> = rows.iter().filter_map(|row| row["id"].as_str()).collect(); + assert_eq!(ids, expected_rows); + assert_eq!(rows.iter().filter(|row| row["separator"] == true).count(), 4); + let enabled: Vec<_> = rows.iter().filter(|row| row["enabled"] == true).map(|row| row["id"].as_str().unwrap()).collect(); + let expected_enabled: &[&str] = if can_delete { &[SAMPLER_DELETE] } else { &[] }; + assert_eq!(enabled, expected_enabled, "right-click at ({x}, {y})"); + + let reply = control(&mut app, "ui.context.choose", json!({"id": SAMPLER_DELETE})); + assert_eq!(reply["ok"], can_delete, "right-click at ({x}, {y}): {reply}"); + if !can_delete { + assert_eq!(samplers(&app), before, "an unavailable Delete changes nothing"); + key(&mut app, egui::Key::Escape, egui::Modifiers::NONE); + } + assert!(app.ui.canvas_tool_menu.is_none(), "the menu closes"); + } + + assert_eq!(samplers(&app), [[20.5, 20.5], [180.5, 90.5]], "only the middle sampler is removed"); + let listed = app.run("view.colorSamplers.list", json!({})).unwrap(); + assert_eq!(listed["samplers"][1]["number"], 2, "the last sampler becomes number 2"); +} + /// Delete never removes a different sampler when the list changes while the menu is open: one /// deleted meanwhile, or another document with a sampler at the same index and spot. #[test] From ffa5efd1a7989f659bedc458dc4e0948bb7224fc Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:07:30 +0000 Subject: [PATCH 27/42] Use an asymmetric resize to verify dialog arguments --- crates/ui-egui/src/menus/view_cmds/tests.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/menus/view_cmds/tests.rs b/crates/ui-egui/src/menus/view_cmds/tests.rs index cf88596d58..ef4261412a 100644 --- a/crates/ui-egui/src/menus/view_cmds/tests.rs +++ b/crates/ui-egui/src/menus/view_cmds/tests.rs @@ -232,12 +232,14 @@ fn fit_image_validates_dialog_bounds_before_one_undoable_resize() { let accepted = fields(&app, id); assert_eq!(accepted["width"].as_f64(), Some(1.0)); assert_eq!(accepted["height"].as_f64(), Some(300_000.0)); + set(&mut app, &ctx, id, "width", json!(80)); + set(&mut app, &ctx, id, "height", json!(40)); let staged = app.session.active().unwrap(); assert_eq!((staged.doc.size, staged.history.past_len(), staged.revision), (size, steps, revision)); confirm(&mut app, &ctx, id).unwrap(); let resized = app.session.active().unwrap(); - assert_eq!((resized.doc.size.width, resized.doc.size.height), (1, 1)); + assert_eq!((resized.doc.size.width, resized.doc.size.height), (50, 40)); assert_eq!(resized.history.past_len(), steps + 1); assert_eq!(resized.history.undo_label(), Some("Image Size")); From b762ac1ea7e66a889537e25b3db84d7a93260d44 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:10:10 +0000 Subject: [PATCH 28/42] Verify the full ordering of Color Sampler menu rows --- .../src/tools/analysis/sampler_menu_tests.rs | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs b/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs index ad1c6ee0ad..677e1d8db0 100644 --- a/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs +++ b/crates/ui-egui/src/tools/analysis/sampler_menu_tests.rs @@ -35,21 +35,25 @@ fn the_sampler_menu_only_deletes_the_point_under_the_pointer() { app.run("view.colorSamplers.add", json!({"x": 180, "y": 90})).unwrap(); let before = samplers(&app); let expected_rows = [ - SAMPLER_DELETE, - "colorSampler.readout.actual", - "colorSampler.readout.proof", - "colorSampler.readout.gray", - "colorSampler.readout.rgb", - "colorSampler.readout.web", - "colorSampler.readout.hsb", - "colorSampler.readout.hsl", - "colorSampler.readout.cmyk", - "colorSampler.readout.lab", - "colorSampler.readout.gray16", - "colorSampler.readout.rgb16", - "colorSampler.readout.cmyk16", - "colorSampler.readout.lab16", - "colorSampler.readout.totalInk", + Some(SAMPLER_DELETE), + None, + Some("colorSampler.readout.actual"), + Some("colorSampler.readout.proof"), + None, + Some("colorSampler.readout.gray"), + Some("colorSampler.readout.rgb"), + Some("colorSampler.readout.web"), + Some("colorSampler.readout.hsb"), + Some("colorSampler.readout.hsl"), + Some("colorSampler.readout.cmyk"), + Some("colorSampler.readout.lab"), + None, + Some("colorSampler.readout.gray16"), + Some("colorSampler.readout.rgb16"), + Some("colorSampler.readout.cmyk16"), + Some("colorSampler.readout.lab16"), + None, + Some("colorSampler.readout.totalInk"), ]; for ((x, y), can_delete) in [((70.0, 40.0), false), ((120.0, 60.0), true)] { @@ -57,9 +61,9 @@ fn the_sampler_menu_only_deletes_the_point_under_the_pointer() { assert_eq!(samplers(&app), before, "a right-click never places a sampler"); let inspected = control(&mut app, "ui.inspect", json!({})); let rows = inspected.pointer("/result/canvasToolMenu/entries").and_then(serde_json::Value::as_array).expect("the open sampler menu"); - let ids: Vec<_> = rows.iter().filter_map(|row| row["id"].as_str()).collect(); - assert_eq!(ids, expected_rows); - assert_eq!(rows.iter().filter(|row| row["separator"] == true).count(), 4); + let order: Vec<_> = + rows.iter().map(|row| if row["separator"] == true { None } else { Some(row["id"].as_str().expect("expected a menu item id")) }).collect(); + assert_eq!(order, expected_rows); let enabled: Vec<_> = rows.iter().filter(|row| row["enabled"] == true).map(|row| row["id"].as_str().unwrap()).collect(); let expected_enabled: &[&str] = if can_delete { &[SAMPLER_DELETE] } else { &[] }; assert_eq!(enabled, expected_enabled, "right-click at ({x}, {y})"); From 3e9bd35d48be126efec006b0286dadf5371e44e3 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:11:03 +0100 Subject: [PATCH 29/42] Restore Alt-drag corner radius coverage --- .../src/tools/shape_controls/corner_tests.rs | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tools/shape_controls/corner_tests.rs b/crates/ui-egui/src/tools/shape_controls/corner_tests.rs index 3ebd32d644..c1d32ca157 100644 --- a/crates/ui-egui/src/tools/shape_controls/corner_tests.rs +++ b/crates/ui-egui/src/tools/shape_controls/corner_tests.rs @@ -57,10 +57,14 @@ fn active(app: &PhotocraftApp) -> photocraft_doc::LayerId { /// A press at `from`, two moves and a release at `to`, as a mouse does it. fn drag(app: &mut PhotocraftApp, from: [f64; 2], to: [f64; 2]) { - testing::press(app, from, NONE); - testing::move_to(app, [(from[0] + to[0]) / 2.0, (from[1] + to[1]) / 2.0], NONE); - testing::move_to(app, to, NONE); - testing::release(app, to, NONE); + drag_with_modifiers(app, from, to, NONE); +} + +fn drag_with_modifiers(app: &mut PhotocraftApp, from: [f64; 2], to: [f64; 2], mods: Modifiers) { + testing::press(app, from, mods); + testing::move_to(app, [(from[0] + to[0]) / 2.0, (from[1] + to[1]) / 2.0], mods); + testing::move_to(app, to, mods); + testing::release(app, to, mods); } /// Live rectangles, bottom first: (20, 20) 60 × 40 radii 15, (110, 20) 70 × 50 radii 15, and (20, 120) 80 × 60 @@ -96,6 +100,25 @@ fn dragging_a_widget_rounds_every_corner_in_one_step() { assert_eq!(radii_of(&app, id), [20.0; 4]); } +#[test] +fn alt_drag_changes_only_the_grabbed_corner_within_its_radius_limits() { + let mut app = app(Tool::PathSelection); + let id = active(&app); + let n = steps(&app); + let alt = Modifiers { alt: true, ..Modifiers::NONE }; + + // Drag the bottom-right widget far enough in to reach half the 80 px short side. + drag_with_modifiers(&mut app, [140.0, 100.0], [80.0, 40.0], alt); + assert_eq!(radii_of(&app, id), [20.0, 20.0, 40.0, 20.0]); + assert_eq!(steps(&app), n + 1); + + // Drag the top-right widget out past its corner to take its radius down to zero. + drag_with_modifiers(&mut app, [140.0, 60.0], [180.0, 20.0], alt); + assert_eq!(radii_of(&app, id), [20.0, 0.0, 40.0, 20.0]); + assert_eq!(steps(&app), n + 2); + assert_eq!(active(&app), id); +} + #[test] fn one_widget_rounds_every_selected_rectangle_alike_in_one_step() { let (mut app, ids) = three(Tool::PathSelection); From c31a1dbbc9f5bc6e9555bd134fd83a58997baa17 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:18:57 +0100 Subject: [PATCH 30/42] Check that canvas Enter records exactly one Crop edit --- crates/ui-egui/tests/it/crop_task_bar.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/it/crop_task_bar.rs b/crates/ui-egui/tests/it/crop_task_bar.rs index 30bbe4d907..87b35c7773 100644 --- a/crates/ui-egui/tests/it/crop_task_bar.rs +++ b/crates/ui-egui/tests/it/crop_task_bar.rs @@ -184,6 +184,8 @@ fn the_options_bar_ratio_list_takes_escape_and_enter_before_the_crop() { assert!(pending(h.state()), "the drawn square crop is pending"); let before = frame_rect(&h).expect("the pending frame"); let size = |h: &Harness| h.state().session.active().map(|s| (s.doc.size.width, s.doc.size.height)); + let history = |h: &Harness| h.state().session.active().expect("the crop document").history.past_len(); + let steps = history(&h); let square = "1 : 1 (Square)"; // Escape dismisses the list. Enter accepts its first row, the selected free Ratio. @@ -208,7 +210,7 @@ fn the_options_bar_ratio_list_takes_escape_and_enter_before_the_crop() { h.key_press(egui::Key::Enter); h.run_steps(6); assert_eq!(size(&h), Some((200, 200)), "Enter on the canvas commits the pending crop"); - assert!(!pending(h.state())); + assert_eq!(history(&h), steps + 1, "Enter adds one document history step"); } #[test] From 59b1751e2106ff9a2277af6de95041113e8655a2 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 11:23:42 +0000 Subject: [PATCH 31/42] Pass the live Crop tool through the canvas adapter --- crates/ui-egui/src/canvas/tools/crop.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/canvas/tools/crop.rs b/crates/ui-egui/src/canvas/tools/crop.rs index d172d522bb..0d9bc1296e 100644 --- a/crates/ui-egui/src/canvas/tools/crop.rs +++ b/crates/ui-egui/src/canvas/tools/crop.rs @@ -21,7 +21,7 @@ pub(crate) fn show_frame(app: &mut PhotocraftApp, ui: &mut egui::Ui, rect: egui: Some(app.canvas_tools.crop.tool.show_frame(ui, rect, &run.input(&ctx))) } -/// Applies what the pass reported to the document and the crop options. -pub(crate) fn finish(app: &mut PhotocraftApp, output: CropOutput) { - crate::crop_ui::finish(app, output); +/// Applies what the pass reported while the live Crop tool is still held by the canvas rig. +pub(crate) fn finish(app: &mut PhotocraftApp, tool: &mut CropTool, output: CropOutput) { + crate::crop_ui::finish(app, tool, output); } From caa4fe860acc25e7c1ec09848592a5b8b8bc2abe Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:23:49 +0100 Subject: [PATCH 32/42] Return crop acceptance to the active tool --- crates/ui-egui/src/tools/crop_ui.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/tools/crop_ui.rs b/crates/ui-egui/src/tools/crop_ui.rs index 23828a19c6..89e3336a32 100644 --- a/crates/ui-egui/src/tools/crop_ui.rs +++ b/crates/ui-egui/src/tools/crop_ui.rs @@ -65,10 +65,14 @@ pub(crate) fn document(app: &PhotocraftApp) -> Option { Some(CropDocument::new(CropDocKey::new(st.doc.id.0), size, f64::from(st.doc.resolution_dpi)).selection(bounds)) } -/// Maps what a pass of the tool reported to the app. -pub(crate) fn finish(app: &mut PhotocraftApp, output: CropOutput) { +/// Maps what a canvas pass reported and acknowledges the crop on the tool that emitted it. +pub(crate) fn finish(app: &mut PhotocraftApp, tool: &mut CropTool, output: CropOutput) { for event in output.events { - handle_event(app, event); + if let CropEvent::Apply(commit) = event { + tool.applied(apply_commit(app, &commit)); + } else { + handle_event(app, event); + } } } @@ -122,7 +126,11 @@ pub(crate) fn toggle_straighten(app: &mut PhotocraftApp) { /// Runs one event of the tool. True for an `Apply` that cropped the document. pub(super) fn handle_event(app: &mut PhotocraftApp, event: impl Into>) -> bool { match event.into() { - Some(CropEvent::Apply(commit)) => apply_commit(app, &commit), + Some(CropEvent::Apply(commit)) => { + let accepted = apply_commit(app, &commit); + app.canvas_tools.crop.tool.applied(accepted); + accepted + } Some(CropEvent::Discard(key)) => { upright_view(app, key); false @@ -137,7 +145,7 @@ pub(super) fn handle_event(app: &mut PhotocraftApp, event: impl Into bool { let rect = commit.frame.rect; let px = |v: f64| v.round().max(1.0) as u64; @@ -164,13 +172,11 @@ fn apply_commit(app: &mut PhotocraftApp, commit: &CropCommit) -> bool { if let Some(view) = app.session.active_index().and_then(|i| app.ui.views.get_mut(i)) { view.place(craft::ui::canvas::ViewCommands::FitOnScreen); } - app.canvas_tools.crop.tool.applied(true); true } Err(error) => { app.ui.status = error; app.ui.status_error = true; - app.canvas_tools.crop.tool.applied(false); false } } From 6e777b496337a27e4d3a548c64767da93f02a663 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:23:58 +0100 Subject: [PATCH 33/42] Acknowledge the result on the Crop tool that emitted it --- crates/ui-egui/src/canvas/tools/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas/tools/mod.rs b/crates/ui-egui/src/canvas/tools/mod.rs index 8e39edf481..94095c3897 100644 --- a/crates/ui-egui/src/canvas/tools/mod.rs +++ b/crates/ui-egui/src/canvas/tools/mod.rs @@ -670,7 +670,7 @@ fn with_rig( if let Some(tool) = crop_tool { tools.crop.tool = tool; } - crop::finish(app, output); + crop::finish(app, &mut tools.crop.tool, output); } result } From eeb92cef243734833e87700d13073570807a0fd1 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:24:03 +0100 Subject: [PATCH 34/42] Verify Enter and Done clear pending Crop state --- crates/ui-egui/tests/it/crop_task_bar.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ui-egui/tests/it/crop_task_bar.rs b/crates/ui-egui/tests/it/crop_task_bar.rs index 87b35c7773..100fb88ee3 100644 --- a/crates/ui-egui/tests/it/crop_task_bar.rs +++ b/crates/ui-egui/tests/it/crop_task_bar.rs @@ -211,6 +211,7 @@ fn the_options_bar_ratio_list_takes_escape_and_enter_before_the_crop() { h.run_steps(6); assert_eq!(size(&h), Some((200, 200)), "Enter on the canvas commits the pending crop"); assert_eq!(history(&h), steps + 1, "Enter adds one document history step"); + assert!(!pending(h.state()), "Enter clears the pending Crop session once the document accepts the crop"); } #[test] @@ -281,6 +282,7 @@ fn cancel_and_done_only_while_a_crop_is_pending() { let at = widget(&h, "Done"); click_at(&mut h, at); assert_eq!(h.state().session.active().map(|s| (s.doc.size.width, s.doc.size.height)), Some((220, 170)), "Done crops"); + assert!(!pending(h.state()), "Done also clears the pending Crop session"); } /// The active document's stored zoom. From 18897c8d0ea8df4e8d90c11fafae0f5981c0952b Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:32:21 +0100 Subject: [PATCH 35/42] Restore guide and selection outline paint-order coverage --- crates/ui-egui/src/canvas/tests.rs | 94 ++++++++++++++++++++++++++---- 1 file changed, 84 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index daf454eb5f..33e44212b5 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -659,6 +659,21 @@ fn a_secondary_canvas_hand_pans_while_a_transform_is_open() { assert_eq!(box_key(&app), box_before, "the drag didn't touch the box"); } +/// The canvas can paint a batch as a nested list, which keeps its place in egui's final paint order. +fn flattened_paint_shapes(output: &egui::FullOutput) -> Vec<&egui::Shape> { + fn open<'a>(shape: &'a egui::Shape, into: &mut Vec<&'a egui::Shape>) { + match shape { + egui::Shape::Vec(list) => list.iter().for_each(|shape| open(shape, into)), + shape => into.push(shape), + } + } + let mut shapes = Vec::new(); + for clipped in &output.shapes { + open(&clipped.shape, &mut shapes); + } + shapes +} + #[test] fn guides_draw_over_the_transform_preview_and_under_its_box() { // #5086: a guide crossing a layer under Free Transform was hidden behind the preview of @@ -692,16 +707,7 @@ fn guides_draw_over_the_transform_preview_and_under_its_box() { // At 100 % centred on the document, screen and document coordinates coincide. let layer = Rect::from_min_max(pos2(100.0, 100.0), pos2(200.0, 160.0)); let near = |r: Rect| (r.min - layer.min).length() < 1.0 && (r.max - layer.max).length() < 1.0; - fn open<'a>(shape: &'a egui::Shape, into: &mut Vec<&'a egui::Shape>) { - match shape { - egui::Shape::Vec(list) => list.iter().for_each(|shape| open(shape, into)), - shape => into.push(shape), - } - } - let mut shapes = Vec::new(); - for clipped in &out.shapes { - open(&clipped.shape, &mut shapes); - } + let shapes = flattened_paint_shapes(&out); let position = |pred: &dyn Fn(&egui::Shape) -> bool| shapes.iter().position(|s| pred(s)); // The moving pixels: the mesh that spans the layer's box. let preview = position(&|s| matches!(s, egui::Shape::Mesh(m) if near(m.calc_bounds()))); @@ -716,6 +722,74 @@ fn guides_draw_over_the_transform_preview_and_under_its_box() { assert!(guide < frame, "the box ({frame}) draws over the guide ({guide})"); } +#[test] +fn marching_ants_draw_over_a_guide_on_the_selection_edge() { + use craft::behavior::kurbo::Point; + + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + let ctx = app.ctx().clone(); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("select.rect", json!({"x": 100, "y": 100, "width": 100, "height": 60})).unwrap(); + app.run("view.newGuide", json!({"orientation": "vertical", "position": 100})).unwrap(); + app.ui.tool = Tool::RectMarquee; + app.ui.extras.rulers = false; + app.ui.extras.grid = false; + app.ui.extras.guides = true; + app.ui.view.extras = true; + app.ui.view.show.canvas_guides = true; + app.ui.view.show.selection_edges = true; + app.sync_views(); + + let mut view = app.ui.views[0].clone(); + view.zoom = 1.0; + view.center = [200.0, 150.0]; + view.clear_pending(); + let rect = Rect::from_min_size(Pos2::ZERO, vec2(400.0, 300.0)); + let draw = |app: &mut PhotocraftApp| { + let input = egui::RawInput { screen_rect: Some(rect), ..Default::default() }; + let mut output = ctx.run_ui(input, |ui| { + canvas_view(app, ui, CanvasHost::main(0), rect, view.clone(), true); + }); + output.textures_delta.clear(); + output + }; + + let output = draw(&mut app); + let shown = active_view(&app).expect("the canvas view"); + let edge = Rect::from_two_pos(shown.to_screen(Point::new(100.0, 100.0)), shown.to_screen(Point::new(100.0, 160.0))); + let pixel = output.pixels_per_point.recip(); + let is_guide = |shape: &egui::Shape| { + let egui::Shape::LineSegment { points, .. } = shape else { return false }; + points.iter().all(|p| (p.x - edge.left()).abs() <= pixel) + && points[0].y.min(points[1].y) < edge.top() - pixel + && points[0].y.max(points[1].y) > edge.bottom() + pixel + }; + let is_ants = |shape: &egui::Shape| { + let bounds = match shape { + egui::Shape::Mesh(mesh) => mesh.calc_bounds(), + egui::Shape::Rect(rect) => rect.rect, + egui::Shape::LineSegment { points, .. } => Rect::from_two_pos(points[0], points[1]), + _ => return false, + }; + // A strip or dash on the selection edge, allowing for the framework's device-pixel snap. + bounds.height() > 0.0 + && bounds.width() <= 2.0 * pixel + && (bounds.center().x - edge.left()).abs() <= pixel + && bounds.top() >= edge.top() - pixel + && bounds.bottom() <= edge.bottom() + 2.0 * pixel + }; + let shapes = flattened_paint_shapes(&output); + let guide = shapes.iter().position(|shape| is_guide(shape)).expect("the guide spanning the selection"); + let ants = shapes.iter().position(|shape| is_ants(shape)).expect("the ants along the left edge"); + assert!(guide < ants, "the guide ({guide}) paints before the ants ({ants})"); + + app.ui.view.show.selection_edges = false; + let output = draw(&mut app); + let shapes = flattened_paint_shapes(&output); + assert!(shapes.iter().any(|shape| is_guide(shape)), "hiding selection edges leaves the guide"); + assert!(!shapes.iter().any(|shape| is_ants(shape)), "the edge paint belongs to the ants"); +} + #[test] fn layer_style_dialog_previews_live_and_cancel_restores() { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); From c3a6cbf4a37b0e0a5ab977281ff5a7e5f8b99ff5 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:32:31 +0100 Subject: [PATCH 36/42] Verify app shortcuts recover when a recorder closes --- .../prefs/prefs_ui/shortcut_capture_tests.rs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/crates/ui-egui/src/prefs/prefs_ui/shortcut_capture_tests.rs b/crates/ui-egui/src/prefs/prefs_ui/shortcut_capture_tests.rs index 7d46727407..8ede607906 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/shortcut_capture_tests.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/shortcut_capture_tests.rs @@ -6,6 +6,7 @@ use craft::keymap::{Binding, CommandRef, Policy}; use egui::{Event, Key, Modifiers}; use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; use photocraft_engine::prefs::{bindable_items, normalize_shortcut}; use serde_json::json; @@ -73,6 +74,37 @@ fn toolbar_shortcut_can_be_captured_and_restored_on_restart() { assert_eq!(restarted.state().ui.tool, crate::state::Tool::Pencil); } +#[test] +fn closing_keyboard_shortcuts_while_recording_restores_app_hotkeys() { + use crate::state::Tool; + + let mut session = photocraft_engine::Session::new(); + session.prefs.edit(|p| p.interface.language = "en".into()); + let mut h = harness_with(session); + edit_and_ok(&mut h, "tools.select.pencil", "F6"); + h.state_mut().ui.tool = Tool::Move; + crate::prefs_ui::open_shortcuts(h.state_mut(), 0); + h.run_steps(2); + + h.get_by_label("Search by key").click(); + h.run_steps(2); + assert!(crate::prefs_ui::recording(h.state()), "the recorder is waiting for a key"); + tap(&mut h, Key::F6, Modifiers::NONE); + assert!(h.query_all_by_label("Search:").any(|node| node.accesskit_node().value().as_deref() == Some("F6")), "the recorder took F6"); + assert_eq!(h.state().ui.tool, Tool::Move, "F6 leaves the tool alone during recording"); + assert!(!crate::prefs_ui::recording(h.state()), "the chord ended the search recording"); + + h.get_by_label("Search by key").click(); + h.run_steps(2); + assert!(crate::prefs_ui::recording(h.state()), "recording again before the dialog closes"); + assert!(super::shortcuts::cancel(h.state_mut()), "Cancel closes the active dialog"); + h.run_steps(2); + assert!(!crate::prefs_ui::shortcuts_open(h.state()), "the modal is gone"); + + tap(&mut h, Key::F6, Modifiers::NONE); + assert_eq!(h.state().ui.tool, Tool::Pencil, "F6 selects Pencil again after the dialog closes"); +} + #[test] fn toolbar_shortcut_overrides_remove_old_keys_and_skip_removed_group_members() { use crate::state::Tool; From d16b7c4b8511ad02d71414a0108a05240c03e493 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:47:45 +0100 Subject: [PATCH 37/42] Cover canceling a staged Vanishing Point paste --- crates/ui-egui/src/dialogs/vp_ui/tests.rs | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/crates/ui-egui/src/dialogs/vp_ui/tests.rs b/crates/ui-egui/src/dialogs/vp_ui/tests.rs index 4da523c58a..7026cb57a2 100644 --- a/crates/ui-egui/src/dialogs/vp_ui/tests.rs +++ b/crates/ui-egui/src/dialogs/vp_ui/tests.rs @@ -109,6 +109,30 @@ fn a_plane_and_ok_paste_in_one_step() { assert!(l.rgba(230, 20)[0] < 0.5, "outside the plane"); } +#[test] +fn vanishing_point_cancel_leaves_pending_paste_unapplied() { + let mut app = app_with_layer(); + copy_red_square(&mut app); + let st = app.session.active().unwrap(); + let (original, steps, revision) = (st.doc.clone(), st.history.past_len(), st.revision); + + let mut h = open(app); + set(&mut h, json!({"planes": [floor()]})); + let pending = describe(h.state()).expect("Vanishing Point is open"); + assert_eq!(pending["paste"].as_array().map(Vec::len), Some(1), "OK would paste onto the plane"); + + let dialog = h.state().vanishing.as_ref().unwrap().dialog; + let ctx = h.ctx.clone(); + crate::control::dialogs::workspace_ui(h.state_mut(), &ctx, VP, &json!({"cancel": true})).unwrap(); + h.run_steps(4); + let app = h.state(); + assert!(app.framework.dialogs.get_dyn(dialog).is_none(), "Cancel closes the dialog"); + assert!(app.vanishing.is_none(), "Cancel drops the workspace"); + let st = app.session.active().unwrap(); + assert_eq!(st.doc, original, "Cancel leaves the document unchanged"); + assert_eq!((st.history.past_len(), st.revision), (steps, revision), "Cancel does not edit the document or its history"); +} + #[test] fn a_torn_wall_and_clone_strokes_are_one_step_and_preview_on_the_source() { let mut app = app_with_layer(); From 779b20eeb0d713af4f87148df5a5f5c2a14ea5a3 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 21 Nov 2026 11:21:29 +0100 Subject: [PATCH 38/42] Open Recent lists an automation open where the file is on disk (#16098) app.open is requested by a path relative to the automation read root. It went into Open Recent as is, where it names nothing: Home drew a blank card and clicking it failed. The workspace now reports the file's location below the root that holds it, and app.open (also the directory .pcraft path) lists that. The document's save-back path stays root-relative; without a location the open is not listed. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft/src/services.rs | 6 +++- crates/automation/src/workspace.rs | 12 ++++++++ crates/automation/src/workspace/tests.rs | 19 ++++++++++++ crates/ui-egui/src/control/dispatch.rs | 14 +++++++-- crates/ui-egui/src/control/tests.rs | 38 ++++++++++++++++++++++-- crates/ui-egui/src/file_open.rs | 11 ++++++- crates/ui-egui/src/lib.rs | 10 +++---- crates/ui-egui/src/services.rs | 10 +++++++ 8 files changed, 108 insertions(+), 12 deletions(-) diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rs index c89876e52d..72e070e7e7 100644 --- a/apps/photocraft/src/services.rs +++ b/apps/photocraft/src/services.rs @@ -429,6 +429,9 @@ pub fn automation(workspace: Option) Ok(opened.map(|doc| (name, doc))) }) as photocraft_ui_egui::AutomationOpenPcraftFn }); + let locate = workspace.clone().map(|workspace| { + Box::new(move |path: &str| workspace.location(path).map(|location| location.to_string_lossy().into_owned())) as photocraft_ui_egui::AutomationLocateFn + }); let save = workspace.clone().map(|workspace| { std::sync::Arc::new(move |doc: &Document, path: &str, settings: &photocraft_ui_egui::ExportSettings, ctl: &photocraft_ui_egui::jobs_ui::SaveCtl| { save_through(doc, path, settings, ctl, |p, encoded, _| workspace.write_stream(p, &mut |w| encoded.write_to(w)).map_err(|e| e.to_string())) @@ -441,7 +444,7 @@ pub fn automation(workspace: Option) photocraft_automation::workspace::authorize_desktop_engine_command(id, params).map_err(|error| error.to_string()) }) as photocraft_ui_egui::AutomationCommandFn }); - photocraft_ui_egui::AutomationServices { read, write, open_pcraft, save, command, authorize } + photocraft_ui_egui::AutomationServices { read, write, open_pcraft, locate, save, command, authorize } } /// What agent requests may read, write and run with the agent settings' folders @@ -486,6 +489,7 @@ pub fn native(automation: Option, wa automation_read: automation.read, automation_write: automation.write, automation_open_pcraft: automation.open_pcraft, + automation_locate: automation.locate, automation_save: automation.save, automation_command: automation.command, automation_authorize: automation.authorize, diff --git a/crates/automation/src/workspace.rs b/crates/automation/src/workspace.rs index 979cae498e..9b86d87b39 100644 --- a/crates/automation/src/workspace.rs +++ b/crates/automation/src/workspace.rs @@ -103,6 +103,18 @@ impl AuthorizedWorkspace { Ok((bytes, save_path)) } + /// Where the file or `.pcraft` folder that `path` names is on disk: below the first read + /// root that holds it (the root `read` and `open_pcraft` pick), as that root was configured + /// at launch. Open Recent lists this, since the person reopens the file outside automation, + /// where a root-relative request path names nothing. It grants no access. + pub fn location(&self, path: &str) -> Option { + self.read.iter().find_map(|root| { + let relative = scoped_path(path, root).ok()??; + root.dir.metadata(&relative).ok()?; + Some(root.configured_path.join(relative)) + }) + } + fn open_read(&self, path: &str) -> Result<(cap_std::fs::File, &RootCapability), AutomationError> { if self.read.is_empty() { return Err(AutomationError::BadRequest(format!("{DENIED}: read authority is absent"))); diff --git a/crates/automation/src/workspace/tests.rs b/crates/automation/src/workspace/tests.rs index 03622c9c59..9207831449 100644 --- a/crates/automation/src/workspace/tests.rs +++ b/crates/automation/src/workspace/tests.rs @@ -64,6 +64,25 @@ fn read_growth_is_rejected_at_the_observed_length() { assert!(read_to_observed_length(&mut empty, 0).is_err()); } +#[test] +fn location_names_the_file_below_the_root_that_holds_it() { + let (library, work, _) = roots("location"); + std::fs::create_dir_all(work.join("shots")).unwrap(); + std::fs::write(work.join("shots/a.png"), b"a").unwrap(); + std::fs::write(library.join("same.png"), b"first").unwrap(); + std::fs::write(work.join("same.png"), b"second").unwrap(); + let workspace = AuthorizedWorkspace::with_read_roots([library.as_path(), work.as_path()], Some(&work)).unwrap(); + // A root-relative request names the file below the root that holds it, as an absolute path. + assert_eq!(workspace.location("shots/a.png"), Some(work.join("shots").join("a.png"))); + // The first root that holds the name wins, as for `read`. + assert_eq!(workspace.location("same.png"), Some(library.join("same.png"))); + // An absolute request below a root keeps naming that file. + assert_eq!(workspace.location(&work.join("same.png").to_string_lossy()), Some(work.join("same.png"))); + assert_eq!(workspace.location("missing.png"), None); + assert_eq!(workspace.location("../outside.png"), None, "a path escaping the roots has no location"); + assert_eq!(AuthorizedWorkspace::default().location("shots/a.png"), None, "no read root, no location"); +} + #[test] fn open_pcraft_loads_a_directory_below_the_read_root() { let (inside, _, workspace) = roots("pcraft-dir"); diff --git a/crates/ui-egui/src/control/dispatch.rs b/crates/ui-egui/src/control/dispatch.rs index 7eb85f9422..273d9dc942 100644 --- a/crates/ui-egui/src/control/dispatch.rs +++ b/crates/ui-egui/src/control/dispatch.rs @@ -1362,7 +1362,8 @@ fn app_open(app: &mut PhotocraftApp, path: &str, approved: bool) -> Reply { let warnings = app.open_automation_bytes_with_approval(&name, &bytes, approved)?; // Brushes/gradients go to the preset libraries: no document, no Open Recent entry. if !crate::preset_files_ui::is_preset_file(&name) { - app.opened_from(path); + let recent = automation_location(app, path); + app.opened_from_listed(path, recent.as_deref()); if let Some(state) = app.session.active_mut() && state.path.is_some() { @@ -1373,6 +1374,13 @@ fn app_open(app: &mut PhotocraftApp, path: &str, approved: bool) -> Reply { })) } +/// Where the file an automation open read is on disk, for Open Recent. The request path is +/// relative to an automation root, so it names nothing when the person reopens it from Open +/// Recent or Home; without a location the open is not listed there. +fn automation_location(app: &PhotocraftApp, path: &str) -> Option { + app.services.automation_locate.as_ref().and_then(|locate| locate(path)) +} + /// Directory .pcraft (the native on-disk form) loads through a capability-scoped /// source; the single-file (zip) form falls back to the bytes path, as do all /// other formats. `None` means "not a directory .pcraft". @@ -1386,7 +1394,9 @@ fn open_pcraft_directory(app: &mut PhotocraftApp, path: &str) -> Option { app.session.add_document(doc, None); // Recent files, but no save-back target: the capability writer // replaces files, never directories. - app.push_recent(path); + if let Some(recent) = automation_location(app, path) { + app.push_recent(&recent); + } app.sync_views(); app.ui.status = crate::i18n::fmt(tl!("Opened {name}"), &[("name", &name)]); app.ui.status_error = false; diff --git a/crates/ui-egui/src/control/tests.rs b/crates/ui-egui/src/control/tests.rs index dc88c6efed..46e782afbd 100644 --- a/crates/ui-egui/src/control/tests.rs +++ b/crates/ui-egui/src/control/tests.rs @@ -1198,6 +1198,34 @@ fn automation_save_passes_dds_options_without_asking() { assert_eq!(asked.borrow().len(), 2, "a bad ddsCompression writes nothing"); } +#[test] +fn an_automation_open_without_a_location_is_not_listed_in_open_recent() { + use photocraft_color::{ColorMode, SampleType}; + use photocraft_doc::Document; + use photocraft_geom::Size; + + let services = crate::Services { + import: Some(Box::new(|name: &str, _b: &[u8], _opts: &photocraft_io::ImportOptions| { + Ok((Document::new(name, Size::new(4, 4), ColorMode::Rgb, SampleType::U8), Vec::new())) + })), + automation_read: Some(Box::new(|path: &str| { + Ok(crate::AutomationReadResult { + name: path.rsplit('/').next().unwrap_or(path).to_string(), + bytes: b"x".to_vec(), + save_path: Some(path.to_string()), + }) + })), + ..Default::default() + }; + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services); + let ctx = app.ctx().clone(); + let r = call(&mut app, &ctx, "app.open", json!({"path": "shots/gk_25.png"})); + assert_eq!(r["ok"], true, "{r}"); + assert_eq!(app.session.active().unwrap().path.as_deref(), Some("shots/gk_25.png"), "the save-back target stays the root-relative path"); + // A root-relative path names no file for Open Recent or Home, so nothing is listed. + assert!(app.ui.recent_files.is_empty(), "{:?}", app.ui.recent_files); +} + #[test] fn automation_open_and_save_use_the_roots_and_reply_with_warnings() { use photocraft_color::{ColorMode, SampleType}; @@ -1234,6 +1262,7 @@ fn automation_open_and_save_use_the_roots_and_reply_with_warnings() { save_path: Some(path.to_string()), }) })), + automation_locate: Some(Box::new(|path: &str| Some(format!("/work/{path}")))), automation_write: Some(Box::new(move |path: &str, _b: &[u8]| { w.borrow_mut().push(path.to_string()); Ok(()) @@ -1245,7 +1274,8 @@ fn automation_open_and_save_use_the_roots_and_reply_with_warnings() { assert_eq!(r["result"]["warnings"], json!(["Adjustment layer flattened"]), "{r}"); assert_eq!(r["result"]["name"], "warn.psd"); assert_eq!(app.session.active().unwrap().path.as_deref(), Some("in/warn.psd")); - assert_eq!(app.ui.recent_files, vec!["in/warn.psd".to_string()]); + // Open Recent lists where the file is, not the root-relative request path, which names nothing outside automation. + assert_eq!(app.ui.recent_files, vec!["/work/in/warn.psd".to_string()]); let r = call(&mut app, &ctx, "app.save", json!({"path": "out.png"})); assert_eq!(r["result"], json!({"path": "out.png", "warnings": ["Layers were flattened"]}), "{r}"); assert_eq!(*written.borrow(), vec!["out.png".to_string()]); @@ -1457,6 +1487,7 @@ fn app_open_opens_a_directory_pcraft_and_falls_back_for_the_zip_form() { Err(format!("no such path: {path}")) } })), + automation_locate: Some(Box::new(|path: &str| Some(format!("/work/{path}")))), ..Default::default() }; let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services); @@ -1465,7 +1496,7 @@ fn app_open_opens_a_directory_pcraft_and_falls_back_for_the_zip_form() { let r = call(&mut app, &ctx, "app.open", json!({"path": "native.pcraft"})); assert_eq!(r["result"], json!({"path": "native.pcraft", "name": "native.pcraft", "warnings": []}), "{r}"); assert_eq!(app.session.active().unwrap().doc.name, "Native"); - assert_eq!(app.ui.recent_files, vec!["native.pcraft".to_string()], "the open is recorded in recent files"); + assert_eq!(app.ui.recent_files, vec!["/work/native.pcraft".to_string()], "the open is recorded in recent files, where it is on disk"); assert_eq!(app.session.active().unwrap().path, None, "no save-back target: the automation writer replaces files, never directories"); let r = call(&mut app, &ctx, "app.save", json!({})); assert!(r["error"].as_str().unwrap().contains("pass `path`"), "an in-place save is refused up front: {r}"); @@ -2120,6 +2151,7 @@ fn automation_library_open_requires_explicit_save_as_before_implicit_save() { save_path: path.starts_with("work/").then(|| path.to_owned()), }) })), + automation_locate: Some(Box::new(|path: &str| Some(format!("/roots/{path}")))), automation_write: Some(Box::new(move |path: &str, _: &[u8]| { if path == "failed.psd" { return Err("test write failure".into()); @@ -2135,7 +2167,7 @@ fn automation_library_open_requires_explicit_save_as_before_implicit_save() { let opened = call(&mut app, &ctx, "app.open", json!({"path": "library/same.psd"})); assert_eq!(opened["ok"], true, "{opened}"); assert_eq!(app.session.active().unwrap().path, None); - assert_eq!(app.ui.recent_files, vec!["library/same.psd"]); + assert_eq!(app.ui.recent_files, vec!["/roots/library/same.psd"]); app.run("layer.new.layer", json!({"name": "edit"})).unwrap(); assert!(app.session.active().unwrap().is_dirty()); let refused = call(&mut app, &ctx, "app.save", json!({})); diff --git a/crates/ui-egui/src/file_open.rs b/crates/ui-egui/src/file_open.rs index 8d4d58dbbc..6f41518347 100644 --- a/crates/ui-egui/src/file_open.rs +++ b/crates/ui-egui/src/file_open.rs @@ -230,6 +230,13 @@ impl PhotocraftApp { /// Record that the active document was just opened from `path`: File › Save writes back to it /// (unless it's a template or derivative preview) and it goes to the top of Open Recent. pub(crate) fn opened_from(&mut self, path: &str) { + self.opened_from_listed(path, Some(path)); + } + + /// [`Self::opened_from`], with `recent` the path Open Recent lists for it (`None`: not listed). + /// An automation open is requested by a root-relative path, which names nothing outside + /// automation, so it lists where the file is on disk instead. + pub(crate) fn opened_from_listed(&mut self, path: &str, recent: Option<&str>) { if !is_template(path) && let Some(st) = self.session.active_mut() && !st.source_read_only @@ -238,7 +245,9 @@ impl PhotocraftApp { let doc = st.doc.id; self.remember_stamp(doc, path); } - self.push_recent(path); + if let Some(recent) = recent { + self.push_recent(recent); + } } /// The name a file called `name` opens under: its own, or the first free "Untitled-N" for a diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index a89837fb4c..7db1cdeaa1 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -236,11 +236,11 @@ pub(crate) use services::SAVE_OPTIONS_OPEN; #[cfg(test)] pub(crate) use services::saved_revision_after_write; pub use services::{ - AdoptAutosaveFn, AppendTextFn, AutomationAuthorizeFn, AutomationCommandFn, AutomationOpenPcraftFn, AutomationReadFn, AutomationServices, AutomationWriteFn, - AutosaveFn, AutosaveResultsFn, CapsLockFn, ClipboardGetFn, ClipboardGetSvgFn, ClipboardSetFn, ClipboardUnreadableFn, CursorPosFn, DiscardAutosaveFn, - ExportFn, ExportSettings, ExternalSvgEditor, ExternalSvgSession, ExternalVectorSave, ExternalVectorSource, FileStamp, FileStampFn, FormatChoices, ImportFn, - Inbox, LoadTextFn, OpenExternalSvgFn, OpenUrlFn, OsEventsFn, PenEndFn, PhotoshopShortcutsFn, PlaceInbox, RecoverFn, Recoverable, RightButtonDownFn, - SameFileFn, SaveFileFn, SaveTextFn, Services, SystemThemeFn, TabletPollFn, WindowFrameFn, WriteFn, + AdoptAutosaveFn, AppendTextFn, AutomationAuthorizeFn, AutomationCommandFn, AutomationLocateFn, AutomationOpenPcraftFn, AutomationReadFn, + AutomationServices, AutomationWriteFn, AutosaveFn, AutosaveResultsFn, CapsLockFn, ClipboardGetFn, ClipboardGetSvgFn, ClipboardSetFn, ClipboardUnreadableFn, + CursorPosFn, DiscardAutosaveFn, ExportFn, ExportSettings, ExternalSvgEditor, ExternalSvgSession, ExternalVectorSave, ExternalVectorSource, FileStamp, + FileStampFn, FormatChoices, ImportFn, Inbox, LoadTextFn, OpenExternalSvgFn, OpenUrlFn, OsEventsFn, PenEndFn, PhotoshopShortcutsFn, PlaceInbox, RecoverFn, + Recoverable, RightButtonDownFn, SameFileFn, SaveFileFn, SaveTextFn, Services, SystemThemeFn, TabletPollFn, WindowFrameFn, WriteFn, }; pub(crate) use services::{opaque_layer, saves_flat_in_place}; pub use text::cjk_fonts; diff --git a/crates/ui-egui/src/services.rs b/crates/ui-egui/src/services.rs index 1249b00557..e84c92bd47 100644 --- a/crates/ui-egui/src/services.rs +++ b/crates/ui-egui/src/services.rs @@ -338,6 +338,11 @@ pub type AutomationWriteFn = Box Result<(), String>>; /// caller falls back to the bytes path for the zip form. pub type AutomationOpenPcraftFn = Box Result, String>>; +/// Where a path an automation read opened is on disk (absolute), for Open Recent: the person +/// reopens it outside automation, where a root-relative request path names nothing. `None` +/// when no read root holds it. +pub type AutomationLocateFn = Box Option>; + /// Reject engine commands which still perform ambient filesystem I/O. pub type AutomationCommandFn = Box Result<(), String>>; /// Same policy as [`AutomationCommandFn`] for each step a command runs (`actions.play`). @@ -351,6 +356,7 @@ pub struct AutomationServices { pub read: Option, pub write: Option, pub open_pcraft: Option, + pub locate: Option, pub save: Option, pub command: Option, pub authorize: Option, @@ -546,6 +552,9 @@ pub struct Services { pub automation_read: Option, pub automation_write: Option, pub automation_open_pcraft: Option, + /// Where an automation open's file is on disk, for Open Recent. Without it an automation + /// open is not listed there. + pub automation_locate: Option, pub automation_command: Option, /// Same policy as [`Self::automation_command`], as a function pointer the engine calls for /// each step of `actions.play`. Installed on the session only while a control request or @@ -657,6 +666,7 @@ impl Services { self.automation_read = a.read; self.automation_write = a.write; self.automation_open_pcraft = a.open_pcraft; + self.automation_locate = a.locate; self.automation_save = a.save; self.automation_command = a.command; self.automation_authorize = a.authorize; From 60ce64e2bfa022fd3104b9f4f7c37585720af645 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 13:33:25 +0100 Subject: [PATCH 39/42] Cover Escape ownership in Targa Options --- .../dialogs/discard_ui/tests/targa_tests.rs | 57 ++++++++++++++++--- 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/dialogs/discard_ui/tests/targa_tests.rs b/crates/ui-egui/src/dialogs/discard_ui/tests/targa_tests.rs index 078d03624c..38786b3901 100644 --- a/crates/ui-egui/src/dialogs/discard_ui/tests/targa_tests.rs +++ b/crates/ui-egui/src/dialogs/discard_ui/tests/targa_tests.rs @@ -16,6 +16,18 @@ fn asked(bits: Option) -> Vec { serde_json::to_vec(&bits).unwrap() } +/// Records the Targa options on each write without encoding or touching the filesystem. +fn targa_writes(app: &mut PhotocraftApp) -> Writes { + let writes: Writes = Rc::default(); + let written = writes.clone(); + app.services.export = Some(Box::new(|_, _, settings| Ok((asked(settings.tga_bits.map(TgaBits::bits)), Vec::new())))); + app.services.write = Some(Box::new(move |path, bytes| { + written.borrow_mut().push((path.to_string(), bytes.to_vec())); + Ok(()) + })); + writes +} + /// One 8×8 RGB document (with an "Alpha 1" channel when `alpha_channel`) whose exports record /// their Targa bits, in a harness running the dialogs and answering a save dialog with `to`. fn targa_app(alpha_channel: bool, to: &str) -> (Prompted, Writes) { @@ -24,13 +36,7 @@ fn targa_app(alpha_channel: bool, to: &str) -> (Prompted, Writes) { app.run("select.all", json!({})).unwrap(); app.run("select.saveSelection", json!({})).unwrap(); } - let writes: Writes = Rc::default(); - let written = writes.clone(); - app.services.export = Some(Box::new(|_, _, settings| Ok((asked(settings.tga_bits.map(TgaBits::bits)), Vec::new())))); - app.services.write = Some(Box::new(move |path, bytes| { - written.borrow_mut().push((path.to_string(), bytes.to_vec())); - Ok(()) - })); + let writes = targa_writes(&mut app); let h = egui_kittest::Harness::builder().with_size(egui::vec2(800.0, 600.0)).with_context(app.ctx().clone()).build_ui_state( |ui, app| { crate::dialogs::run(app, ui); @@ -76,6 +82,43 @@ fn targa_options_writes_the_choice_or_cancels() { assert_eq!(writes.borrow().as_slice(), &[("t.tga".to_string(), asked(Some(24)))]); } +/// With the real window key handling running, Targa Options owns the first Escape. +#[test] +fn escape_cancels_targa_options_before_deselecting() { + let mut h = egui_kittest::Harness::builder().with_size(egui::vec2(1100.0, 760.0)).with_max_steps(64).build_eframe(|cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, crate::theme::AppTheme::pro()); + let mut app = PhotocraftApp::with_context(cc.egui_ctx.clone(), photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 8, "height": 8})).unwrap(); + app + }); + let writes = targa_writes(h.state_mut()); + h.run_steps(4); + h.state_mut().run("select.all", json!({})).unwrap(); + let st = h.state().session.active().unwrap(); + let (selection, history) = (st.doc.selection.clone().expect("Select All created a selection"), st.history.past_len()); + + h.state_mut().save_as(Some("t.tga".into())).unwrap(); + h.run_steps(2); + assert_eq!(parked(&h), Some(("t.tga".to_string(), false))); + let dialog = h.state().framework.dialogs.open_dialogs().last().expect("Targa Options is open").id; + + h.key_press(Key::Escape); + h.run_steps(4); + assert!(h.state().framework.dialogs.get_dyn(dialog).is_none(), "Escape closes Targa Options"); + assert!(parked(&h).is_none(), "Escape cancels the parked save"); + assert!(writes.borrow().is_empty(), "the cancelled save writes nothing"); + let st = h.state().session.active().unwrap(); + assert_eq!(st.path, None, "the cancelled save leaves the document unsaved"); + assert_eq!(st.doc.selection.as_ref(), Some(&selection), "the dialog's Escape leaves the selection intact"); + assert_eq!(st.history.past_len(), history, "the dialog's Escape leaves document history intact"); + + h.key_press(Key::Escape); + h.run_steps(4); + let st = h.state().session.active().unwrap(); + assert!(st.doc.selection.is_none(), "once the dialog is gone, Escape reaches the window and deselects"); + assert_eq!(st.history.past_len(), history + 1, "only the second Escape edits the document"); +} + /// Scripts choose with `tgaBits` and are never asked; a grayscale Targa (8-bit, nothing to choose) /// and other formats aren't asked either. #[test] From e1d950d6b2c91b146b87d3ee4eeb3d74fedf6db3 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 21 Nov 2026 14:04:27 +0100 Subject: [PATCH 40/42] Smart Filter Lens Blur: setParams refuses an alpha channel depth Applying Lens Blur to a Smart Object already refuses an alpha channel as the depth map: a smart filter re-renders from its params alone, without the document's channels (#7400). layer.smartFilter.setParams did not, so since the Lens Blur dialog sends a chosen channel as `depthMap: "channel"` (#15883), OK in a Smart Filter's Lens Blur dialog could record a source the re-render cannot read. setParams now refuses it with the same message, merged or replaced, and the filter and history stay as they were. Follow-up to the review of integration batch #16092. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/smart_cmds/filters.rs | 4 +++ crates/engine/src/cmd/smart_cmds/tests.rs | 28 +++++++++++++++++++++ crates/engine/src/filters.rs | 7 +++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/smart_cmds/filters.rs b/crates/engine/src/cmd/smart_cmds/filters.rs index 46a5ccba39..70486a8451 100644 --- a/crates/engine/src/cmd/smart_cmds/filters.rs +++ b/crates/engine/src/cmd/smart_cmds/filters.rs @@ -229,6 +229,10 @@ pub(super) fn set_filter_params(s: &mut Session, p: &Value) -> Result { f.params = photocraft_io::smart_map::displace_without_map(&f.params); } } + // As applying it does: the re-render can't read the document's alpha channels. + if f.command == "filter.blur.lensBlur" && f.params.get("depthMap").and_then(Value::as_str) == Some("channel") { + return Err(EngineError::Other(crate::filters::LENS_BLUR_CHANNEL_ON_SMART.into())); + } // Authorize the underlying command with the complete merged params, including paths // already stored in the document, before committing the edit or starting a worker. if let Some(gate) = authorize { diff --git a/crates/engine/src/cmd/smart_cmds/tests.rs b/crates/engine/src/cmd/smart_cmds/tests.rs index 34cb323dae..8465f33719 100644 --- a/crates/engine/src/cmd/smart_cmds/tests.rs +++ b/crates/engine/src/cmd/smart_cmds/tests.rs @@ -1667,3 +1667,31 @@ fn set_params_replace_drops_a_shape_blur_radius_it_leaves_out() { s.execute("layer.smartFilter.setParams", json!({"params": {"shape": "circle"}, "replace": true})).unwrap(); assert!(params(&s).get("radius").is_none(), "replaced: {}", params(&s)); } + +/// A smart filter re-renders from its params alone, without the document's alpha channels (#7400): Lens Blur refuses an +/// alpha channel as its depth on a Smart Object, both when it is applied and when a recorded filter's params are edited +/// (merged or replaced), and the refused edit changes neither the filter nor the history. +#[test] +fn lens_blur_smart_filter_refuses_an_alpha_channel_depth_on_edit() { + let mut s = session(8); + paint(&mut s); + s.execute("select.all", json!({})).unwrap(); + s.execute("select.saveSelection", json!({"name": "Depth"})).unwrap(); + s.execute("select.deselect", json!({})).unwrap(); + s.execute("filter.convertForSmartFilters", json!({})).unwrap(); + let channel = json!({"radius": 4, "depthMap": "channel", "depthChannel": 0}); + let applied = s.execute("filter.blur.lensBlur", channel.clone()).unwrap_err().to_string(); + assert!(applied.contains("rasterize the layer first"), "{applied}"); + s.execute("filter.blur.lensBlur", json!({"radius": 4, "depthMap": "transparency"})).unwrap(); + let recorded = active_smart(&s).smart_filters[0].params.clone(); + let steps = s.active().unwrap().history.past_len(); + for replace in [false, true] { + let e = s.execute("layer.smartFilter.setParams", json!({"index": 0, "params": channel, "replace": replace})).unwrap_err().to_string(); + assert!(e.contains("rasterize the layer first"), "replace={replace}: {e}"); + assert_eq!(active_smart(&s).smart_filters[0].params, recorded, "replace={replace}"); + assert_eq!(s.active().unwrap().history.past_len(), steps, "replace={replace}"); + } + // Sources that need no channel stay editable. + s.execute("layer.smartFilter.setParams", json!({"index": 0, "params": {"depthMap": "none"}})).unwrap(); + assert_eq!(active_smart(&s).smart_filters[0].params["depthMap"], json!("none")); +} diff --git a/crates/engine/src/filters.rs b/crates/engine/src/filters.rs index dd263e335a..9a48debb9b 100644 --- a/crates/engine/src/filters.rs +++ b/crates/engine/src/filters.rs @@ -76,6 +76,11 @@ fn preset(id: &str) -> Option<(&'static str, FilterParams)> { }) } +/// Why Lens Blur refuses an alpha channel as its depth on a Smart Object: a smart filter re-renders from its params +/// alone, without the document's channels, so the depth would be lost (#7400). Applying it and editing a recorded +/// filter's params both refuse it. +pub(crate) const LENS_BLUR_CHANNEL_ON_SMART: &str = "Lens Blur can't read an alpha channel as depth on a Smart Object: rasterize the layer first"; + /// Builds the algorithm parameters for a filter command id from JSON params /// (Photoshop dialog units). Stored smart filters and previews retain their tolerant decoding; /// new command invocations pass through `validate_params` before any document changes. @@ -339,7 +344,7 @@ pub(crate) fn run_filter(s: &mut Session, id: &str, p: &Value) -> Result // A smart filter re-renders from its params alone, without the document's // channels, so Lens Blur's alpha-channel depth would be lost (#7400). if matches!(fp, FilterParams::LensBlur { depth: algo::DepthSource::Channel, .. }) { - return Err(EngineError::Other("Lens Blur can't read an alpha channel as depth on a Smart Object: rasterize the layer first".into())); + return Err(EngineError::Other(LENS_BLUR_CHANNEL_ON_SMART.into())); } // A smart filter re-renders from its params alone: a Displace map read from an // open document, which the re-render can't read again, is kept in them, as From 3dbb289460105c265031a3ebf2c0b8b5c28919ec Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 21 Nov 2026 16:59:54 +0100 Subject: [PATCH 41/42] Status bar: keep the bar the slot's direct child, memoize its body and trailing group One memoized view around the whole status bar made the bar a child of the status slot's row: since craft-libs 02be56cfbb a memoized view in a row moves down onto the row's line, so the bar was shifted about 5 px and its readout was clipped at the window's bottom edge. The bar now stays the slot's direct child, as on main, and its body (readout, message) and trailing group (render path, redraw, job) are a memoized view each, as the options bar's lead is. --- crates/ui-egui/src/menu_floor_trials.rs | 29 +++++ crates/ui-egui/src/panels/status_bar.rs | 159 +++++++++++++----------- 2 files changed, 113 insertions(+), 75 deletions(-) diff --git a/crates/ui-egui/src/menu_floor_trials.rs b/crates/ui-egui/src/menu_floor_trials.rs index 333f8b484c..9fdb3eb08a 100644 --- a/crates/ui-egui/src/menu_floor_trials.rs +++ b/crates/ui-egui/src/menu_floor_trials.rs @@ -6,6 +6,7 @@ use craft::ui::runtime::measure::{MemoRun, last_frame_derived_builds, last_frame_memo_runs, last_pass_memo_key_bytes}; use egui::{Event, Pos2, vec2}; use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT as _, Queryable as _}; use serde_json::json; use crate::PhotocraftApp; @@ -156,3 +157,31 @@ fn the_held_menu_model_equals_a_fresh_build_after_each_step() { h.state_mut().session.saved_to("/tmp/Renamed.psd".into()); held_is_fresh(&mut h, "a save that renames the document"); } + +#[test] +fn the_status_bar_sits_inside_the_window_when_its_views_run_and_replay() { + let mut h = harness(1, 0, 0); + let screen = h.ctx.content_rect(); + // The status bar's zoom field: the lowest node named Zoom that shows the percentage as its value. + let field = |h: &H| { + h.query_all_by_label("Zoom") + .filter(|n| { + let a = n.accesskit_node(); + a.role() != egui::accesskit::Role::Slider && a.value().is_some() && a.bounding_box().is_some() + }) + .map(|n| n.rect()) + .max_by(|a, b| a.bottom().total_cmp(&b.bottom())) + }; + // A settled frame replays the bar's views; a status message runs its body again. + for step in ["settled", "a status message"] { + if step == "a status message" { + h.state_mut().ui.status = "Saved".into(); + } + h.run_steps(2); + let Some(field) = field(&h) else { panic!("{step}: the status bar shows its zoom field") }; + assert!( + field.bottom() <= screen.bottom() && field.top() >= screen.bottom() - 40.0, + "{step}: the zoom field {field:?} sits in the status bar inside the window {screen:?}, not moved down past its edge" + ); + } +} diff --git a/crates/ui-egui/src/panels/status_bar.rs b/crates/ui-egui/src/panels/status_bar.rs index e7a87005f8..9ca8bd15da 100644 --- a/crates/ui-egui/src/panels/status_bar.rs +++ b/crates/ui-egui/src/panels/status_bar.rs @@ -33,7 +33,7 @@ impl Progress { } } -/// Every input of the status bar. +/// Every input of the status bar's body: the readout and the status message. #[derive(MemoProps)] struct StatusProps<'a> { values: StatusValues, @@ -42,6 +42,12 @@ struct StatusProps<'a> { /// The active document's main canvas as its last pass showed it; a document not yet shown has no readout. view: Option, message: Option, + out: Outbox<'a, StatusEvent>, +} + +/// Every input of the status bar's trailing group: the render-path note, the background redraw and the job. +#[derive(MemoProps)] +struct TrailingProps<'a> { render_path: Option, redraw: Option, job: Option, @@ -62,91 +68,94 @@ enum StatusEvent { /// The status bar, in the shell's status slot: the zoom readout of the active document and the latest status /// message, and at the far end the render-path note, the background redraw and the background jobs' progress with -/// Cancel (#210). One view holds the whole bar, so a frame where none of it changed replays it. +/// Cancel (#210). The body and the trailing group are a memoized view each, so a frame where neither changed replays +/// them. The bar itself stays the slot's direct child: it fills the slot's height and centres its content there, where +/// a memoized view around it would be moved down onto the slot row's line and clipped at the window's bottom edge. pub fn status_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let job = crate::jobs_ui::status_job(app); - let mut sent = Vec::new(); - let props = StatusProps { - values: chrome_ui::status_values(app), - item: chrome_ui::status_item(&app.ui.chrome), - document: app.session.active().map(|st| Size::new(st.doc.size.width as f64, st.doc.size.height as f64)), - view: crate::canvas::active_view(app), - message: (!app.ui.status.is_empty()) - .then(|| StatusMessage::new(app.ui.status.clone()).tone(if app.ui.status_error { Tone::Warn } else { Tone::Neutral })), - render_path: chrome_ui::render_path_label(app) - .map(|(label, tip, command)| StatusMessage::new(label).tone(Tone::Warn).command(CommandRef::new(command)).tooltip(tip)), - redraw: crate::background_redraw::progress(app), - job: job.as_ref().map(|(_, progress)| progress.clone()), - out: Outbox::new(&mut sent), - }; - let _ = MemoView::new("status-bar", props, status_view).show(ui); - let mut invalid_zoom = None; - for event in sent { + let values = chrome_ui::status_values(app); + let item = chrome_ui::status_item(&app.ui.chrome); + let document = app.session.active().map(|st| Size::new(st.doc.size.width as f64, st.doc.size.height as f64)); + let view = crate::canvas::active_view(app); + let message = + (!app.ui.status.is_empty()).then(|| StatusMessage::new(app.ui.status.clone()).tone(if app.ui.status_error { Tone::Warn } else { Tone::Neutral })); + let render_path = chrome_ui::render_path_label(app) + .map(|(label, tip, command)| StatusMessage::new(label).tone(Tone::Warn).command(CommandRef::new(command)).tooltip(tip)); + let redraw = crate::background_redraw::progress(app); + let progress = job.as_ref().map(|(_, progress)| progress.clone()); + // The bar may run each group more than once in a pass (it measures the trailing group first); each run sends into + // its group's outbox, and the last of each kind of event applies below. + let (mut body_sent, mut trailing_sent) = (Vec::new(), Vec::new()); + Bar::new("", BarKind::Status) + .trailing(|ui, _| { + let props = TrailingProps { render_path: render_path.clone(), redraw: redraw.clone(), job: progress.clone(), out: Outbox::new(&mut trailing_sent) }; + let _ = MemoView::new("status-bar-trailing", props, trailing_view).show(ui); + }) + .show(ui, |ui, _| { + let props = StatusProps { values: values.clone(), item, document, view, message: message.clone(), out: Outbox::new(&mut body_sent) }; + let _ = MemoView::new("status-bar", props, body_view).show(ui); + }); + let (mut picked, mut edited, mut invalid_zoom, mut cancelled) = (None, None, None, false); + for event in body_sent.into_iter().chain(trailing_sent) { match event { - StatusEvent::Item(picked) => chrome_ui::set_status_item(&mut app.ui.chrome, picked), - StatusEvent::View(new) => { - if let Some(i) = app.session.active_index() { - let ppp = app.canvas_ppp(); - app.ui.views[i].set_from(&new, ppp); - } - } + StatusEvent::Item(item) => picked = Some(item), + StatusEvent::View(new) => edited = Some(new), StatusEvent::InvalidZoom(invalid) => invalid_zoom = Some(invalid), - StatusEvent::CancelJob => { - if let Some((id, _)) = &job { - crate::jobs_ui::cancel(app, *id); - } - } + StatusEvent::CancelJob => cancelled = true, } } + if let Some(picked) = picked { + chrome_ui::set_status_item(&mut app.ui.chrome, picked); + } + if let Some(new) = edited + && let Some(i) = app.session.active_index() + { + let ppp = app.canvas_ppp(); + app.ui.views[i].set_from(&new, ppp); + } + if cancelled && let Some((id, _)) = &job { + crate::jobs_ui::cancel(app, *id); + } chrome_ui::zoom_alert(app, invalid_zoom); } -/// The status bar's view. -fn status_view(props: &mut StatusProps<'_>, ui: &mut egui::Ui) { - let mut cancelled = false; - let mut picked = None; - let mut invalid_zoom = None; - let mut edited = None; - Bar::new("", BarKind::Status) - .trailing(|ui, _| { - if let Some(shown) = &props.render_path { - shown.show(ui); - } - if let Some(progress) = &props.redraw { - progress.widget().show(ui); - } - if let Some(progress) = &props.job { - cancelled |= progress.widget().show(ui).cancelled; - } - }) - .show(ui, |ui, _| { - match (props.document, props.view) { - (Some(size), Some(view)) => { - let out = StatusReadout::new(Bind::given(view), size, props.item, &props.values).show(ui); - picked = out.item.or(picked); - invalid_zoom = out.invalid_zoom.or(invalid_zoom.take()); - edited = out.view.value().copied().or(edited); - } - (Some(_), None) => {} - (None, _) => { - StatusMessage::new(tl!("No document")).show(ui); - } - } - // A command run with no document open still reports here (#1567: File › Automate › Batch). - if let Some(shown) = &props.message { - shown.show(ui); - } - }); - if let Some(picked) = picked { - props.out.send(StatusEvent::Item(picked)); +/// The status bar's trailing group. +fn trailing_view(props: &mut TrailingProps<'_>, ui: &mut egui::Ui) { + if let Some(shown) = &props.render_path { + shown.show(ui); } - if let Some(view) = edited { - props.out.send(StatusEvent::View(view)); + if let Some(progress) = &props.redraw { + progress.widget().show(ui); } - if let Some(invalid) = invalid_zoom { - props.out.send(StatusEvent::InvalidZoom(invalid)); - } - if cancelled { + if let Some(progress) = &props.job + && progress.widget().show(ui).cancelled + { props.out.send(StatusEvent::CancelJob); } } + +/// The status bar's body. +fn body_view(props: &mut StatusProps<'_>, ui: &mut egui::Ui) { + match (props.document, props.view) { + (Some(size), Some(view)) => { + let out = StatusReadout::new(Bind::given(view), size, props.item, &props.values).show(ui); + if let Some(picked) = out.item { + props.out.send(StatusEvent::Item(picked)); + } + if let Some(view) = out.view.value().copied() { + props.out.send(StatusEvent::View(view)); + } + if let Some(invalid) = out.invalid_zoom { + props.out.send(StatusEvent::InvalidZoom(invalid)); + } + } + (Some(_), None) => {} + (None, _) => { + StatusMessage::new(tl!("No document")).show(ui); + } + } + // A command run with no document open still reports here (#1567: File › Automate › Batch). + if let Some(shown) = &props.message { + shown.show(ui); + } +} From 1f86f4bacf1ec4b5aaa779277fa67334ac564ea5 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Sun, 22 Nov 2026 00:17:28 +0700 Subject: [PATCH 42/42] io: cover Camera Raw settings through PSD save and reopen (#16218) Co-authored-by: FredApps --- crates/io/src/camera_raw_map/tests.rs | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/crates/io/src/camera_raw_map/tests.rs b/crates/io/src/camera_raw_map/tests.rs index 0d1e1a603a..6e2373657a 100644 --- a/crates/io/src/camera_raw_map/tests.rs +++ b/crates/io/src/camera_raw_map/tests.rs @@ -165,6 +165,54 @@ fn active_unimplemented_controls_and_malformed_curves_stay_opaque() { } } +#[test] +fn psd_reopen_keeps_editable_camera_raw_and_preserves_active_unsupported_optics() { + use std::sync::Arc; + + use photocraft_color::{ColorMode, SampleType}; + use photocraft_doc::{Document, Layer, LayerContent, SmartObject, SmartSource}; + use photocraft_geom::{Affine, Size}; + use photocraft_raster::Surface; + + let size = Size::new(2, 2); + let mut source = Document::new("contents", size, ColorMode::Rgb, SampleType::U8); + let mut pixels = Surface::new(source.pixel_format()); + pixels.fill_rect(source.bounds(), &[0.25, 0.50, 0.75, 1.0]); + source.layers.push(Layer::new("synthetic pixels", LayerContent::Raster(pixels.clone()))); + let bytes = Arc::new(photocraft_format::save_to_bytes(&source, &Default::default()).unwrap()); + + // Use the existing generated descriptor, not the optional external PSD. Nonzero MDis cannot + // be rendered by the editable Camera Raw filter and must survive even when the layer is saved. + for optics in [false, true] { + let mut item = source_item(); + if optics { + let mut settings = get_desc(&item, "Fltr").unwrap().clone(); + set(&mut settings, "MDis", Value::Integer(17)); + set(&mut item, "Fltr", Value::Descriptor(settings)); + } + let mut smart = + SmartObject::new(SmartSource::Embedded { file_name: "contents.pcraft".into(), bytes: bytes.clone() }, Affine::IDENTITY, Some(pixels.clone())); + smart.smart_filters.push(filter_from_item(&item)); + let mut doc = Document::new("camera raw compatibility", size, ColorMode::Rgb, SampleType::U8); + doc.layers.push(Layer::new("edited", LayerContent::Smart(smart))); + + let saved = crate::export(&doc, "psd", &Default::default()).unwrap(); + let reopened = crate::import("saved.psd", &saved.bytes).unwrap().document; + let layer = reopened.layers.iter().find(|layer| layer.name == "edited").unwrap(); + let LayerContent::Smart(smart) = &layer.content else { panic!("the Camera Raw layer must reopen as a smart object") }; + let [filter] = smart.smart_filters.as_slice() else { panic!("expected the saved Camera Raw filter") }; + if optics { + assert_eq!(filter.command, UNSUPPORTED_FILTER); + } else { + assert_eq!(filter.command, COMMAND); + let settings: CameraRaw = serde_json::from_value(filter.params.clone()).unwrap(); + assert!((settings.exposure - 1.15).abs() < 1e-6); + } + let roundtripped = item_for_filter(filter).unwrap(); + assert_eq!(get_desc(&roundtripped, "Fltr"), get_desc(&item, "Fltr")); + } +} + #[test] #[ignore = "requires a user-supplied Camera Raw PSD"] fn all_sliders_fixture() {