From 6a004bf610feba45d3efc0b166d81963066b4238 Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Wed, 21 Oct 2026 17:31:17 -0400 Subject: [PATCH] Engine: stopping Record Actions waits while a macro in its workbook is being debugged Stopping Record Actions saves a script into the workbook, which the debugger lock refuses while a macro there is paused. The refusal came after Record Actions had taken its recording, so the recording was lost. Stopping is now refused before anything changes, and stopping again after the run saves the script. --- crates/engine/src/lib.rs | 6 +++++- crates/engine/src/macros/debug.rs | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 6807d1cce..242c86b97 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -415,7 +415,11 @@ impl Session { // touched wait, also when another command runs them (a script, or a recording that stops // and saves). Only the run's own steps go ahead. Other workbooks stay editable. let locked = self.active().is_some_and(|d| self.macro_debug.as_ref().is_some_and(|m| m.locks(d.uid) && !m.stepping())); - if spec.undoable && id != "macro.debug" && locked { + // Stopping Record Actions saves a script into the workbook; refuse it before it takes the + // recording, so stopping again after the run keeps what was recorded. + let stops_record_actions = + id == "automate.recordActions" && (params.get("stop").and_then(Json::as_bool) == Some(true) || self.recording.is_some()); + if (spec.undoable || stops_record_actions) && id != "macro.debug" && locked { return Err(EngineError::Disabled(id.to_string(), macros::debug::BUSY.into())); } let before = self.active().map(|d| (d.uid, d.wb.clone(), d.selection.clone())); diff --git a/crates/engine/src/macros/debug.rs b/crates/engine/src/macros/debug.rs index b1e53cf9b..8c5b7e201 100644 --- a/crates/engine/src/macros/debug.rs +++ b/crates/engine/src/macros/debug.rs @@ -468,5 +468,10 @@ mod tests { let r = s.execute("macro.debug", json!({"action": "step"})).unwrap(); assert_eq!(r["executed"], 2, "{r}"); assert!(s.macro_debug.is_none()); + // The recording was kept: stopping now saves it. + let saved = s.execute("automate.recordActions", json!({"stop": true, "name": "S"})).unwrap(); + assert_eq!(saved["saved"], "S", "{saved}"); + let scripts = s.execute("automate.allScripts", json!({})).unwrap(); + assert_eq!(scripts[0]["name"], "S", "{scripts}"); } }