diff --git a/src/Main.cpp b/src/Main.cpp index ae5389f88..90e6965a2 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -6284,6 +6284,9 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr ack->setProperty("ok",opened); ack->setProperty("error",error); ack->setProperty("instanceId",token); + // G-MV36: correlate the HWND result to its exact GUI click. + // The requestId is feedback only; it is not installed PCM proof. + ack->setProperty("requestId",args.getProperty("requestId",juce::var())); if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( "arMixRoutingFxEditorAck",juce::var(ack.release())); if(opened)diagnostics_.record("ROUTED_FX_EDITOR_OPENED", diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 0b9ee5e82..64796f3dc 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -2193,7 +2193,8 @@ test("P0 real slot VST3 power and native editor use verified instance tokens",() assert.match(bridge,/requestAdmittedFxPower\(t,action,btn\)/); assert.match(bridge,/FX rack unchanged/); assert.match(bridge,/pendingM4RackPowers/); - assert.match(bridge,/action:"routingFxEditor"/); + assert.match(read("web/approved-fx-rack-view-model.js"),/action:"routingFxEditor"/); + assert.match(bridge,/dispatchPhysicalFxEditor\(plan,lease,"M4"\)/); assert.match(bridge,/action:plan\.action,requestId,\.\.\.plan\.payload/); assert.match(read("web/approved-fx-rack-view-model.js"), /action:"routingFxBypass"/); @@ -3617,9 +3618,14 @@ test("ImmerSIB opens the exact native ChannelId HWND, survives VST3 editor, no s const editorVM=read("web/approved-fx-rack-view-model.js"); assert.match(bridge,/fxRackVM\.editorNavigationPlan\(current,/); assert.match(editorVM,/view\.raw\?\.mixerSession\?\.authority==="CHANNEL_ID"/); - assert.match(bridge,/else \{\s*\/\/ Both vendor VST3 and ImmerSIB retain their exact real/); - assert.match(bridge,/backend\.emitEvent\("arMixAction",\{action:"routingFxEditor",\s*channelId:editor\.channelId,slot:editor\.slot,/); - assert.match(bridge,/else if\(editor\.authority==="LOGICAL"\)/); + assert.match(bridge,/fxRackVM\.editorSurfacePlan\(current,editor,/); + assert.match(bridge,/surface\.kind==="NATIVE_HOST"/); + assert.match(editorVM,/if\(lease\.authority==="CHANNEL_ID"\)return \{kind:"NATIVE_HOST"\};/); + assert.match(bridge,/openChannelIdFxEditor\(editor\)/); + assert.match(bridge,/fxRackVM\.nativeEditorDispatchPlan\(current,lease,/); + assert.match(bridge,/dispatchPhysicalFxEditor\(plan,lease,"CHANNEL_ID"\)/); + assert.match(bridge,/surface\.kind==="LOGICAL_VENDOR"/); + assert.match(editorVM,/if\(lease\.authority==="LOGICAL"\)return \{kind:"LOGICAL_VENDOR"\};/); assert.match(bridge,/action:"logicalVendorFxEditor"/); assert.doesNotMatch(bridge,/else status\("Native VST3 editor opened"\)/); assert.match(host,/shownWindow=dedicatedImmerSIB\?immersibEditorWindow_:editorWindow_/); @@ -4980,7 +4986,9 @@ test("MV-9B bridge uses only accepted native snapshots for global FX, fences M4 "globalPowerSettlement","m4SlotPowerAckResult","m4SlotPowerSettlement"]) assert.match(bridge,new RegExp("fxRackVM\\."+name+"\\(")); assert.match(bridge,/const current=controller\?\.state\(\)\?\.current;\s*const button=document\.getElementById\?\.\("globalFxToggle"\)/); - assert.match(bridge,/onAccepted:\(next,confirmed\)=>\{\s*onNativeReadback\(next,confirmed\);\s*syncGlobalFxReadback\(\);/); + assert.match(bridge,/onAccepted:\(next,confirmed\)=>\{\s*onNativeReadback\(next,confirmed\);/); + assert.match(bridge,/fxRackVM\.nativeEditorAckResult\(pendingFxEditorAck,null,accepted,/); + assert.match(bridge,/pendingFxEditorAck=null;\s*syncGlobalFxReadback\(\);/); assert.match(bridge,/const apply=\(\)=>controller\.onSnapshot\(snapshot\);/); assert.doesNotMatch(bridge,/controller\.onSnapshot\(snapshot\);syncGlobalFxReadback/); assert.doesNotMatch(bridge,/const actual=snapshot\?\.globalFxBypassed;/); @@ -6399,6 +6407,144 @@ test("G-MV35 native MOVE/REMOVE FX demands installed ChannelId hardware owner",( assert.doesNotMatch(pure,/backend\.emitEvent|document\.|window\.|setTimeout/); }); +test("G-MV36 ChannelId vendor FX editor dispatch retains exactly one physical instance lease",()=>{ + const channelId="9007199254740993",epoch="31",revision="45",rosterRevision="18"; + const device={epoch,sampleRate:48000,bufferFrames:256, + enabledInputs:[0,1],enabledOutputs:[0,1]}; + const hardwareConfiguration=protocol.nativeHardwareConfiguration(device); + const snap={admitted:true,retained:false,device,raw:{ + mixerSession:{authority:"CHANNEL_ID",deviceEpoch:epoch}},graph:{ + revision,rosterRevision,capabilities:{callbackOwnsChannelIds:true}, + channels:[{id:channelId,role:"INPUT",inserts:[ + {id:"vst3-instance",catalogId:"vendor.alpha",bypassed:false}]}] + }}; + const original=JSON.stringify(snap); + const navigation=fxRackVM.editorNavigationPlan(snap,{ + channelId,slot:0,hardwareConfiguration}); + assert.equal(navigation.kind,"OPEN"); + assert.equal(navigation.lease.authority,"CHANNEL_ID"); + const plan=(snapshot=snap,lease=navigation.lease,hw=hardwareConfiguration)=> + fxRackVM.nativeEditorDispatchPlan(snapshot,lease,{hardwareConfiguration:hw}); + assert.deepEqual(plan(),{kind:"READY",action:"routingFxEditor",payload:{ + channelId,slot:0,instanceId:"vst3-instance",deviceEpoch:epoch,revision}}); + assert.equal(Object.isFrozen(navigation.lease),true); + for(const bad of [null,{}, {...navigation.lease,authority:"LOGICAL"}, + {...navigation.lease,workspaceToken:"other"}, {...navigation.lease,slot:1}]) + assert.equal(plan(snap,bad).kind,"UNAVAILABLE"); + for(const mutate of [ + s=>{s.device.epoch="32";},s=>{s.device.enabledInputs=[2,3];}, + s=>{s.raw.mixerSession.authority="M4";}, + s=>{s.raw.mixerSession.deviceEpoch="32";}, + s=>{s.admitted=false;},s=>{s.retained=true;}, + s=>{s.graph.revision="46";},s=>{s.graph.rosterRevision="19";}, + s=>{s.graph.capabilities.callbackOwnsChannelIds=false;}, + s=>{s.graph.channels[0].inserts[0].id="replacement";}, + s=>{s.graph.channels[0].inserts[0].catalogId="vendor.beta";}, + s=>{s.graph.channels[0].inserts=[];} + ]){ + const next=clone(snap);mutate(next); + assert.equal(plan(next,navigation.lease, + protocol.nativeHardwareConfiguration(next.device)).kind,"UNAVAILABLE"); + } + assert.equal(plan(snap,navigation.lease,"wrong-device").kind,"UNAVAILABLE"); + assert.equal(fxRackVM.nativeEditorDispatchPlan(snap,navigation.lease,{ + hardwareConfiguration,offline:true}).kind,"UNAVAILABLE"); + assert.equal(JSON.stringify(snap),original,"pure editor plan never writes PCM"); +}); +test("G-MV36 correlated FX HWND ACK guards request, device, roster, and plugin instance",()=>{ + const channelId="9007199254740993",epoch="51",revision="46"; + const device={epoch,sampleRate:48000,bufferFrames:256, + enabledInputs:[0,1],enabledOutputs:[0,1]}; + const hardwareConfiguration=protocol.nativeHardwareConfiguration(device); + const native={admitted:true,retained:false,device,raw:{ + mixerSession:{authority:"CHANNEL_ID",deviceEpoch:epoch}},graph:{ + revision,rosterRevision:"19",capabilities:{callbackOwnsChannelIds:true}, + channels:[{id:channelId,role:"INPUT",inserts:[ + {id:"native-fx-8",catalogId:"vendor.vst3"}]}] + }}; + const nav=fxRackVM.editorNavigationPlan(native,{ + channelId,slot:0,hardwareConfiguration}); + assert.equal(nav.kind,"OPEN"); + const pending={authority:"CHANNEL_ID",requestId:"fx-editor-7",lease:nav.lease}; + const verdict=(p=pending,ack=null,snapshot=native,hw=hardwareConfiguration)=> + fxRackVM.nativeEditorAckResult(p,ack,snapshot,{ + hardwareConfiguration:hw,verifiedM4:true}); + assert.equal(verdict(null,{requestId:pending.requestId, + instanceId:"native-fx-8",ok:true}),"IGNORE"); + assert.equal(verdict(),"IGNORE"); + assert.equal(verdict(pending,{requestId:"old",instanceId:"native-fx-8", + ok:false}),"IGNORE"); + assert.equal(verdict(pending,{requestId:pending.requestId, + instanceId:"wrong",ok:true}),"REJECTED"); + assert.equal(verdict(pending,{requestId:pending.requestId, + instanceId:"native-fx-8",ok:false}),"REJECTED"); + assert.equal(verdict(pending,{requestId:pending.requestId, + instanceId:"native-fx-8",ok:true}),"ACKED"); + assert.equal(verdict(pending,{instanceId:"native-fx-8",ok:true}),"IGNORE"); + assert.equal(fxRackVM.nativeEditorAckResult(pending,null,native,{ + hardwareConfiguration,offline:true}),"STALE"); + for(const mutate of [ + s=>{s.graph.rosterRevision="20";}, + s=>{s.graph.revision="47";}, + s=>{s.graph.channels[0].inserts[0].id="retired";}, + s=>{s.raw.mixerSession.authority="M4";}, + s=>{s.device.enabledOutputs=[2,3];} + ]){ + const updated=clone(native);mutate(updated); + const hw=protocol.nativeHardwareConfiguration(updated.device); + assert.equal(verdict(pending,null,updated,hw),"STALE"); + assert.equal(verdict(pending,{requestId:pending.requestId, + instanceId:"native-fx-8",ok:true},updated,hw),"STALE"); + } + const m4Device={epoch:"55",sampleRate:48000,bufferFrames:256, + enabledInputs:[0,1],enabledOutputs:[0,1]}; + const m4Hw=protocol.nativeHardwareConfiguration(m4Device); + const m4={admitted:false,retained:false,device:m4Device,raw:{ + mixerSession:{authority:"M4",deviceEpoch:"55",routeRevision:"12", + channels:Array.from({length:10},()=>({role:"INPUT"}))}, + legacyM4:{active:true,routeAccepted:true,nativeBusStructural:false, + routingRevision:"12",fxInstances:Array.from({length:10},()=>[])} + }}; + m4.raw.legacyM4.fxInstances[4][0]={ + instanceId:"m4-fx",catalogId:"vendor.m4",bypassed:false}; + const accepted=fxRackVM.m4EditorDispatchPlan(m4,{ + channel:4,slot:0,instanceId:"m4-fx",deviceEpoch:55,revision:12, + verifiedM4:true,hardwareConfiguration:m4Hw}); + assert.equal(accepted.kind,"READY"); + const m4Pending={requestId:"fx-editor-9",authority:"M4",lease:accepted.lease}; + const m4Result=(p=m4Pending,ack=null,snapshot=m4,hw=m4Hw)=> + fxRackVM.nativeEditorAckResult(p,ack,snapshot,{ + verifiedM4:true,hardwareConfiguration:hw}); + assert.equal(m4Result(),"IGNORE"); + assert.equal(m4Result(m4Pending,{requestId:"fx-editor-7", + instanceId:"m4-fx",ok:true}),"IGNORE"); + assert.equal(m4Result(m4Pending,{requestId:"fx-editor-9", + instanceId:"m4-fx",ok:true}),"ACKED"); + const replacement=clone(m4); + replacement.raw.legacyM4.fxInstances[4][0].catalogId="other"; + assert.equal(m4Result(m4Pending,null,replacement),"STALE"); + assert.equal(m4Result(m4Pending,null,m4,"old-hardware"),"STALE"); + assert.equal(m4Result({...m4Pending,authority:"LOGICAL"}),"STALE"); +}); +test("G-MV36 one correlated native editor transport and JUCE echo, no duplicate toast",()=>{ + const bridge=read("web/approved-native-bridge.js"), + main=read("src/Main.cpp"),viewmodel=read("web/approved-fx-rack-view-model.js"); + assert.match(main,/if \(action == "routingFxEditor"\) \{/); + assert.match(main,/ack->setProperty\("requestId",args\.getProperty\("requestId",juce::var\(\)\)\);/); + assert.match(main,/ack->setProperty\("instanceId",token\);/); + assert.match(bridge,/function dispatchPhysicalFxEditor\(plan,lease,authority\)/); + assert.match(bridge,/backend\.emitEvent\("arMixAction",\{action:plan\.action,requestId,\.\.\.plan\.payload\}\);/); + assert.match(bridge,/dispatchPhysicalFxEditor\(plan,lease,"M4"\)/); + assert.match(bridge,/dispatchPhysicalFxEditor\(plan,lease,"CHANNEL_ID"\)/); + assert.match(bridge,/if\(logicalView\|\|fxRackVM\.nativeEditorDispatchPlan\(current,lease,/); + assert.match(bridge,/pendingFxEditorAck=null; \/\/ expire old native HWND/); + assert.match(bridge,/fxRackVM\.nativeEditorAckResult\(pendingFxEditorAck,ack,accepted,/); + assert.match(bridge,/if\(verdict==="IGNORE"\)return; \/\/ obsolete, duplicate or unrelated ACK/); + assert.match(bridge,/fxRackVM\.nativeEditorAckResult\(pendingFxEditorAck,null,accepted,/); + assert.doesNotMatch(bridge,/if\(ack\?\.ok!==true\)\s*nativeToast\(ack\?\.error\|\|/); + assert.doesNotMatch(viewmodel,/backend\.emitEvent|document\.|window\.|setTimeout/); +}); + test("G-MV37 one physical ChannelId M/ST policy validates exact accepted input",()=>{ const id="9007199254740993",hw="asio|48000|256|0,1|0,1"; const graph={revision:"45",rosterRevision:"8", @@ -6489,3 +6635,69 @@ test("G-MV37 M4 M/ST reuses exact existing routed channel patch",()=>{ assert.match(section,/dispatchM4ChannelPatch\(t,plan\.operation,plan\.target,plan\.channel\)/); assert.doesNotMatch(section,/const target=.*processingFormat|channelFormat===/); }); + +test("G-MV38 editor surface routing has one allowlisted browser owner; future FX remain native",()=>{ + const channelId="9007199254740993",epoch="53"; + const device={epoch,sampleRate:48000,bufferFrames:256, + enabledInputs:[0,1],enabledOutputs:[0,1]}; + const hardwareConfiguration=protocol.nativeHardwareConfiguration(device); + const view={admitted:true,retained:false,device,raw:{ + mixerSession:{authority:"CHANNEL_ID",deviceEpoch:epoch}},graph:{ + revision:"72",rosterRevision:"11", + capabilities:{callbackOwnsChannelIds:true}, + channels:[{id:channelId,role:"INPUT",inserts:[ + {id:"native-fx-instance",catalogId:"vendor.vst3"}]}]}}; + const project=(catalogId,snapshot=view,hw=hardwareConfiguration)=>{ + const fx=snapshot.graph.channels[0].inserts[0]; + fx.catalogId=catalogId; + const nav=fxRackVM.editorNavigationPlan(snapshot,{channelId,slot:0, + hardwareConfiguration:hw}); + assert.equal(nav.kind,"OPEN"); + return {lease:nav.lease,result:fxRackVM.editorSurfacePlan(snapshot,nav.lease, + {hardwareConfiguration:hw})}; + }; + const allowlisted=[ + ["armix.builtin.channel-eq.v1","ArSonMixNativeEq"], + ["armix.builtin.channel-compressor.v1","ArSonMixNativeCompressor"], + ["armix.builtin.arson-harmony.v1","ArSonMixNativeHarmony"], + ["armix.builtin.vocal-throw.v1","ArSonMixNativeVocalThrow"], + ["armix.builtin.8d-sonku.v1","ArSonMixNativeSonKu"] + ]; + for(const [id,windowKey] of allowlisted){ + const {result}=project(id); + assert.deepEqual(result,{kind:"BROWSER",windowKey}); + } + for(const id of ["vendor.vst3","armix.builtin.graphic-eq31.v1", + "armix.builtin.immersib.v1","__proto__"]){ + assert.deepEqual(project(id).result,{kind:"NATIVE_HOST"}, + "non-allowlisted catalogs cannot choose an arbitrary browser host"); + } + const {lease}=project("vendor.vst3"); + assert.deepEqual(fxRackVM.editorSurfacePlan(view,lease,{ + hardwareConfiguration:"wrong-hardware"}),{kind:"UNAVAILABLE"}); + const stale=JSON.parse(JSON.stringify(view)); + stale.graph.revision="73"; + assert.deepEqual(fxRackVM.editorSurfacePlan(stale,lease,{ + hardwareConfiguration}),{kind:"UNAVAILABLE"}); + const offline=JSON.parse(JSON.stringify(view)); + offline.logical=true;offline.admitted=false;offline.workspaceToken="saved-workspace"; + offline.raw.mixerSession.authority="LOGICAL"; + const logicalLease=fxRackVM.editorNavigationPlan(offline,{ + channelId,slot:0}).lease; + assert.deepEqual(fxRackVM.editorSurfacePlan(offline,logicalLease), + {kind:"LOGICAL_VENDOR"}); + offline.graph.channels[0].inserts[0].catalogId="armix.builtin.arson-harmony.v1"; + const builtInLogical=fxRackVM.editorNavigationPlan(offline,{ + channelId,slot:0}).lease; + assert.deepEqual(fxRackVM.editorSurfacePlan(offline,builtInLogical), + {kind:"BROWSER",windowKey:"ArSonMixNativeHarmony"}, + "existing offline built-in editor remains available"); + assert.deepEqual(fxRackVM.editorSurfacePlan(null,lease), + {kind:"UNAVAILABLE"}); + const bridge=read("web/approved-native-bridge.js"); + assert.match(bridge,/fxRackVM\.editorSurfacePlan\(current,editor,/); + assert.match(bridge,/const host=window\[surface\.windowKey\]/); + assert.match(bridge,/openChannelIdFxEditor\(editor\)/); + assert.match(bridge,/action:"logicalVendorFxEditor"/); + assert.doesNotMatch(bridge,/if\(editor\.catalogId==='armix\.builtin/); +}); diff --git a/tests/imersip_p92_catalog_contract_test.py b/tests/imersip_p92_catalog_contract_test.py index e5f88c8b3..07c5fdeac 100644 --- a/tests/imersip_p92_catalog_contract_test.py +++ b/tests/imersip_p92_catalog_contract_test.py @@ -13,11 +13,11 @@ def test_immersib_rack_opens_real_native_editor_without_fake_toast(self): host=source("src/Main.cpp") self.assertIn("fxRackVM.editorNavigationPlan(current,",bridge) self.assertIn('view.raw?.mixerSession?.authority==="CHANNEL_ID"',editor_vm) - self.assertRegex(bridge, - r'backend\.emitEvent\("arMixAction",\{action:"routingFxEditor",\s*' - r'channelId:editor\.channelId,slot:editor\.slot,\s*' - r'instanceId:editor\.instanceId,deviceEpoch:editor\.deviceEpoch,\s*' - r'revision:editor\.graphRevision\}\)') + self.assertIn("openChannelIdFxEditor(editor)",bridge) + self.assertIn("fxRackVM.nativeEditorDispatchPlan(current,lease,",bridge) + self.assertIn('dispatchPhysicalFxEditor(plan,lease,"CHANNEL_ID")',bridge) + self.assertIn('action:"routingFxEditor"',editor_vm) + self.assertIn('ack->setProperty("requestId",args.getProperty("requestId",juce::var()))',host) self.assertNotIn('else status("Native VST3 editor opened")',bridge) self.assertIn("ImerSipP92Editor*>(editor)",host) self.assertIn("std::make_unique",host) diff --git a/tests/native_harmony_assembly_test.py b/tests/native_harmony_assembly_test.py index 4b8ba2873..6b22f81e5 100644 --- a/tests/native_harmony_assembly_test.py +++ b/tests/native_harmony_assembly_test.py @@ -31,7 +31,10 @@ def test_native_catalog_bridge_and_editor(self): # User-facing FX picker and graph/snapshot names change together, # while persisted catalog identity and browser editor hook are stable. self.assertIn("armix.builtin.arson-harmony.v1",self.bridge) - self.assertIn("window.ArSonMixNativeHarmony?.open(t,slot)",self.bridge) + vm=(ROOT/"web/approved-fx-rack-view-model.js").read_text("utf-8") + self.assertIn('"armix.builtin.arson-harmony.v1":"ArSonMixNativeHarmony"',vm) + self.assertIn("const host=window[surface.windowKey]",self.bridge) + self.assertIn("fxRackVM.editorSurfacePlan(current,editor,",self.bridge) self.assertIn('data-fast-native-harmony="1">Harmonice',self.html) self.assertNotIn('data-fast-native-harmony="1">ArSon Harmony',self.html) self.assertIn("['harmonice','arson harmony','harmony','vocal harmony','built-in fx']",self.html) diff --git a/web/approved-fx-rack-view-model.js b/web/approved-fx-rack-view-model.js index c1a551758..1454ed098 100644 --- a/web/approved-fx-rack-view-model.js +++ b/web/approved-fx-rack-view-model.js @@ -338,6 +338,30 @@ Object.keys(lease).length===Object.keys(now.lease).length; } + // G-MV38: a single allowlisted editor surface policy. The native FX catalog + // is *not* permission to create a browser HWND; only these five approved + // built-in controls have a dedicated /preview/ WebView editor. Other installed + // FX (including future built-ins hosted in JUCE) use the existing exact + // native HWND path; offline vendor references keep their logical route. + // Adding a new approved browser editor changes this registry, not the bridge. + const BROWSER_EDITOR_HANDLES=Object.freeze({ + "armix.builtin.channel-eq.v1":"ArSonMixNativeEq", + "armix.builtin.channel-compressor.v1":"ArSonMixNativeCompressor", + "armix.builtin.arson-harmony.v1":"ArSonMixNativeHarmony", + "armix.builtin.vocal-throw.v1":"ArSonMixNativeVocalThrow", + "armix.builtin.8d-sonku.v1":"ArSonMixNativeSonKu" + }); + function editorSurfacePlan(snapshot,lease,{hardwareConfiguration}={}){ + if(!editorNavigationLeaseMatches(snapshot,lease,{hardwareConfiguration})) + return {kind:"UNAVAILABLE"}; + const key=lease.catalogId; + if(Object.prototype.hasOwnProperty.call(BROWSER_EDITOR_HANDLES,key)) + return {kind:"BROWSER",windowKey:BROWSER_EDITOR_HANDLES[key]}; + if(lease.authority==="LOGICAL")return {kind:"LOGICAL_VENDOR"}; + if(lease.authority==="CHANNEL_ID")return {kind:"NATIVE_HOST"}; + return {kind:"UNAVAILABLE"}; + } + // M4 uses host ordinals, never ChannelIds. An old accepted FX inventory // cannot be permission to open an editor after device/route owner changes. function m4EditorPlan(snapshot,{channel,slot,verifiedM4=false, @@ -388,6 +412,40 @@ Object.keys(current.lease).every(key=>current.lease[key]===lease[key]); } + // G-MV36: physical ChannelId VST3 / ImmerSIB editors use the original + // JUCE HWND only when the EXACT G-MV31 accepted instance lease survives. + // Logical .smix and native built-in /preview/ editor owners stay separate. + function nativeEditorDispatchPlan(snapshot,lease,{ + hardwareConfiguration,offline=false}={}){ + if(offline||lease?.authority!=="CHANNEL_ID"|| + !editorNavigationLeaseMatches(snapshot,lease,{hardwareConfiguration})) + return {kind:"UNAVAILABLE"}; + return {kind:"READY",action:"routingFxEditor", + payload:{channelId:lease.channelId,slot:lease.slot, + instanceId:lease.instanceId,deviceEpoch:lease.deviceEpoch, + revision:lease.graphRevision}}; + } + // One pure HWND ACK policy for M4 and ChannelId: transport requestId AND + // installed FX instance must match, and the current accepted hardware, + // route, roster, catalog and owner must still hold the exact click lease. + // Called with ack=null by the controller on every accepted PCM snapshot; + // this retires stale HWND requests even if the native host never responds. + function nativeEditorAckResult(pending,ack,snapshot,{ + verifiedM4=false,offline=false,hardwareConfiguration}={}){ + if(!pending)return "IGNORE"; + const lease=pending.lease; + const valid=pending.authority==="CHANNEL_ID"? + !offline&&lease?.authority==="CHANNEL_ID"&& + editorNavigationLeaseMatches(snapshot,lease,{hardwareConfiguration}): + pending.authority==="M4"&& + m4EditorDispatchLeaseMatches(snapshot,lease,{ + verifiedM4,offline,hardwareConfiguration}); + if(!valid)return "STALE"; + if(!ack||ack.requestId!==pending.requestId)return "IGNORE"; + if(ack.instanceId!==lease.instanceId||ack.ok!==true)return "REJECTED"; + return "ACKED"; + } + // G-MV34: one physically admitted ChannelId FX owner for bypass/insert. // The bridge supplies the canonical existing native device fingerprint. // Historical pure/partial fixtures without the optional fingerprint stay @@ -599,8 +657,9 @@ return Object.freeze({powerReadback,mountedRackMatches, m4Presentation,nativePowerSettlement,m4PowerPlan,m4RackAckResult, m4RackSettlement,m4EditorDispatchPlan,m4EditorDispatchLeaseMatches, + nativeEditorDispatchPlan,nativeEditorAckResult, m4InsertPlan,m4InsertAckResult,m4InsertReadbackSettlement, - editorNavigationPlan,editorNavigationLeaseMatches,m4EditorPlan, + editorNavigationPlan,editorNavigationLeaseMatches,editorSurfacePlan,m4EditorPlan, nativeInsertPlan,nativeEditPlan,nativeInsertSettlement, nativePowerPlan,nativePowerAckResult, globalPowerContext,globalPowerPlan,globalPowerAckResult, diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index d91e66f2e..930bb8c00 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -1298,6 +1298,7 @@ return true; } let pendingFxInsert=null,fxRequestSerial=0,nativeCatalog=new Map(); + let pendingFxEditorAck=null,fxEditorSerial=0; // HWND feedback, never PCM owner // One pending M4 insert is owned by the bridge until ACK AND independent // accepted Console-v6 snapshot. A stale/superseded ACK can never open HWND. function reconcileM4FxInsertReadback(snapshot){ @@ -1321,6 +1322,33 @@ return decision; } + // One original native editor transport for M4 and ChannelId vendor FX. + // The publisher's accepted lease is checked again BEFORE calling this. + function dispatchPhysicalFxEditor(plan,lease,authority){ + const requestId="fx-editor-"+(++fxEditorSerial); + pendingFxEditorAck={requestId,authority,lease}; + backend.emitEvent("arMixAction",{action:plan.action,requestId,...plan.payload}); + window.setTimeout(()=>{ + if(pendingFxEditorAck?.requestId===requestId)pendingFxEditorAck=null; + },8000); + } + function openChannelIdFxEditor(lease){ + if(lease?.authority!=="CHANNEL_ID"||logicalView)return false; + const accepted=controller?.state()?.current; + const plan=fxRackVM.nativeEditorDispatchPlan(accepted,lease,{ + hardwareConfiguration:protocol.nativeHardwareConfiguration(accepted?.device), + offline:!!logicalView}); + if(plan.kind!=="READY")return false; + window.queueMicrotask(()=>{ + const current=controller?.state()?.current; + if(logicalView||fxRackVM.nativeEditorDispatchPlan(current,lease,{ + hardwareConfiguration:protocol.nativeHardwareConfiguration(current?.device), + offline:!!logicalView}).kind!=="READY") + return; // same-epoch hardware/FX replacement or offline .smix switch + dispatchPhysicalFxEditor(plan,lease,"CHANNEL_ID"); + }); + return true; + } function openRoutedFxEditor(lane,slot,instanceId,deviceEpoch,revision, hardwareConfiguration){ const accepted=controller?.state()?.current; @@ -1338,7 +1366,7 @@ verifiedM4:m4Verified(current),offline:!!logicalView, hardwareConfiguration:protocol.nativeHardwareConfiguration(current?.device)})) return; - backend.emitEvent("arMixAction",{action:plan.action,...plan.payload}); + dispatchPhysicalFxEditor(plan,lease,"M4"); }); return true; } @@ -2714,6 +2742,7 @@ activeNativeSource=null;nativeUiSourcePending=null;pendingSourceId=0; pendingOutputPatch=null;pendingNativeFxPower=null;pendingGlobalFx=null; pendingBusCreate=null;pendingTrackDelete=null;pendingFxInsert=null; + pendingFxEditorAck=null; // expire old native HWND on device owner change startupWire=null;activeWireAttempt=null;pendingNativeGainIntent=false; pendingWireGains.clear();pendingNativeControl.clear(); liveFaderVisualTargets.clear();lastNativeControlSent.clear(); @@ -2997,6 +3026,11 @@ emit:(name,payload)=>backend.emitEvent(name,payload), onAccepted:(next,confirmed)=>{ onNativeReadback(next,confirmed); + const accepted=controller?.state()?.current; + if(fxRackVM.nativeEditorAckResult(pendingFxEditorAck,null,accepted,{ + verifiedM4:m4Verified(accepted),offline:!!logicalView, + hardwareConfiguration:protocol.nativeHardwareConfiguration(accepted?.device)})==="STALE") + pendingFxEditorAck=null; syncGlobalFxReadback(); }, onStatus:state=>{ @@ -3223,11 +3257,16 @@ controller?.subscribe(); }); backend.addEventListener("arMixRoutingFxEditorAck",ack=>{ - if(ack?.ok!==true) - nativeToast(ack?.error||"FX editor could not open"); - // A successful native HWND is its own feedback. Do not send a - // generic status("... editor opened") that the UI translates to - // the misleading "Effect settings updated" toast. + const accepted=controller?.state()?.current; + const verdict=fxRackVM.nativeEditorAckResult(pendingFxEditorAck,ack,accepted,{ + verifiedM4:m4Verified(accepted),offline:!!logicalView, + hardwareConfiguration:protocol.nativeHardwareConfiguration(accepted?.device)}); + if(verdict==="IGNORE")return; // obsolete, duplicate or unrelated ACK + pendingFxEditorAck=null; // first ACK wins; no accepted PCM mutation + if(verdict==="REJECTED") + status("FX editor rejected · "+String(ack?.error||"native editor unavailable")); + // Original JUCE emitNotice reports errors. Its HWND controls success. + // Never show the misleading generic "Effect settings updated" toast. }); backend.addEventListener("arMixRoutingFxInsertAck",ack=>{ const verdict=fxRackVM.m4InsertAckResult(pendingFxInsert,ack); @@ -3618,31 +3657,26 @@ scope?.openFastPicker?.(t,slot,btn); }else if(plan.kind==="OPEN"){ const editor=plan.lease; - if(editor.catalogId==='armix.builtin.channel-eq.v1') { - window.ArSonMixNativeEq?.open(t,slot); - } else if(editor.catalogId==='armix.builtin.channel-compressor.v1') { - window.ArSonMixNativeCompressor?.open(t,slot); - } else if(editor.catalogId==='armix.builtin.arson-harmony.v1') { - window.ArSonMixNativeHarmony?.open(t,slot); - } else if(editor.catalogId==='armix.builtin.vocal-throw.v1') { - window.ArSonMixNativeVocalThrow?.open(t,slot); - } else if(editor.catalogId==='armix.builtin.8d-sonku.v1') { - if(window.ArSonMixNativeSonKu?.open) - window.ArSonMixNativeSonKu.open(t,slot); - else nativeToast("8D-SonKu editor unavailable · refresh the approved GUI bundle"); - } else if(editor.authority==="LOGICAL") { + // Pure VM selects an allowlisted browser editor, offline logical + // vendor reference or the existing correlated native HWND route. + // No catalog-specific branching, second renderer or JS PCM owner. + const surface=fxRackVM.editorSurfacePlan(current,editor,{ + hardwareConfiguration:protocol.nativeHardwareConfiguration(current?.device)}); + if(surface.kind==="BROWSER"){ + const host=window[surface.windowKey]; + if(typeof host?.open==="function")host.open(t,slot); + else nativeToast("Built-in FX editor unavailable · refresh the approved GUI bundle"); + }else if(surface.kind==="LOGICAL_VENDOR"){ backend.emitEvent("arMixAction",{action:"logicalVendorFxEditor", channelId:editor.channelId,slot:editor.slot,instanceId:editor.instanceId, workspaceToken:editor.workspaceToken, graphRevision:editor.graphRevision,deviceEpoch:"0"}); - } else { - // Both vendor VST3 and ImmerSIB retain their exact real - // JUCE HWND path; no parallel WebView editor authority. - backend.emitEvent("arMixAction",{action:"routingFxEditor", - channelId:editor.channelId,slot:editor.slot, - instanceId:editor.instanceId,deviceEpoch:editor.deviceEpoch, - revision:editor.graphRevision}); - } + }else if(surface.kind==="NATIVE_HOST"){ + // VST3, ImmerSIB and hosted future JUCE FX retain one original + // correlated native editor owner and its independent lease. + if(!openChannelIdFxEditor(editor)) + nativeToast("FX editor unavailable · native instance changed"); + }else nativeToast("FX editor unavailable · accepted FX identity changed"); }else nativeToast("This FX is held with the disconnected audio session"); return true; }