diff --git a/src/Main.cpp b/src/Main.cpp index a759c09d3..815982a11 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -946,7 +946,22 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr action.startsWith ("import") || action.startsWith ("fx") || action == "addCatalog" || action == "addScanFolder" || action == "scanVst3" || action == "routingDryApply")) - return emitNotice ("Studio backup in progress. Finish backup before editing saved FX or VST library.", true); + { + const auto reason = juce::String ( + "Studio backup in progress. Finish backup before editing saved FX or VST library."); + // Routing APPLY is an acknowledged transaction. An early IO-busy + // rejection must answer once; it must not mutate the current graph. + if (action == "routingDryApply" && browser_.loaded) + { + auto ack = std::make_unique(); + ack->setProperty ("ok", false); + ack->setProperty ("error", reason); + ack->setProperty ("state", engine_.status().getProperty ("dryRoutingLab", {})); + browser_.emitEventIfBrowserIsVisible ("arMixRoutingLabAck", + juce::var (ack.release())); + } + return emitNotice (reason, true); + } // Structural plugin operations currently detach the original callback // and must never mutate a running independent render thread. diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs index d094a8550..8d59c519b 100644 --- a/tests/live_routing_ui_contract_test.mjs +++ b/tests/live_routing_ui_contract_test.mjs @@ -205,3 +205,22 @@ test("R0 premium workspace is anchored to mixer chrome and lazily opens INTERNAL assert.match(ui,/routingDryApply/); assert.match(ui,/hydrateAcceptedRoute/); }); + +test("R1 Studio backup rejection sends one negative native ACK and leaves graph untouched",()=>{ + const first=main.indexOf('if ((studioBackupBusy_ || nativeShowBusy_)'); + const next=main.indexOf('// Structural plugin operations',first); + assert.ok(first>=0 && next>first); + const gate=main.slice(first,next); + assert.match(gate,/action == "routingDryApply"/); + assert.match(gate,/setProperty \("ok", false\)/); + assert.match(gate,/setProperty \("state", engine_\.status\(\)\.getProperty/); + assert.match(gate,/arMixRoutingLabAck/); + assert.ok(gate.indexOf("arMixRoutingLabAck") < gate.indexOf("return emitNotice")); + assert.doesNotMatch(gate,/enableDryRoutingLab|applyDryRoutingLab|disableDryRoutingLab/); + assert.match(ui,/if\(patchPending\)return/); + const apply=ui.slice(ui.indexOf('document.getElementById("arRouteApply").addEventListener')); + assert.ok(apply.indexOf("patchPreflight()"){ + const d=window.__arPatchStatus.dryRoutingLab; + window.__arMixMockEvents.arMixRoutingLabAck({ + ok:false,error:"Studio backup in progress",state:d + }); + }""") + assert await native.locator("#arRouteApply").is_enabled() + assert "REJECTED" in await native.locator("#arRouteFeedback").inner_text() + assert await native.locator('[data-patch-row="0"][data-patch-port="2"].arPatchCell').get_attribute("data-patch-state")=="draft" + await native.locator("#arRouteApply").click() + assert await native.locator("#arRouteApply").is_disabled() + assert await native.evaluate("""()=>window.__arMixSent.filter( + x=>x.payload?.action==='routingDryApply').length""")==2 await native.evaluate("""()=>{ const d=window.__arPatchStatus.dryRoutingLab; d.active=true;d.ready=true;d.revision=1; diff --git a/web/monitor.js b/web/monitor.js index 56a905668..01146ae87 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -579,18 +579,11 @@ if(failure){patchFeedback("REJECTED · "+failure);return;} if(state.monitor){patchFeedback("MUTE OUTPUT FIRST · structural routing cannot be applied while speakers are armed.");return;} syncNativeLevelsToRouteDraft(); + // patchPreflight checked the native epoch and real enabled ports, and + // output-MUTE was checked above. Only now disable APPLY awaiting its ACK. patchPending=true; renderPatchMatrix(); - if(!draftEpoch || draftEpoch!==Number(d.epoch)){ - document.getElementById("arRouteFeedback").textContent= - "DEVICE CHANGED · old channel assignments discarded. Re-select the actual physical inputs."; - drawRoutes(); - return; // must never submit old ports with a newly observed epoch - } - if(!Array.isArray(d.ports)||!d.ports.length){ - document.getElementById("arRouteFeedback").textContent="Select a real ASIO/WASAPI audio input in AUDIO SETUP first.";return; - } - document.getElementById("arRouteFeedback").textContent="Applying native route (output must be MUTED)..."; + document.getElementById("arRouteFeedback").textContent="Applying verified native route (output remains MUTED)..."; api.emitEvent("arMixAction",{action:"routingDryApply",value:{ deviceEpoch:draftEpoch,revision:Number(d.revision)||0, channels:draftRoutes.map(c=>({...c})),