diff --git a/frontend/src/components/control/AMSMaterialsModal.tsx b/frontend/src/components/control/AMSMaterialsModal.tsx index 698e02a86..5e6613d39 100644 --- a/frontend/src/components/control/AMSMaterialsModal.tsx +++ b/frontend/src/components/control/AMSMaterialsModal.tsx @@ -11,6 +11,7 @@ interface AMSMaterialsModalProps { printerId: number; printerModel: string; // e.g., "H2D", "X1C", "P1S" nozzleDiameter?: string; + extruderId?: number; // 0=right nozzle, 1=left nozzle (for filtering K-profiles) onClose: () => void; onConfirm?: (data: MaterialSettings) => void; } @@ -170,6 +171,7 @@ export function AMSMaterialsModal({ printerId, printerModel, nozzleDiameter = '0.4', + extruderId = 0, onClose, onConfirm, }: AMSMaterialsModalProps) { @@ -282,7 +284,40 @@ export function AMSMaterialsModal({ }; // Find best K-profile when data loads or filament type changes - const profiles = kProfilesData?.profiles || []; + // First filter all profiles by extruder ID (for dual-nozzle printers) + const allProfiles = kProfilesData?.profiles || []; + const profiles = allProfiles.filter(p => p.extruder_id === extruderId); + + // Filter profiles to show only matching ones in dropdown + const getMatchingProfiles = (): KProfile[] => { + if (!profiles.length) return []; + + const subBrands = isBambuSpool + ? tray.tray_sub_brands?.toLowerCase() + : (selectedPresetName ? getCleanFilamentName(selectedPresetName).toLowerCase() : null); + const type = isBambuSpool + ? tray.tray_type?.toUpperCase() + : (selectedFilamentType?.toUpperCase() || tray.tray_type?.toUpperCase()); + + // If we have tray_sub_brands, only show profiles matching that (not generic type) + // For Bambu spools, also require "bambu" in the profile name to exclude third-party profiles + if (subBrands) { + const matches = profiles.filter(p => p.name.toLowerCase().includes(subBrands)); + if (isBambuSpool) { + return matches.filter(p => p.name.toLowerCase().includes('bambu')); + } + return matches; + } + + // Only fall back to type matching if no sub_brands available + if (type) { + return profiles.filter(p => p.name.toUpperCase().includes(type)); + } + + return []; + }; + + const matchingProfiles = getMatchingProfiles(); // Get color name from Bambu tray_id_name (e.g., "A00-Y2" -> "Sunflower Yellow") const bambuColorName = getColorNameFromTrayId(tray.tray_id_name); @@ -511,14 +546,14 @@ export function AMSMaterialsModal({ {/* K Profile */}
- +