diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py
index d1d9e19e2..f38406916 100644
--- a/scripts/build_approved_native_gui.py
+++ b/scripts/build_approved_native_gui.py
@@ -25,6 +25,7 @@
'\n'
'\n'
'\n'
+ '\n'
'\n'
'\n'
'\n')
@@ -368,6 +369,8 @@ def stage(out: Path) -> dict:
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")
+ shutil.copy2(ROOT / "web" / "approved-wire-view-model.js",
+ out / "assets" / "approved-wire-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 ba2cf12c3..0cbec11dc 100644
--- a/tests/approved_native_cold_start_smoke.py
+++ b/tests/approved_native_cold_start_smoke.py
@@ -77,9 +77,10 @@ def main():
assert page.evaluate("""()=>Boolean(
window.ArSonApprovedChannelStripViewModel &&
window.ArSonApprovedFxRackViewModel &&
+ window.ArSonApprovedWireViewModel &&
window.__ARMIX_NATIVE_M2__?.inputChoices &&
window.__ARMIX_NATIVE_M2__?.outputChoices)"""), (
- 'native assembled GUI missing GUI-1 Channel Strip ViewModel')
+ 'native assembled GUI missing MVVM presentation modules')
io_inventory={
'types':[{'name':'Windows Audio','separate':True,
'inputs':['Studio Mic'],'outputs':['Speakers']}],
diff --git a/tests/approved_native_gui_bundle_test.py b/tests/approved_native_gui_bundle_test.py
index 1604a9468..e6f08d004 100644
--- a/tests/approved_native_gui_bundle_test.py
+++ b/tests/approved_native_gui_bundle_test.py
@@ -69,15 +69,21 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self)
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-wire-view-model.js'))
+ self.assertLess(native.index('assets/approved-wire-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.assertNotIn('assets/approved-wire-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())
+ self.assertEqual(
+ (out / 'assets/approved-wire-view-model.js').read_bytes(),
+ (ROOT / 'web/approved-wire-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 4b07b28c6..c2fd91a10 100644
--- a/tests/approved_native_m2_contract.test.cjs
+++ b/tests/approved_native_m2_contract.test.cjs
@@ -7,6 +7,7 @@ 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 wireVM=require("../web/approved-wire-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));
@@ -74,6 +75,85 @@ test("GUI-2 exact mounted FX instance/power identity rejects stale, duplicate or
assert.doesNotMatch(bridge,/const effective=enabled&&globalEnabled&&!insert\.bypassed/,
"old duplicated FX bypass projection must be removed from DOM bridge");
});
+test("GUI-3 WIRE selector keeps exact PRIMARY OUT vs parallel SEND identity, even to MAIN",()=>{
+ const source="9007199254740993",main="18446744073709551615",bus="9007199254740999";
+ const primary={edgeId:"9007199254741000",from:source,to:bus,enabled:true,
+ primaryOutput:true,gainLinear:1,tap:"POST_FADER",sendEnabled:true};
+ const busOut=wireVM.edgePresentation(primary,bus,main);
+ assert.equal(busOut.kind,"primary");assert.equal(busOut.mode,"routeOnly");
+ assert.equal(busOut.levelDb,0);
+ const mainSend={...primary,edgeId:"9007199254741001",to:main,
+ primaryOutput:false,gainLinear:.5,sendEnabled:false};
+ const independent=wireVM.edgePresentation(mainSend,main,main);
+ assert.equal(independent.kind,"send",
+ "parallel SEND to MAIN cannot be promoted by matching primaryOutId");
+ assert.equal(independent.mode,"send");
+ assert.equal(independent.levelDb,-6);
+ assert.equal(independent.sendEnabled,false);
+ assert.equal(wireVM.edgePresentation({...primary,gainLinear:.7},bus,main),null,
+ "primary OUT is unity; incorrect PCM readback is rejected");
+ assert.equal(wireVM.edgePresentation(primary,main,main),null,
+ "stale primary destination must not be repainted as verified");
+ const old={...primary};delete old.primaryOutput;
+ assert.equal(wireVM.edgePresentation(old,bus,main).kind,"primary",
+ "legacy readback without explicit primaryOutput keeps existing fallback");
+ const split={...mainSend,tap:"SPLIT_PRE",tapStage:"SPLIT_PRE",to:bus};
+ assert.equal(wireVM.edgePresentation(split,main,main).mode,"splitPre");
+ const updated={...split,tapStage:"PRE_FADER"};
+ assert.equal(wireVM.edgePresentation(updated,main,main).nativeTap,"PRE_FADER",
+ "actual native post-insert PRE_FADER wins over old PRE_FX tap");
+ assert.equal(wireVM.gainDb(0),-60);
+ assert.equal(wireVM.gainDb(10),6);
+ assert.equal(wireVM.gainDb(-1),null);
+});
+test("GUI-3 WIRE gain/readback and native edit eligibility are fail-closed by exact EdgeId",()=>{
+ const source="9007199254740993",other="9007199254740994",
+ edgeId="9223372036854775808",main="18446744073709551615";
+ const send={edgeId,from:source,to:main,enabled:true,
+ primaryOutput:false,gainLinear:.5,tap:"POST_FADER"};
+ const primary={...send,edgeId:"9223372036854775809",primaryOutput:true};
+ const graph={capabilities:{supportedOps:["SET_WIRE_GAIN","APPLY_WIRE_TRANSACTION",
+ "SET_SEND_ENABLED"]},edges:[send,primary]};
+ const snap={admitted:true,retained:false,graph};
+ const previous=JSON.stringify(snap);
+ assert.equal(wireVM.acceptedParallelEdge(snap,true,source,edgeId,"SET_WIRE_GAIN"),send);
+ assert.equal(wireVM.acceptedParallelEdge(snap,true,other,edgeId,"SET_WIRE_GAIN"),null);
+ assert.equal(wireVM.acceptedParallelEdge(snap,false,source,edgeId,"SET_WIRE_GAIN"),null);
+ assert.equal(wireVM.acceptedParallelEdge({...snap,retained:true},true,
+ source,edgeId,"SET_WIRE_GAIN"),null);
+ assert.equal(wireVM.acceptedParallelEdge({...snap,admitted:false},true,
+ source,edgeId,"SET_WIRE_GAIN"),null);
+ assert.equal(wireVM.acceptedParallelEdge(snap,true,source,edgeId,"MISSING_OP"),null);
+ assert.equal(wireVM.parallelEdge(graph,source,primary.edgeId),null);
+ assert.equal(wireVM.parallelEdge({...graph,edges:[send,send]},source,edgeId),null);
+ assert.equal(wireVM.parallelEdge(graph,source,edgeId,other),null);
+ const mapping=new Map([[edgeId,42],[primary.edgeId,41]]);
+ const pending=new Map([[edgeId,{requestId:"gain-1"}]]);
+ const rows=wireVM.gainReadback(graph.edges,mapping,pending);
+ assert.deepEqual(rows,[{id:42,pending:true,levelDb:-6}]);
+ assert.deepEqual(wireVM.gainReadback(graph.edges,new Map(),pending),[],
+ "unknown native EdgeId may never invent a new view-id");
+ assert.equal(JSON.stringify(snap),previous,"selectors never mutate native snapshot");
+ assert.equal(wireVM.canEditTap(send,{supported:true}),true);
+ assert.equal(wireVM.canEditTap(send,{supported:true,pending:true}),false);
+ assert.equal(wireVM.canEditTap(send,{supported:false}),false);
+ assert.equal(wireVM.canEditTap({...send,tap:"PRE_FX"},{supported:true}),false);
+ assert.equal(wireVM.gestureTap("split"),"PRE_FADER");
+ assert.equal(wireVM.gestureTap("send"),"POST_FADER");
+ assert.equal(wireVM.gestureTap("routeOnly"),null);
+ assert.equal(wireVM.sofAvailable(snap,true),true);
+ assert.equal(wireVM.sofAvailable({...snap,retained:true},true),false);
+ assert.equal(wireVM.sofAvailable(snap,false),false);
+ assert.equal(wireVM.sofAvailable({...snap,graph:{...graph,capabilities:{
+ supportedOps:["SET_WIRE_GAIN"]}}},true),false);
+ const bridge=read("web/approved-native-bridge.js");
+ assert.match(bridge,/wireVM\.gainReadback\(/);
+ assert.match(bridge,/wireVM\.parallelEdge\(/);
+ assert.match(bridge,/wireVM\.canEditTap\(/);
+ assert.match(bridge,/wireVM\.sofAvailable\(/);
+ assert.doesNotMatch(bridge,/const kind=isPrimary\?"primary"/,
+ "old WIRE presentation policy must be REMOVED, not copied");
+});
function acceptedFixture(){
const s=clone(fixtures.g0);
s.device.epoch="18446744073709551610";
@@ -112,7 +192,8 @@ test("WIRE inspector controls PRIMARY BUS and PARALLEL MAIN by actual EdgeId, wi
const bridge=read("web/approved-native-bridge.js");
const builder=read("scripts/build_approved_native_gui.py");
assert.match(bridge,/function admittedParallelWire\(uiSourceId,uiEdgeId,operation\)/);
- assert.match(bridge,/e\.edgeId===edgeId&&e\.from===source&&e\.primaryOutput===false/);
+ assert.match(bridge,/wireVM\.acceptedParallelEdge\(/);
+ assert.match(read("web/approved-wire-view-model.js"),/e\.from===sourceId&&e\.edgeId===edgeId&&e\.primaryOutput===false/);
assert.match(builder,/getElementById\('wireWsGainText'\)/);
assert.match(builder,/!row\.pending/);
const renderStart=html.indexOf("function renderWireWsInspector(){");
@@ -217,7 +298,9 @@ test("native PRE_FADER WIRE inspector uses one exact SET_TAP PCM intent and acce
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(bridge,/wireVM\.edgePresentation\(/);
+ assert.match(read("web/approved-wire-view-model.js"),
+ /const tap=TAPS\.has\(edge\.tapStage\)\?edge\.tapStage:edge\.tap/);
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'/);
@@ -870,8 +953,10 @@ test("P0 installed ChannelId WIRE capability reaches the GUI",()=>{
assert.match(native,/NATIVE_APPLY_WIRE_TRANSACTION/);
assert.match(projection,/if\(has\("NATIVE_APPLY_WIRE_TRANSACTION"\)\)/);
assert.match(projection,/available\.add\(juce::String\("APPLY_WIRE_TRANSACTION"\)\)/);
- assert.match(bridge,/const kind=isPrimary\?"primary"/);
- assert.match(bridge,/if \(isPrimary && edge\.gainLinear!==1\)/);
+ const wire=read("web/approved-wire-view-model.js");
+ assert.match(bridge,/wireVM\.edgePresentation\(/);
+ assert.match(wire,/const kind=primary\?"primary"/);
+ assert.match(wire,/if\(primary&&edge\.gainLinear!==1\)return null/);
assert.doesNotMatch(bridge,/if \(isMain && edge\.gainLinear!==1\)/);
});
test("P0 WIRE-to-MAIN and channel OUT use one acknowledged native transaction",()=>{
@@ -1314,7 +1399,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,ArSonApprovedFxRackViewModel:fxRackVM,
+ __JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,ArSonApprovedWireViewModel:wireVM,
__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"),{
@@ -1538,7 +1623,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,ArSonApprovedFxRackViewModel:fxRackVM,
+ const win={__JUCE__:{backend:native},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,ArSonApprovedWireViewModel:wireVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(){return 0},clearTimeout(){},queueMicrotask(fn){fn();}};
vm.runInNewContext(read("web/approved-native-bridge.js"),
@@ -1716,7 +1801,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,ArSonApprovedFxRackViewModel:fxRackVM,
+ __JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,ArSonApprovedWireViewModel:wireVM,
__ARMIX_NATIVE_SCOPE__:scope,addEventListener(){},
setTimeout(){return 0},clearTimeout(){},queueMicrotask(fn){fn();}
};
@@ -1803,7 +1888,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,ArSonApprovedFxRackViewModel:fxRackVM,
+ const win={__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,ArSonApprovedWireViewModel:wireVM,
__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 4158147f1..03116ed98 100644
--- a/tests/live_fader_held_drag.test.cjs
+++ b/tests/live_fader_held_drag.test.cjs
@@ -9,6 +9,7 @@ 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 wireVM=require("../web/approved-wire-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;
@@ -79,7 +80,7 @@ function harness({m4=false}={}){
};
const window={
__JUCE__:{backend},ArSonApprovedNativeContract:protocol,ArSonApprovedDeviceViewModel:deviceVM,
- ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,
+ ArSonApprovedChannelStripViewModel:stripVM,ArSonApprovedFxRackViewModel:fxRackVM,ArSonApprovedWireViewModel:wireVM,
__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-native-bridge.js b/web/approved-native-bridge.js
index 371e6dfd2..c5ff74340 100644
--- a/web/approved-native-bridge.js
+++ b/web/approved-native-bridge.js
@@ -7,11 +7,12 @@
const deviceVM = window.ArSonApprovedDeviceViewModel;
const stripVM = window.ArSonApprovedChannelStripViewModel;
const fxRackVM = window.ArSonApprovedFxRackViewModel;
+ const wireVM = window.ArSonApprovedWireViewModel;
// 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 && fxRackVM);
+ protocol && deviceVM && stripVM && fxRackVM && wireVM);
// Public browser preview keeps its header; the native JUCE caption replaces it.
if (backend?.emitEvent && backend?.addEventListener)
document.documentElement?.classList?.add?.("armix-native-desktop");
@@ -395,14 +396,9 @@
// EdgeId, not a destination kind, strip label, or reference graph index.
// A PARALLEL_SEND can legally point to MAIN; a PRIMARY_OUT can point to BUS.
function admittedParallelWire(uiSourceId,uiEdgeId,operation){
- const current=controller?.state()?.current;
- const source=nativeByUiId.get(uiSourceId),edgeId=wireByUiId.get(uiEdgeId);
- if(!flags.acceptedGraphConnected||!current?.admitted||current.retained||
- !source||!edgeId||!current.graph.capabilities.supportedOps.includes(operation))
- return null;
- const matches=current.graph.edges.filter(e=>e.enabled&&
- e.edgeId===edgeId&&e.from===source&&e.primaryOutput===false);
- return matches.length===1?matches[0]:null;
+ return wireVM.acceptedParallelEdge(controller?.state()?.current,
+ flags.acceptedGraphConnected,nativeByUiId.get(uiSourceId),
+ wireByUiId.get(uiEdgeId),operation);
}
function requestWireGain(op){
const db=Number(op.levelDb);
@@ -440,12 +436,11 @@
!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)){
+ const selected=wireVM.parallelEdge(current.graph,source,edgeId);
+ if(!wireVM.canEditTap(selected,{supported:true})){
status("PRE/POST unavailable · selected send identity changed");return false;
}
- if(matches[0].tap===tap)return true;
+ if(selected.tap===tap)return true;
const result=controller.intent("APPLY_WIRE_TRANSACTION",source,{changes:[{
op:"SET_TAP",from:source,edgeId,tap
}]});
@@ -460,14 +455,13 @@
(x.kind==="bus"||x.kind==="fx"))||[];
if(!current?.admitted||!source||matches.length!==1)return null;
const dest=nativeIdFor(matches[0]);
- const edges=current.graph.edges.filter(e=>e.enabled&&
+ const edges=current.graph.edges.filter(e=>e.enabled===true&&
e.from===source&&e.to===dest&&e.primaryOutput===false);
- return edges.length===1?edges[0]:null;
+ return edges.length===1?wireVM.parallelEdge(current.graph,source,
+ edges[0].edgeId,dest):null;
}
function syncNativeSofAvailability(next=controller?.state()?.current) {
- const admitted=!!next?.admitted&&!!scope?.toggleSof&&
- ["SET_WIRE_GAIN","SET_SEND_ENABLED","APPLY_WIRE_TRANSACTION"].every(op=>
- next.graph.capabilities.supportedOps.includes(op));
+ const admitted=wireVM.sofAvailable(next,!!scope?.toggleSof);
const toggle=document.getElementById("sofToggle"),target=document.getElementById("sofTarget");
for(const el of [toggle,target])if(el){
el.style?.setProperty?.("display",admitted?"":"none","important");
@@ -553,26 +547,16 @@
const src=localByNative.get(edge.from), dst=localByNative.get(edge.to);
if (!src || !dst || edge.from===accepted.mainChannelId) return false;
const source=accepted.channels.find(ch=>ch.id===edge.from);
- const isMain=edge.to===accepted.mainChannelId;
- const isPrimary=source?.primaryOutId===edge.to;
- // An independent SEND to MAIN is not the source's primary OUT.
- // 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":
- 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;
+ const view=wireVM.edgePresentation(edge,source?.primaryOutId,
+ accepted.mainChannelId);
+ if(!view)return false; // invalid native WIRE identity: no demo fallback
let uiId=uiByWireId.get(edge.edgeId);
if (uiId===undefined) uiId=scope.allocateWireId();
newWireByUi.set(uiId,edge.edgeId);
newUiByWire.set(edge.edgeId,uiId);
- edges.push({id:uiId,sourceId:src,destId:dst,kind,mode,
- nativeTap:tap,sendEnabled:edge.sendEnabled!==false,
- enabled:true,levelDb:gainDb});
+ edges.push({id:uiId,sourceId:src,destId:dst,
+ kind:view.kind,mode:view.mode,nativeTap:view.nativeTap,
+ sendEnabled:view.sendEnabled,enabled:true,levelDb:view.levelDb});
}
if (!scope.wireGraph.validateCandidateGraph(nextTracks,nextMaster.id,edges).ok) return false;
const previouslySelected = nextTracks.filter(t=>t.selected);
@@ -638,10 +622,8 @@
// One authoritative EdgeId gain projection for normal readback AND failure
// rollback. No duplicate DSP math or synthetic accepted control state.
function nativeWireGainReadback(next){
- return (next?.graph?.edges||[]).filter(e=>e.enabled&&e.primaryOutput===false)
- .map(e=>({id:uiByWireId.get(e.edgeId),pending:pendingWireGains.has(e.edgeId),
- levelDb:Math.round(Math.max(-60,Math.min(6,
- e.gainLinear>0?20*Math.log10(e.gainLinear):-60))*10)/10}));
+ return wireVM.gainReadback(next?.graph?.edges||[],
+ uiByWireId,pendingWireGains);
}
// Paint ONLY an independently accepted ChannelId input scalar. Comparing
// the actual DOM as well as the model also repairs a rejected/expired gain
@@ -3675,17 +3657,15 @@
canWireTap(uiEdgeId,uiSourceId){
if(logicalView){
const from=nativeByUiId.get(uiSourceId),edgeId=wireByUiId.get(uiEdgeId);
- const matching=logicalView.graph.edges.filter(e=>e.enabled &&
- e.from===from && e.edgeId===edgeId && e.primaryOutput===false);
- const edge=matching.length===1?matching[0]:null;
- // Offline PRE/POST is a saved document edit, never PCM admission.
- return !!edge&&!logicalView.readOnly&&!pendingLogical&&
- logicalView.graph.capabilities.supportedOps.includes("SET_SEND_TAP")&&
- ["PRE_FADER","POST_FADER"].includes(edge.tapStage||edge.tap);
+ const edge=wireVM.parallelEdge(logicalView.graph,from,edgeId);
+ // Offline PRE/POST edits only .smix, never PCM admission.
+ return wireVM.canEditTap(edge,{logical:true,
+ readOnly:logicalView.readOnly,pending:!!pendingLogical,
+ supported:logicalView.graph.capabilities.supportedOps.includes("SET_SEND_TAP")});
}
const edge=admittedParallelWire(uiSourceId,uiEdgeId,"APPLY_WIRE_TRANSACTION");
- return !!edge&&["PRE_FADER","POST_FADER"].includes(edge.tap)&&
- !controller?.state()?.pending;
+ return wireVM.canEditTap(edge,{pending:!!controller?.state()?.pending,
+ supported:true});
},
consumeWire(ops,retries=0) {
if (!connected)return false;
@@ -3705,11 +3685,8 @@
// The same WIRE inspector gesture must remain available before
// binding a physical interface. Exact native EdgeId/readback,
// not a reference-renderer-only toggle or a fabricated PCM ACK.
- const tap=op.mode==="split"?"PRE_FADER":
- op.mode==="send"?"POST_FADER":null;
- const matching=logicalView.graph.edges.filter(e=>e.enabled &&
- e.from===from && e.edgeId===edgeId && e.primaryOutput===false);
- const edge=matching.length===1?matching[0]:null;
+ const tap=wireVM.gestureTap(op.mode);
+ const edge=wireVM.parallelEdge(logicalView.graph,from,edgeId);
if(!tap||!edge||!nativeHooks.canWireTap(op.edgeId,op.sourceId)){
status("Offline PRE/POST unavailable · select a saved parallel SEND");
return true;
@@ -3740,8 +3717,7 @@
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;
+ const tap=wireVM.gestureTap(op.mode);
requestNativeTap(source,edgeId,tap);
return true;
}
diff --git a/web/approved-wire-view-model.js b/web/approved-wire-view-model.js
new file mode 100644
index 000000000..46a99c4aa
--- /dev/null
+++ b/web/approved-wire-view-model.js
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// GUI-3: pure WIRE/EdgeId presentation selectors for the ONE /preview/ GUI.
+// Native graph, .smix, ACK and PCM render authority remain external.
+(function (root, factory) {
+ const api=factory();
+ if(typeof module==="object"&&module.exports)module.exports=api;
+ if(root)root.ArSonApprovedWireViewModel=api;
+})(typeof globalThis==="object"?globalThis:undefined,function () {
+ "use strict";
+ const TAPS=new Set(["PRE_FADER","POST_FADER"]);
+ const SOF_OPS=["SET_WIRE_GAIN","SET_SEND_ENABLED","APPLY_WIRE_TRANSACTION"];
+
+ function gainDb(linear) {
+ if(!Number.isFinite(linear)||linear<0)return null;
+ return Math.round(Math.max(-60,Math.min(6,
+ linear>0?20*Math.log10(linear):-60))*10)/10;
+ }
+
+ // Explicit native primaryOutput is decisive. Only old snapshots without
+ // that field use the primaryOutId fallback. A parallel SEND to MAIN is not
+ // promoted to PRIMARY just because it shares the same destination.
+ function edgePresentation(edge,sourcePrimaryOutId,mainChannelId) {
+ if(!edge||edge.enabled!==true||
+ typeof edge.edgeId!=="string"||!edge.edgeId||
+ typeof edge.from!=="string"||typeof edge.to!=="string")return null;
+ const primary=typeof edge.primaryOutput==="boolean"?
+ edge.primaryOutput:sourcePrimaryOutId===edge.to;
+ if(primary&&sourcePrimaryOutId!==edge.to)return null;
+ if(primary&&edge.gainLinear!==1)return null; // exact native unity OUT
+ const levelDb=primary?0:gainDb(edge.gainLinear);
+ if(levelDb===null)return null;
+ const isMain=edge.to===mainChannelId;
+ const tap=TAPS.has(edge.tapStage)?edge.tapStage:edge.tap;
+ const legacySplit=tap==="SPLIT_PRE"||tap==="SPLIT_POST";
+ const kind=primary?"primary":legacySplit?"split":"send";
+ const mode=isMain?(primary?"postFader":"send"):primary?"routeOnly":
+ legacySplit?(tap==="SPLIT_PRE"?"splitPre":"splitPost"):"send";
+ return {kind,mode,nativeTap:tap,sendEnabled:edge.sendEnabled!==false,
+ enabled:true,levelDb,primary};
+ }
+
+ // Exact decimal-string native identities only. Reject collisions: a
+ // UI ordinal or destination label is never a substitute for an EdgeId.
+ function parallelEdge(graph,sourceId,edgeId,destinationId) {
+ if(!sourceId||!edgeId||!Array.isArray(graph?.edges))return null;
+ const matches=graph.edges.filter(e=>e.enabled===true&&
+ e.from===sourceId&&e.edgeId===edgeId&&e.primaryOutput===false&&
+ (destinationId===undefined||e.to===destinationId));
+ return matches.length===1?matches[0]:null;
+ }
+
+ function acceptedParallelEdge(snapshot,projected,sourceId,edgeId,operation) {
+ if(projected!==true||snapshot?.admitted!==true||snapshot.retained||
+ !snapshot.graph?.capabilities?.supportedOps?.includes(operation))
+ return null;
+ return parallelEdge(snapshot.graph,sourceId,edgeId);
+ }
+
+ function gainReadback(edges,uiByEdgeId,pendingGains) {
+ if(!Array.isArray(edges))return [];
+ return edges.filter(e=>e.enabled===true&&e.primaryOutput===false)
+ .flatMap(e=>{
+ const id=uiByEdgeId.get(e.edgeId),levelDb=gainDb(e.gainLinear);
+ if(id===undefined||levelDb===null)return [];
+ return [{id,pending:pendingGains.has(e.edgeId),levelDb}];
+ });
+ }
+
+ function canEditTap(edge,{pending=false,readOnly=false,
+ supported=false,logical=false}={}) {
+ if(!edge||pending||readOnly||!supported)return false;
+ const tap=logical?(edge.tapStage||edge.tap):edge.tap;
+ return TAPS.has(tap);
+ }
+
+ function gestureTap(mode) {
+ return mode==="split"?"PRE_FADER":mode==="send"?"POST_FADER":null;
+ }
+
+ function sofAvailable(snapshot,canToggle) {
+ return snapshot?.admitted===true&&snapshot.retained!==true&&
+ canToggle===true&&SOF_OPS.every(op=>
+ snapshot.graph?.capabilities?.supportedOps?.includes(op));
+ }
+
+ return Object.freeze({gainDb,edgePresentation,parallelEdge,
+ acceptedParallelEdge,gainReadback,canEditTap,gestureTap,sofAvailable});
+});