fix(moonraker): re-resolve host on user→user preset switch for AMS sync

Two Moonraker user presets on different ports (:7125, :7126) share the
same printer agent type. switch_printer_agent() only called select_machine()
when the agent *type* changed — not when the host changed within the same
agent. A user→user preset switch therefore left the MachineObject pointing
at the first connected printer, causing AMS sync to always query the wrong
host.

Fix: when the agent type stays the same (and is not the BBL agent),
also call select_machine() so the host is re-resolved from the current
preset and set_selected_machine() reconnects to the correct Moonraker
instance.

Fixes: AMS Sync locked to first printer in multi-printer sessions (SirPeroples)
This commit is contained in:
thysson2701
2026-06-28 18:14:55 +02:00
parent 31c667443e
commit 87f6e62f26

View File

@@ -3564,6 +3564,11 @@ void GUI_App::switch_printer_agent()
// Auto-switch MachineObject
select_machine(effective_agent_id);
} else if (effective_agent_id != BBL_PRINTER_AGENT_ID) {
// Same agent type but host may have changed (e.g. user→user preset switch between
// two Moonraker instances on different ports). select_machine() re-resolves the host
// from the current preset and reconnects if the MachineObject differs.
select_machine(effective_agent_id);
}
}