[Fix] Spool assignment UI shows wrong filament preset name (#681)

After assigning a spool to an AMS slot, the Bambuddy UI could show the
  wrong filament preset (e.g. "Bambu PLA Matte" instead of "Bambu PLA
  Silk") even though the printer was configured correctly.

  Two bugs:
  1. AssignSpoolModal (PrintersPage hover card path) never saved the slot
     preset mapping to the DB, so the display fell back to the old/stale
     mapping from a previous manual configuration.
  2. AssignToAmsModal (SpoolBuddy path) constructed the preset name from
     spool.material + spool.subtype ("PLA Silk") instead of using the
     authoritative spool.slicer_filament_name ("Bambu PLA Silk").

  Fix: the backend now saves the slot preset mapping in assign_spool()
  after successful MQTT configuration, using slicer_filament_name as the
  display name. This covers both frontend paths and ensures the correct
  name is always stored.
This commit is contained in:
maziggy
2026-03-18 08:12:08 +01:00
parent b12c51189d
commit dcdebef9a8
6 changed files with 283 additions and 103 deletions
@@ -100,25 +100,9 @@ export function AssignToAmsModal({ isOpen, onClose, spool, printerId }: AssignTo
tray_id: trayId,
});
// Save slot preset mapping so ConfigureAmsSlotModal can show the preset
// (same as ConfigureAmsSlotModal does after configuring a slot)
if (spool.slicer_filament) {
const base = spool.slicer_filament.includes('_')
? spool.slicer_filament.split('_')[0]
: spool.slicer_filament;
// Convert filament_id (GFL05) → setting_id (GFSL05); user presets (P*) pass through
const presetId = base.startsWith('GF') && !base.startsWith('GFS')
? 'GFS' + base.slice(2)
: base;
const presetName = spool.subtype
? `${spool.material} ${spool.subtype}`
: spool.material;
try {
await api.saveSlotPreset(printerId, amsId, trayId, presetId, presetName, 'cloud');
} catch (e) {
console.warn('Failed to save slot preset mapping:', e);
}
}
// Slot preset mapping is now saved by the backend in assign_spool()
// after successful MQTT configuration, using the authoritative
// slicer_filament_name from the spool record.
},
onSuccess: () => {
setStatusType('success');