From 5fa0401acdf940439e19b448caf9389c6949f25a Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Fri, 9 May 2025 14:58:16 +1000 Subject: [PATCH] Fix workflow Export missing viewport scale/offset (#3828) --- src/services/workflowService.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/services/workflowService.ts b/src/services/workflowService.ts index 0536354b1..2527d99ef 100644 --- a/src/services/workflowService.ts +++ b/src/services/workflowService.ts @@ -36,6 +36,21 @@ export const useWorkflowService = () => { } return defaultName } + + /** + * Adds scale and offset from litegraph canvas to the workflow JSON. + * @param workflow The workflow to add the view restore data to + */ + function addViewRestore(workflow: ComfyWorkflowJSON) { + if (!settingStore.get('Comfy.EnableWorkflowViewRestore')) return + + const { offset, scale } = app.canvas.ds + const [x, y] = offset + + workflow.extra ??= {} + workflow.extra.ds = { scale, offset: [x, y] } + } + /** * Export the current workflow as a JSON file * @param filename The filename to save the workflow as @@ -50,6 +65,8 @@ export const useWorkflowService = () => { filename = workflow.filename } const p = await app.graphToPrompt() + + addViewRestore(p.workflow) const json = JSON.stringify(p[promptProperty], null, 2) const blob = new Blob([json], { type: 'application/json' }) const file = await getFilename(filename)