fix(moonraker): Vendor-Match auch wenn tray_info_idx gesetzt aber inkompatibel

Wenn die Bridge eine tray_info_idx sendet (z.B. GFL99 für Bambu Lab PLA)
die kein kompatibler Preset für den aktiven Drucker hat, wird jetzt
trotzdem der Vendor+Type+Color-Match versucht statt direkt auf Generic
zurückzufallen.

Behebt: Bridge sendet GFL99 (Bambu-ID) für Slot mit vendor='Bambu Lab'
→ kein Kobra-X-kompatibler Preset für GFL99 → bisher Generic PLA
→ jetzt Vendor-Match → findet besten Bambu-Lab-PLA-Preset

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
viewit
2026-05-31 21:18:48 +02:00
parent 12f5d7b19c
commit 4ca3deebba

View File

@@ -874,7 +874,22 @@ bool MoonrakerPrinterAgent::fetch_moonraker_filament_data(std::vector<AmsTrayDat
tray.tray_info_idx = safe_json_string(lane_obj, "tray_info_idx");
tray.filament_vendor = safe_json_string(lane_obj, "filament_vendor");
auto* bundle = GUI::wxGetApp().preset_bundle;
if (tray.tray_info_idx.empty() && bundle && !tray.filament_vendor.empty()) {
// If tray_info_idx is set but no compatible preset exists for it,
// and we have a vendor hint, prefer vendor+type+color match instead.
// This handles cases where the bridge sends a generic/other-printer ID
// (e.g. GFL99 for Bambu Lab) that has no compatible preset for this printer.
bool idx_has_compatible_preset = false;
if (!tray.tray_info_idx.empty() && bundle) {
for (const auto& p : bundle->filaments.get_presets()) {
if (p.is_compatible && p.filament_id == tray.tray_info_idx) {
idx_has_compatible_preset = true;
break;
}
}
}
if (bundle && !tray.filament_vendor.empty() && (tray.tray_info_idx.empty() || !idx_has_compatible_preset)) {
std::string mid = find_closest_color_preset_by_vendor_and_type(
bundle->filaments, tray.filament_vendor, tray.tray_type, tray.tray_color);
if (!mid.empty()) tray.tray_info_idx = mid;