fix(ams): surface active K-profile when no slot preset is resolvable (#1689 follow-up)

Configure Slot dropped to "default 0.020" on reopen for slots that were
  physically loaded but unconfigured (tray_type="", no slot_preset_mappings
  row). The #1689 cali_idx safety net was unreachable from that path —
  matchingKProfiles early-returned [] on !selectedPresetInfo before the
  safety net ran.

  Split the early return so the cali_idx fallback survives the no-preset
  case: when selectedPresetInfo is null but slotInfo.caliIdx > 0, return
  the active profile as a single-item list (extruder-matched when known).
  Strictly additive; caliIdx == 0/null still returns [], existing matcher
  unchanged when a preset is resolvable.
This commit is contained in:
maziggy
2026-06-09 12:45:36 +02:00
parent f87b5bb3b8
commit 53b318c797
5 changed files with 61 additions and 3 deletions
@@ -748,7 +748,24 @@ export function ConfigureAmsSlotModal({
}, [colorCatalog, selectedPresetInfo]);
const matchingKProfiles = useMemo(() => {
if (!kprofilesData?.profiles || !selectedPresetInfo) return [];
if (!kprofilesData?.profiles) return [];
if (!selectedPresetInfo) {
// Assigned-but-unconfigured slot (filament loaded but the printer hasn't
// bound a preset yet: tray_type=""/tray_info_idx=""/no slot_preset_mappings
// row). The cali_idx safety net further down lives past the main name+id
// matcher and never runs from here, so surface the slot's currently-active
// K-profile directly so Configure Slot keeps showing it across reopen
// instead of dropping to default 0.020 (#1689 follow-up).
const activeIdx = slotInfo.caliIdx;
if (activeIdx != null && activeIdx > 0) {
const active = kprofilesData.profiles.find(
p => p.slot_id === activeIdx
&& (slotInfo.extruderId === undefined || p.extruder_id === slotInfo.extruderId),
);
if (active) return [active];
}
return [];
}
const { fullName, material, brand, filamentId } = selectedPresetInfo;
const upperFullName = fullName.toUpperCase();