FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
#1544: an export started without wait says where to follow it (jobs.list, jobs.cancel)
00xJ0a358c3518e41
diff --git a/crates/engine/src/export_tests.rs b/crates/engine/src/export_tests.rsindex d0cec7035..79ddcb810 100644--- a/crates/engine/src/export_tests.rs+++ b/crates/engine/src/export_tests.rs@@ -23,6 +23,38 @@ fn hostile_export_ranges_are_rejected_without_panicking() {}}+/// #1544: an export started without `wait` says where it can be followed: `jobs.list` (not+/// `export.queue.list`, which lists the Export Queue only) and `jobs.cancel` to stop it.+#[test]+fn export_without_wait_says_where_to_poll() {+ let mut s = demo();+ let dir = Scratch::new("poll");+ let r = s+ .execute("file.exportMedia", json!({"path": dir.path("Demo.wav"), "format": "wav", "range": "custom", "startSeconds": 0, "endSeconds": 0.25}))+ .unwrap();+ assert_eq!((r["poll"].as_str(), r["cancel"].as_str()), (Some("jobs.list"), Some("jobs.cancel")), "{r}");+ let job = r["job"].as_u64().unwrap();+ // the job is there to poll, and the Export Queue is not where it is+ let listed = |s: &mut Session| s.execute("jobs.list", json!({})).unwrap().as_array().unwrap().iter().find(|j| j["id"] == job).cloned();+ assert!(listed(&mut s).is_some(), "the job is in jobs.list");+ assert_eq!(s.execute("export.queue.list", json!({})).unwrap()["items"], json!([]));+ for _ in 0..1200 {+ if listed(&mut s).is_some_and(|j| j["finished"] == true) {+ break;+ }+ std::thread::sleep(std::time::Duration::from_millis(25));+ }+ assert_eq!(listed(&mut s).map(|j| j["finished"].clone()), Some(json!(true)), "the export finished");+ // a waited export answers its result instead+ let r = s+ .execute(+ "file.exportMedia",+ json!({"path": dir.path("Demo2.wav"), "format": "wav", "range": "custom", "startSeconds": 0, "endSeconds": 0.25, "wait": true}),+ )+ .unwrap();+ assert!(r.get("poll").is_none() && r["result"].is_object(), "{r}");+}+/// A scratch directory under the workspace `target/`, removed when dropped.struct Scratch(PathBuf);diff --git a/crates/engine/src/export_tools.rs b/crates/engine/src/export_tools.rsindex 2fd68925b..98c7ad2fc 100644--- a/crates/engine/src/export_tools.rs+++ b/crates/engine/src/export_tools.rs@@ -549,6 +549,12 @@ pub fn export_media(s: &mut Session, p: &Value) -> Result<Value> {if let Some(pr) = preset {out["preset"] = json!(pr.name);}+ if !wait {+ // where the job can be followed (#1544: it is not in `export.queue.list`, which only lists+ // the Export Queue, so agents looked there and found nothing)+ out["poll"] = json!("jobs.list");+ out["cancel"] = json!("jobs.cancel");+ }if wait && let Some(j) = s.jobs.iter().find(|j| j.id == id) {let v = j.to_json();if let Some(e) = v["result"]["error"].as_str() {diff --git a/docs/agents.md b/docs/agents.mdindex cbbeecaa7..4b85410f0 100644--- a/docs/agents.md+++ b/docs/agents.md@@ -123,8 +123,9 @@ progress and stop it:- `notifications/cancelled` for the request stops the encode at the next batch (`jobs.cancel`),deletes the partial output (the movie, or the frames and caption sidecar written so far) and sendsno response, as the MCP cancellation utility asks.-- Without `wait` the command returns `{job, path}` at once, as before: poll `jobs.list` and stop it- with `jobs.cancel`. Other exports (`file.exportFrame`, interchange formats, …) finish quickly and+- Without `wait` the command returns `{job, path, poll: "jobs.list", cancel: "jobs.cancel"}` at+ once: poll `jobs.list` for the job's `progress`, `etaSeconds`, `finished` and `result`, and stop it+ with `jobs.cancel` (`export.queue.list` lists the Export Queue only, not direct exports, #1544). Other exports (`file.exportFrame`, interchange formats, …) finish quickly andignore the token.- Bridge mode works the same way: the export runs as an app job (the app stays responsive and shows"Exporting… NN%" in its status bar) and the call returns when it is written, however long it