forge
Explore
Log in

Don't you dare go Hollow

✨ MCP: export_queue pause, start and status

Browse files at this commit

9776376cb6240c77ec934283e078324adf61f08dAhmet Kaan GümüşParent: 29cb69f
MCP.mdmodified+2 -1
@@ -412,7 +412,8 @@ Piper's stderr is reported on failure.
412412 | `proxies` | action (`status`, the default, `make`, `cancel` or `delete`), source (`src:<n>`, a list or `"all"`) | the editing copies (proxies) of sources. `status` shows each source's state (ready, making with its percent, off, not needed for a sound or still, or why a stand-in failed). `make` starts one in the background and turns that film's switch back on; a film that plays at speed on this machine needs none, and says so. `cancel` stops one being made and leaves the film off, as the Proxies switch on a library row does. `delete` removes the stand-in and keeps the film off. With `auto_proxies` on, each `media_import` starts its stand-ins the same way |
413413 | `speech_model` | download (false), model (`tiny`, `base` or `small`; default `base`), cancel (false) | the speech model that `transcript`, `find_words` and `auto_captions` run on: no argument shows which models are installed and the download in progress. `download: true` fetches a model in the background (the GUI's Download model fetches `base`); `cancel: true` stops it and keeps the files fetched so far. Nothing is downloaded unless `download` is true |
414414 | `export_status` | job, out | a queued job (`export_start {queue:true}`) reads `waiting` with the number of exports ahead of it; progress, elapsed, ETA, encoder, outcome of one job; while a stabilised clip is measured before it can encode, the line and `stage`/`stage_progress` name that stage (`Measuring shake`) with its own percent; `out` reports a file this session did not start; omitted, every export so far, with its size when done (decimal: 12,139,083 bytes is 12.1 MB) and the integrated loudness (LUFS) and true peak of the written file (`integrated_lufs`, `true_peak_dbtp`, measured once from the file with the `loudness` measurement), or its error when failed. When a job finishes, a peak over the format's ceiling gets a warning line: -1 dBTP for lossless (wav, flac), -2 dBTP for lossy (the rest, since encoding can overshoot the mix) |
415-| `export_cancel` | job, all | cancels a running job; a waiting (queued) job is removed from the queue and never starts. `all: true` cancels every unfinished export at once (the queued ones and the running one), as the export queue's Cancel all does. The queue's Pause and Start are not offered here: the MCP queue starts each job as the one before it ends, with no pause state to reach |
415+| `export_cancel` | job, all | cancels a running job; a waiting (queued) job is removed from the queue and never starts. `all: true` cancels every unfinished export at once (the queued ones and the running one), as the export queue's Cancel all does. |
416+| `export_queue` | action (`pause`, `start` or `status`, the default) | `pause` stops the queue after the running export: the running one finishes, and the queued exports (`export_start {queue:true}`) stay waiting. `start` lifts the pause and starts the next queued export now if nothing is running. `status` says whether the queue is paused, the running export and the queued ones in order. A pause holds only queued exports; a direct export (no `queue`) starts at once. `export_status` names a paused queue |
416417 | `render_preview` | range (`"all"`, the default, or `{from, to}`), cancel, clear | `clear: true` deletes every render file in the cache (finished or half written) and says how many went, as File > Delete render files does; refused while a render is running. Pre-renders a stretch of the timeline at preview size into the render cache, so playback over it reads finished frames instead of compositing them (heavy sections: stacked effects, titles over video, colour, speed, multicam). One render at a time, in the background; `project_status` shows the progress and the cached ranges. A render is keyed by a hash of everything that changes its pixels (the clips overlapping it and their neighbours, their sources, titles, captions, tone, rate), so an edit inside a cached range drops it and playback composes live there again. `cancel: true` stops the running render and removes its partial file. The sound is not rendered; the live mix always plays |
417418
418419 `format` is one of `mp4`, `av1`, `av1-mp4`, `hevc`, `hevc-mp4`, `webm`, `wav`,
crates/mcp/src/help.rsmodified+2 -1
@@ -42,7 +42,7 @@ const GROUPS: &[(&str, &[&str])] = &[
4242 ("scan", &["scenes", "stabilize_status", "track", "track_status"]),
4343 ("hear", &["levels", "silence", "cut_silence", "loudness", "normalize", "clean_voice"]),
4444 ("edit", &["edit", "sequence", "multicam_create", "multicam_flatten", "effect", "undo", "redo", "checkpoint", "restore", "checkpoints"]),
45- ("export", &["export_start", "export_presets", "export_status", "export_cancel", "export_captions", "render_preview"]),
45+ ("export", &["export_start", "export_presets", "export_status", "export_cancel", "export_queue", "export_captions", "render_preview"]),
4646 ("listen", &["transcript", "find_words", "auto_captions", "speech_model"]),
4747 ("captions", &["captions"]),
4848 ("speak", &["voices", "voiceover"]),
@@ -261,6 +261,7 @@ EXPORT
261261 The export keeps running while you do other things. If the client closes the server's input, the server waits for running exports to finish before it exits. A stop signal (SIGTERM or SIGINT) cancels them and deletes their partial files. Poll export_status until it finishes; export_cancel {job} stops one.
262262 export_status reports progress, ETA, the encoder and the outcome; a done export reports its file size.
263263 Queue: export_start {queue:true} lines an export up. It keeps its own copy of the timeline as it is at that moment (later edits do not change it) and starts when every earlier export has finished, one encode at a time, with no polling needed; export_status shows it as `waiting` with the number of exports ahead. export_cancel {job} on a waiting job removes it from the queue. Without queue the export starts at once, beside any others.
264+ export_queue {action:\"pause\"} pauses the queue: the running export finishes, and the queued ones stay waiting until export_queue {action:\"start\"}, which lifts the pause and starts the next one now if nothing is running. export_queue {action:\"status\"} (the default) says whether the queue is paused, the running export and the queued ones in order. A pause holds only queued exports; a direct export starts at once. export_status says when the queue is paused.
264265 Render preview: render_preview {range?} pre-renders a stretch (default: the whole timeline) so playback over the heavy parts of a cut reads finished frames instead of compositing them. It runs in the background; project_status shows the progress and the cached ranges. An edit inside a cached range drops that render. render_preview {cancel:true} stops it.
265266 export_status {out} for a file this session did not write reports whether it is there, its size and its time; the progress
266267 of a job from an earlier session is not known.
crates/mcp/src/main.rsmodified+4 -1
@@ -144,7 +144,9 @@ fn wait_for_exports(server: &mut server::Server) {
144144 .filter(|(_, j)| tools::export::job_running(j))
145145 .map(|(i, j)| (i + 1, j.progress()))
146146 .collect();
147- if running.is_empty() {
147+ // A paused queue starts nothing, so once only held exports remain the wait is over.
148+ let held = server.queue_paused && server.jobs.iter().all(|j| !tools::export::job_running(j) || j.waiting());
149+ if running.is_empty() || held {
148150 // Nothing else can read this outcome back, so it goes to stderr once: a failure
149151 // always (the client is gone and a missing file would otherwise be silent), a
150152 // success only under EDITH_DEBUG.
@@ -154,6 +156,7 @@ fn wait_for_exports(server: &mut server::Server) {
154156 Some(Ok(())) if debug => eprintln!("export job:{} finished: {} ({:.0?} after start)", i + 1, job.out.display(), job.started.elapsed()),
155157 Some(Ok(())) => {}
156158 Some(Err(e)) => eprintln!("export job:{} failed: {}: {e}", i + 1, job.out.display()),
159+ None if job.waiting() => eprintln!("export job:{} was queued and never started (the queue was paused): {}", i + 1, job.out.display()),
157160 None => eprintln!("export job:{} ended without a result: {}", i + 1, job.out.display()),
158161 }
159162 }
crates/mcp/src/server.rsmodified+3 -0
@@ -39,6 +39,9 @@ pub struct Server {
3939 /// the history did not survive the open. Cleared wherever a new edit lands.
4040 pub history_lost_on_open: bool,
4141 pub jobs: Vec<Job>,
42+ /// Set by `export_queue {action:"pause"}`: a queued export does not start while it is set, so
43+ /// the running one finishes and the rest wait for `export_queue {action:"start"}`.
44+ pub queue_paused: bool,
4245 /// Editing copies (proxies) being made or settled, one per source (`proxies`).
4346 pub proxy_runs: Vec<crate::tools::media::ProxyRun>,
4447 /// The speech model download running or finished (`speech_model`).
crates/mcp/src/tools/export.rsmodified+117 -6
@@ -58,9 +58,99 @@ pub fn tools() -> Vec<Tool> {
5858 schema: cancel_schema,
5959 run: export_cancel,
6060 },
61+ Tool {
62+ name: "export_queue",
63+ description: "Pause or start the export queue (export_start {queue:true}). pause: the running export finishes, and the queued ones stay queued until start. start: lifts the pause and starts the next queued export now, if nothing is running. status: whether the queue is paused, the running export and the queued ones in order. A direct export (no queue) is not held by a pause.",
64+ schema: queue_schema,
65+ run: export_queue,
66+ },
6167 ]
6268 }
6369
70+fn queue_schema() -> Value {
71+ json!({
72+ "type": "object",
73+ "properties": {
74+ "action": {
75+ "type": "string",
76+ "enum": ["pause", "start", "status"],
77+ "description": "pause: queued exports stay queued after the running one ends. start: lifts the pause and starts the next queued export now if nothing is running. status (the default): whether the queue is paused, the running export and the queued ones in order."
78+ }
79+ },
80+ "additionalProperties": false
81+ })
82+}
83+
84+/// The running job's index: one with a worker that has not finished (a waiting job has none).
85+fn running_index(srv: &Server) -> Option<usize> {
86+ srv.jobs.iter().position(|j| j.handle.is_some() && job_running(j))
87+}
88+
89+/// `export_queue`: pauses the queue, lifts the pause, or reports the queue's state.
90+fn export_queue(srv: &mut Server, args: &Value) -> Reply {
91+ let action = opt_str(args, "action").unwrap_or("status");
92+ let queued_list = |srv: &Server| -> String {
93+ let waiting: Vec<String> = srv.jobs.iter().enumerate().filter(|(_, j)| j.waiting()).map(|(i, _)| format!("job:{}", i + 1)).collect();
94+ if waiting.is_empty() { "none".to_string() } else { waiting.join(", ") }
95+ };
96+ match action {
97+ "pause" => {
98+ let was = srv.queue_paused;
99+ srv.queue_paused = true;
100+ let head = if was { "queue already paused" } else { "queue paused" };
101+ let running = running_index(srv).map_or("no export is running".to_string(), |i| format!("job:{} keeps running and finishes", i + 1));
102+ Reply::ok(format!(
103+ "{head}: {running}; queued exports wait ({}) until export_queue {{action:\"start\"}}",
104+ queued_list(srv)
105+ ))
106+ .with(json!({ "action": "pause", "paused": true, "queued": queued_list(srv) }))
107+ }
108+ "start" => {
109+ let was = srv.queue_paused;
110+ srv.queue_paused = false;
111+ let next = srv.jobs.iter().position(|j| j.waiting());
112+ advance(srv);
113+ let started = next.is_some_and(|i| !srv.jobs[i].waiting());
114+ let mut text = if was { "queue started".to_string() } else { "queue was not paused".to_string() };
115+ match (started, running_index(srv), next) {
116+ (true, _, Some(i)) => text.push_str(&format!(": job:{} started now", i + 1)),
117+ (false, Some(r), Some(i)) => text.push_str(&format!(": job:{} is still running, and job:{} starts when it finishes", r + 1, i + 1)),
118+ _ => text.push_str(": nothing is waiting"),
119+ }
120+ Reply::ok(text).with(json!({ "action": "start", "paused": false, "running": running_index(srv).map(|i| i + 1), "queued": queued_list(srv) }))
121+ }
122+ "status" => {
123+ let running = running_index(srv).map(|i| {
124+ let n = i + 1;
125+ let pct = f64::from(srv.jobs[i].progress()).clamp(0.0, 1.0) * 100.0;
126+ format!("job:{n} running {pct:.0}% → {}", srv.jobs[i].out.display())
127+ });
128+ let queued: Vec<String> = srv
129+ .jobs
130+ .iter()
131+ .enumerate()
132+ .filter(|(_, j)| j.waiting())
133+ .enumerate()
134+ .map(|(k, (i, j))| format!("{}. job:{} waiting → {}", k + 1, i + 1, j.out.display()))
135+ .collect();
136+ let state = if srv.queue_paused { "paused" } else { "running" };
137+ let mut lines = vec![format!("queue {state}; {} queued", queued.len())];
138+ lines.push(format!("running: {}", running.unwrap_or_else(|| "none".to_string())));
139+ if queued.is_empty() {
140+ lines.push("queued: none".to_string());
141+ } else {
142+ lines.push("queued, in order:".to_string());
143+ lines.extend(queued);
144+ }
145+ if srv.queue_paused {
146+ lines.push("The queue is paused: queued exports do not start until export_queue {action:\"start\"}.".to_string());
147+ }
148+ Reply::ok(lines.join("\n")).with(json!({ "action": "status", "paused": srv.queue_paused, "queued": queued_list(srv), "running": running_index(srv).map(|i| i + 1) }))
149+ }
150+ other => Reply::err(format!("export_queue action `{other}` is not one of pause, start, status")),
151+ }
152+}
153+
64154 fn presets_schema() -> Value {
65155 json!({ "type": "object", "properties": {} })
66156 }
@@ -1666,7 +1756,9 @@ fn export_start(srv: &mut Server, args: &Value) -> Reply {
16661756 // timeline and starts when they are done (`advance`). With nothing ahead it starts now.
16671757 let queued = opt_bool(args, "queue").unwrap_or(false);
16681758 let ahead = srv.jobs.iter().position(job_running).map(|i| i + 1);
1669- let (handle, pending) = if queued && ahead.is_some() {
1759+ // A paused queue holds a queued export even with nothing ahead of it.
1760+ let paused = srv.queue_paused;
1761+ let (handle, pending) = if queued && (ahead.is_some() || paused) {
16701762 let frames = settings.range.map_or(project.media_frames(), |(a, b)| b.min(project.media_frames()).saturating_sub(a));
16711763 let length_secs = f64::from(frames) / meta.frame_rate;
16721764 (None, Some(Box::new(Pending { project, meta, settings: settings.clone(), sample_rate, length_secs })))
@@ -1705,7 +1797,9 @@ fn export_start(srv: &mut Server, args: &Value) -> Reply {
17051797 let preset_note = preset.map_or_else(String::new, |p| format!("; preset {}", p.id));
17061798 let verb = if waiting { "queued" } else { "started" };
17071799 let mut text = format!("job:{job} {verb} → {} ({when}); {words}{captions}{tone_note}{size_note}{fit_note}{preset_note}{loudness_note}", out.display());
1708- if waiting {
1800+ if waiting && paused {
1801+ text.push_str("\nWaiting: the export queue is paused, so this one starts only when export_queue {action:\"start\"} is sent, from the timeline as it is now (later edits do not change it). export_status shows the queue; export_cancel with its job removes it.");
1802+ } else if waiting {
17091803 text.push_str(&format!(
17101804 "\nWaiting: it starts when job:{} and every export queued before it have finished, from the timeline as it is now (later edits do not change it). export_status shows it as waiting; export_cancel with its job removes it.",
17111805 ahead.unwrap_or(1)
@@ -1838,12 +1932,13 @@ pub fn job_running(job: &Job) -> bool {
18381932
18391933 /// Moves the queue on: a waiting job whose cancel arrived is settled by `Job::cancel`; when no
18401934 /// worker is running, the first waiting job starts from its own copy of the timeline. One encode
1841-/// at a time. Called on every server tick, so a queue drains with no client polling.
1935+/// at a time. A paused queue (`export_queue {action:"pause"}`) starts nothing new. Called on every
1936+/// server tick, so a queue drains with no client polling.
18421937 pub fn advance(srv: &mut Server) {
18431938 for job in srv.jobs.iter_mut() {
18441939 settle(job);
18451940 }
1846- if srv.jobs.iter().any(|j| j.handle.is_some() && job_running(j)) {
1941+ if srv.queue_paused || srv.jobs.iter().any(|j| j.handle.is_some() && job_running(j)) {
18471942 return;
18481943 }
18491944 if let Some(job) = srv.jobs.iter_mut().find(|j| j.outcome.is_none() && j.waiting())
@@ -1874,7 +1969,7 @@ fn export_status(srv: &mut Server, args: &Value) -> Reply {
18741969 None => Reply::ok(unknown_out_text(&anchored)).with(json!({"jobs": [], "finished": 0})),
18751970 };
18761971 }
1877- if srv.jobs.is_empty() && args.get("job").is_none() {
1972+ if srv.jobs.is_empty() && args.get("job").is_none() && !srv.queue_paused {
18781973 return Reply::ok(
18791974 "no exports in this session — export_start makes one. An export from an earlier session is not tracked here: pass out (its file path) to see whether its file is there",
18801975 )
@@ -1922,6 +2017,9 @@ fn export_status(srv: &mut Server, args: &Value) -> Reply {
19222017 if args.get("job").is_none() {
19232018 let unfinished = srv.jobs.len() - finished_total;
19242019 lines.push(format!("exports: {unfinished} unfinished, {finished_total} finished"));
2020+ if srv.queue_paused {
2021+ lines.push("queue paused: queued exports wait until export_queue {action:\"start\"}".to_string());
2022+ }
19252023 }
19262024 for i in ids {
19272025 let job = &srv.jobs[i];
@@ -1977,6 +2075,7 @@ fn export_status(srv: &mut Server, args: &Value) -> Reply {
19772075 let eta_text = eta.map_or_else(|| "unknown".to_string(), clock_secs);
19782076 let ahead = srv.jobs[..i].iter().filter(|j| j.outcome.is_none()).count();
19792077 let line = match job.stage() {
2078+ _ if job.waiting() && srv.queue_paused => format!("job:{n} waiting (queue paused) · {ahead} export{} ahead → {out}", if ahead == 1 { "" } else { "s" }),
19802079 _ if job.waiting() => format!("job:{n} waiting · {ahead} export{} ahead → {out}", if ahead == 1 { "" } else { "s" }),
19812080 // A stage before the encode has its own percent; the encode's ETA
19822081 // means nothing yet.
@@ -2036,7 +2135,7 @@ fn export_status(srv: &mut Server, args: &Value) -> Reply {
20362135 if lines.is_empty() {
20372136 lines.push("no exports to show".to_string());
20382137 }
2039- Reply::ok(lines.join("\n")).with(json!({ "jobs": rows, "finished": finished_total }))
2138+ Reply::ok(lines.join("\n")).with(json!({ "jobs": rows, "finished": finished_total, "queue_paused": srv.queue_paused }))
20402139 }
20412140
20422141 /// The true-peak ceiling the advice names: -2 dBTP for a lossy file, whose encoder can add about a
@@ -3155,6 +3254,18 @@ mod tests {
31553254 }
31563255 }
31573256
3257+ /// Pause sets the flag and status says so; start lifts it, with nothing waiting to start.
3258+ #[test]
3259+ fn queue_pause_and_start_set_the_flag_and_say_so() {
3260+ let mut srv = Server::new();
3261+ let paused = export_queue(&mut srv, &json!({"action": "pause"}));
3262+ assert!(!paused.is_error && srv.queue_paused, "{}", paused.text);
3263+ let status = export_queue(&mut srv, &json!({"action": "status"}));
3264+ assert!(status.text.contains("queue paused") && status.text.contains("queued: none"), "{}", status.text);
3265+ let started = export_queue(&mut srv, &json!({"action": "start"}));
3266+ assert!(!srv.queue_paused && started.text.contains("nothing is waiting"), "{}", started.text);
3267+ }
3268+
31583269 /// A waiting job cancelled by number never starts and writes nothing; the queue moves past it.
31593270 #[test]
31603271 fn a_waiting_job_can_be_cancelled_and_never_starts() {