Preserve resolver display mode when auto-opening for missing models
Add openResolverForDetectedMissingModels() in model_resolver.js to keep the current resolver display state when missing models are detected: if the resolver dialog is already visible, schedule an active workflow refresh instead of re-activating the button; if it is hidden, activate the resolver button as before. Update the auto-open-on-missing path to use the new method, and adjust/add tests to cover the preserved display mode behavior.
This commit is contained in:
@@ -699,12 +699,40 @@ test('automatic opening for missing models is disabled by default', () => {
|
||||
test('automatic opening remains conditional on unresolved models', () => {
|
||||
assert.match(
|
||||
modelResolverSource,
|
||||
/if \(data\.total_missing > 0\) \{[\s\S]*?this\.openResolverManager\(\);/
|
||||
/if \(data\.total_missing > 0\) \{[\s\S]*?this\.openResolverForDetectedMissingModels\(\);/
|
||||
);
|
||||
assert.match(optionsMethodsSource, /id="mr-options-auto-open-on-missing"/);
|
||||
assert.match(optionsMethodsSource, /auto_open_on_missing: Boolean\(autoOpenOnMissingInput\?\.checked\)/);
|
||||
});
|
||||
|
||||
test('automatic opening preserves the current resolver display mode', () => {
|
||||
const openResolverForDetectedMissingModels = eval(`(${extractMethod(modelResolverSource, 'openResolverForDetectedMissingModels')})`);
|
||||
const refreshReasons = [];
|
||||
let activationCount = 0;
|
||||
const visibleResolver = {
|
||||
dialog: {
|
||||
isVisible: () => true,
|
||||
scheduleActiveWorkflowRefresh: reason => refreshReasons.push(reason),
|
||||
},
|
||||
activateResolverButton() {
|
||||
activationCount += 1;
|
||||
},
|
||||
};
|
||||
|
||||
openResolverForDetectedMissingModels.call(visibleResolver);
|
||||
assert.equal(activationCount, 0);
|
||||
assert.deepEqual(refreshReasons, ['auto-open-missing-models']);
|
||||
|
||||
const hiddenResolver = {
|
||||
dialog: { isVisible: () => false },
|
||||
activateResolverButton() {
|
||||
activationCount += 1;
|
||||
},
|
||||
};
|
||||
openResolverForDetectedMissingModels.call(hiddenResolver);
|
||||
assert.equal(activationCount, 1);
|
||||
});
|
||||
|
||||
test('active workflow label prefers selected ComfyUI workflow tab name over route hash', () => {
|
||||
const cleanWorkflowLabel = eval(`(${extractMethod(queueMethodsSource, 'cleanWorkflowLabel')})`);
|
||||
const getWorkflowLabelFromActiveTabElement = eval(`(${extractMethod(queueMethodsSource, 'getWorkflowLabelFromActiveTabElement')})`);
|
||||
|
||||
@@ -1069,6 +1069,15 @@ export class ModelResolver {
|
||||
return localStorage.getItem('ModelResolver.autoOpenOnMissing') === 'true';
|
||||
}
|
||||
|
||||
openResolverForDetectedMissingModels() {
|
||||
if (this.dialog?.isVisible?.()) {
|
||||
this.dialog.scheduleActiveWorkflowRefresh?.('auto-open-missing-models');
|
||||
return;
|
||||
}
|
||||
|
||||
this.activateResolverButton();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for missing models and auto-open dialog if any are found
|
||||
@@ -1121,7 +1130,7 @@ export class ModelResolver {
|
||||
// Auto-open dialog if there are missing models
|
||||
if (data.total_missing > 0) {
|
||||
log.debug(`Model Resolver: Found ${data.total_missing} missing model(s), opening dialog...`);
|
||||
this.openResolverManager();
|
||||
this.openResolverForDetectedMissingModels();
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user