From 367928e4fda2728cb00f02d847d01272aa2344f8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:48:46 +0700 Subject: [PATCH 1/9] refactor(gui): extract immutable native FX rack and slot power readback presentation --- web/approved-fx-rack-view-model.js | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 web/approved-fx-rack-view-model.js 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}); +}); From 3764644fa554da37073aa79769a38d8af904f309 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:49:24 +0700 Subject: [PATCH 2/9] refactor(gui): consume one pure FX power selector; keep only DOM adapter in native bridge --- web/approved-native-bridge.js | 87 +++++++++++++---------------------- 1 file changed, 33 insertions(+), 54 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index eb871b9d6..652d01a86 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,45 @@ // 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.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; } From d47cc000418ebbcda1c4f30631385dba27dcef27 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:49:42 +0700 Subject: [PATCH 3/9] build(gui): bundle FX Rack ViewModel before native bridge in the single approved /preview/ --- scripts/build_approved_native_gui.py | 3 +++ 1 file changed, 3 insertions(+) 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())] From 3c75b49412074b21ff0dc12a634726c8bf4f0a4c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:50:06 +0700 Subject: [PATCH 4/9] test(gui): supply actual FX Rack ViewModel to existing native bridge regression harnesses --- tests/approved_native_m2_contract.test.cjs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 4b4661048..d1a2b5677 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -6,6 +6,7 @@ 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)); @@ -1249,7 +1250,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 +1474,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 +1652,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 +1739,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);}}; From 1c8445eafc5734f2c10388421002c6a2f38fe7f4 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:50:10 +0700 Subject: [PATCH 5/9] test(gui): supply actual FX Rack ViewModel to existing native bridge regression harnesses --- tests/live_fader_held_drag.test.cjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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;} }; From 6bf8ae694476849900877bdec7b2f164c31345d3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:50:52 +0700 Subject: [PATCH 6/9] test(gui): validate FX rack global/slot bypass readback, exact instance matching and missing-value rejection --- tests/approved_native_m2_contract.test.cjs | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index d1a2b5677..4b07b28c6 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -10,6 +10,70 @@ 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"; From cda81680e84d5776f30542de2d06cd7a96d53746 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:51:09 +0700 Subject: [PATCH 7/9] test(gui): verify FX Rack ViewModel bundle order and exact public preview parity --- tests/approved_native_gui_bundle_test.py | 6 ++++++ 1 file changed, 6 insertions(+) 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) From f35776250ac026e8925e7924b76930c2cf5aab1e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:51:29 +0700 Subject: [PATCH 8/9] test(gui): require FX Rack ViewModel in real assembled native cold-start Chromium --- tests/approved_native_cold_start_smoke.py | 1 + 1 file changed, 1 insertion(+) 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') From 1b3d1241faf9cc1bae6f56f12e5e604224dbe0b7 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 18 Nov 2026 09:52:19 +0700 Subject: [PATCH 9/9] fix(gui): reject noncanonical FX slot dataset before touching mounted instance controls --- web/approved-native-bridge.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 652d01a86..371e6dfd2 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -605,7 +605,8 @@ rows=[...rack.querySelectorAll('.fxslot-row:not(.is-empty)')]; const mounted=rows.map(row=>({ index:Number(row.dataset.slot),insertId:row.dataset.insertId, - hasPower:!!row.querySelector('[data-action="slotPower"]') + 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