From 40491cd8da5170860e22367a9029ac1d4e58c92f Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Thu, 26 Nov 2026 08:20:38 +0100 Subject: [PATCH] Actions: the Custom-area message of an empty Content-Aware Fill step is translatable (#14254) The engine keeps its English message for automation clients, now as `atn_cmds::CAF_CUSTOM_AREA_NOT_REMEMBERED`. When a step fails with it, the status bar shows the shell's literal `tl!` copy instead, so the recovery instructions follow the UI language and the translation coverage report lists the key. --- crates/engine-core/src/cmd/atn_cmds.rs | 2 +- .../src/cmd/atn_cmds/steps_content_aware.rs | 6 ++++-- crates/ui-egui/src/dialogs/caf_ui/tests.rs | 4 ++++ crates/ui-egui/src/panels/actions/runner.rs | 14 +++++++++++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/engine-core/src/cmd/atn_cmds.rs b/crates/engine-core/src/cmd/atn_cmds.rs index d626f197c0..28fa834642 100644 --- a/crates/engine-core/src/cmd/atn_cmds.rs +++ b/crates/engine-core/src/cmd/atn_cmds.rs @@ -85,8 +85,8 @@ use events::{EVENTS, event_and_descriptor, event_for}; use fields::Mapped; use files::{load, save}; pub use menu_item::{MENU_ITEM, menu_item_command, menu_item_commands, menu_item_needs_settings}; -pub use steps_content_aware::CAF_WORKSPACE_PREFS; pub(crate) use steps_content_aware::caf_remembered; +pub use steps_content_aware::{CAF_CUSTOM_AREA_NOT_REMEMBERED, CAF_WORKSPACE_PREFS}; #[cfg(test)] use steps_doc::crop_from; pub(crate) use steps_gallery::RECORDED_EVENT; diff --git a/crates/engine-core/src/cmd/atn_cmds/steps_content_aware.rs b/crates/engine-core/src/cmd/atn_cmds/steps_content_aware.rs index 72f63118f7..958fd1961b 100644 --- a/crates/engine-core/src/cmd/atn_cmds/steps_content_aware.rs +++ b/crates/engine-core/src/cmd/atn_cmds/steps_content_aware.rs @@ -98,6 +98,9 @@ fn descriptor(p: &Value) -> Option { ) } +/// Why an empty recorded step refuses remembered Custom sampling ([`caf_remembered`]). The shell shows it translated. +pub const CAF_CUSTOM_AREA_NOT_REMEMBERED: &str = "This step plays with the remembered Content-Aware Fill settings, and their Custom sampling area isn't remembered. Fill once with Auto or Rectangular sampling in Content-Aware Fill, then play it again."; + /// Resolve an empty recorded step: the remembered settings fill what the step doesn't name, and /// before any were remembered it writes to a new layer. Playing never changes what is remembered. /// Remembered Custom sampling is refused: its area is painted in the workspace, which keeps none @@ -117,8 +120,7 @@ pub(crate) fn caf_remembered(p: &mut Value, prefs: &crate::prefs::Preferences) - } object.entry("output").or_insert_with(|| "new".into()); if object.get("sampling").and_then(Value::as_str) == Some("custom") && !["area", "channel", "samplingStrokes"].iter().any(|key| object.contains_key(*key)) { - let msg = "this step plays with the remembered settings, and their Custom sampling area isn't remembered: fill once with Auto or Rectangular sampling in Content-Aware Fill, then play it again"; - return Err(EngineError::BadParams { cmd: CMD.into(), msg: msg.into() }); + return Err(EngineError::BadParams { cmd: CMD.into(), msg: CAF_CUSTOM_AREA_NOT_REMEMBERED.into() }); } Ok(()) } diff --git a/crates/ui-egui/src/dialogs/caf_ui/tests.rs b/crates/ui-egui/src/dialogs/caf_ui/tests.rs index 21f108c52b..e2d2031ac3 100644 --- a/crates/ui-egui/src/dialogs/caf_ui/tests.rs +++ b/crates/ui-egui/src/dialogs/caf_ui/tests.rs @@ -393,6 +393,10 @@ fn an_empty_recorded_step_after_a_custom_fill_stops_and_says_why() { assert_eq!(result["ran"], 0, "{result}"); let error = result["failed"]["error"].as_str().unwrap_or_default(); assert!(error.contains("Custom sampling area isn't remembered"), "{result}"); + // The status bar shows the shell's translatable copy of the message, not the engine's parameter error. + crate::actions::report_play(&mut app, &result); + let status = &app.ui.status; + assert!(status.contains(photocraft_engine::atn_cmds::CAF_CUSTOM_AREA_NOT_REMEMBERED) && !status.contains("invalid parameters"), "{status}"); assert_eq!(app.session.active().unwrap().revision, revision, "the document is unchanged"); assert_eq!(app.session.prefs().dialogs.get(photocraft_engine::atn_cmds::CAF_WORKSPACE_PREFS), Some(&remembered), "playing remembers nothing"); } diff --git a/crates/ui-egui/src/panels/actions/runner.rs b/crates/ui-egui/src/panels/actions/runner.rs index c97cfd1d8b..069c15c7b5 100644 --- a/crates/ui-egui/src/panels/actions/runner.rs +++ b/crates/ui-egui/src/panels/actions/runner.rs @@ -655,12 +655,24 @@ pub(crate) fn report_play(app: &mut PhotocraftApp, v: &Value) { }; let step = failed.get("step").and_then(Value::as_u64).unwrap_or(0); let id = failed.get("id").and_then(Value::as_str).unwrap_or(""); - let error = failed.get("error").and_then(Value::as_str).unwrap_or(""); + let error = step_error(failed.get("error").and_then(Value::as_str).unwrap_or("")); let template = "Step {step} ({id}) failed: {error}"; app.ui.status = crate::i18n::fmt(tl!(template), &[("step", &(step + 1).to_string()), ("id", id), ("error", error)]); app.ui.status_error = true; } +/// A failed step's `error` in the UI language when the engine's message is one the shell spells out, otherwise as the +/// engine gave it. Automation clients keep the engine's English. +fn step_error(error: &str) -> &str { + if error.ends_with(photocraft_engine::atn_cmds::CAF_CUSTOM_AREA_NOT_REMEMBERED) { + // The engine's text, as a literal the translation coverage report collects (#14254). + return tl!( + "This step plays with the remembered Content-Aware Fill settings, and their Custom sampling area isn't remembered. Fill once with Auto or Rectangular sampling in Content-Aware Fill, then play it again." + ); + } + error +} + /// Resume the recording a paused call suspended and journal that call, once. fn restore_recording(app: &mut PhotocraftApp, owner: Option<&Value>) { let Some(owner) = owner else { return };