Fix active filament preset not matching wizard selection on first run (#12132)
Some checks are pending
Build all / Build Linux (push) Waiting to run
Build all / Build Non-Linux (push) Waiting to run
Build all / Unit Tests (push) Blocked by required conditions
Build all / Flatpak (push) Waiting to run

* Fix active filament preset not matching wizard selection on first run

After completing the setup wizard with only a non-PLA filament selected
(e.g. Generic ABS), the active filament preset defaulted to Generic PLA
instead of the user's selection. This happened because load_presets()
falls back to Generic PLA when the initial printer differs from the
preferred printer, and the first_added_filament override was disabled.

Add post-load correction in apply_config() that switches the active
filament to the first compatible wizard-selected filament when the
current active filament is not in the wizard selection. Also fix the
guide JS (22.js, 23.js) to use the filalist attribute for building
the filament array, and add platform-specific build test commands to
CLAUDE.md.

* Replace @System filaments with vendor-specific overrides in wizard

When the wizard selects a generic filament like "Generic ABS @System",
check if a vendor-specific override exists (e.g. BBL "Generic ABS")
and use that instead. This ensures printer-tuned profiles are preferred,
preventing load_installed_filaments from adding unwanted BBL defaults.

When printers from the default bundle are also selected, both variants
are kept since those printers need the @System version.

Also adds diagnostic logging for filament loading in LoadProfileFamily.

* Guard against persisting presets for Default Printer and fix filament override logic

Prevent export_selections from saving stale preset settings for the
built-in "Default Printer" placeholder, which is only the initial state
before a real printer is loaded. Also require a non-default vendor printer
to be selected before replacing @System filaments with vendor-specific
overrides in the wizard, avoiding incorrect filament substitution when
only the default bundle is present.
This commit is contained in:
SoftFever 2026-02-01 21:34:14 +08:00 committed by GitHub
parent 3a056f2aa3
commit 977a66be39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 98 additions and 17 deletions

View file

@ -838,14 +838,67 @@ bool GuideFrame::apply_config(AppConfig *app_config, PresetBundle *preset_bundle
// Not switch filament
//get_first_added_material_preset(AppConfig::SECTION_FILAMENTS, first_added_filament);
// For each @System filament, check if a vendor-specific override exists
// in the loaded profiles. If so, replace the @System variant with the
// override (e.g. replace "Generic ABS @System" with BBL "Generic ABS").
// When printers from the default bundle are also selected, keep @System
// too since those printers need it.
static const std::string system_suffix = " @System";
auto it_default = enabled_vendors.find(PresetBundle::ORCA_DEFAULT_BUNDLE);
bool has_default_bundle_printer = it_default != enabled_vendors.end() && !it_default->second.empty();
bool has_filament_profiles = m_ProfileJson.contains("filament");
// Check if any non-default vendor has selected printers
bool has_vendor_printer = false;
for (const auto& [vendor, models] : enabled_vendors) {
if (vendor != PresetBundle::ORCA_DEFAULT_BUNDLE && !models.empty()) {
has_vendor_printer = true;
break;
}
}
std::map<std::string, std::string> supplemented_filaments;
for (const auto& [name, value] : enabled_filaments) {
if (name.size() > system_suffix.size() &&
name.compare(name.size() - system_suffix.size(), system_suffix.size(), system_suffix) == 0) {
std::string short_name = name.substr(0, name.size() - system_suffix.size());
if (has_vendor_printer && has_filament_profiles && m_ProfileJson["filament"].contains(short_name)) {
supplemented_filaments[short_name] = value;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " Replacing @System filament: '" << name << "' -> '" << short_name << "'";
if (has_default_bundle_printer) {
supplemented_filaments[name] = value;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " Also keeping '" << name << "' for default bundle printers";
}
continue;
}
}
supplemented_filaments[name] = value;
}
//update the app_config
app_config->set_section(AppConfig::SECTION_FILAMENTS, enabled_filaments);
app_config->set_section(AppConfig::SECTION_FILAMENTS, supplemented_filaments);
app_config->set_vendors(m_appconfig_new);
if (check_unsaved_preset_changes)
preset_bundle->load_presets(*app_config, ForwardCompatibilitySubstitutionRule::Enable,
{preferred_model, preferred_variant, first_added_filament, std::string()});
// If the active filament is not in the wizard-selected filaments, switch to the first
// compatible wizard-selected filament. This handles the first-run case where load_presets
// falls back to "Generic PLA" even though the user selected a different filament.
bool active_filament_selected = supplemented_filaments.empty()
|| supplemented_filaments.count(preset_bundle->filament_presets.front()) > 0;
if (!active_filament_selected) {
for (const auto& [filament_name, _] : supplemented_filaments) {
const Preset* preset = preset_bundle->filaments.find_preset(filament_name);
if (preset && preset->is_visible && preset->is_compatible) {
preset_bundle->filaments.select_preset_by_name(filament_name, true);
preset_bundle->filament_presets.front() = preset_bundle->filaments.get_selected_preset_name();
break;
}
}
}
// Update the selections from the compatibilty.
preset_bundle->export_selections(*app_config);