From de1f4c89bc28441e2efa7c336a7af807e33d048f Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Fri, 30 Oct 2026 05:09:26 +0000 Subject: [PATCH 1/2] fix: pick up new node types when ComfyUI reconnects after any restart (#22138) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If ComfyUI restarts while the agent panel is closed (or through `comfy launch`/`comfy stop`, or a Desktop server restart), the open tab keeps the old node definitions, and nodes from a pack installed before the restart stay missing until the page is reloaded. **Refresh Node Definitions** alone does not help, because it updates definitions but leaves nodes that already loaded as missing. Now, on every ComfyUI `/ws` reconnect (local and Desktop; cloud is skipped), the page reads `/object_info` once. If it lists node types the page has not registered, it runs **Refresh Node Definitions**. If the open workflow still holds a missing node whose type is now registered, it reloads that workflow from its current state once the user is not mid-edit, so the node is rebuilt from its definition. Unsaved edits stay in the graph and stay marked unsaved. A reconnect with no new types changes nothing. It also fixes a bug every `reloadCurrentWorkflow` caller had (Manager apply changes, the agent restart refresh, late custom nodes, the canvas): the reload reset the workflow's saved baseline to the unsaved state, so a later undo could mark a modified workflow as saved. Fixes FE-3483. Follow-up to #20903 and #21644, which cover only restarts the agent panel sees.
Design notes - Lives next to the queue refresh in `GraphView.vue`'s `reconnected` handler (`src/platform/customNodes/useReconnectNodeDefinitionRefresh.ts`, with the shared `useUserBusy` check), not in the agent extension, so it runs whether or not the agent panel was ever opened. - Detection is "new type names", checked against both `nodeDefStore` and `LiteGraph.registered_node_types`. Only the refresh depends on new types; the rebuild depends on the canvas (a placeholder node with `last_serialization` whose type is now registered, root graph or subgraph). So a refresh that registered types but then failed in an extension callback is recovered on the next reconnect, and a workflow another restart path already rebuilt is not reloaded twice. - **Saved baseline at the load boundary.** `openWorkflow` takes `keepSavedBaseline`. For a workflow that was modified before the reload, it reads the saved baseline inside the load queue right before the graph load (so a save made while the reload waited is kept), puts it back after the load finishes or throws, and derives the modified flag from content (so an edit made during post-load asset scans stays modified). If the workflow was saved during the load itself (judged by `originalContent`, which changes only after a successful write), the save wins. A clean workflow accepts the reloaded state as its baseline, as before, so a locale change or a rebuilt placeholder does not mark it modified. `reloadCurrentWorkflow` always passes it. The late custom nodes wrapper in `lateCustomNodes/lateLoading.ts` is **not** made redundant by that: it snapshots the baseline and the dirty flag before the service call, i.e. before the load queue, and restores both unconditionally afterwards, so a save that completes while the reload waits is still overwritten there. That overwrite predates this PR and is unchanged by it; `keepSavedBaseline` is what avoids it inside the service, and ADR-EXTENSION-LOADING-0048 gives the late-loading path its own clean-baseline contract, so the wrapper is left alone rather than deleted. - **Readiness at the load boundary.** The rebuild waits (polling, up to 30s) until there is no open change transaction (`changeCount`), no undo/redo restore (`_restoringState`), no held pointer (resize, drag or link gestures, which do not all open a transaction) and no focused text field. The same check runs as `isCurrent` inside the queued load, immediately before capture, so a gesture that starts while the reload waits behind another load defers it; a deferred reload retries, a reload that fails for another reason does not. Remaining gap, same as before this PR: a load that calls `app.loadGraphData` directly (file drop, paste, template) can still be ahead in the app's own graph-load queue. Tracked in https://linear.app/comfyorg/issue/FRONT-3720. - Cost: one `/object_info` read per local reconnect. Fetching only when the canvas has missing nodes would be cheaper, but then a pack installed outside the panel would not show up in node search or the library until a manual refresh. Reconnects during a check coalesce into one more check. - Known limits, tracked in https://linear.app/comfyorg/issue/FRONT-3668: (1) a restart that only changes the inputs of existing node types (an updated pack) is not detected and still needs **Refresh Node Definitions**; (2) the Manager and agent restart paths still run their own refresh on the same reconnect, so the refresh can run twice (redundant, not harmful). (3) If `/object_info` is still failing after the API client's own retries, that reconnect does nothing until the next one.
- The reconnect catalog read now goes through `app.fetchNodeDefs()` instead of casting the raw `/object_info` body to `Record`. A 200 response that is not an object of definitions used to yield fabricated type names (`"unavailable"` → types `0`..`10`), so every reconnect ran a full **Refresh Node Definitions**; `toNodeDefs` filters the container and its entries, and this file no longer imports `api` directly. One behavioural consequence worth naming: that boundary also refreshes backend node display text from the response, the same way the bootstrap and refresh paths do. - Reconnect work is now cancelled with the effect scope that started it. The idle-wait loop outlived its scope and could reload a workflow after `GraphView` had gone away, using the stale busy state of listeners VueUse had already removed; disposal is checked while polling and again at queued admission. - Unit: `src/platform/customNodes/useReconnectNodeDefinitionRefresh.test.ts` covers new type on the canvas (refresh, then rebuild with the saved baseline kept), new type not on the canvas, known types in the Vue store or LiteGraph only, subgraphs, an already-rebuilt workflow, cloud, a refused `/object_info`, a failing refresh and recovery on the next reconnect, reconnect bursts, waiting for an edit, an undo, a held pointer or a focused text field, an edit that starts while the reload is queued (retried), and a failed load (not retried). `workflowService.test.ts` covers `keepSavedBaseline`: unsaved edits stay unsaved after a reload, the baseline survives a load that throws after resetting the tracker, a save made while the reload waited or while it loaded is kept, a save whose write fails is not, and a clean workflow stays clean. - Browser: `browser_tests/tests/graph/reconnectNodeDefinitionRefresh.spec.ts` (chromium, real ComfyUI backend) loads a workflow whose node type the server lacks, closes ComfyUI's socket, serves the new type after the reconnect, and expects the node rebuilt with its widgets and saved values. Run against a local ComfyUI master: fails on `main`, passes on this branch (rerun at the current head). - New unit cases, each proven red on the code before its fix and green after: a catalog response that is not a map of definitions changes nothing (no refresh, no reload), and a rebuild waiting for an edit is dropped when the scope that started it stops. Each handler is now constructed in a disposable test scope so its real pointer listeners do not survive into later cases. - The workflow-service persistence cases assert which state became the baseline rather than only that the reference changed, and the preservation case now runs the real activation path (`afterLoadNewGraph`) with seeded undo history. Measured there, and worth recording because it reads like a regression and is not: `openWorkflow`'s pre-load `prepareForSave` captures the canvas, which appends one undo entry and clears the redo queue whenever the canvas holds uncaptured edits. That is base behaviour of every reload, so the case asserts the seeded history survives rather than that the queues are untouched. - `pnpm typecheck`, `pnpm typecheck:browser`, `fallow audit` (no new findings), `deps:audit`, `knip`, and lint-staged pass. Workflow service, late custom nodes, Manager, agent store and graph canvas unit suites pass. --------- Co-authored-by: Alexander Brown Co-authored-by: mrseek-reviews[bot] <337131926+mrseek-reviews[bot]@users.noreply.github.com> --- .../reconnectNodeDefinitionRefresh.spec.ts | 79 +++ .../useReconnectNodeDefinitionRefresh.test.ts | 458 ++++++++++++++++++ .../useReconnectNodeDefinitionRefresh.ts | 146 ++++++ src/platform/customNodes/useUserBusy.test.ts | 86 ++++ src/platform/customNodes/useUserBusy.ts | 33 ++ .../core/services/workflowService.test.ts | 144 +++++- .../workflow/core/services/workflowService.ts | 54 ++- src/views/GraphView.test.ts | 14 +- src/views/GraphView.vue | 3 + src/workbench/extensions/agent/README.md | 6 +- 10 files changed, 1007 insertions(+), 16 deletions(-) create mode 100644 browser_tests/tests/graph/reconnectNodeDefinitionRefresh.spec.ts create mode 100644 src/platform/customNodes/useReconnectNodeDefinitionRefresh.test.ts create mode 100644 src/platform/customNodes/useReconnectNodeDefinitionRefresh.ts create mode 100644 src/platform/customNodes/useUserBusy.test.ts create mode 100644 src/platform/customNodes/useUserBusy.ts diff --git a/browser_tests/tests/graph/reconnectNodeDefinitionRefresh.spec.ts b/browser_tests/tests/graph/reconnectNodeDefinitionRefresh.spec.ts new file mode 100644 index 00000000000..ecc351e557f --- /dev/null +++ b/browser_tests/tests/graph/reconnectNodeDefinitionRefresh.spec.ts @@ -0,0 +1,79 @@ +import { mergeTests } from '@playwright/test' + +import { + comfyExpect as expect, + comfyPageFixture +} from '@e2e/fixtures/ComfyPage' +import { webSocketFixture } from '@e2e/fixtures/ws' +import type { ComfyNodeDef } from '@/schemas/nodeDefSchema' +import { toNodeId } from '@/types/nodeId' + +const test = mergeTests(comfyPageFixture, webSocketFixture).extend<{ + restartedServer: { installed: boolean } +}>({ + restartedServer: async ({ page }, use) => { + const server = { installed: false } + await page.route('**/object_info', async (route) => { + const response = await route.fetch() + const defs: Record = await response.json() + if (server.installed) { + defs.BrowserProofNode = { + ...defs.KSampler, + name: 'BrowserProofNode', + display_name: 'Browser Proof Node' + } + } + await route.fulfill({ response, json: defs }) + }) + await use(server) + } +}) + +test.describe( + 'Node definitions after a ComfyUI restart', + { tag: ['@canvas', '@node'] }, + () => { + test('loads a node the restarted server now serves into the open workflow', async ({ + comfyPage, + getWebSocket, + nextWebSocket, + restartedServer + }) => { + const page = comfyPage.page + const proofNode = () => + page.evaluate((nodeId) => { + const node = window.app!.graph.getNodeById(nodeId) + return { + type: node?.type, + hasErrors: node?.has_errors === true, + hasStepsWidget: + node?.widgets?.some((widget) => widget.name === 'steps') === true, + seed: node?.widgets?.find((widget) => widget.name === 'seed')?.value + } + }, toNodeId(1)) + + await comfyPage.workflow.loadWorkflow('agent/restart_node_refresh') + await expect.poll(proofNode).toEqual({ + type: 'BrowserProofNode', + hasErrors: true, + hasStepsWidget: false, + seed: undefined + }) + + await test.step('restart ComfyUI with the node pack installed', async () => { + const socket = await getWebSocket() + const reconnected = nextWebSocket() + restartedServer.installed = true + await socket.close() + await reconnected + }) + + await expect.poll(proofNode).toEqual({ + type: 'BrowserProofNode', + hasErrors: false, + hasStepsWidget: true, + seed: 156680208700286 + }) + }) + } +) diff --git a/src/platform/customNodes/useReconnectNodeDefinitionRefresh.test.ts b/src/platform/customNodes/useReconnectNodeDefinitionRefresh.test.ts new file mode 100644 index 00000000000..4b1e2fc7b42 --- /dev/null +++ b/src/platform/customNodes/useReconnectNodeDefinitionRefresh.test.ts @@ -0,0 +1,458 @@ +import { assert, beforeEach, describe, expect, it, vi } from 'vitest' +import { effectScope } from 'vue' + +import type { LGraph } from '@/lib/litegraph/src/litegraph' +import { LGraphNode, LiteGraph } from '@/lib/litegraph/src/litegraph' +import { + createTestRootGraph, + createTestSubgraph, + createTestSubgraphNode +} from '@/lib/litegraph/src/subgraph/__fixtures__/subgraphHelpers' +import { reportError } from '@/platform/telemetry/reportError' +import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' +import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' +import type { ComfyNodeDef } from '@/schemas/nodeDefSchema' +import { api } from '@/scripts/api' +import { app } from '@/scripts/app' +import { useCommandStore } from '@/stores/commandStore' +import { useNodeDefStore } from '@/stores/nodeDefStore' +import { + createMockChangeTracker, + createMockLoadedWorkflow +} from '@/utils/__tests__/litegraphTestUtils' + +import { useReconnectNodeDefinitionRefresh as createReconnectRefresh } from './useReconnectNodeDefinitionRefresh' + +const distribution = vi.hoisted(() => ({ isCloud: false })) + +vi.mock(import('@/platform/distribution/types'), () => distribution) +vi.mock(import('@/platform/workflow/core/services/workflowService')) +vi.mock(import('@/platform/telemetry/reportError')) + +function nodeDef(name: string): ComfyNodeDef { + return { + name, + display_name: name, + category: 'test', + python_module: 'custom_nodes.test', + description: '', + input: { required: {}, optional: {} }, + output: [], + output_name: [], + output_is_list: [], + output_node: false + } +} + +function serverHas(...names: string[]) { + const defs = Object.fromEntries(names.map((name) => [name, nodeDef(name)])) + return vi + .spyOn(api, 'fetchApi') + .mockImplementation(async () => Response.json(defs)) +} + +function pageKnows(...names: string[]) { + useNodeDefStore().updateNodeDefs(names.map(nodeDef)) +} + +function node(type: string, { missing = false } = {}): LGraphNode { + const node = new LGraphNode('', type) + if (missing) node.last_serialization = node.serialize() + return node +} + +function showCanvas(...nodes: LGraphNode[]): LGraph { + const graph = createTestRootGraph() + for (const each of nodes) graph.add(each) + vi.spyOn(app, 'rootGraph', 'get').mockReturnValue(graph) + return graph +} + +function registerRefreshCommand( + refresh = vi.fn<() => Promise>(async () => {}) +) { + useCommandStore().registerCommand({ + id: 'Comfy.RefreshNodeDefinitions', + function: refresh + }) + return refresh +} + +describe('useReconnectNodeDefinitionRefresh', () => { + let scope: ReturnType + + beforeEach(() => { + const testScope = effectScope() + scope = testScope + distribution.isCloud = false + showCanvas() + useWorkflowStore().activeWorkflow = createMockLoadedWorkflow({ + path: 'workflows/open.json', + changeTracker: createMockChangeTracker({ changeCount: 0 }) + }) + vi.mocked(useWorkflowService().openWorkflow).mockResolvedValue(true) + return () => testScope.stop() + }) + + function useReconnectNodeDefinitionRefresh() { + const handler = scope.run(createReconnectRefresh) + assert.exists(handler) + return handler + } + + it('refreshes node definitions and reloads the open workflow when the server came back with a node the canvas shows as missing', async () => { + const order: string[] = [] + registerRefreshCommand( + vi.fn(async () => { + pageKnows('KSampler', 'NewPackNode') + order.push('refresh') + }) + ) + vi.mocked(useWorkflowService().openWorkflow).mockImplementation( + async () => { + order.push('reload') + return true + } + ) + pageKnows('KSampler') + showCanvas(node('KSampler'), node('NewPackNode', { missing: true })) + serverHas('KSampler', 'NewPackNode') + + await useReconnectNodeDefinitionRefresh()() + + expect(order).toEqual(['refresh', 'reload']) + expect(useWorkflowService().openWorkflow).toHaveBeenCalledWith( + useWorkflowStore().activeWorkflow, + expect.objectContaining({ force: true, keepSavedBaseline: true }) + ) + }) + + it('refreshes node definitions but keeps the open workflow when the new node is not on the canvas', async () => { + const refresh = registerRefreshCommand() + pageKnows('KSampler') + showCanvas(node('KSampler')) + serverHas('KSampler', 'NewPackNode') + + await useReconnectNodeDefinitionRefresh()() + + expect(refresh).toHaveBeenCalledOnce() + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + }) + + it.for([ + { + registry: 'Vue store', + types: ['KSampler', 'CLIPTextEncode'], + registerKnownTypes: pageKnows + }, + { + registry: 'LiteGraph only', + types: ['FrontendOnlyNode'], + registerKnownTypes: (...types: string[]) => { + for (const type of types) { + LiteGraph.registerNodeType(type, class extends LGraphNode {}) + } + } + } + ])( + 'does nothing for types already in $registry', + async ({ types, registerKnownTypes }) => { + const refresh = registerRefreshCommand() + registerKnownTypes(...types) + showCanvas(...types.map((type) => node(type))) + serverHas(...types) + + await useReconnectNodeDefinitionRefresh()() + + expect(refresh).not.toHaveBeenCalled() + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + } + ) + + it('rebuilds a missing node inside a subgraph', async () => { + const refresh = registerRefreshCommand( + vi.fn(async () => pageKnows('NewPackNode')) + ) + const rootGraph = showCanvas() + const subgraph = createTestSubgraph({ rootGraph }) + subgraph.add(node('NewPackNode', { missing: true })) + rootGraph.add(createTestSubgraphNode(subgraph)) + serverHas('NewPackNode') + + await useReconnectNodeDefinitionRefresh()() + + expect(refresh).toHaveBeenCalledOnce() + expect(useWorkflowService().openWorkflow).toHaveBeenCalledOnce() + }) + + it('keeps the open workflow when another refresh already rebuilt its missing nodes', async () => { + const graph = showCanvas(node('NewPackNode', { missing: true })) + registerRefreshCommand( + vi.fn(async () => { + pageKnows('NewPackNode') + graph.clear() + graph.add(node('NewPackNode')) + }) + ) + serverHas('NewPackNode') + + await useReconnectNodeDefinitionRefresh()() + + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + }) + + it('keeps the open workflow when the refresh resolves without registering the new type', async () => { + const refresh = registerRefreshCommand() + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + + await useReconnectNodeDefinitionRefresh()() + + expect(refresh).toHaveBeenCalledOnce() + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + }) + + it('reloads the checked workflow only while it is still the active one', async () => { + registerRefreshCommand(vi.fn(async () => pageKnows('NewPackNode'))) + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + const checked = useWorkflowStore().activeWorkflow + + await useReconnectNodeDefinitionRefresh()() + + const [workflow, options] = vi.mocked(useWorkflowService().openWorkflow) + .mock.calls[0] + expect(workflow).toBe(checked) + expect(options).toMatchObject({ force: true }) + expect(options?.isCurrent?.()).toBe(true) + useWorkflowStore().activeWorkflow = createMockLoadedWorkflow({ + path: 'workflows/other.json' + }) + expect(options?.isCurrent?.()).toBe(false) + }) + + it('does not fetch node definitions on cloud', async () => { + distribution.isCloud = true + const refresh = registerRefreshCommand() + const fetchDefs = serverHas('NewPackNode') + + await useReconnectNodeDefinitionRefresh()() + + expect(fetchDefs).not.toHaveBeenCalled() + expect(refresh).not.toHaveBeenCalled() + }) + + it('does nothing when the server refuses the node definitions', async () => { + const refresh = registerRefreshCommand() + vi.spyOn(api, 'fetchApi').mockResolvedValue( + new Response('down', { status: 503 }) + ) + + await useReconnectNodeDefinitionRefresh()() + + expect(refresh).not.toHaveBeenCalled() + expect(reportError).not.toHaveBeenCalled() + }) + + it('does nothing when the node definitions come back as something other than definitions', async () => { + const refresh = registerRefreshCommand() + vi.spyOn(api, 'fetchApi').mockResolvedValue(Response.json('unavailable')) + + await useReconnectNodeDefinitionRefresh()() + + expect(refresh).not.toHaveBeenCalled() + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + }) + + it('reports a failed refresh and keeps the open workflow', async () => { + const failure = new Error('refresh failed') + registerRefreshCommand( + vi.fn<() => Promise>().mockRejectedValue(failure) + ) + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + + await expect(useReconnectNodeDefinitionRefresh()()).resolves.toBeUndefined() + + expect(reportError).toHaveBeenCalledOnce() + expect(reportError).toHaveBeenCalledWith( + failure, + expect.objectContaining({ + errorType: 'failure_refreshing_node_definitions_after_reconnect' + }) + ) + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + }) + + it('checks once more when ComfyUI reconnects again during a check', async () => { + const refresh = registerRefreshCommand( + vi.fn(async () => pageKnows('NewPackNode')) + ) + let resolveFirst!: (response: Response) => void + const fetchDefs = vi + .spyOn(api, 'fetchApi') + .mockImplementationOnce( + () => + new Promise((resolve) => { + resolveFirst = resolve + }) + ) + .mockImplementation(async () => + Response.json({ NewPackNode: nodeDef('NewPackNode') }) + ) + + const onReconnected = useReconnectNodeDefinitionRefresh() + const first = onReconnected() + const second = onReconnected() + const third = onReconnected() + expect(fetchDefs).toHaveBeenCalledOnce() + resolveFirst(Response.json({})) + await Promise.all([first, second, third]) + + expect(fetchDefs).toHaveBeenCalledTimes(2) + expect(refresh).toHaveBeenCalledOnce() + + await onReconnected() + + expect(fetchDefs).toHaveBeenCalledTimes(3) + }) + + it('rebuilds missing nodes on a later reconnect after a refresh registered their type but then failed', async () => { + registerRefreshCommand( + vi.fn(async () => { + pageKnows('NewPackNode') + throw new Error('an extension refresh callback failed') + }) + ) + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + const onReconnected = useReconnectNodeDefinitionRefresh() + + await onReconnected() + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + + await onReconnected() + expect(useWorkflowService().openWorkflow).toHaveBeenCalledOnce() + }) + + it.for([ + { + busy: 'an edit in progress', + start: () => { + useWorkflowStore().activeWorkflow!.changeTracker.changeCount = 1 + return () => { + useWorkflowStore().activeWorkflow!.changeTracker.changeCount = 0 + } + } + }, + { + busy: 'an undo or redo', + start: () => { + useWorkflowStore().activeWorkflow!.changeTracker._restoringState = true + return () => { + useWorkflowStore().activeWorkflow!.changeTracker._restoringState = false + } + } + }, + { + busy: 'a held pointer', + start: () => { + window.dispatchEvent(new PointerEvent('pointerdown')) + return () => window.dispatchEvent(new PointerEvent('pointerup')) + } + }, + { + busy: 'a focused text field', + start: () => { + const input = document.createElement('input') + document.body.append(input) + input.focus() + return () => input.remove() + } + } + ])('waits for $busy to finish before rebuilding', async ({ start }) => { + registerRefreshCommand(vi.fn(async () => pageKnows('NewPackNode'))) + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + const onReconnected = useReconnectNodeDefinitionRefresh() + const finish = start() + + const done = onReconnected() + await vi.advanceTimersByTimeAsync(1_000) + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + + finish() + await vi.advanceTimersByTimeAsync(200) + await done + expect(useWorkflowService().openWorkflow).toHaveBeenCalledOnce() + }) + + it('retries the rebuild when an edit starts while it waits behind another load', async () => { + registerRefreshCommand(vi.fn(async () => pageKnows('NewPackNode'))) + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + const tracker = useWorkflowStore().activeWorkflow!.changeTracker + const openWorkflow = vi.mocked(useWorkflowService().openWorkflow) + openWorkflow.mockImplementationOnce(async (_workflow, options) => { + tracker.changeCount = 1 + return options?.isCurrent?.() ?? true + }) + + const done = useReconnectNodeDefinitionRefresh()() + await vi.advanceTimersByTimeAsync(1_000) + expect(openWorkflow).toHaveBeenCalledOnce() + + tracker.changeCount = 0 + await vi.advanceTimersByTimeAsync(200) + await done + expect(openWorkflow).toHaveBeenCalledTimes(2) + }) + + it('does not retry a rebuild whose load failed', async () => { + registerRefreshCommand(vi.fn(async () => pageKnows('NewPackNode'))) + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + const openWorkflow = vi.mocked(useWorkflowService().openWorkflow) + openWorkflow.mockImplementation(async (_workflow, options) => { + options?.isCurrent?.() + return false + }) + + const done = useReconnectNodeDefinitionRefresh()() + await vi.advanceTimersByTimeAsync(1_000) + await done + + expect(openWorkflow).toHaveBeenCalledOnce() + }) + + it('drops a waiting rebuild when the view that started it goes away', async () => { + registerRefreshCommand(vi.fn(async () => pageKnows('NewPackNode'))) + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + const onReconnected = useReconnectNodeDefinitionRefresh() + const tracker = useWorkflowStore().activeWorkflow!.changeTracker + tracker.changeCount = 1 + + const done = onReconnected() + await vi.advanceTimersByTimeAsync(200) + scope.stop() + tracker.changeCount = 0 + await vi.advanceTimersByTimeAsync(1_000) + await done + + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + }) + + it('skips the rebuild when an edit stays in progress', async () => { + registerRefreshCommand(vi.fn(async () => pageKnows('NewPackNode'))) + showCanvas(node('NewPackNode', { missing: true })) + serverHas('NewPackNode') + useWorkflowStore().activeWorkflow!.changeTracker.changeCount = 1 + + const done = useReconnectNodeDefinitionRefresh()() + await vi.advanceTimersByTimeAsync(31_000) + await done + + expect(useWorkflowService().openWorkflow).not.toHaveBeenCalled() + }) +}) diff --git a/src/platform/customNodes/useReconnectNodeDefinitionRefresh.ts b/src/platform/customNodes/useReconnectNodeDefinitionRefresh.ts new file mode 100644 index 00000000000..8f3fcbad22c --- /dev/null +++ b/src/platform/customNodes/useReconnectNodeDefinitionRefresh.ts @@ -0,0 +1,146 @@ +import { delay } from 'es-toolkit' +import { getCurrentScope } from 'vue' +import type { ComputedRef } from 'vue' + +import { LiteGraph } from '@/lib/litegraph/src/litegraph' +import { isCloud } from '@/platform/distribution/types' +import { reportError } from '@/platform/telemetry/reportError' +import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' +import type { LoadedComfyWorkflow } from '@/platform/workflow/management/stores/comfyWorkflow' +import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' +import { api } from '@/scripts/api' +import { app } from '@/scripts/app' +import { useCommandStore } from '@/stores/commandStore' +import { useNodeDefStore } from '@/stores/nodeDefStore' +import { forEachNode } from '@/utils/graphTraversalUtil' + +import { useUserBusy } from './useUserBusy' + +const IDLE_POLL_MS = 100 +const IDLE_TIMEOUT_MS = 30_000 + +function isNodeDefEntry(entry: [string, unknown]): boolean { + const def = entry[1] + return ( + typeof def === 'object' && + def !== null && + typeof (def as { name?: unknown }).name === 'string' + ) +} + +async function fetchServerNodeTypes(): Promise { + try { + const response = await api.fetchApi('/object_info', { cache: 'no-store' }) + if (!response.ok) return undefined + const body: unknown = await response.json() + if (typeof body !== 'object' || body === null || Array.isArray(body)) + return [] + return Object.entries(body) + .filter(isNodeDefEntry) + .map(([type]) => type) + } catch { + return undefined + } +} + +function isRegistered(type: string): boolean { + return ( + type in useNodeDefStore().nodeDefsByName || + type in LiteGraph.registered_node_types + ) +} + +function canvasHasRebuildablePlaceholder(): boolean { + let found = false + forEachNode(app.rootGraph, (node) => { + if (found || node.last_serialization === undefined) return + if (isRegistered(node.type)) found = true + }) + return found +} + +async function rebuildWhenIdle( + workflow: LoadedComfyWorkflow, + userBusy: ComputedRef, + isDisposed: () => boolean +): Promise { + const workflowStore = useWorkflowStore() + const isActive = () => + !isDisposed() && workflowStore.activeWorkflow === workflow + const isIdle = () => + workflow.changeTracker.changeCount === 0 && + !workflow.changeTracker._restoringState && + !userBusy.value + const deadline = Date.now() + IDLE_TIMEOUT_MS + while (isActive() && canvasHasRebuildablePlaceholder()) { + if (isIdle()) { + const attempt = { deferred: false } + const rebuilt = await useWorkflowService().openWorkflow(workflow, { + force: true, + isCurrent: () => { + attempt.deferred = !(isActive() && isIdle()) + return !attempt.deferred + }, + keepSavedBaseline: true + }) + if (rebuilt || !attempt.deferred) return + } + if (Date.now() >= deadline) return + await delay(IDLE_POLL_MS) + } +} + +/** + * Returns the `reconnected` handler that loads node types a restarted local + * ComfyUI added, and rebuilds the open workflow's missing nodes from them. + */ +export function useReconnectNodeDefinitionRefresh() { + if (isCloud) return async () => {} + + const userBusy = useUserBusy() + const scope = getCurrentScope() + const isDisposed = () => scope?.active === false + let inFlight: Promise | null = null + let reconnects = 0 + + async function refreshAndRebuild(): Promise { + if (isDisposed()) return + const serverTypes = await fetchServerNodeTypes() + if (!serverTypes || isDisposed()) return + if (serverTypes.some((type) => !isRegistered(type))) { + await useCommandStore().execute('Comfy.RefreshNodeDefinitions', { + errorHandler: (error) => { + throw error + } + }) + } + if (isDisposed()) return + const workflow = useWorkflowStore().activeWorkflow + if (workflow) await rebuildWhenIdle(workflow, userBusy, isDisposed) + } + + async function refreshUntilSettled(): Promise { + let handled: number + do { + handled = reconnects + try { + await refreshAndRebuild() + } catch (error) { + reportError(error, { + surface: 'graph', + errorType: 'failure_refreshing_node_definitions_after_reconnect', + level: 'warning' + }) + } + } while (handled !== reconnects) + } + + return async function refreshNodeDefinitionsOnReconnect(): Promise { + reconnects += 1 + if (inFlight) return inFlight + inFlight = refreshUntilSettled().finally(() => { + inFlight = null + }) + return inFlight + } +} diff --git a/src/platform/customNodes/useUserBusy.test.ts b/src/platform/customNodes/useUserBusy.test.ts new file mode 100644 index 00000000000..c6ccd395d33 --- /dev/null +++ b/src/platform/customNodes/useUserBusy.test.ts @@ -0,0 +1,86 @@ +import { afterEach, assert, describe, expect, it } from 'vitest' +import { effectScope, nextTick } from 'vue' + +import { useUserBusy } from './useUserBusy' + +describe('useUserBusy', () => { + const scopes: ReturnType[] = [] + + afterEach(() => { + for (const scope of scopes.splice(0)) scope.stop() + document.body.replaceChildren() + }) + + function watchUserBusy() { + const scope = effectScope() + scopes.push(scope) + const userBusy = scope.run(useUserBusy) + assert.exists(userBusy) + return userBusy + } + + function focusedField(tag: 'input' | 'textarea' | 'div') { + const field = document.createElement(tag) + if (tag === 'div') field.contentEditable = 'true' + document.body.append(field) + field.focus() + return field + } + + it('is busy while a pointer is held, even over a canvas that stops propagation', () => { + const userBusy = watchUserBusy() + const canvas = document.createElement('canvas') + document.body.append(canvas) + canvas.addEventListener('pointerdown', (event) => event.stopPropagation(), { + capture: true + }) + + canvas.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true })) + expect(userBusy.value).toBe(true) + + window.dispatchEvent(new PointerEvent('pointerup')) + expect(userBusy.value).toBe(false) + }) + + it('stops being busy when a held pointer is cancelled', () => { + const userBusy = watchUserBusy() + + window.dispatchEvent(new PointerEvent('pointerdown')) + window.dispatchEvent(new PointerEvent('pointercancel')) + + expect(userBusy.value).toBe(false) + }) + + it.for(['input', 'textarea', 'div'] as const)( + 'is busy while a %s holds focus', + (tag) => { + const userBusy = watchUserBusy() + + const field = focusedField(tag) + expect(userBusy.value).toBe(true) + + field.blur() + expect(userBusy.value).toBe(false) + } + ) + + it('stops being busy when a focused field is removed without blurring', async () => { + const userBusy = watchUserBusy() + const field = focusedField('input') + expect(userBusy.value).toBe(true) + + field.remove() + await nextTick() + + expect(userBusy.value).toBe(false) + }) + + it('stops reporting after its scope is disposed', () => { + const userBusy = watchUserBusy() + + scopes[0].stop() + window.dispatchEvent(new PointerEvent('pointerdown')) + + expect(userBusy.value).toBe(false) + }) +}) diff --git a/src/platform/customNodes/useUserBusy.ts b/src/platform/customNodes/useUserBusy.ts new file mode 100644 index 00000000000..0bd54e687a0 --- /dev/null +++ b/src/platform/customNodes/useUserBusy.ts @@ -0,0 +1,33 @@ +import { useActiveElement, useEventListener } from '@vueuse/core' +import { computed, ref } from 'vue' +import type { ComputedRef } from 'vue' + +function isTextField(element: Element | null | undefined): boolean { + return ( + element instanceof HTMLInputElement || + element instanceof HTMLTextAreaElement || + (element instanceof HTMLElement && element.isContentEditable) + ) +} + +export function useUserBusy(): ComputedRef { + const pointerHeld = ref(false) + const activeElement = useActiveElement({ triggerOnRemoval: true }) + useEventListener( + window, + 'pointerdown', + () => { + pointerHeld.value = true + }, + { capture: true } + ) + useEventListener( + window, + ['pointerup', 'pointercancel'], + () => { + pointerHeld.value = false + }, + { capture: true } + ) + return computed(() => pointerHeld.value || isTextField(activeElement.value)) +} diff --git a/src/platform/workflow/core/services/workflowService.test.ts b/src/platform/workflow/core/services/workflowService.test.ts index 0b50a8bd3d8..699857724c8 100644 --- a/src/platform/workflow/core/services/workflowService.test.ts +++ b/src/platform/workflow/core/services/workflowService.test.ts @@ -4,7 +4,7 @@ import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' // oxlint-di import { useWorkflowDraftStoreV2 } from '@/platform/workflow/persistence/stores/workflowDraftStoreV2' import { useDomWidgetStore } from '@/stores/domWidgetStore' -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, assert, beforeEach, describe, expect, it, vi } from 'vitest' import { fromAny } from '@total-typescript/shoehorn' @@ -523,6 +523,148 @@ describe('useWorkflowService', () => { ) }) + describe('keepSavedBaseline', () => { + function openEditedWorkflow() { + const saved = makeWorkflowData({ saved: true }) + const workflow = createModeTestWorkflow() + workflow.changeTracker = new ChangeTracker(workflow, saved) + workflow.changeTracker.activeState = makeWorkflowData({ + saved: true, + unsavedEdit: true + }) + workflow.isModified = true + useWorkflowStore().activeWorkflow = workflow + app.rootGraph.extra.unsavedEdit = true + vi.mocked(app.loadGraphData).mockImplementation(async (data) => { + workflow.changeTracker.reset(data) + workflow.isModified = false + return true + }) + return { workflow, saved } + } + + it('keeps unsaved edits and history after a reload', async () => { + const { workflow, saved } = openEditedWorkflow() + const undo = makeWorkflowData({ previousEdit: true }) + workflow.changeTracker.undoQueue = [undo] + vi.mocked(app.loadGraphData).mockImplementation(async (data) => { + assert.exists(data) + await useWorkflowService().afterLoadNewGraph(workflow, data) + return true + }) + + await useWorkflowService().reloadCurrentWorkflow() + + expect(workflow.changeTracker.initialState).toBe(saved) + expect(workflow.changeTracker.activeState.extra).toMatchObject({ + unsavedEdit: true + }) + expect(workflow.changeTracker.undoQueue).toContainEqual(undo) + expect(workflow.isModified).toBe(true) + }) + + it('keeps the saved baseline when the reload throws after resetting the tracker', async () => { + const { workflow, saved } = openEditedWorkflow() + vi.mocked(app.loadGraphData).mockImplementation(async (data) => { + workflow.changeTracker.reset(data) + throw new Error('afterLoadNewGraph failed') + }) + + await expect( + useWorkflowService().openWorkflow(workflow, { + force: true, + keepSavedBaseline: true + }) + ).rejects.toThrow('afterLoadNewGraph failed') + + expect(workflow.changeTracker.initialState).toBe(saved) + expect(workflow.isModified).toBe(true) + }) + + it('keeps a save made while the reload waited behind another load', async () => { + const { workflow } = openEditedWorkflow() + const other = createModeTestWorkflow({ path: 'workflows/other.json' }) + let releaseOther = () => {} + vi.mocked(app.loadGraphData).mockImplementationOnce( + () => + new Promise((resolve) => { + releaseOther = () => resolve(true) + }) + ) + const otherLoad = useWorkflowService().openWorkflow(other) + const reload = useWorkflowService().openWorkflow(workflow, { + force: true, + keepSavedBaseline: true + }) + await vi.waitFor(() => expect(app.loadGraphData).toHaveBeenCalled()) + + workflow.changeTracker.prepareForSave() + const savedNow = workflow.changeTracker.activeState + workflow.changeTracker.reset() + workflow.isModified = false + releaseOther() + await Promise.all([otherLoad, reload]) + + expect(workflow.changeTracker.initialState).toEqual(savedNow) + expect(workflow.isModified).toBe(false) + }) + + it('keeps a clean workflow clean when the reloaded graph serializes differently', async () => { + const { workflow } = openEditedWorkflow() + workflow.isModified = false + + await useWorkflowService().reloadCurrentWorkflow() + + expect(workflow.changeTracker.initialState).toEqual( + workflow.changeTracker.activeState + ) + expect(workflow.isModified).toBe(false) + }) + + it('keeps a save made while the reload was loading', async () => { + const { workflow } = openEditedWorkflow() + vi.mocked(app.loadGraphData).mockImplementation(async (data) => { + workflow.changeTracker.reset(data) + workflow.originalContent = workflow.content = JSON.stringify(data) + workflow.isModified = false + return true + }) + + await useWorkflowService().reloadCurrentWorkflow() + + expect(workflow.changeTracker.initialState).toEqual( + workflow.changeTracker.activeState + ) + expect(workflow.isModified).toBe(false) + }) + + it('keeps the saved baseline when a save during the reload fails to write', async () => { + const { workflow, saved } = openEditedWorkflow() + vi.mocked(app.loadGraphData).mockImplementation(async (data) => { + workflow.changeTracker.reset(data) + workflow.content = JSON.stringify(data) + workflow.isModified = false + return true + }) + + await useWorkflowService().reloadCurrentWorkflow() + + expect(workflow.changeTracker.initialState).toBe(saved) + expect(workflow.isModified).toBe(true) + }) + + it('resets the baseline to the reloaded state without the option', async () => { + const { workflow } = openEditedWorkflow() + + await useWorkflowService().openWorkflow(workflow, { force: true }) + + expect(workflow.changeTracker.initialState).toEqual( + workflow.changeTracker.activeState + ) + expect(workflow.isModified).toBe(false) + }) + }) + describe('reloadCurrentWorkflow during a tab switch', () => { let previous: LoadedComfyWorkflow let next: LoadedComfyWorkflow diff --git a/src/platform/workflow/core/services/workflowService.ts b/src/platform/workflow/core/services/workflowService.ts index 7a82a59212b..0841506d636 100644 --- a/src/platform/workflow/core/services/workflowService.ts +++ b/src/platform/workflow/core/services/workflowService.ts @@ -26,6 +26,7 @@ import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/w // oxlint-disable-next-line comfy/no-restricted-paths import { useWorkflowThumbnail } from '@/renderer/core/thumbnail/useWorkflowThumbnail' import { useApp } from '@/scripts/appInstance' +import { ChangeTracker } from '@/scripts/changeTracker' import { blankGraph, defaultGraph } from '@/scripts/defaultGraph' import { useDialogService } from '@/services/dialogService' import { useAppMode } from '@/composables/useAppMode' @@ -133,6 +134,26 @@ function resetAndRestoreTracker( return true } +async function keepingSavedBaseline( + workflow: ComfyWorkflow, + load: () => Promise +): Promise { + const savedState = workflow.changeTracker?.initialState + const savedContent = workflow.originalContent + try { + return await load() + } finally { + const tracker = workflow.changeTracker + if (tracker && savedState && workflow.originalContent === savedContent) { + tracker.initialState = savedState + workflow.isModified = !ChangeTracker.graphEqual( + savedState, + tracker.activeState + ) + } + } +} + /** @internal Test-only: clears the module-level load queue between tests. */ export function resetWorkflowLoadQueueForTests(): { pendingLoads: number @@ -401,7 +422,8 @@ export const useWorkflowService = () => { if (workflow) { await openWorkflow(workflow, { force: true, - isCurrent: () => workflowStore.activeWorkflow === workflow + isCurrent: () => workflowStore.activeWorkflow === workflow, + keepSavedBaseline: true }) } } @@ -462,6 +484,7 @@ export const useWorkflowService = () => { force?: boolean navigationIntentId?: number isCurrent?: () => boolean + keepSavedBaseline?: boolean } = {} ): Promise => { if (options.isCurrent?.() === false) return Promise.resolve(false) @@ -496,18 +519,23 @@ export const useWorkflowService = () => { } workflow.changeTracker?.prepareForSave() - const loaded = await useApp().loadGraphData( - toRaw(workflow.activeState) as ComfyWorkflowJSON, - /* clean=*/ true, - /* restore_view=*/ true, - workflow, - { - checkForRerouteMigration: false, - deferWarnings: true, - skipAssetScans: !loadFromRemote && !options.force, - workflowNavigationId: navigationIntentId - } - ) + const load = () => + useApp().loadGraphData( + toRaw(workflow.activeState) as ComfyWorkflowJSON, + true, + true, + workflow, + { + checkForRerouteMigration: false, + deferWarnings: true, + skipAssetScans: !loadFromRemote && !options.force, + workflowNavigationId: navigationIntentId + } + ) + const loaded = + options.keepSavedBaseline && workflow.isModified + ? await keepingSavedBaseline(workflow, load) + : await load() if (loaded === false) { useSubgraphNavigationStore().endWorkflowNavigation(navigationIntentId) await restoreRetainedWorkflow(workflow) diff --git a/src/views/GraphView.test.ts b/src/views/GraphView.test.ts index ff3a2276667..ced6a13fe2b 100644 --- a/src/views/GraphView.test.ts +++ b/src/views/GraphView.test.ts @@ -5,6 +5,7 @@ import { createI18n } from 'vue-i18n' import { useReconnectQueueRefresh } from '@/composables/useReconnectQueueRefresh' import { useReconnectingNotification } from '@/composables/useReconnectingNotification' import type * as DistributionTypes from '@/platform/distribution/types' +import { useReconnectNodeDefinitionRefresh } from '@/platform/customNodes/useReconnectNodeDefinitionRefresh' import { useVersionCompatibilityStore } from '@/platform/updates/common/versionCompatibilityStore' import { app } from '@/scripts/app' import { useAssetsStore } from '@/stores/assetsStore' @@ -88,6 +89,16 @@ vi.mock( () => ({ registerCoreBottomPanelTabs: vi.fn(async () => {}) }) ) +vi.mock( + import('@/platform/customNodes/useReconnectNodeDefinitionRefresh'), + () => { + const refreshNodeDefinitionsOnReconnect = vi.fn(async () => {}) + return { + useReconnectNodeDefinitionRefresh: () => refreshNodeDefinitionsOnReconnect + } + } +) + vi.mock(import('@/composables/useReconnectQueueRefresh'), () => { const refreshOnReconnect = vi.fn(async () => {}) return { useReconnectQueueRefresh: () => refreshOnReconnect } @@ -240,7 +251,7 @@ describe('GraphView - reconnect wiring', () => { delete window.__comfyDesktop2 }) - it('wires the reconnected event to the toast and queue refresh', () => { + it('wires the reconnected event to the toast, queue refresh and node definition refresh', () => { render(GraphView, { global: { plugins: [i18n] } }) apiMock.dispatchEvent(new Event('reconnected')) @@ -250,6 +261,7 @@ describe('GraphView - reconnect wiring', () => { // only hid how long the import above was taking. expect(useReconnectingNotification().onReconnected).toHaveBeenCalledTimes(1) expect(useReconnectQueueRefresh()).toHaveBeenCalledTimes(1) + expect(useReconnectNodeDefinitionRefresh()).toHaveBeenCalledTimes(1) }) it('reconciles a completed template input without a page refresh', async () => { diff --git a/src/views/GraphView.vue b/src/views/GraphView.vue index 9efb39eac71..341add28822 100644 --- a/src/views/GraphView.vue +++ b/src/views/GraphView.vue @@ -63,6 +63,7 @@ import { registerCoreSidebarTabs } from '@/composables/sidebarTabs/registerCoreS import { useBrowserTabTitle } from '@/composables/useBrowserTabTitle' import { useCoreCommands } from '@/composables/useCoreCommands' import { useQueuePolling } from '@/platform/remote/comfyui/useQueuePolling' +import { useReconnectNodeDefinitionRefresh } from '@/platform/customNodes/useReconnectNodeDefinitionRefresh' import { useErrorHandling } from '@/composables/useErrorHandling' import { useReconnectQueueRefresh } from '@/composables/useReconnectQueueRefresh' import { useReconnectingNotification } from '@/composables/useReconnectingNotification' @@ -307,9 +308,11 @@ const onExecutionSuccess = async () => { const { onReconnecting, onReconnected } = useReconnectingNotification() const refreshOnReconnect = useReconnectQueueRefresh() +const refreshNodeDefinitionsOnReconnect = useReconnectNodeDefinitionRefresh() const handleReconnected = async () => { onReconnected() + void refreshNodeDefinitionsOnReconnect() await refreshOnReconnect() } diff --git a/src/workbench/extensions/agent/README.md b/src/workbench/extensions/agent/README.md index 0862091d04e..10b4d2bd0d2 100644 --- a/src/workbench/extensions/agent/README.md +++ b/src/workbench/extensions/agent/README.md @@ -17,7 +17,11 @@ own "Update requested" and "Node definitions updated" toasts. A failed refresh runs again on the next reconnect in the window. A reconnect outside the window does nothing, so if none comes within it the store does nothing, and **Refresh Node Definitions** recovers definitions. A restart made while the panel is -closed is not observed. +closed is not observed here; outside the agent, +`platform/customNodes/useReconnectNodeDefinitionRefresh.ts` (wired in +`GraphView.vue`, local only) checks `/object_info` on every reconnect and, when +it lists node types the page lacks, refreshes definitions and reloads the open +workflow if it holds one of them. ## Activation and consent From 19e37c23ba1fa17b8f146884b91eab794a59fe62 Mon Sep 17 00:00:00 2001 From: bymyself Date: Fri, 30 Oct 2026 06:23:16 +0000 Subject: [PATCH 2/2] fix: call graphEqual through the tracker instance to avoid an import cycle On core/1.57 a value import of ChangeTracker in workflowService closes workflowService -> changeTracker -> subgraphNavigationStore -> workflowService, which fallow reports and the preflight gate fails on. Import the type only and reach the static through the tracker's constructor. --- src/platform/workflow/core/services/workflowService.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/platform/workflow/core/services/workflowService.ts b/src/platform/workflow/core/services/workflowService.ts index 0841506d636..c3b9f730400 100644 --- a/src/platform/workflow/core/services/workflowService.ts +++ b/src/platform/workflow/core/services/workflowService.ts @@ -26,7 +26,7 @@ import type { ComfyWorkflowJSON } from '@/platform/workflow/validation/schemas/w // oxlint-disable-next-line comfy/no-restricted-paths import { useWorkflowThumbnail } from '@/renderer/core/thumbnail/useWorkflowThumbnail' import { useApp } from '@/scripts/appInstance' -import { ChangeTracker } from '@/scripts/changeTracker' +import type { ChangeTracker } from '@/scripts/changeTracker' import { blankGraph, defaultGraph } from '@/scripts/defaultGraph' import { useDialogService } from '@/services/dialogService' import { useAppMode } from '@/composables/useAppMode' @@ -146,10 +146,8 @@ async function keepingSavedBaseline( const tracker = workflow.changeTracker if (tracker && savedState && workflow.originalContent === savedContent) { tracker.initialState = savedState - workflow.isModified = !ChangeTracker.graphEqual( - savedState, - tracker.activeState - ) + const Tracker = tracker.constructor as typeof ChangeTracker + workflow.isModified = !Tracker.graphEqual(savedState, tracker.activeState) } } }