Stable Diffusion: migrate stale flux1 VAE selection, snap VAE setting to offered list

6276520a70c3b5ac6a13750ec4490ef38a61daf2

permissionBRICK <40219477+permissionBRICK@users.noreply.github.com>

1 files changed, +14 -1Showing whitespace changes
public/scripts/extensions/stable-diffusion/index.js+14 -1
@@ -740,6 +740,16 @@ async function loadSettings() {
740740 extension_settings.sd.lora_strength = 1.0;
741741 }
742742
743+ // The flux workflows moved from a hardcoded flux2 VAE to %vae%; a leftover
744+ // flux1 selection ('ae.safetensors') would fail pod-side validation.
745+ const migrateVae = (config) => {
746+ if (config && config.vae === 'ae.safetensors') {
747+ config.vae = 'flux2-vae.safetensors';
748+ }
749+ };
750+ migrateVae(extension_settings.sd);
751+ (extension_settings.sd.settings_preset_chain ?? []).forEach(entry => migrateVae(entry?.preset));
752+
743753 if (typeof extension_settings.sd.comfy_workflow_prefs !== 'object' || !extension_settings.sd.comfy_workflow_prefs) {
744754 extension_settings.sd.comfy_workflow_prefs = {};
745755 }
@@ -4001,7 +4011,10 @@ async function loadVaes() {
40014011 $('#sd_vae').append(option);
40024012 }
40034013
4004- if (!extension_settings.sd.vae && vaes.length > 0 && vaes[0] !== 'N/A') {
4014+ // Snap to the first real entry when nothing is selected OR the saved value
4015+ // is not offered (otherwise the dropdown displays the first option while
4016+ // generations keep sending the stale saved value).
4017+ if (vaes.length > 0 && vaes[0] !== 'N/A' && !vaes.includes(extension_settings.sd.vae)) {
40054018 extension_settings.sd.vae = vaes[0];
40064019 $('#sd_vae').val(extension_settings.sd.vae).trigger('change');
40074020 }