'+badge+''+
@@ -756,25 +757,28 @@
const parallelSends=wireEdges.filter(e=>e.enabled&&e.sourceId===t.id&&e.kind==='send'&&e.destId!==master.id);
const allSendPost=parallelSends.length>0&¶llelSends.every(e=>e.mode==='send');
const allSendPre=parallelSends.length>0&¶llelSends.every(e=>e.mode==='split');
- const tapMode=allSendPost?'send':allSendPre?'split':parallelSends.length?'mixed':t.wireTapMode==='split'?'split':'send';
+ const tapTarget=parallelSends.find(edge=>edge.id===selectedWireEdgeId)||
+ (parallelSends.length===1?parallelSends[0]:null);
+ const tapMode=tapTarget?tapTarget.mode:allSendPost?'send':allSendPre?'split':
+ parallelSends.length?'mixed':'idle';
const nativeTapUnavailable=!!window.__JUCE__?.backend&&!t.nativeTapAvailable;
// An unpatched channel has a future WIRE default, not an illuminated send.
// Four dedicated PNG frames avoid CSS-faked lighting: PRE, POST idle, POST
// routed, MIX (several outgoing SEND edges with different tap positions).
const tapVisual=nativeTapUnavailable?'idle':
- parallelSends.length===0?(tapMode==='split'?'pre':'idle'):
+ parallelSends.length===0?'idle':
tapMode==='mixed'?'mixed':tapMode==='split'?'pre':'post';
const tapText=tapVisual==='mixed'?'MIX':tapVisual==='pre'?'PRE':'POST';
+ const tapEditable=!nativeTapUnavailable&&!!tapTarget;
const tapTitle=nativeTapUnavailable?'PRE/POST unavailable until native WIRE tap ACK; routing unchanged':
- !parallelSends.length?'No parallel sends · '+(tapMode==='split'?'PRE':'POST')+
- ' is only the future WIRE default; primary MAIN unchanged':
- tapMode==='mixed'?'Mixed PRE and POST parallel WIRE sends · click to set all POST':
+ !parallelSends.length?'NO SEND · connect and select an independent WIRE first':
+ tapMode==='mixed'?'Mixed PRE and POST parallel WIRE sends · select one WIRE before editing':
(tapMode==='send'?'POST follows channel fader':'PRE independent before FX')+
- ' · '+parallelSends.length+' outgoing parallel SEND(s), primary MAIN unchanged';
+ ' · selected EdgeId '+(tapTarget?.id||'none')+' of '+parallelSends.length+' parallel SEND(s)';
code+='
'
+''
+'';
- if(t.kind!=='master'&&!sofEnabled)code+='';
+ if(t.kind!=='master'&&!sofEnabled)code+='';
code+='
';
code+=sectionFader(t);
code+='
'+(sofEnabled&&t.kind==='audio'?'S ': '')+formatDb(sofEnabled&&t.kind==='audio'?getSofLevel(t):t.level)+'
';
@@ -819,8 +823,8 @@
if(tracksEl.style?.setProperty)tracksEl.style.setProperty('--bank-columns',String(capacity));
// Release observers for detached bank DOM; never accumulate orphan lanes.
meterObserver?.disconnect();meterGeometry=new WeakMap();
+ updateSofTargets(); // Resolve selected EdgeId destination before painting strips.
tracksEl.innerHTML=bankTracks.map(strip).join('');
- updateSofTargets();
const gainBtn=document.getElementById('gainView'),fxBtn=document.getElementById('fxView');
for(const [button,value] of [[gainBtn,'gain'],[fxBtn,'fx']]){
button.disabled=sofEnabled;
@@ -866,23 +870,33 @@
btn.classList.toggle('active',compact);btn.setAttribute('aria-pressed',String(compact));
return density;
}
+function selectedSofDestination(){
+ // A stable local display ID, never an audio-graph identity or a bus name.
+ // Native ChannelId stays a precise decimal string in the bridge.
+ return tracks.find(t=>t.id===sofTargetId&&(t.kind==='bus'||t.kind==='fx'))||null;
+}
function updateSofTargets(){
- const el=document.getElementById('sofTarget'),choices=tracks.filter(t=>t.kind==='bus'||t.kind==='fx').map(t=>t.name);
- const target=choices.includes(sofTarget)?sofTarget:choices[0]||'';
- sofTarget=target;
- const html=choices.map(name=>'
').join('');
- if(el.innerHTML!==html)el.innerHTML=html;el.value=sofTarget;
+ const el=document.getElementById('sofTarget');
+ const choices=tracks.filter(t=>t.kind==='bus'||t.kind==='fx');
+ let target=selectedSofDestination();
+ if(!target){
+ const named=choices.filter(t=>t.name===sofTarget);
+ target=named.length===1?named[0]:choices[0]||null;
+ }
+ sofTargetId=target?.id??null;sofTarget=target?.name||'';
+ const html=choices.map(t=>'
').join('');
+ if(el.innerHTML!==html)el.innerHTML=html;
+ el.value=target?String(target.id):'';
}
function getSofIndex(t){return t.sendSlots.findIndex((slot,i)=>(i===t.activeSend?t.send:slot.send)===sofTarget);}
function getSofEdge(t){
- const options=tracks.filter(x=>x.name===sofTarget&&(x.kind==='bus'||x.kind==='fx'));
- const dest=options.length===1?options[0]:null;
+ const dest=selectedSofDestination();
const edge=dest&&wireFor(t.id,dest.id);
return edge&&edge.kind==='send'?edge:null;
}
function getSofLevel(t){const edge=getSofEdge(t);return edge?edge.levelDb:-60;}
function setSofLevel(t,newLevel){
- const dest=tracks.find(x=>x.name===sofTarget&&x.id!==t.id);
+ const dest=selectedSofDestination();
if(!dest||t.kind==='master')return false;
const level=Math.round(Math.max(-60,Math.min(6,newLevel))*10)/10;
const edge=getSofEdge(t);
@@ -892,7 +906,8 @@
}
function toggleSof(force){
sofEnabled=typeof force==='boolean'?force:!sofEnabled;
- if(sofEnabled&&!sofTarget){sofEnabled=false;say('Create a Bus or FX Return to use Sends on Faders');return;}
+ updateSofTargets();
+ if(sofEnabled&&!selectedSofDestination()){sofEnabled=false;say('Create a Bus or FX Return to use Sends on Faders');return;}
const btn=document.getElementById('sofToggle');btn.classList.toggle('active',sofEnabled);
btn.setAttribute('aria-pressed',String(sofEnabled));document.querySelector('.console-body').classList.toggle('sends-mode',sofEnabled);
render();say(sofEnabled?'SENDS ON FADERS: adjusting '+sofTarget+' send levels · main faders protected':'MAIN MIX: faders control primary channel level');
@@ -2137,14 +2152,13 @@
// MIX status is not permission to rewrite all parallel connections.
const selected=sends.find(edge=>edge.id===selectedWireEdgeId)||(sends.length===1?sends[0]:null);
if(sends.length>1&&!selected){say('Select a specific WIRE before changing its tap');return;}
- const next=selected?(selected.mode==='send'?'split':'send'):(t.wireTapMode==='split'?'send':'split');
- if(selected&&!wireGraphCommit([{type:'MODE',sourceId:t.id,edgeId:selected.id,mode:next}]))return;
- t.wireTapMode=next;
- if(wireSourceId===t.id){wireMode=next;document.getElementById('wireMode').value=next;}
+ if(!selected){say('NO SEND · patch and select one WIRE before changing its tap');return;}
+ const next=selected.mode==='send'?'split':'send';
+ if(!wireGraphCommit([{type:'MODE',sourceId:t.id,edgeId:selected.id,mode:next}]))return;
refreshStrip(t);selectTrack(t);
- say(t.name+' '+(next==='split'?'PRE (independent pre-FX)':'POST (follow fader)')+
- ' · outgoing parallel WIRE sends '+(sends.length?'updated':'default selected')+
- ' · primary MAIN unchanged · GUI reference only');
+ say(t.name+' → '+(tracks.find(x=>x.id===selected.destId)?.name||'BUS')+
+ ' '+(next==='split'?'PRE-FX':'POST-FADER')+
+ ' · one EdgeId only · primary MAIN unchanged · GUI reference');
return;
}
if(a==='eq')t.eq=!t.eq;
@@ -2164,7 +2178,28 @@
if(e.target.closest?.('.wire-gain,.wire-pot')){
const el=e.target.closest('.wire-pot')?.querySelector('.wire-gain')||e.target.closest('.wire-gain');el.value='0';handleField({target:el,type:'change'});return;
}
- if(e.target.classList.contains('fader')){t.level=0;refreshStrip(t);say(t.name+' fader reset to 0.0 dB');}
+ const dial=e.target.closest?.('.gain-dial');
+ if(dial){
+ const gain=dial.querySelector('[data-field="trim"]');
+ if(!gain||gain.disabled)return;
+ // Same field path as a knob gesture: native ACK, no UI-only gain mutation.
+ gain.value='0';gain.dispatchEvent(new Event('input',{bubbles:true}));
+ gain.dispatchEvent(new Event('change',{bubbles:true}));
+ if(!window.__JUCE__?.backend)say(t.name+' digital input gain → unity (0.0 dB)');
+ return;
+ }
+ if(e.target.classList.contains('fader')){
+ const send=sofEnabled&&t.kind==='audio';
+ if(send&&!getSofEdge(t)){say('NO SEND · patch one WIRE first');return;}
+ // Never mutate t.level directly: in SOF the physical fader belongs to
+ // the selected EdgeId, not MAIN. Native bridge owns the accepted write.
+ const fader=e.target;
+ if(fader.disabled)return;
+ fader.value='0';fader.dispatchEvent(new Event('input',{bubbles:true}));
+ fader.dispatchEvent(new Event('change',{bubbles:true}));
+ if(!window.__JUCE__?.backend)say(t.name+(send?' SEND':' MAIN')+' fader → 0.0 dB');
+ return;
+ }
if(e.target.classList.contains('center-pan')){t.pan=0;refreshStrip(t);say(t.name+' pan centered');}
if(e.target.closest('.footer-label,.strip-identity-top'))openChannelIdentity(t,e.target);
});
@@ -2645,13 +2680,25 @@
for(const [id,value] of [['gainView','gain'],['fxView','fx']]){
document.getElementById(id).addEventListener('click',()=>{
if(sofEnabled)return;
- if(value==='gain'&&window.__JUCE__?.backend){say('Native input gain requires accepted DSP control');return;}
+ if(value==='gain'&&window.__JUCE__?.backend&&
+ !tracks.some(t=>t.kind==='audio'&&t.nativeGainAvailable===true)){
+ say('INPUT GAIN unavailable · no channel has an acknowledged native gain stage');
+ return;
+ }
+ // View selection is presentation-only; the DSP insert chain stays resident.
stripView=value;render();
- say(value==='gain'?'Digital INPUT GAIN view · preview trim only':'FX RACK view · existing inserts preserved');
+ say(value==='gain'?'Digital INPUT GAIN · each knob follows accepted channel readback':
+ 'FX RACK · existing inserts preserved');
});
}
document.getElementById('sofToggle').addEventListener('click',()=>toggleSof());
-document.getElementById('sofTarget').addEventListener('change',()=>{sofTarget=document.getElementById('sofTarget').value;render();say('Sends target: '+sofTarget);});
+document.getElementById('sofTarget').addEventListener('change',()=>{
+ const id=Number(document.getElementById('sofTarget').value);
+ const target=tracks.find(t=>t.id===id&&(t.kind==='bus'||t.kind==='fx'));
+ if(!target){updateSofTargets();say('Invalid SEND target · selection unchanged');return;}
+ sofTargetId=target.id;sofTarget=target.name;
+ render();say('SEND MIX → '+sofTarget+' · MAIN faders protected');
+});
document.getElementById('addTrack').addEventListener('click',()=>{
const n=tracks.filter(t=>t.kind==='audio').length+1,t=make('Track '+n,'audio',COLORS[(n-1)%COLORS.length]);const firstBus=tracks.findIndex(x=>x.kind==='bus');tracks.splice(firstBus<0?tracks.length:firstBus,0,t);
if(!wireGraphCommit([{type:'CONNECT',sourceId:t.id,destId:master.id}],{record:false})){tracks=tracks.filter(x=>x.id!==t.id);return;}revealTrack(t);say('Added '+t.name+' → MAIN · reference only');
@@ -2713,7 +2760,7 @@
if(x.send===old)x.send=name;
x.sendSlots.forEach(slot=>{if(slot.send===old)slot.send=name;});
});
- if(sofTarget===old)sofTarget=name;
+ if(sofTargetId===t.id)sofTarget=name;
closeChannelIdentity();render();say('Channel identity updated · '+name+' · routing references preserved');
}
document.getElementById('identityClose').addEventListener('click',closeChannelIdentity);
diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs
index a4f66f437..1d0d3f331 100644
--- a/tests/approved_native_m2_contract.test.cjs
+++ b/tests/approved_native_m2_contract.test.cjs
@@ -1981,3 +1981,24 @@ test("O3 OUTPUTS stays in one existing Audio I/O with safe, read-only DOM",()=>{
assert.match(bridge,/owner\.textContent=patch\.role/);
assert.doesNotMatch(bridge,/owner\.innerHTML=patch/);
});
+
+test("SOF double-click and target selection never commandeer MAIN fader",()=>{
+ const html=read("site/preview-v2/index.html");
+ const bridge=read("web/approved-native-bridge.js");
+ const bundle=read("scripts/build_approved_native_gui.py");
+ assert.match(html,/function selectedSofDestination\(\)/);
+ assert.match(html,/sofTargetId=target\?\.id\?\?null/);
+ assert.match(html,/const send=sofEnabled&&t\.kind==='audio'/);
+ assert.match(html,/fader\.dispatchEvent\(new Event\('change'/);
+ assert.match(bundle,/get sofTargetId\(\)\{return sofTargetId;\}/);
+ assert.match(bridge,/x\.id===scope\.sofTargetId/);
+ const start=bridge.indexOf("consumeDoubleClick(event,t)");
+ const end=bridge.indexOf("applyIdentity:",start);
+ assert.ok(start>0&&end>start,"native delegate must own double-click");
+ const handler=bridge.slice(start,end);
+ assert.ok(handler.indexOf("scope?.sofEnabled") <
+ handler.indexOf('sendM4Control'),
+ "SOF must intercept fader reset BEFORE M4/Main fader ownership");
+ assert.match(handler,/requestWireGain\(\{sourceId:t\.id,edgeId:id,levelDb:0\}\)/);
+ assert.match(handler,/intent\("SET_INPUT_GAIN",t,\{valueDb:0\}\)/);
+});
diff --git a/tests/sof_contextual_console_smoke.py b/tests/sof_contextual_console_smoke.py
index a50a0417f..39eadb05e 100644
--- a/tests/sof_contextual_console_smoke.py
+++ b/tests/sof_contextual_console_smoke.py
@@ -34,6 +34,10 @@ def run() -> None:
assert 'id="gainView"' in source and 'id="fxView"' in source
assert 'id="mixContext"' in source
assert "Never auto-patch or remove a WIRE at minimum send level." in source
+ assert "const send=sofEnabled&&t.kind==='audio';" in source, (
+ "Fader reset must inspect active SEND context instead of overwriting MAIN")
+ assert "nativeGainAvailable===true" in source, (
+ "Native input gain should be available only with installed capability")
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
try:
@@ -62,6 +66,14 @@ def run() -> None:
}""")
assert "+6.5 dB" in first.locator(".gain-readout").inner_text()
assert "6.5" in knob.get_attribute("value") or knob.input_value() == "6.5"
+ # Double-click must use the same gain parameter path and restore unity.
+ first.locator(".gain-dial").dblclick()
+ assert "+0.0 dB" in first.locator(".gain-readout").inner_text()
+ assert knob.input_value() == "0"
+ knob.evaluate("""el => {
+ el.value = '6.5';
+ el.dispatchEvent(new Event('input', {bubbles:true}));
+ }""")
fx.click()
assert first.locator(".is-gain-view").count() == 0
@@ -88,12 +100,38 @@ def run() -> None:
assert "harmonice-thin-flat-v9-approved-off-shadow-57x30.png" in sprite, sprite
assert tap.is_disabled()
- # Keep FX slots/trim values when returning from SENDS.
+ # SOF target is a stable strip ID, never a BUS display name.
+ target_select = page.locator("#sofTarget")
+ initial_id = target_select.input_value()
+ assert initial_id.isdigit(), (width, initial_id)
+ expected_name = target_select.locator("option:checked").inner_text()
+ assert page.locator("#mixContext").inner_text() == "SEND MIX → " + expected_name
+ assert first.locator(".mx-sof-on-key").get_attribute("aria-pressed") == "false", (
+ "An absent SEND is not secretly ON")
+
+ # Returning to MAIN must keep FX/GAIN selection and actual fader mix.
page.locator("#sofToggle").click()
assert page.locator("#mixContext").inner_text() == "MAIN MIX"
gain.click()
assert "+6.5 dB" in first.locator(".gain-readout").inner_text()
+ # Rename the selected BUS in the native-style identity card.
+ # SOF selection must follow its ID, not jump back to Bus A.
+ page.locator("#viewFilter").select_option("bus")
+ selected_bus = page.locator('#tracks .strip[data-id="' + initial_id + '"]')
+ assert selected_bus.count() == 1, (width, initial_id)
+ selected_bus.locator(".strip-identity-top").dblclick()
+ page.locator("#identityName").fill("STAGE MONITOR A")
+ page.locator("#identitySave").click()
+ assert target_select.input_value() == initial_id
+ assert target_select.locator("option:checked").inner_text() == "STAGE MONITOR A"
+ page.locator("#viewFilter").select_option("all")
+ page.locator("#sofToggle").click()
+ assert page.locator("#mixContext").inner_text() == "SEND MIX → STAGE MONITOR A"
+ assert first.locator(".is-sof-view").get_attribute("data-sof-target") == initial_id
+ page.locator("#sofToggle").click()
+ gain.click()
+
# Every visible cell remains in its strip bounds.
geometry = first.locator(".gain-view-body").evaluate("""el => {
const a=el.getBoundingClientRect(),
diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js
index 9b9ca7698..43a9e68fc 100644
--- a/web/approved-native-bridge.js
+++ b/web/approved-native-bridge.js
@@ -407,7 +407,7 @@
function selectedNativeSofEdge(t) {
if(!scope?.sofEnabled||!t||t.kind!=="audio")return null;
const current=controller?.state()?.current,source=nativeIdFor(t);
- const matches=scope?.tracks?.filter(x=>x.name===scope.sofTarget&&
+ const matches=scope?.tracks?.filter(x=>x.id===scope.sofTargetId&&
(x.kind==="bus"||x.kind==="fx"))||[];
if(!current?.admitted||!source||matches.length!==1)return null;
const dest=nativeIdFor(matches[0]);
@@ -635,7 +635,7 @@
const t=scope?.tracks?.find(x=>x.id===tId);
if(t&&scope?.sofEnabled)scope.refreshStrip?.(t);
}
- if(scope?.sofEnabled && local.destId===scope?.tracks?.find(x=>x.name===scope.sofTarget)?.id){
+ if(scope?.sofEnabled && local.destId===scope?.sofTargetId){
const t=scope?.tracks?.find(x=>x.id===tId);
const slider=document.querySelector('.strip[data-id="'+tId+'"] input.fader');
if(t&&slider&&document.activeElement!==slider){
@@ -3839,12 +3839,27 @@
},
consumeDoubleClick(event,t) {
if (!connected)return false;
+ // Reset the parameter the fader CURRENTLY owns. A SOF reset must not
+ // write the main channel's SET_FADER or M4 faderDb by accident.
if (event.target.classList.contains("fader")){
+ if(scope?.sofEnabled&&t?.kind==="audio"){
+ const edge=selectedNativeSofEdge(t),id=edge&&uiByWireId.get(edge.edgeId);
+ if(!edge||id===undefined||
+ !requestWireGain({sourceId:t.id,edgeId:id,levelDb:0}))
+ status("SOF unity reset unavailable · select one admitted SEND");
+ return true;
+ }
if((m4ControlIsOwner()&&m4Verified()) ||
(t?.kind==="master"&&(m4Verified()||nativeMasterReady())))
sendM4Control(t?.kind==="master"?"masterGain":"faderDb",t,0);
else intent("SET_FADER",t,{valueDb:0});
}
+ else if(event.target.closest?.(".gain-dial")){
+ if(t?.kind!=="audio"||t.nativeGainAvailable!==true)
+ status("INPUT GAIN unity reset requires native PCM admission");
+ else intent("SET_INPUT_GAIN",t,{valueDb:0});
+ return true;
+ }
else if(event.target.classList.contains("center-pan")){
if(m4ControlIsOwner()&&m4Verified())sendM4Control("pan",t,0);
else intent("SET_PAN",t,{value:0});