Fix workflow picker not switching active workflow

The store's openWorkflow only updates Pinia state without switching
the canvas. Use app.loadGraphData with the workflow object instead,
matching ComfyUI's internal workflow service pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 13:53:58 +01:00
parent 24fe846646
commit ebbdfa4249

View File

@@ -2836,15 +2836,17 @@ async function buildSidebar(el) {
// Try to switch to the workflow in ComfyUI // Try to switch to the workflow in ComfyUI
const wfStore = app.extensionManager?.workflow; const wfStore = app.extensionManager?.workflow;
const openWfs = wfStore?.openWorkflows; const openWfs = wfStore?.openWorkflows;
if (openWfs && wfStore.openWorkflow) { if (openWfs) {
const target = openWfs.find(wf => const target = openWfs.find(wf =>
(wf.key || wf.filename || wf.path) === entry.workflowKey (wf.key || wf.filename || wf.path) === entry.workflowKey
); );
if (target) { if (target) {
try { try {
if (!target.isLoaded && target.load) await target.load();
collapsePicker(); collapsePicker();
await wfStore.openWorkflow(target); await app.loadGraphData(target.activeState, true, true, target);
// openWorkflow listener handles viewingWorkflowKey reset + refresh // loadGraphData triggers the openWorkflow store action,
// whose listener handles viewingWorkflowKey reset + refresh
return; return;
} catch { /* fall through to view-only */ } } catch { /* fall through to view-only */ }
} }