diff --git a/tests/test_downloads_tab_workflow_route.mjs b/tests/test_downloads_tab_workflow_route.mjs index 07ac76c..2763170 100644 --- a/tests/test_downloads_tab_workflow_route.mjs +++ b/tests/test_downloads_tab_workflow_route.mjs @@ -2064,9 +2064,6 @@ test('Power Lora Loader strength updates only its Loaded Models chip and cache', const updateLoadedModelStrengthsFromNode = eval( `(${extractMethod(tabsLoadedMethodsSource, 'updateLoadedModelStrengthsFromNode')})` ); - const normalizeLoadedModelIdentity = eval( - `(${extractMethod(tabsLoadedMethodsSource, 'normalizeLoadedModelIdentity')})` - ); const getLoadedModelDomKey = eval( `(${extractMethod(tabsLoadedMethodsSource, 'getLoadedModelDomKey')})` ); @@ -2100,7 +2097,6 @@ test('Power Lora Loader strength updates only its Loaded Models chip and cache', }, cachedLoadedModelsSignature: 'old-signature', activeWorkflowSignature: 'old-signature', - normalizeLoadedModelIdentity, getLoadedModelDomKey, getMissingModelKey: () => 'model-key', updateLoadedModelCopyValues: (_container, models) => { diff --git a/web/resolver/node_context_menu.js b/web/resolver/node_context_menu.js index 2ef1097..9796529 100644 --- a/web/resolver/node_context_menu.js +++ b/web/resolver/node_context_menu.js @@ -1,8 +1,4 @@ -import { getFilenameFromPath } from './utils/html_utils.js'; - -function normalizeIdentity(value) { - return String(value ?? '').trim().replaceAll('\\', '/').toLowerCase(); -} +import { getFilenameFromPath, normalizePathIdentity } from './utils/html_utils.js'; function getResolvedModelPath(model = {}) { return String(model.full_path || model.path || model.resolved_path || '').trim(); @@ -44,7 +40,7 @@ function getWidgetChoiceValue(choice) { } function isCurrentWidgetSelection(widget, value) { - const normalizedValue = normalizeIdentity(value); + const normalizedValue = normalizePathIdentity(value); if (!normalizedValue || ['none', 'null', 'undefined'].includes(normalizedValue)) { return false; } @@ -54,7 +50,7 @@ function isCurrentWidgetSelection(widget, value) { return true; } return choices.some(choice => ( - normalizeIdentity(getWidgetChoiceValue(choice)) === normalizedValue + normalizePathIdentity(getWidgetChoiceValue(choice)) === normalizedValue )); } @@ -108,7 +104,7 @@ export function matchesWorkflowModelReference(model = {}, reference = {}) { } if (reference.original_path) { - return normalizeIdentity(model.original_path) === normalizeIdentity(reference.original_path); + return normalizePathIdentity(model.original_path) === normalizePathIdentity(reference.original_path); } return true; @@ -162,7 +158,7 @@ export function getImmediateModelsForNode(data = {}, node = {}, scope = {}) { if (typeof currentValue !== 'string') continue; if (!isCurrentWidgetSelection(widget, currentValue)) continue; - if (normalizeIdentity(currentValue) === normalizeIdentity(reference.original_path)) { + if (normalizePathIdentity(currentValue) === normalizePathIdentity(reference.original_path)) { if (isExistingResolvedModel(reference)) { modelsByWidget.set(widgetIndex, reference); } @@ -201,7 +197,7 @@ function getSubgraphModelReferenceKey(model = {}) { model.subgraph_id || '', model.node_id ?? '', model.widget_index ?? '', - normalizeIdentity(model.original_path || model.name || ''), + normalizePathIdentity(model.original_path || model.name || ''), ].join('|'); } diff --git a/web/resolver/views/tabs_loaded_methods.js b/web/resolver/views/tabs_loaded_methods.js index c34e94a..1d44daf 100644 --- a/web/resolver/views/tabs_loaded_methods.js +++ b/web/resolver/views/tabs_loaded_methods.js @@ -3,6 +3,7 @@ import { getCustomNodeModelEntries, getCustomNodeOriginalIdentity, } from "../custom_nodes/registry.js"; +import { normalizePathIdentity } from "../utils/html_utils.js"; export const tabsLoadedMethods = { getTabButton(tab) { return { @@ -203,13 +204,6 @@ export const tabsLoadedMethods = { return this.getMissingModelKey(model); }, - normalizeLoadedModelIdentity(value) { - return String(value || '') - .trim() - .replace(/\\/g, '/') - .toLowerCase(); - }, - updateLoadedModelCopyValues(container, loadedModels = []) { if (!container) return; @@ -291,7 +285,7 @@ export const tabsLoadedMethods = { const entries = getCustomNodeModelEntries(node) .filter(entry => Number.isFinite(entry.strength)) .map(entry => ({ - identity: this.normalizeLoadedModelIdentity(entry.identity), + identity: normalizePathIdentity(entry.identity), strength: entry.strength, })); if (!entries.length) return false; @@ -300,7 +294,7 @@ export const tabsLoadedMethods = { const modelBuckets = new Map(); for (const model of this.cachedLoadedModelsData.loaded_models) { if (String(model.node_id ?? '') !== nodeId) continue; - const identity = this.normalizeLoadedModelIdentity( + const identity = normalizePathIdentity( getCustomNodeOriginalIdentity(model) || model.original_path || model.name