diff --git a/site/preview-v2/index.html b/site/preview-v2/index.html index 41607dc3d..2a1058a83 100644 --- a/site/preview-v2/index.html +++ b/site/preview-v2/index.html @@ -652,7 +652,12 @@ let label='',status=''; if(isSource){label='SOURCE';status='⇢ '+wireOutgoingCount(t.id)+' OUT';} else if(t.kind==='master'){label='MAIN';status=source&&wireFor(source.id,master.id)?'DIRECT ON':'DIRECT OFF';} - else if(edge){label='IN ← CH'+String(source.id).padStart(2,'0');status=edge.mode==='split'?'PRE FX':'POST FADER';} + else if(edge){ + label='IN ← CH'+String(source.id).padStart(2,'0'); + status=edge.nativeTap==='PRE_FADER'?'PRE FADER': + edge.nativeTap==='POST_FADER'?'POST FADER': + edge.mode==='split'?'PRE FX':'POST FADER'; + } else if(legacy){label='LEGACY';status='SEND ACTIVE';} else if(t.kind==='bus')label='BUS'; else if(t.kind==='fx')label='FX RETURN'; @@ -1267,14 +1272,23 @@ const src=tracks.find(t=>t.id===p.src),dst=tracks.concat(master).find(t=>t.id===p.dst); if(!src||!dst){panel.hidden=true;return;} const edge=info.edge,key=p.src+':'+p.dst; + const native=!!window.__JUCE__?.backend; + const tapValue=edge?.nativeTap==='PRE_FADER'?'split': + edge?.nativeTap==='POST_FADER'?'send':edge?.mode; + const tapEditable=!native||(src.nativeTapAvailable===true&& + edge?.kind==='send'&&['PRE_FADER','POST_FADER'].includes(edge.nativeTap)); const controls=edge? - '
'+ + '
'+ ''+ ''+edge.levelDb+' dB'+ ''+ - ''+ + ''+ '
': '
Managed by existing '+escapeHtml(info.kind.toUpperCase())+' routing. No duplicate WIRE edge.
'; panel.innerHTML=''+escapeHtml(wireWsLabel(p.src))+' → '+escapeHtml(wireWsLabel(p.dst))+''+ diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 875119210..fc5bdb022 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -27,6 +27,46 @@ function acceptedFixture(){ tap:"POST",gainLinear:1,enabled:true,signalKind:"AUDIO"}]; return s; } +test("native PRE_FADER WIRE inspector uses one exact SET_TAP PCM intent and accepted readback",()=>{ + const bridge=read("web/approved-native-bridge.js"); + const preview=read("site/preview-v2/index.html"); + assert.match(bridge,/function requestNativeTap\(source,edgeId,tap\)/); + assert.match(bridge,/ops\[0\]\.type==="MODE"/); + assert.match(bridge,/op:"SET_TAP",from:source,edgeId,tap/); + assert.match(bridge,/const tap=\["PRE_FADER","POST_FADER"\]\.includes\(edge\.tapStage\)/); + assert.match(preview,/edge\.nativeTap==='PRE_FADER'\?'PRE FADER'/); + assert.match(preview,/edge\?\.nativeTap==='PRE_FADER'\?'split'/); + assert.match(preview,/native\?'PRE FADER':'Pre FX'/); + const s=acceptedFixture(),source=s.graph.channels[0].id; + const bus={id:"9007199254740999",role:"GROUP",name:"BUS B",processingFormat:"STEREO", + controls:{faderDb:0,pan:0,mute:false,solo:false},inserts:[],sends:[]}; + s.graph.channels.splice(1,0,bus); + s.graph.destinations.push({id:bus.id,role:"GROUP"}); + delete s.graph.channels[0].primaryOutId; + s.graph.edges[0]={edgeId:"9223372036854775808",from:source,to:bus.id, + tap:"POST_FADER",gainLinear:.5,enabled:true,sendEnabled:true, + primaryOutput:false,signalKind:"AUDIO"}; + const sent=[],c=protocol.createController({emit:(event,payload)=>sent.push({event,payload})}); + assert.equal(c.onSnapshot(clone(s)),true); + const change={op:"SET_TAP",from:source,edgeId:s.graph.edges[0].edgeId,tap:"PRE_FADER"}; + const t=c.intent("APPLY_WIRE_TRANSACTION",source,{changes:[change]}); + assert.equal(t.ok,true); + assert.deepEqual(sent.at(-1).payload.payload.changes,[change]); + assert.equal(c.state().current.graph.edges[0].tap,"POST_FADER"); + assert.equal(c.onAck({requestId:t.requestId,status:"ACCEPTED",errorCode:"NONE", + deviceEpoch:s.device.epoch,graphRevision:"6",rosterRevision:"8"}),true); + assert.equal(c.state().current.graph.edges[0].tap,"POST_FADER", + "ACK alone cannot repaint a PRE_FADER send"); + const next=clone(s);next.graph.revision="6";next.graph.rosterRevision="8"; + next.graph.edges[0].tap="PRE_FADER"; + assert.equal(c.onSnapshot(next),true); + assert.equal(c.state().pending,null); + assert.equal(c.state().current.graph.edges[0].tap,"PRE_FADER"); + assert.equal(c.state().current.graph.edges[0].edgeId,change.edgeId); + assert.equal(c.state().current.graph.edges[0].gainLinear,.5); + assert.equal(c.state().current.graph.edges[0].sendEnabled,true); +}); + test("native input Gain is a separate ChannelId scalar proven only by ACK plus inputGain readback",()=>{ const s=acceptedFixture(),id=s.graph.channels[0].id; s.graph.capabilities.supportedOps.push("SET_INPUT_GAIN"); @@ -1233,6 +1273,25 @@ test("M3 native-only Pages scope performs real bridge projection, fader intent a listeners.get("arMixConsoleSnapshot")(gained); assert.equal(scope.edges[0].levelDb,-12); assert.equal(paints,paintBeforeGain); + // WIRE inspector MODE is a legacy visual gesture. It MUST become one + // exact native SET_TAP EdgeId transaction; rejection leaves the PCM tap intact. + const tapUi=scope.edges[0].id; + assert.equal(window.__ARMIX_NATIVE_M2__.consumeWire([{ + type:"MODE",sourceId:sourceUi,edgeId:tapUi,mode:"split" + }]),true); + const tapRequest=sent.findLast(x=>x.name==="arMixConsoleIntent").payload; + assert.equal(tapRequest.operation,"APPLY_WIRE_TRANSACTION"); + assert.deepEqual(JSON.parse(JSON.stringify(tapRequest.payload.changes)),[{ + op:"SET_TAP",from:routed.graph.channels[0].id, + edgeId:"9223372036854775810",tap:"PRE_FADER" + }]); + assert.equal(scope.edges[0].nativeTap,"POST_FADER"); + listeners.get("arMixConsoleAck")({requestId:tapRequest.requestId,status:"REJECTED", + errorCode:"NATIVE_WIRE_TRANSACTION_REJECTED",deviceEpoch:gained.device.epoch, + graphRevision:"8",rosterRevision:"8"}); + assert.equal(window.__ARMIX_NATIVE_M2__.state().pending,null); + assert.equal(scope.edges[0].nativeTap,"POST_FADER", + "rejected native tap must restore the last accepted PCM stage"); // OUT uses the same actual INPUT destination as WIRE, not a name-only // GROUP lookup. An exclusive route promotes the existing native edge. const hooks=window.__ARMIX_NATIVE_M2__,sourceTrack=scope.tracks[0]; diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index ed554e3d8..ab7831212 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -404,6 +404,29 @@ else window.setTimeout(()=>controller?.expire(result.requestId),8000); return result.ok; }; + // One accepted EdgeId/tap command shared by SOF and the WIRE inspector. + // A typed SET_TAP recompiles the existing PCM graph; neither GUI may + // repaint PRE/POST until the subsequent independent accepted readback. + function requestNativeTap(source,edgeId,tap){ + const state=controller?.state(),current=state?.current; + if(!current?.admitted||current.retained||state.pending|| + !current.graph.capabilities.supportedOps.includes("APPLY_WIRE_TRANSACTION")|| + !source||!edgeId||!["PRE_FADER","POST_FADER"].includes(tap)){ + status("PRE/POST unavailable · wait for an admitted native WIRE");return false; + } + const matches=current.graph.edges.filter(e=>e.enabled&&e.edgeId===edgeId&& + e.from===source&&e.primaryOutput===false); + if(matches.length!==1||!["PRE_FADER","POST_FADER"].includes(matches[0].tap)){ + status("PRE/POST unavailable · selected send identity changed");return false; + } + if(matches[0].tap===tap)return true; + const result=controller.intent("APPLY_WIRE_TRANSACTION",source,{changes:[{ + op:"SET_TAP",from:source,edgeId,tap + }]}); + if(!result.ok){status("PRE/POST unchanged · "+result.error);return false;} + window.setTimeout(()=>controller?.expire(result.requestId),8000); + return true; + } function selectedNativeSofEdge(t) { if(!scope?.sofEnabled||!t||t.kind!=="audio")return null; const current=controller?.state()?.current,source=nativeIdFor(t); @@ -514,10 +537,13 @@ const isMain=edge.to===accepted.mainChannelId; const isPrimary=source?.primaryOutId===edge.to; // An independent SEND to MAIN is not the source's primary OUT. - const kind=isPrimary?"primary":edge.tap==="SPLIT_PRE"||edge.tap==="SPLIT_POST"?"split":"send"; + // Explicit native tapStage disambiguates legacy PRE_FX SPLIT_PRE from + // real post-FX PRE_FADER. The reference 'split' mode means PRE_FX only. + const tap=["PRE_FADER","POST_FADER"].includes(edge.tapStage)?edge.tapStage:edge.tap; + const legacySplit=tap==="SPLIT_PRE"||tap==="SPLIT_POST"; + const kind=isPrimary?"primary":legacySplit?"split":"send"; const mode=isMain?(isPrimary?"postFader":"send"):kind==="primary"?"routeOnly": - kind==="split"?(edge.tap==="SPLIT_PRE"?"splitPre":"splitPost"): - edge.tap==="PRE_FADER"?"split":"send"; + legacySplit?(tap==="SPLIT_PRE"?"splitPre":"splitPost"):"send"; if (isPrimary && edge.gainLinear!==1) return false; const gainDb=isPrimary?0:Math.round(Math.max(-60,Math.min(6, edge.gainLinear>0?20*Math.log10(edge.gainLinear):-60))*10)/10; @@ -526,7 +552,7 @@ newWireByUi.set(uiId,edge.edgeId); newUiByWire.set(edge.edgeId,uiId); edges.push({id:uiId,sourceId:src,destId:dst,kind,mode, - nativeTap:edge.tap,sendEnabled:edge.sendEnabled!==false, + nativeTap:tap,sendEnabled:edge.sendEnabled!==false, enabled:true,levelDb:gainDb}); } if (!scope.wireGraph.validateCandidateGraph(nextTracks,nextMaster.id,edges).ok) return false; @@ -3477,9 +3503,7 @@ return true; } const next=target.tap==="PRE_FADER"?"POST_FADER":"PRE_FADER"; - intent("APPLY_WIRE_TRANSACTION",t,{changes:[{ - op:"SET_TAP",from:id,edgeId:target.edgeId,tap:next - }]}); + requestNativeTap(id,target.edgeId,next); return true; } if(action==="sofOn"){ @@ -3648,6 +3672,17 @@ nativeToast("WIRE not saved · previous routing retained"); return true; } + // The inspector's legacy MODE gesture is only a presentation gesture. + // Map it to one real installed PRE_FADER/POST_FADER EdgeId transaction; + // never queue/replay it as a startup wire or mutate a demo graph. + if(Array.isArray(ops)&&ops.length===1&&ops[0].type==="MODE"){ + const op=ops[0]; + const source=nativeByUiId.get(op.sourceId),edgeId=wireByUiId.get(op.edgeId); + const tap=op.mode==="split"?"PRE_FADER": + op.mode==="send"?"POST_FADER":null; + requestNativeTap(source,edgeId,tap); + return true; + } const state=controller?.state(); // A first drag may arrive before SOURCE's later accepted snapshot. // Preserve that one operator intent; resolve only against fresh native