Fix workflow key detection — use extensionManager.workflow store

app.workflowManager doesn't exist in the modern Vue-based frontend.
The active workflow is accessed via the Pinia store at
app.extensionManager.workflow.activeWorkflow. Also replaces the
non-existent addEventListener("changeWorkflow") with Pinia's
$onAction watching for "openWorkflow" actions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 20:55:22 +01:00
parent d32349bfdf
commit 4cbd8fd0a9

View File

@@ -207,7 +207,7 @@ function quickHash(str) {
function getWorkflowKey() { function getWorkflowKey() {
try { try {
const wf = app.workflowManager?.activeWorkflow; const wf = app.extensionManager?.workflow?.activeWorkflow;
return wf?.key || wf?.filename || wf?.path || "default"; return wf?.key || wf?.filename || wf?.path || "default";
} catch { } catch {
return "default"; return "default";
@@ -1130,9 +1130,12 @@ if (window.__COMFYUI_FRONTEND_VERSION__) {
scheduleCaptureSnapshot(); scheduleCaptureSnapshot();
}); });
// Listen for workflow switches // Listen for workflow switches via Pinia store action
if (app.workflowManager) { const workflowStore = app.extensionManager?.workflow;
app.workflowManager.addEventListener("changeWorkflow", () => { if (workflowStore?.$onAction) {
workflowStore.$onAction(({ name, after }) => {
if (name === "openWorkflow") {
after(() => {
// Cancel any pending capture from the previous workflow // Cancel any pending capture from the previous workflow
if (captureTimer) { if (captureTimer) {
clearTimeout(captureTimer); clearTimeout(captureTimer);
@@ -1144,6 +1147,8 @@ if (window.__COMFYUI_FRONTEND_VERSION__) {
} }
}); });
} }
});
}
// Capture initial state after a short delay (decoupled from debounceMs) // Capture initial state after a short delay (decoupled from debounceMs)
setTimeout(() => { setTimeout(() => {