fix: update preset NAM block path when loading a model globally
CI / test (push) Has been cancelled

/api/models/load now also updates the current preset's NAM Amp
block(s) nam_model_path, so the UI block reflects the loaded model.
This commit is contained in:
2026-06-17 23:21:14 -04:00
parent aa0bcf35fe
commit de5723f138
+24 -1
View File
@@ -1239,7 +1239,12 @@ class WebServer:
@app.post("/api/models/load")
async def load_model(data: dict, channel: str = "guitar"):
"""Load a NAM model by path for the given channel."""
"""Load a NAM model by path for the given channel.
Also updates the current preset's NAM Amp block(s) nam_model_path
so the block UI reflects the newly loaded model.
"""
from ..presets.types import Channel
_pm, _pl, nam, _ir = self._channel_deps(channel)
if not nam:
raise HTTPException(status_code=503)
@@ -1250,6 +1255,24 @@ class WebServer:
if not ok:
detail = nam.last_error or "Failed to load model"
raise HTTPException(status_code=422, detail=detail)
# Also update the current preset's NAM Amp blocks to match
if _pm is not None:
try:
bank = _pm.current_bank
program = _pm.current_program
preset = _pm.load(bank, program, channel=Channel(channel))
changed = False
for b in preset.chain:
if b.fx_type.value == "nam_amp" or b.nam_model_path:
if b.nam_model_path != path:
b.nam_model_path = path
changed = True
if changed:
_pm.save(preset, channel=Channel(channel))
except Exception:
logger.warning("Failed to update preset NAM block path", exc_info=True)
await self._manager.broadcast({
"type": "model_loaded",
"model": path,