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() {
try {
const wf = app.workflowManager?.activeWorkflow;
const wf = app.extensionManager?.workflow?.activeWorkflow;
return wf?.key || wf?.filename || wf?.path || "default";
} catch {
return "default";
@@ -1130,17 +1130,22 @@ if (window.__COMFYUI_FRONTEND_VERSION__) {
scheduleCaptureSnapshot();
});
// Listen for workflow switches
if (app.workflowManager) {
app.workflowManager.addEventListener("changeWorkflow", () => {
// Cancel any pending capture from the previous workflow
if (captureTimer) {
clearTimeout(captureTimer);
captureTimer = null;
}
viewingWorkflowKey = null;
if (sidebarRefresh) {
sidebarRefresh(true).catch(() => {});
// Listen for workflow switches via Pinia store action
const workflowStore = app.extensionManager?.workflow;
if (workflowStore?.$onAction) {
workflowStore.$onAction(({ name, after }) => {
if (name === "openWorkflow") {
after(() => {
// Cancel any pending capture from the previous workflow
if (captureTimer) {
clearTimeout(captureTimer);
captureTimer = null;
}
viewingWorkflowKey = null;
if (sidebarRefresh) {
sidebarRefresh(true).catch(() => {});
}
});
}
});
}