diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py
index 08dc37a85..d1d9e19e2 100644
--- a/scripts/build_approved_native_gui.py
+++ b/scripts/build_approved_native_gui.py
@@ -24,6 +24,7 @@
ADAPTER_MARKER = ('\n'
'\n'
'\n'
+ '\n'
'\n'
'\n'
'\n')
@@ -365,6 +366,8 @@ def stage(out: Path) -> dict:
out / "assets" / "approved-device-view-model.js")
shutil.copy2(ROOT / "web" / "approved-channel-strip-view-model.js",
out / "assets" / "approved-channel-strip-view-model.js")
+ shutil.copy2(ROOT / "web" / "approved-fx-rack-view-model.js",
+ out / "assets" / "approved-fx-rack-view-model.js")
native = native_html(approved.decode("utf-8")).encode("utf-8")
(out / "index.html").write_bytes(native)
files = [out / "index.html", *sorted(p for p in (out / "assets").rglob("*") if p.is_file())]
diff --git a/tests/approved_native_cold_start_smoke.py b/tests/approved_native_cold_start_smoke.py
index 0ac252381..ba2cf12c3 100644
--- a/tests/approved_native_cold_start_smoke.py
+++ b/tests/approved_native_cold_start_smoke.py
@@ -76,6 +76,7 @@ def main():
page.locator('.command-bar [data-native-io]').click()
assert page.evaluate("""()=>Boolean(
window.ArSonApprovedChannelStripViewModel &&
+ window.ArSonApprovedFxRackViewModel &&
window.__ARMIX_NATIVE_M2__?.inputChoices &&
window.__ARMIX_NATIVE_M2__?.outputChoices)"""), (
'native assembled GUI missing GUI-1 Channel Strip ViewModel')
diff --git a/tests/approved_native_gui_bundle_test.py b/tests/approved_native_gui_bundle_test.py
index 0f425100e..1604a9468 100644
--- a/tests/approved_native_gui_bundle_test.py
+++ b/tests/approved_native_gui_bundle_test.py
@@ -67,11 +67,17 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self)
self.assertLess(native.index('assets/approved-device-view-model.js'),
native.index('assets/approved-channel-strip-view-model.js'))
self.assertLess(native.index('assets/approved-channel-strip-view-model.js'),
+ native.index('assets/approved-fx-rack-view-model.js'))
+ self.assertLess(native.index('assets/approved-fx-rack-view-model.js'),
native.index('assets/approved-native-bridge.js'))
self.assertNotIn('assets/approved-channel-strip-view-model.js', approved)
+ self.assertNotIn('assets/approved-fx-rack-view-model.js', approved)
self.assertEqual(
(out / 'assets/approved-channel-strip-view-model.js').read_bytes(),
(ROOT / 'web/approved-channel-strip-view-model.js').read_bytes())
+ self.assertEqual(
+ (out / 'assets/approved-fx-rack-view-model.js').read_bytes(),
+ (ROOT / 'web/approved-fx-rack-view-model.js').read_bytes())
vm_source = (ROOT / "web/approved-device-view-model.js").read_bytes()
self.assertEqual((out / "assets/approved-device-view-model.js").read_bytes(),
vm_source)
diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs
index 4b4661048..4b07b28c6 100644
--- a/tests/approved_native_m2_contract.test.cjs
+++ b/tests/approved_native_m2_contract.test.cjs
@@ -6,9 +6,74 @@ const {readFileSync}=require("node:fs");
const protocol=require("../web/approved-native-contract.js");
const deviceVM=require("../web/approved-device-view-model.js");
const stripVM=require("../web/approved-channel-strip-view-model.js");
+const fxRackVM=require("../web/approved-fx-rack-view-model.js");
const read=p=>readFileSync(p,"utf8");
const fixtures=JSON.parse(read("integration/console-v6/fixtures.json"));
const clone=x=>JSON.parse(JSON.stringify(x));
+
+test("GUI-2 pure FX power readback preserves independent rack/slot/global states and labels",()=>{
+ const channel={id:"9007199254740993",fxRackBypassed:false,inserts:[
+ {id:"instance-1",bypassed:false,latencySamples:96},
+ {id:"instance-2",bypassed:true,latencyChanged:true}
+ ]};
+ const original=JSON.stringify(channel);
+ const normal=fxRackVM.powerReadback(channel,false,"Vocal");
+ assert.equal(normal.enabled,true);
+ assert.equal(normal.globalEnabled,true);
+ assert.equal(normal.chainBypassed,false);
+ assert.equal(normal.headerPressed,"true");
+ assert.equal(normal.slots[0].effective,true);
+ assert.equal(normal.slots[1].effective,false);
+ assert.equal(normal.slots[0].latencyTitle,"Plugin delay: 96 samples · compensated");
+ assert.match(normal.slots[1].latencyTitle,/Plugin delay changed/);
+ assert.equal(normal.slots[0].label,"Bypass only FX insert 1 in Vocal");
+ assert.equal(normal.slots[1].title,"Enable only insert 2");
+ const rackOff=fxRackVM.powerReadback({...channel,fxRackBypassed:true},false,"Vocal");
+ assert.equal(rackOff.enabled,false);
+ assert.equal(rackOff.slots[0].bypassed,false,
+ "rack bypass must never become an insert bypass");
+ assert.equal(rackOff.slots[0].effective,false);
+ const globalOff=fxRackVM.powerReadback(channel,true,"Vocal");
+ assert.equal(globalOff.globalEnabled,false);
+ assert.equal(globalOff.slots[0].effective,false);
+ assert.equal(globalOff.slots[0].bypassed,false);
+ assert.equal(globalOff.headerPressed,"false");
+ assert.equal(JSON.stringify(channel),original,"projection cannot mutate native graph");
+
+ // Missing/incomplete readback, including wrong type, is NOT a default ON.
+ assert.equal(fxRackVM.powerReadback({},false,"Vocal"),null);
+ assert.equal(fxRackVM.powerReadback(channel,undefined,"Vocal"),null);
+ assert.equal(fxRackVM.powerReadback({...channel,
+ inserts:[{id:"instance-1",bypassed:"false"}]},false,"Vocal"),null);
+ assert.equal(fxRackVM.powerReadback({...channel,
+ inserts:[{id:"",bypassed:false}]},false,"Vocal"),null);
+});
+test("GUI-2 exact mounted FX instance/power identity rejects stale, duplicate or missing rows",()=>{
+ const data=fxRackVM.powerReadback({fxRackBypassed:false,inserts:[
+ {id:"instance-1",bypassed:false},
+ {id:"instance-2",bypassed:true}
+ ]},false,"Vocal");
+ const good=[
+ {index:0,insertId:"instance-1",hasPower:true},
+ {index:1,insertId:"instance-2",hasPower:true}
+ ];
+ assert.equal(fxRackVM.mountedRackMatches(data,good,true),true);
+ assert.equal(fxRackVM.mountedRackMatches(data,[good[1],good[0]],true),true,
+ "DOM row order is not allowed to substitute native slot identity");
+ assert.equal(fxRackVM.mountedRackMatches(data,good,false),false);
+ assert.equal(fxRackVM.mountedRackMatches(data,good.slice(0,1),true),false);
+ assert.equal(fxRackVM.mountedRackMatches(data,[good[0],good[0]],true),false);
+ assert.equal(fxRackVM.mountedRackMatches(data,[good[0],
+ {...good[1],insertId:"new-plugin"}],true),false);
+ assert.equal(fxRackVM.mountedRackMatches(data,[good[0],
+ {...good[1],hasPower:false}],true),false);
+ assert.equal(fxRackVM.mountedRackMatches(data,null,true),false);
+ const bridge=read("web/approved-native-bridge.js");
+ assert.match(bridge,/fxRackVM\.powerReadback\(/);
+ assert.match(bridge,/fxRackVM\.mountedRackMatches\(/);
+ assert.doesNotMatch(bridge,/const effective=enabled&&globalEnabled&&!insert\.bypassed/,
+ "old duplicated FX bypass projection must be removed from DOM bridge");
+});
function acceptedFixture(){
const s=clone(fixtures.g0);
s.device.epoch="18446744073709551610";
@@ -1249,7 +1314,7 @@ test("M3 native-only Pages scope performs real bridge projection, fader intent a
querySelector:()=>null,addEventListener(){}
};
const window={
- __JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,
+ __JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},queueMicrotask(fn){microtasks.push(fn);},setTimeout(fn,ms){timers.push({fn,ms});return timers.length;}
};
vm.runInNewContext(read("web/approved-native-bridge.js"),{
@@ -1473,7 +1538,7 @@ test("P0 native FX rack and per-slot readback update mounted strip without repla
querySelector:selector=>selector.startsWith('.strip[data-id=')?strip:null,
addEventListener(){}
};
- const win={__JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,
+ const win={__JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(){return 0},clearTimeout(){},queueMicrotask(fn){fn();}};
vm.runInNewContext(read("web/approved-native-bridge.js"),
@@ -1651,7 +1716,7 @@ test("P0 FIRST SOUND G0 offers verified input and leaves automatic MAIN to nativ
addEventListener(){}
};
win={
- __JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,
+ __JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(){return 0},clearTimeout(){},queueMicrotask(fn){fn();}
};
@@ -1738,7 +1803,7 @@ test("P0 native hardware IN remains selectable after ChannelId ownership, failed
id==="preview"?{disabled:true}:null,
querySelector:()=>null,addEventListener(){}
};
- const win={__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,
+ const win={__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(){return 0},clearTimeout(){},
queueMicrotask(fn){microtasks.push(fn);}};
diff --git a/tests/live_fader_held_drag.test.cjs b/tests/live_fader_held_drag.test.cjs
index 93f5ea605..4158147f1 100644
--- a/tests/live_fader_held_drag.test.cjs
+++ b/tests/live_fader_held_drag.test.cjs
@@ -8,6 +8,7 @@ const vm=require("node:vm");
const protocol=require("../web/approved-native-contract.js");
const deviceVM=require("../web/approved-device-view-model.js");
const stripVM=require("../web/approved-channel-strip-view-model.js");
+const fxRackVM=require("../web/approved-fx-rack-view-model.js");
const read=p=>readFileSync(p,"utf8");
const clone=x=>JSON.parse(JSON.stringify(x));
const fixture=JSON.parse(read("integration/console-v6/fixtures.json")).g0;
@@ -78,7 +79,7 @@ function harness({m4=false}={}){
};
const window={
__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,
- ArSonApprovedChannelStripViewModel:stripVM,
+ ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(fn,delay=0){timers.push({fn,at:now+Math.max(0,Number(delay)||0)});return timers.length;}
};
diff --git a/web/approved-fx-rack-view-model.js b/web/approved-fx-rack-view-model.js
new file mode 100644
index 000000000..0b73ef511
--- /dev/null
+++ b/web/approved-fx-rack-view-model.js
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// GUI-2: pure FX Rack readback projection for the ONE approved /preview/ GUI.
+// No DOM, timer, native dispatch, plugin lifecycle or accepted audio authority.
+// Only the already-validated native snapshot may supply these values.
+(function (root, factory) {
+ const api=factory();
+ if(typeof module==="object"&&module.exports)module.exports=api;
+ if(root)root.ArSonApprovedFxRackViewModel=api;
+})(typeof globalThis==="object"?globalThis:undefined,function () {
+ "use strict";
+
+ // null means missing or incomplete readback, never a guess based on CSS or
+ // an optimistic click. Channel-local, global and insert bypass are distinct.
+ function powerReadback(channel,globalFxBypassed,channelName) {
+ if(typeof channel?.fxRackBypassed!=="boolean" ||
+ !Array.isArray(channel.inserts) ||
+ typeof globalFxBypassed!=="boolean")return null;
+ const enabled=!channel.fxRackBypassed,globalEnabled=!globalFxBypassed;
+ const name=String(channelName??"");
+ const slots=[];
+ for(let index=0;index{
+ const mounted=byIndex.get(slot.index);
+ return mounted?.insertId===slot.insertId && mounted?.hasPower===true;
+ });
+ }
+
+ return Object.freeze({powerReadback,mountedRackMatches});
+});
diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js
index eb871b9d6..371e6dfd2 100644
--- a/web/approved-native-bridge.js
+++ b/web/approved-native-bridge.js
@@ -6,11 +6,12 @@
const protocol = window.ArSonApprovedNativeContract;
const deviceVM = window.ArSonApprovedDeviceViewModel;
const stripVM = window.ArSonApprovedChannelStripViewModel;
+ const fxRackVM = window.ArSonApprovedFxRackViewModel;
// The public GUI owns one lexical model. Native-only bundle exports a narrow
// reference to that SAME model; never reconstruct a parallel DOM/DSP.
const scope = window.__ARMIX_NATIVE_SCOPE__ || null;
const connected = Boolean(backend?.emitEvent && backend?.addEventListener &&
- protocol && deviceVM && stripVM);
+ protocol && deviceVM && stripVM && fxRackVM);
// Public browser preview keeps its header; the native JUCE caption replaces it.
if (backend?.emitEvent && backend?.addEventListener)
document.documentElement?.classList?.add?.("armix-native-desktop");
@@ -591,67 +592,46 @@
// steal focus, interrupt a fader drag or reallocate WIRE render objects.
// The verified individual bypass flag stays distinct from rack bypass.
function paintNativeFxPowerReadback(ch,t,globalFxBypassed){
- if(typeof ch.fxRackBypassed!=="boolean"||!Array.isArray(ch.inserts)||
- typeof globalFxBypassed!=="boolean")
- return true; // never synthesize missing DSP readback
- const enabled=!ch.fxRackBypassed;
- // Read the SAME accepted native PCM snapshot as every slot, not a
- // CSS class from the PREVIOUS browser render frame.
- const globalEnabled=!globalFxBypassed;
+ const readback=fxRackVM.powerReadback(ch,globalFxBypassed,t.name);
+ if(!readback)return true; // no authoritative DSP value to paint
const strip=document.querySelector('.strip[data-id="'+t.id+'"]');
- // GAIN/SOF are alternate views of the FX area; power readback still
- // updates the model but must not rebuild the rack or steal knob focus.
+ // GAIN/SOF can hide the rack without losing its accepted power model.
const rackArea=strip?.querySelector(".fx-section");
const rack=rackArea?.classList?.contains?.("is-gain-view") ||
rackArea?.classList?.contains?.("is-sof-view")?null:rackArea;
- // Virtualized mobile banks may have no mounted strip. The model still
- // receives verified state; normal bank render creates the right buttons.
+ let header=null,rows=[];
if(rack){
- const header=rack.querySelector('[data-action="fxOn"]');
- const rows=[...rack.querySelectorAll('.fxslot-row:not(.is-empty)')];
- if(!header||rows.length!==ch.inserts.length)return false;
- for(let slot=0;slot
- r.dataset.slot===String(slot));
- if(!insert||typeof insert.bypassed!=="boolean"||
- !row||row.dataset.insertId!==insert.id||
- !row.querySelector('[data-action="slotPower"]'))
- return false; // structural re-render, never modify wrong FX owner
- }
+ header=rack.querySelector('[data-action="fxOn"]');
+ rows=[...rack.querySelectorAll('.fxslot-row:not(.is-empty)')];
+ const mounted=rows.map(row=>({
+ index:Number(row.dataset.slot),insertId:row.dataset.insertId,
+ hasPower:row.dataset.slot===String(Number(row.dataset.slot)) &&
+ !!row.querySelector('[data-action="slotPower"]')
+ }));
+ if(!fxRackVM.mountedRackMatches(readback,mounted,!!header))
+ return false; // existing graph projection repairs replaced FX instance
}
- t.fxOn=enabled;
+ t.fxOn=readback.enabled;
if(!Array.isArray(t.slotBypass))t.slotBypass=Array(8).fill(false);
- for(let slot=0;slotr.dataset.slot===String(slot));
- const effective=enabled&&globalEnabled&&!insert.bypassed;
- if(insert.latencyChanged===true)
- row.title="Plugin delay changed · aligned dry signal retained; reload the plugin before using its new delay";
- else if(Number.isInteger(insert.latencySamples))
- row.title="Plugin delay: "+insert.latencySamples+" samples · compensated";
- row.dataset.fxSlotEnabled=String(!insert.bypassed);
- row.dataset.fxEffective=String(effective);
- row.classList.toggle("is-active",effective);
- row.classList.toggle("is-bypassed",!effective);
+ for(const slot of readback.slots)t.slotBypass[slot.index]=slot.bypassed;
+ if(!rack)return true; // virtual bank: native snapshot still owns model
+ rack.dataset.fxChainEnabled=String(readback.enabled);
+ rack.dataset.globalFxEnabled=String(readback.globalEnabled);
+ rack.classList.toggle("is-chain-bypassed",readback.chainBypassed);
+ header.setAttribute("aria-pressed",readback.headerPressed);
+ header.title=readback.headerTitle;
+ header.setAttribute("aria-label",readback.headerLabel);
+ for(const slot of readback.slots){
+ const row=rows.find(r=>r.dataset.slot===String(slot.index));
+ if(slot.latencyTitle!==null)row.title=slot.latencyTitle;
+ row.dataset.fxSlotEnabled=String(!slot.bypassed);
+ row.dataset.fxEffective=String(slot.effective);
+ row.classList.toggle("is-active",slot.effective);
+ row.classList.toggle("is-bypassed",!slot.effective);
const button=row.querySelector('[data-action="slotPower"]');
- button.setAttribute("aria-pressed",String(effective));
- button.title=(insert.bypassed?"Enable":"Bypass")+
- " only insert "+(slot+1);
- button.setAttribute("aria-label",
- (insert.bypassed?"Enable":"Bypass")+" only FX insert "+
- (slot+1)+" in "+t.name);
+ button.setAttribute("aria-pressed",slot.pressed);
+ button.title=slot.title;
+ button.setAttribute("aria-label",slot.label);
}
return true;
}