diff --git a/crates/engine-core/src/jobs/tests.rs b/crates/engine-core/src/jobs/tests.rs index f1195bafb1..e2f542eec5 100644 --- a/crates/engine-core/src/jobs/tests.rs +++ b/crates/engine-core/src/jobs/tests.rs @@ -285,6 +285,19 @@ fn a_running_job_locks_its_document_but_not_others() { assert_eq!(s.documents()[0].history.past_len(), 3); } +/// The Frame tool asks for a job conflict separately from a mode refusal (#13886): a running job +/// keeps its status message, while the Bitmap/Indexed refusal stays silent. +#[test] +fn the_frame_press_can_tell_a_job_conflict_from_a_mode_refusal() { + let mut s = session(64, 64); + let gate = Arc::new(std::sync::atomic::AtomicBool::new(false)); + let id = gated_job(&mut s, &gate); + let reason = s.job_conflict_reason("layer.new.frame").expect("a running job conflicts"); + assert!(reason.contains("still running"), "{reason}"); + gate.store(true, std::sync::atomic::Ordering::Relaxed); + wait_event(&mut s, id); +} + #[test] fn jobs_list_puts_running_jobs_before_ended_ones() { let mut s = session(64, 64); diff --git a/crates/engine-core/src/session/execute.rs b/crates/engine-core/src/session/execute.rs index 6bbecf98ff..cb5a2bcdc0 100644 --- a/crates/engine-core/src/session/execute.rs +++ b/crates/engine-core/src/session/execute.rs @@ -125,6 +125,14 @@ impl Session { self.precondition(spec, &channel_cmds::inject_target(self, id, params.clone())).err().or_else(|| self.job_conflict(id, spec.journal)) } + /// Why a background job on the active document stops `id` now, if one does. The Frame tool's + /// press uses this to keep the job-conflict message while the Bitmap/Indexed refusal stays + /// silent (#13886). + pub fn job_conflict_reason(&self, id: &str) -> Option { + let spec = commands::find(id)?; + self.job_conflict(id, spec.journal) + } + /// The command's own precondition for a call with `params` (their target filled in). fn precondition(&self, spec: &commands::CommandSpec, params: &Value) -> std::result::Result<(), String> { if let Some(why) = color_channels::refusal(self, spec.id, params) {