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.
This commit is contained in:
RickiNano committed 2026-11-26 08:20:38 +01:00
1 parent 9e8827aa45
commit 40491cd8da
4 files changed
+22 -4

No files matched your search

+1 -1
View File
@@ -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;
@@ -98,6 +98,9 @@ fn descriptor(p: &Value) -> Option<Descriptor> {
)
}
/// 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(())
}
@@ -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");
}
+13 -1
View File
@@ -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 };