From 758ab0d2dcd3a8c43e07a16c4a71bc87e6eeeddb Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Nov 2025 02:12:33 +0100 Subject: [PATCH] fix: Update workflow in place instead of creating new tab for resolve and auto-resolve --- web/linker.js | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/web/linker.js b/web/linker.js index e4d0e01..da87065 100644 --- a/web/linker.js +++ b/web/linker.js @@ -628,17 +628,44 @@ class LinkerManagerDialog extends ComfyDialog { /** * Update workflow in ComfyUI's UI/memory + * Updates the current workflow in place instead of creating a new tab */ async updateWorkflowInComfyUI(workflow) { - if (app && app.loadGraphData) { - try { - await app.loadGraphData(workflow, false, false); - } catch (error) { - console.error('Model Linker: Error updating workflow in ComfyUI:', error); - throw error; + if (!app || !app.graph) { + console.warn('Model Linker: Could not update workflow - app or app.graph not available'); + return; + } + + try { + // Method 1: Try to directly update the current graph using configure + // This is the most direct way to update in place + if (app.graph && typeof app.graph.configure === 'function') { + app.graph.configure(workflow); + return; } - } else { - console.warn('Model Linker: Could not update workflow - app.loadGraphData not available'); + + // Method 2: Try deserialize to update the graph in place + if (app.graph && typeof app.graph.deserialize === 'function') { + app.graph.deserialize(workflow); + return; + } + + // Method 3: Use loadGraphData with explicit parameters to update current tab + // The key is to NOT create a new workflow - pass null or undefined for the workflow parameter + // clean=false means don't clear the graph first + // restore_view=false means don't restore the viewport + // workflow=null means update current workflow instead of creating new one + if (app.loadGraphData) { + // Try with null as 4th parameter first + await app.loadGraphData(workflow, false, false, null); + return; + } + + console.warn('Model Linker: No method available to update workflow'); + } catch (error) { + console.error('Model Linker: Error updating workflow in ComfyUI:', error); + // Don't throw - allow the workflow update to continue even if UI update fails + // The backend has already updated the workflow data } } }