From 381b327791b15a7182c36fa5b169dbc4c8a94f5a Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Sat, 25 Apr 2026 02:41:23 +0200 Subject: [PATCH] Update linker.js --- web/linker.js | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/web/linker.js b/web/linker.js index b361788..cc04ede 100644 --- a/web/linker.js +++ b/web/linker.js @@ -22,6 +22,8 @@ class LinkerManagerDialog extends ComfyDialog { this.pendingIndex = new Map(); // key -> index in pendingResolutions this.activeDownloads = {}; // Track active downloads this.searchResultCache = new Map(); + this.cachedAnalysisData = null; + this.cachedWorkflowSignature = null; this.boundHandleOutsideClick = this.handleOutsideClick.bind(this); this.activeTab = 'missing'; // Default tab this.fullscreen = false; @@ -2970,6 +2972,16 @@ class LinkerManagerDialog extends ComfyDialog { await new Promise(resolve => setTimeout(resolve, 250)); } } + + getWorkflowSignature(workflow) { + if (!workflow) return null; + try { + return JSON.stringify(workflow); + } catch (error) { + console.warn('Model Linker: workflow signature generation failed', error); + return null; + } + } /** * Handle clicks outside the dialog @@ -4470,17 +4482,7 @@ class LinkerManagerDialog extends ComfyDialog { async loadWorkflowData(workflow = null) { if (!this.contentElement) return; - const analysisId = `an-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; - this._analysisProgressToken = analysisId; - // Show loading state - this.contentElement.innerHTML = this.renderAnalysisProgress({ - status: 'starting', - message: 'Starting analysis...', - current: 0, - total: 0 - }); - try { // Use provided workflow, or get current workflow from ComfyUI if (!workflow) { @@ -4493,6 +4495,26 @@ class LinkerManagerDialog extends ComfyDialog { return; } + const workflowSignature = this.getWorkflowSignature(workflow); + if ( + workflowSignature && + this.cachedWorkflowSignature === workflowSignature && + this.cachedAnalysisData + ) { + this.displayMissingModels(this.contentElement, this.cachedAnalysisData); + this.reconnectActiveDownloads(); + return; + } + + const analysisId = `an-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`; + this._analysisProgressToken = analysisId; + this.contentElement.innerHTML = this.renderAnalysisProgress({ + status: 'starting', + message: 'Starting analysis...', + current: 0, + total: 0 + }); + // Call analyze endpoint const progressPromise = this.pollAnalysisProgress(analysisId, analysisId); const response = await api.fetchApi('/model_linker/analyze', { @@ -4508,6 +4530,8 @@ class LinkerManagerDialog extends ComfyDialog { } const data = await response.json(); + this.cachedWorkflowSignature = workflowSignature; + this.cachedAnalysisData = data; this.searchResultCache.clear(); this.displayMissingModels(this.contentElement, data);