● Add prefer lowest remaining filament in auto-matching (#805)

When multiple AMS spools match the same type/color criteria, an optional
  setting now prefers the spool with the lowest remaining filament. This
  helps consume partial spools before starting new ones. Sorting applies
  to all matching paths: queue scheduler, print modal, and multi-printer
  mapping. Unknown remain values (-1) sort to end.
This commit is contained in:
maziggy
2026-03-31 14:14:15 +02:00
parent 3c887f5166
commit 5a696f9fa3
24 changed files with 476 additions and 155 deletions
@@ -107,7 +107,8 @@ function InlineMappingEditor({
isManual = true;
} else {
const usedTrayIds = new Set<number>(Object.values(printerResult.config.manualMappings));
loaded = autoMatchFilament(req, printerResult.loadedFilaments, usedTrayIds) as LoadedFilament | undefined;
const cachedSettings = queryClient.getQueryData<{ prefer_lowest_filament?: boolean }>(['settings']);
loaded = autoMatchFilament(req, printerResult.loadedFilaments, usedTrayIds, cachedSettings?.prefer_lowest_filament) as LoadedFilament | undefined;
}
// Determine status
+3 -2
View File
@@ -324,7 +324,7 @@ export function PrintModal({
});
// Get AMS mapping from hook (only when single printer selected)
const { amsMapping } = useFilamentMapping(effectiveFilamentReqs, printerStatus, manualMappings);
const { amsMapping } = useFilamentMapping(effectiveFilamentReqs, printerStatus, manualMappings, settings?.prefer_lowest_filament);
// Multi-printer filament mapping (for per-printer configuration)
const multiPrinterMapping = useMultiPrinterFilamentMapping(
@@ -333,7 +333,8 @@ export function PrintModal({
effectiveFilamentReqs,
manualMappings,
perPrinterConfigs,
setPerPrinterConfigs
setPerPrinterConfigs,
settings?.prefer_lowest_filament,
);
// Auto-select first plate when plates load (single or multi-plate)