mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
fix(engine): expose a command's job-conflict reason (#13886)
Signed-off-by: MaheshDesu <[email protected]>
This commit is contained in:
1 parent
9948e6f1e7
commit
759f088deb
2 files changed
+21
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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<String> {
|
||||
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) {
|
||||
|
||||
Reference in new issue
Block a user