From 490af1d28653e48826b3d25eebdd067d8fb96fc6 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 14 Oct 2026 14:10:26 -0400 Subject: [PATCH 01/15] fix(models): show the selected deployment's Release models --- src/components/graph/GraphCanvas.test.ts | 58 ++++++++++++++ src/components/graph/GraphCanvas.vue | 6 ++ src/locales/en/main.json | 1 + .../assets/services/assetService.test.ts | 19 +++++ src/platform/assets/services/assetService.ts | 5 +- .../composables/waitForDeploymentPick.ts | 20 +++++ .../useComboWidget.deployment.test.ts | 80 +++++++++++++++++++ src/stores/modelStore.test.ts | 52 ++++++++++++ src/stores/modelStore.ts | 22 ++--- 9 files changed, 251 insertions(+), 12 deletions(-) create mode 100644 src/platform/workspace/composables/waitForDeploymentPick.ts create mode 100644 src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.deployment.test.ts diff --git a/src/components/graph/GraphCanvas.test.ts b/src/components/graph/GraphCanvas.test.ts index acf0397487e..3602b3992f2 100644 --- a/src/components/graph/GraphCanvas.test.ts +++ b/src/components/graph/GraphCanvas.test.ts @@ -18,6 +18,9 @@ import { IS_CONTROL_WIDGET } from '@/core/graph/widgets/controlWidgetMarker' import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' import { useSettingStore } from '@/platform/settings/settingStore' +import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' +import { DEPLOYMENT_LISTING_BACKSTOP_MS } from '@/platform/workspace/api/deploymentListingTimeouts' +import { useToast } from '@/components/ui/toast/toastStore' import { useReleaseStore } from '@/platform/updates/common/releaseStore' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' @@ -29,6 +32,15 @@ import { toNodeId } from '@/types/nodeId' import { createNodeLocatorId } from '@/types/nodeIdentification' import GraphCanvas from './GraphCanvas.vue' +const distribution = vi.hoisted(() => ({ isCloud: false })) +vi.mock(import('@/platform/distribution/types'), () => ({ + DISTRIBUTION: 'localhost' as const, + isDesktop: false, + isNightly: false, + get isCloud() { + return distribution.isCloud + } +})) const agentDocked = { value: true } vi.mock( import('@/workbench/extensions/agent/composables/useAgentDockMount'), @@ -636,3 +648,49 @@ describe('GraphCanvas agent dock', () => { expect(screen.queryByTestId('docked-agent-panel')).not.toBeInTheDocument() }) }) + +describe('deployment model options at startup', () => { + beforeEach(() => { + distribution.isCloud = true + onTestFinished(() => { + distribution.isCloud = false + }) + }) + + it('waits for the deployment before constructing workflow widgets', async () => { + let finishListing = () => {} + const listing = new Promise((resolve) => { + finishListing = resolve + }) + vi.spyOn(useDeploymentPickStore(), 'loadOnce').mockReturnValue(listing) + await mountGraphCanvas() + expect(app.setup).not.toHaveBeenCalled() + finishListing() + await vi.waitFor(() => expect(app.setup).toHaveBeenCalledOnce()) + }) + + it('does not wait for a deployment lookup on a local build', async () => { + distribution.isCloud = false + vi.spyOn(useDeploymentPickStore(), 'loadOnce').mockReturnValue( + new Promise(() => {}) + ) + await mountGraphCanvas() + expect(app.setup).toHaveBeenCalledOnce() + expect(useDeploymentPickStore().loadOnce).not.toHaveBeenCalled() + }) + + it('stops startup with a reload message if the deployment lookup never settles', async () => { + vi.spyOn(useDeploymentPickStore(), 'loadOnce').mockReturnValue( + new Promise(() => {}) + ) + await mountGraphCanvas() + await vi.advanceTimersByTimeAsync(DEPLOYMENT_LISTING_BACKSTOP_MS) + expect(app.setup).not.toHaveBeenCalled() + expect(useToast().toasts).toEqual([ + expect.objectContaining({ + kind: 'error', + title: 'deploymentSwitcher.lookupTimedOut' + }) + ]) + }) +}) diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 406730364ac..100ac3afd68 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -176,6 +176,8 @@ import { LiteGraph } from '@/lib/litegraph/src/litegraph' import { useLitegraphSettings } from '@/platform/settings/composables/useLitegraphSettings' import { CORE_SETTINGS } from '@/platform/settings/constants/coreSettings' import { useSettingStore } from '@/platform/settings/settingStore' +import { isCloud } from '@/platform/distribution/types' +import { waitForDeploymentPick } from '@/platform/workspace/composables/waitForDeploymentPick' import { bootstrapTracer } from '@/platform/telemetry/perf/bootstrapTracer' import { useToast } from '@/components/ui/toast/toastStore' import { useWorkflowService } from '@/platform/workflow/core/services/workflowService' @@ -576,6 +578,10 @@ onMounted(async () => { const canvas = canvasRef.value if (!canvas) throw new TypeError('GraphCanvas mounted without a canvas') + if (isCloud && !(await waitForDeploymentPick())) { + toast.error(t('deploymentSwitcher.lookupTimedOut')) + return + } await comfyApp.setup(canvas) canvasStore.canvas = comfyApp.canvas canvasStore.canvas.render_canvas_border = false diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 43a77b20be3..fb07e176357 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -3868,6 +3868,7 @@ "failedToSwitch": "Failed to switch workspace" }, "deploymentSwitcher": { + "lookupTimedOut": "Could not check which deployment this editor runs on. Reload the page to try again.", "runningOn": "Running on", "comfyCloud": "Comfy Cloud", "comfyCloudCaption": "Comfy's own node set", diff --git a/src/platform/assets/services/assetService.test.ts b/src/platform/assets/services/assetService.test.ts index 2f1e4eafd21..2c25be0d417 100644 --- a/src/platform/assets/services/assetService.test.ts +++ b/src/platform/assets/services/assetService.test.ts @@ -14,6 +14,7 @@ import { assetService } from '@/platform/assets/services/assetService' import { api } from '@/scripts/api' +import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' const mockDistributionState = vi.hoisted(() => ({ isCloud: false })) @@ -104,6 +105,24 @@ describe(assetService.shouldUseWidgetAssetPicker, () => { mockDistributionState.isCloud = false }) + it.for([ + { node: 'CheckpointLoaderSimple', input: 'ckpt_name' }, + { node: 'LoraLoader', input: 'lora_name' }, + { node: 'LoadLoraModel', input: 'lora_name' }, + { node: 'LoadLoraTextEncoder', input: 'lora_name' } + ])('uses catalog options for $node on a deployment', ({ node, input }) => { + mockDistributionState.isCloud = true + useDeploymentPickStore().bootDeployment = { + deployment_id: 'dep-release', + release_id: 'release-1', + status: 'ready', + created_at: '2026-10-01T00:00:00Z' + } + + expect(assetService.shouldUseWidgetAssetPicker(node, input)).toBe(false) + expect(assetService.isWidgetAssetPickerEnabled()).toBe(false) + }) + it('returns false when not on cloud', () => { mockDistributionState.isCloud = false diff --git a/src/platform/assets/services/assetService.ts b/src/platform/assets/services/assetService.ts index e8d2bf00d93..592000863a3 100644 --- a/src/platform/assets/services/assetService.ts +++ b/src/platform/assets/services/assetService.ts @@ -28,6 +28,7 @@ import { isModelTypeCovered } from '@/platform/assets/utils/assetMetadataUtils' import { isCloud } from '@/platform/distribution/types' +import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' import { api } from '@/scripts/api' import { useModelToNodeStore } from '@/stores/modelToNodeStore' import { parseErrorResponse } from '@/platform/remote/comfyui/errors' @@ -531,12 +532,12 @@ function createAssetService() { /** * Whether widget-embedded asset pickers (canvas + Vue node model widgets) are - * enabled. Hardcoded to cloud: MODEL_NODE_MAPPINGS is only maintained for + * enabled on Comfy Cloud without a deployment: MODEL_NODE_MAPPINGS is maintained for * cloud asset tagging. NOT the asset-API gate — that is * useFeatureFlags().flags.assetsEnabled. */ function isWidgetAssetPickerEnabled(): boolean { - return isCloud + return isCloud && !useDeploymentPickStore().bootDeployment } /** diff --git a/src/platform/workspace/composables/waitForDeploymentPick.ts b/src/platform/workspace/composables/waitForDeploymentPick.ts new file mode 100644 index 00000000000..7cc7093ad8b --- /dev/null +++ b/src/platform/workspace/composables/waitForDeploymentPick.ts @@ -0,0 +1,20 @@ +import { DEPLOYMENT_LISTING_BACKSTOP_MS } from '@/platform/workspace/api/deploymentListingTimeouts' +import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' + +export async function waitForDeploymentPick(): Promise { + const listing = useDeploymentPickStore().loadOnce() + let timeout: ReturnType | undefined + try { + return await Promise.race([ + listing.then(() => true), + new Promise((resolve) => { + timeout = setTimeout( + () => resolve(false), + DEPLOYMENT_LISTING_BACKSTOP_MS + ) + }) + ]) + } finally { + clearTimeout(timeout) + } +} diff --git a/src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.deployment.test.ts b/src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.deployment.test.ts new file mode 100644 index 00000000000..0e2a76f4e15 --- /dev/null +++ b/src/renderer/extensions/vueNodes/widgets/composables/useComboWidget.deployment.test.ts @@ -0,0 +1,80 @@ +import { fromPartial } from '@total-typescript/shoehorn' +import { beforeEach, describe, expect, it, vi } from 'vitest' + +import { LGraphNode } from '@/lib/litegraph/src/litegraph' +import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' +import { useNodeDefStore } from '@/stores/nodeDefStore' + +import { ComfyWidgets } from '@/scripts/widgets' +import { app } from '@/scripts/app' + +vi.mock(import('@/scripts/api')) +vi.mock(import('@/scripts/app')) +vi.mock(import('@/platform/assets/composables/useAssetBrowserDialog'), () => ({ + registerAssetBrowserModalComponent: vi.fn(), + useAssetBrowserDialog: () => ({ show: vi.fn(), browse: vi.fn() }) +})) +vi.mock(import('@/platform/distribution/types'), () => ({ + DISTRIBUTION: 'localhost' as const, + isDesktop: false, + isNightly: false, + isCloud: true +})) + +const deployment = { + deployment_id: 'dep-1', + release_id: 'release-1', + status: 'ready', + created_at: '2026-10-01T00:00:00Z' +} + +describe('model widgets on a deployment', () => { + beforeEach(() => { + useNodeDefStore().nodeDefsByName = { + CheckpointLoaderSimple: fromPartial({ name: 'CheckpointLoaderSimple' }) + } + }) + + it.for([ + { nodeType: 'CheckpointLoaderSimple', input: 'ckpt_name' }, + { nodeType: 'LoraLoader', input: 'lora_name' }, + { nodeType: 'VAELoader', input: 'vae_name' }, + { nodeType: 'UNETLoader', input: 'unet_name' }, + { nodeType: 'DualCLIPLoader', input: 'clip_name1' }, + { nodeType: 'CustomModelLoader', input: 'custom_model' } + ])( + 'constructs $nodeType with the catalog options and default', + ({ nodeType, input }) => { + useDeploymentPickStore().bootDeployment = deployment + const node = new LGraphNode(nodeType) + node.comfyClass = nodeType + const { widget } = ComfyWidgets.COMBO( + node, + input, + [['release.safetensors', 'other.safetensors'], {}], + app + ) + + expect(widget.type).toBe('combo') + expect(widget.options.values).toEqual([ + 'release.safetensors', + 'other.safetensors' + ]) + expect(widget.value).toBe('release.safetensors') + } + ) + + it('keeps the Cloud asset picker when the page booted without a deployment', () => { + useDeploymentPickStore().bootDeployment = null + const node = new LGraphNode('CheckpointLoaderSimple') + node.comfyClass = 'CheckpointLoaderSimple' + const { widget } = ComfyWidgets.COMBO( + node, + 'ckpt_name', + [['catalog.safetensors'], {}], + app + ) + + expect(widget.type).toBe('asset') + }) +}) diff --git a/src/stores/modelStore.test.ts b/src/stores/modelStore.test.ts index 69de3486cd6..d687309e114 100644 --- a/src/stores/modelStore.test.ts +++ b/src/stores/modelStore.test.ts @@ -6,6 +6,7 @@ import { assetService } from '@/platform/assets/services/assetService' import type * as DistributionTypes from '@/platform/distribution/types' import { remoteConfig } from '@/platform/remoteConfig/remoteConfig' import { api } from '@/scripts/api' +import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' import { ResourceState, effectiveModelExtensions, @@ -104,6 +105,57 @@ describe('useModelStore', () => { remoteConfig.value = {} }) + it('lists and refreshes Release models without asset filtering on a picked deployment', async () => { + enableMocks(true) + mockDistribution.isCloud = true + useDeploymentPickStore().bootDeployment = { + deployment_id: 'dep-release', + release_id: 'release-1', + status: 'ready', + created_at: '2026-10-01T00:00:00Z' + } + vi.mocked(api.getModels).mockResolvedValue([ + { name: 'release.gguf', pathIndex: 0 } + ]) + store = useModelStore() + await store.loadModels() + expect(store.models.map((model) => model.file_name)).toEqual([ + 'release.gguf', + 'release.gguf' + ]) + vi.mocked(api.getModels).mockResolvedValue([ + { name: 'updated.gguf', pathIndex: 0 } + ]) + await store.refreshModelFolder('checkpoints') + expect(store.models.map((model) => model.file_name)).toEqual([ + 'updated.gguf', + 'release.gguf' + ]) + expect(assetService.getAssetModels).not.toHaveBeenCalled() + }) + + it('replaces cached Cloud models when the boot deployment arrives late', async () => { + enableMocks(true) + mockDistribution.isCloud = true + store = useModelStore() + await store.loadModels() + expect(store.models[0].file_name).toBe('sdxl.safetensors') + vi.mocked(api.getModels).mockResolvedValue([ + { name: 'release.safetensors', pathIndex: 0 } + ]) + useDeploymentPickStore().bootDeployment = { + deployment_id: 'dep-release', + release_id: 'release-1', + status: 'ready', + created_at: '2026-10-01T00:00:00Z' + } + await vi.advanceTimersByTimeAsync(500) + expect(store.models.map((model) => model.file_name)).toEqual([ + 'release.safetensors', + 'release.safetensors' + ]) + }) + it('should load models', async () => { enableMocks() store = useModelStore() diff --git a/src/stores/modelStore.ts b/src/stores/modelStore.ts index e6a0eb45848..306a9b5abfe 100644 --- a/src/stores/modelStore.ts +++ b/src/stores/modelStore.ts @@ -6,6 +6,7 @@ import { useFeatureFlags } from '@/composables/useFeatureFlags' import type { ModelFile } from '@/platform/assets/schemas/assetSchema' import { assetService } from '@/platform/assets/services/assetService' import { isCloud } from '@/platform/distribution/types' +import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' import { api } from '@/scripts/api' /** (Internal helper) finds a value in a metadata object from any of a list of keys. */ @@ -279,6 +280,10 @@ export class ModelFolder { /** Model store handler, wraps individual per-folder model stores */ export const useModelStore = defineStore('models', () => { const { flags } = useFeatureFlags() + const deploymentPick = isCloud ? useDeploymentPickStore() : undefined + const useAssetModels = computed( + () => flags.assetsEnabled && !deploymentPick?.bootDeployment + ) const modelFolderNames = ref([]) const modelFolderByName = ref>({}) const modelFolders = computed(() => @@ -297,7 +302,7 @@ export const useModelStore = defineStore('models', () => { * all-registered-folders view. */ const visibleModelFolders = computed(() => - flags.assetsEnabled + useAssetModels.value ? modelFolders.value.filter( (folder) => folder.state !== ResourceState.Loaded || @@ -307,13 +312,13 @@ export const useModelStore = defineStore('models', () => { ) function createGetModelsFunc(): (folder: string) => Promise { - return flags.assetsEnabled + return useAssetModels.value ? (folder) => assetService.getAssetModels(folder) : (folder) => api.getModels(folder) } const modelSource = computed(() => - !flags.assetsEnabled + !useAssetModels.value ? 'legacy-api' : flags.supportsModelTypeTags ? 'asset-model-type-tags' @@ -358,7 +363,7 @@ export const useModelStore = defineStore('models', () => { getModelsFunc, // Display filtering applies to the asset walk only; the legacy // listing keeps its historical server-side (global-set) filtering. - flags.assetsEnabled ? effectiveModelExtensions(folder.extensions) : [] + useAssetModels.value ? effectiveModelExtensions(folder.extensions) : [] ) } return { @@ -531,13 +536,10 @@ export const useModelStore = defineStore('models', () => { }) /** - * The WS `feature_flags` handshake can land after createGetModelsFunc() - * already captured its data-source choice at store-init time, so a flag - * flip after boot must force a reload to switch the sidebar's source. + * The deployment listing and feature handshake can arrive after a folder + * captured its source, so reload when the source changes. */ - watch([() => flags.assetsEnabled, () => flags.supportsModelTypeTags], () => - scheduleModelReload() - ) + watch(modelSource, () => scheduleModelReload()) return { models, From 2006992fda3ad47fed2d672197c0bab6b3704e1c Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 14 Oct 2026 14:12:00 -0400 Subject: [PATCH 02/15] test(models): keep startup checks within the app boundary --- src/components/graph/GraphCanvas.test.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/graph/GraphCanvas.test.ts b/src/components/graph/GraphCanvas.test.ts index 3602b3992f2..8b9b1fa41e9 100644 --- a/src/components/graph/GraphCanvas.test.ts +++ b/src/components/graph/GraphCanvas.test.ts @@ -20,7 +20,6 @@ import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' import { useSettingStore } from '@/platform/settings/settingStore' import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' import { DEPLOYMENT_LISTING_BACKSTOP_MS } from '@/platform/workspace/api/deploymentListingTimeouts' -import { useToast } from '@/components/ui/toast/toastStore' import { useReleaseStore } from '@/platform/updates/common/releaseStore' import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore' import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' @@ -679,18 +678,13 @@ describe('deployment model options at startup', () => { expect(useDeploymentPickStore().loadOnce).not.toHaveBeenCalled() }) - it('stops startup with a reload message if the deployment lookup never settles', async () => { + it('does not construct workflow widgets if the deployment lookup never settles', async () => { vi.spyOn(useDeploymentPickStore(), 'loadOnce').mockReturnValue( new Promise(() => {}) ) await mountGraphCanvas() await vi.advanceTimersByTimeAsync(DEPLOYMENT_LISTING_BACKSTOP_MS) expect(app.setup).not.toHaveBeenCalled() - expect(useToast().toasts).toEqual([ - expect.objectContaining({ - kind: 'error', - title: 'deploymentSwitcher.lookupTimedOut' - }) - ]) + expect(mocks.initializeWorkflow).not.toHaveBeenCalled() }) }) From 4dc75c770b6a37380237debaff3a93c89e3c42d1 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 14 Oct 2026 14:32:40 -0400 Subject: [PATCH 03/15] fix(models): keep startup model sources consistent after lookup failures --- scripts/checkAssetsFlagArtifact.test.ts | 29 +++++++++------ scripts/checkAssetsFlagArtifact.ts | 19 +--------- src/components/graph/GraphCanvas.test.ts | 35 +++++++++++++++++++ .../composables/waitForDeploymentPick.ts | 5 +-- .../stores/deploymentPickStore.test.ts | 12 +++++++ .../workspace/stores/deploymentPickStore.ts | 7 ++-- 6 files changed, 75 insertions(+), 32 deletions(-) diff --git a/scripts/checkAssetsFlagArtifact.test.ts b/scripts/checkAssetsFlagArtifact.test.ts index 7087ac431fd..e423d241e15 100644 --- a/scripts/checkAssetsFlagArtifact.test.ts +++ b/scripts/checkAssetsFlagArtifact.test.ts @@ -35,19 +35,23 @@ describe('assertWidgetAssetPickerGate', () => { } ) - it('accepts a Cloud gate folded to a static true', () => { + it('accepts a Cloud gate that excludes selected deployments', () => { expect(() => assertWidgetAssetPickerGate( - ['function isWidgetAssetPickerEnabled() {\n return true;\n}'], + [ + 'function isWidgetAssetPickerEnabled() {\n return !useDeploymentPickStore().bootDeployment;\n}' + ], 'cloud' ) ).not.toThrow() }) - it('accepts a minified Cloud gate spelling true as !0', () => { + it('accepts a compact Cloud deployment gate', () => { expect(() => assertWidgetAssetPickerGate( - ['function isWidgetAssetPickerEnabled(){return!0}'], + [ + 'function isWidgetAssetPickerEnabled(){return!useDeploymentPickStore().bootDeployment}' + ], 'cloud' ) ).not.toThrow() @@ -55,12 +59,17 @@ describe('assertWidgetAssetPickerGate', () => { it.for([ 'function isWidgetAssetPickerEnabled() {\n track();\n return true;\n}', - 'function isWidgetAssetPickerEnabled() {\n return isCloud;\n}' - ])('rejects a Cloud gate that is not a static constant: %s', (gate) => { - expect(() => assertWidgetAssetPickerGate([gate], 'cloud')).toThrow( - 'Built widget asset-picker gate is invalid for cloud' - ) - }) + 'function isWidgetAssetPickerEnabled() {\n return isCloud;\n}', + 'function isWidgetAssetPickerEnabled(){return!0}', + 'function isWidgetAssetPickerEnabled(){return useDeploymentPickStore().bootDeployment}' + ])( + 'rejects a Cloud gate that ignores the selected deployment: %s', + (gate) => { + expect(() => assertWidgetAssetPickerGate([gate], 'cloud')).toThrow( + 'Built widget asset-picker gate is invalid for cloud' + ) + } + ) it.for([ 'function isWidgetAssetPickerEnabled() {\n if (!api.getServerFeature("assets", false)) return false;\n return true;\n}', diff --git a/scripts/checkAssetsFlagArtifact.ts b/scripts/checkAssetsFlagArtifact.ts index fcafa6fefe6..47f51e30f9c 100644 --- a/scripts/checkAssetsFlagArtifact.ts +++ b/scripts/checkAssetsFlagArtifact.ts @@ -34,26 +34,9 @@ const TEXT_ASSET_EXTENSIONS = new Set([ /** Sourcemaps carry the gate's own source, which would count as a second gate. */ const EXECUTABLE_ASSET_EXTENSIONS = new Set(['.js', '.mjs', '.cjs', '.html']) -/** - * The widget asset-picker gate must compile to a static constant per - * distribution: `false`/`!1` off-cloud, meaning the feature is statically - * stripped, and `true`/`!0` on cloud. - * - * The two legs are deliberately asymmetric. `nonCloud` carries the real - * invariant: a body that folds to a constant `false` proves the picker is - * unreachable in a non-cloud artifact, which is what lets the bundler drop - * everything behind it. `cloud` is much weaker — it only proves some static - * truthy constant survived — but that is honest, because the gate is now - * nothing more than a build-time constant. Its job is to catch the gate - * regressing into a runtime read, not to constrain runtime behaviour. - * - * Both are anchored against the whole compiled body: a substring search would - * accept a `return true` sitting beside an extra statement. The alternations - * are the two spellings minification emits for each literal. - */ const GATE_BODIES = { nonCloud: /^return\s*(?:false|!1)\s*;?$/, - cloud: /^return\s*(?:true|!0)\s*;?$/ + cloud: /^return\s*!useDeploymentPickStore\(\)\.bootDeployment\s*;?$/ } as const function artifactFiles(directory: string): string[] { diff --git a/src/components/graph/GraphCanvas.test.ts b/src/components/graph/GraphCanvas.test.ts index 8b9b1fa41e9..2986948f7de 100644 --- a/src/components/graph/GraphCanvas.test.ts +++ b/src/components/graph/GraphCanvas.test.ts @@ -664,10 +664,37 @@ describe('deployment model options at startup', () => { vi.spyOn(useDeploymentPickStore(), 'loadOnce').mockReturnValue(listing) await mountGraphCanvas() expect(app.setup).not.toHaveBeenCalled() + useDeploymentPickStore().bootDeployment = null finishListing() await vi.waitFor(() => expect(app.setup).toHaveBeenCalledOnce()) }) + it('stops startup after a failed lookup even if the menu retries successfully', async () => { + const store = useDeploymentPickStore() + vi.spyOn(store, 'loadOnce').mockResolvedValue() + await mountGraphCanvas() + expect(app.setup).not.toHaveBeenCalled() + expect(getActivePinia()?.state.value.toast?.toasts).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + kind: 'error', + title: 'deploymentSwitcher.lookupTimedOut' + }) + ]) + ) + store.bootDeployment = { + deployment_id: 'dep-1', + release_id: 'r-1', + build_id: 'b-1', + build_name: 'Build', + release_version: 1, + status: 'ready', + created_at: '' + } + await nextTick() + expect(app.setup).not.toHaveBeenCalled() + }) + it('does not wait for a deployment lookup on a local build', async () => { distribution.isCloud = false vi.spyOn(useDeploymentPickStore(), 'loadOnce').mockReturnValue( @@ -684,6 +711,14 @@ describe('deployment model options at startup', () => { ) await mountGraphCanvas() await vi.advanceTimersByTimeAsync(DEPLOYMENT_LISTING_BACKSTOP_MS) + expect(getActivePinia()?.state.value.toast?.toasts).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + kind: 'error', + title: 'deploymentSwitcher.lookupTimedOut' + }) + ]) + ) expect(app.setup).not.toHaveBeenCalled() expect(mocks.initializeWorkflow).not.toHaveBeenCalled() }) diff --git a/src/platform/workspace/composables/waitForDeploymentPick.ts b/src/platform/workspace/composables/waitForDeploymentPick.ts index 7cc7093ad8b..f6da9e40cf6 100644 --- a/src/platform/workspace/composables/waitForDeploymentPick.ts +++ b/src/platform/workspace/composables/waitForDeploymentPick.ts @@ -2,11 +2,12 @@ import { DEPLOYMENT_LISTING_BACKSTOP_MS } from '@/platform/workspace/api/deploym import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' export async function waitForDeploymentPick(): Promise { - const listing = useDeploymentPickStore().loadOnce() + const store = useDeploymentPickStore() + const listing = store.loadOnce() let timeout: ReturnType | undefined try { return await Promise.race([ - listing.then(() => true), + listing.then(() => store.bootDeployment !== undefined), new Promise((resolve) => { timeout = setTimeout( () => resolve(false), diff --git a/src/platform/workspace/stores/deploymentPickStore.test.ts b/src/platform/workspace/stores/deploymentPickStore.test.ts index b846f52e236..33bf7d4e8b1 100644 --- a/src/platform/workspace/stores/deploymentPickStore.test.ts +++ b/src/platform/workspace/stores/deploymentPickStore.test.ts @@ -70,6 +70,18 @@ describe('useDeploymentPickStore', () => { }) }) + it('keeps Cloud as the boot source when an excluded account later gets a listing', async () => { + mockWorkspaceApi.listDeployments + .mockRejectedValueOnce(new WorkspaceApiError('Outside rollout', 403)) + .mockResolvedValueOnce(listing) + const store = useDeploymentPickStore() + await store.loadOnce() + expect(store.bootDeployment).toBeNull() + await store.load() + expect(store.bootDeployment).toBeNull() + expect(store.changeSinceBoot).toBe('deployment') + }) + it('loads the listing and knows which deployment is picked', async () => { mockWorkspaceApi.listDeployments.mockResolvedValue(listing) const store = useDeploymentPickStore() diff --git a/src/platform/workspace/stores/deploymentPickStore.ts b/src/platform/workspace/stores/deploymentPickStore.ts index 62743a5af99..59987bc1f10 100644 --- a/src/platform/workspace/stores/deploymentPickStore.ts +++ b/src/platform/workspace/stores/deploymentPickStore.ts @@ -125,8 +125,8 @@ export const useDeploymentPickStore = defineStore('deploymentPick', () => { const isSwitching = computed(() => state.value.phase === 'switching') /** * The deployment this page booted on, from the first listing that - * answered: null for Comfy Cloud (a gone pick included), undefined before - * any listing answered. The editor's node catalog is that deployment's + * answered: null for Comfy Cloud (a gone pick or rollout refusal included), + * undefined before the model source is known. The editor's node catalog is that deployment's * Release as it was at boot, since a pick or a workspace switch reloads * the page. */ @@ -183,6 +183,9 @@ export const useDeploymentPickStore = defineStore('deploymentPick', () => { lastApplied = request dispatch(event) if (event.type === 'loaded') noteListing(event.gonePickedDeploymentId) + if (event.type === 'loadRefused' && bootDeployment.value === undefined) { + bootDeployment.value = null + } } function keepPickGone(gonePickedDeploymentId: string | null) { From 2817a54088554d29e310ab7f61b46bf7a931132e Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 14 Oct 2026 14:52:11 -0400 Subject: [PATCH 04/15] test(cloud): provide the deployment lookup response during browser boot --- browser_tests/fixtures/utils/cloudBootMocks.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/browser_tests/fixtures/utils/cloudBootMocks.ts b/browser_tests/fixtures/utils/cloudBootMocks.ts index 8106040dfe9..d6aff2deaf2 100644 --- a/browser_tests/fixtures/utils/cloudBootMocks.ts +++ b/browser_tests/fixtures/utils/cloudBootMocks.ts @@ -26,6 +26,12 @@ export async function mockCloudBootRoutes( page: Page, { features, settings = {}, objectInfo }: CloudBootOptions ) { + await page.route('**/api/workspaces/*/deployments', (route) => + route.fulfill({ + ...jsonRoute({ error: 'Deployment selection is outside the rollout' }), + status: 403 + }) + ) await page.route('**/api/features', (r) => r.fulfill(jsonRoute(features))) await page.route('**/api/system_stats', (r) => r.fulfill(jsonRoute(mockSystemStats)) From e570b116357715b0f42555f23269a9a888ea2adf Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 15 Oct 2026 10:44:02 -0400 Subject: [PATCH 05/15] test(cloud): default every cloud test to the deployment rollout refusal The editor waits for the deployment lookup before it builds the canvas, and the local backend answers that route with a 404, which leaves the model source unknown and stops startup. Cloud-tagged tests now get the rollout refusal (403, Comfy Cloud) by default; a spec's own page route still wins. --- browser_tests/fixtures/ComfyPage.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/browser_tests/fixtures/ComfyPage.ts b/browser_tests/fixtures/ComfyPage.ts index 44927263ae6..f58996c081a 100644 --- a/browser_tests/fixtures/ComfyPage.ts +++ b/browser_tests/fixtures/ComfyPage.ts @@ -716,6 +716,15 @@ export const comfyPageFixture = base.extend<{ await context.route('**/customers/balance', (route) => route.fulfill({ json: ZERO_BALANCE }) ) + // The editor waits for the deployment lookup before it builds the + // canvas; the local backend has no such route. Default to the + // rollout refusal (Comfy Cloud); a spec's own page route wins. + await context.route('**/api/workspaces/*/deployments', (route) => + route.fulfill({ + status: 403, + json: { error: 'Deployment selection is outside the rollout' } + }) + ) await mockWorkspace(context, workspace('personal', 'owner'), []) } if (testInfo.tags.includes('@cloud') || testInfo.tags.includes('@auth')) { From 5750a19a6b8e155bcd6e628a9fbe8c5ac83e312f Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 15 Oct 2026 11:00:58 -0400 Subject: [PATCH 06/15] fix(models): stop deployment startup after editor unmount --- src/components/graph/GraphCanvas.test.ts | 24 ++++++++++++++++++++++++ src/components/graph/GraphCanvas.vue | 7 ++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/components/graph/GraphCanvas.test.ts b/src/components/graph/GraphCanvas.test.ts index 2986948f7de..23464ac5106 100644 --- a/src/components/graph/GraphCanvas.test.ts +++ b/src/components/graph/GraphCanvas.test.ts @@ -669,6 +669,30 @@ describe('deployment model options at startup', () => { await vi.waitFor(() => expect(app.setup).toHaveBeenCalledOnce()) }) + it.for([true, false])( + 'does not resume startup after unmount when deployment lookup succeeds: %s', + async (succeeds) => { + const store = useDeploymentPickStore() + let finishListing = () => {} + const listing = new Promise((resolve) => { + finishListing = resolve + }) + vi.spyOn(store, 'loadOnce').mockReturnValue(listing) + await mountGraphCanvas() + expect(store.loadOnce).toHaveBeenCalledOnce() + expect(app.setup).not.toHaveBeenCalled() + + cleanup() + store.bootDeployment = succeeds ? null : undefined + finishListing() + await vi.advanceTimersByTimeAsync(0) + + expect(app.setup).not.toHaveBeenCalled() + expect(mocks.initializeWorkflow).not.toHaveBeenCalled() + expect(getActivePinia()?.state.value.toast?.toasts ?? []).toEqual([]) + } + ) + it('stops startup after a failed lookup even if the menu retries successfully', async () => { const store = useDeploymentPickStore() vi.spyOn(store, 'loadOnce').mockResolvedValue() diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 100ac3afd68..980aeff8fdd 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -537,6 +537,8 @@ useEventListener( } ) +let disposed = false + onMounted(async () => { comfyApp.vueAppReady = true workspaceStore.spinner = true @@ -578,7 +580,9 @@ onMounted(async () => { const canvas = canvasRef.value if (!canvas) throw new TypeError('GraphCanvas mounted without a canvas') - if (isCloud && !(await waitForDeploymentPick())) { + const deploymentReady = !isCloud || (await waitForDeploymentPick()) + if (disposed) return + if (!deploymentReady) { toast.error(t('deploymentSwitcher.lookupTimedOut')) return } @@ -640,6 +644,7 @@ onMounted(async () => { }) onUnmounted(() => { + disposed = true cleanupErrorHooks?.() cleanupErrorHooks = null }) From 11c0eeeb1c39811b1b357bccc9496919be865eed Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 15 Oct 2026 11:22:41 -0400 Subject: [PATCH 07/15] fix(models): preserve replacement editor startup state --- src/components/graph/GraphCanvas.test.ts | 37 ++++++++++++++++++++++++ src/components/graph/GraphCanvas.vue | 6 ++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/components/graph/GraphCanvas.test.ts b/src/components/graph/GraphCanvas.test.ts index 23464ac5106..7b96561de5f 100644 --- a/src/components/graph/GraphCanvas.test.ts +++ b/src/components/graph/GraphCanvas.test.ts @@ -17,6 +17,8 @@ import { createI18n } from 'vue-i18n' import { IS_CONTROL_WIDGET } from '@/core/graph/widgets/controlWidgetMarker' import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets' import { LGraph, LGraphNode } from '@/lib/litegraph/src/litegraph' +import { bootstrapTracer } from '@/platform/telemetry/perf/bootstrapTracer' +import { useWorkspaceStore } from '@/stores/workspaceStore' import { useSettingStore } from '@/platform/settings/settingStore' import { useDeploymentPickStore } from '@/platform/workspace/stores/deploymentPickStore' import { DEPLOYMENT_LISTING_BACKSTOP_MS } from '@/platform/workspace/api/deploymentListingTimeouts' @@ -693,6 +695,41 @@ describe('deployment model options at startup', () => { } ) + it('lets the replacement editor finish startup after unmount during lookup', async () => { + const store = useDeploymentPickStore() + let finishListing = () => {} + vi.spyOn(store, 'loadOnce').mockReturnValue( + new Promise((resolve) => { + finishListing = resolve + }) + ) + let finishSetup = () => {} + vi.mocked(app.setup).mockReturnValue( + new Promise((resolve) => { + finishSetup = resolve + }) + ) + const complete = vi.spyOn(bootstrapTracer, 'complete') + await mountGraphCanvas() + cleanup() + await mountGraphCanvas() + + store.bootDeployment = null + finishListing() + await vi.advanceTimersByTimeAsync(0) + + expect(app.setup).toHaveBeenCalledOnce() + expect(useWorkspaceStore().spinner).toBe(true) + expect(complete).not.toHaveBeenCalled() + + finishSetup() + await vi.advanceTimersByTimeAsync(0) + + expect(useWorkspaceStore().spinner).toBe(false) + expect(complete).toHaveBeenCalledExactlyOnceWith('completed') + expect(mocks.initializeWorkflow).toHaveBeenCalledOnce() + }) + it('stops startup after a failed lookup even if the menu retries successfully', async () => { const store = useDeploymentPickStore() vi.spyOn(store, 'loadOnce').mockResolvedValue() diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 980aeff8fdd..503299d5ab8 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -613,8 +613,10 @@ onMounted(async () => { await useFirstRunEntry().handleStartupOutcome(startupOutcome) bootstrapOutcome = 'completed' } finally { - workspaceStore.spinner = false - bootstrapTracer.complete(bootstrapOutcome) + if (!disposed) { + workspaceStore.spinner = false + bootstrapTracer.complete(bootstrapOutcome) + } } const sharedStatus = await workflowPersistence.loadSharedWorkflowFromUrlIfPresent() From 814e13101bd305008b314715d79b55d212ac2657 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 15 Oct 2026 11:33:32 -0400 Subject: [PATCH 08/15] fix: clear abandoned editor startup state --- src/components/graph/GraphCanvas.test.ts | 30 ++++++++++++++++++++++++ src/components/graph/GraphCanvas.vue | 17 ++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/components/graph/GraphCanvas.test.ts b/src/components/graph/GraphCanvas.test.ts index 7b96561de5f..9482efc02f2 100644 --- a/src/components/graph/GraphCanvas.test.ts +++ b/src/components/graph/GraphCanvas.test.ts @@ -695,6 +695,36 @@ describe('deployment model options at startup', () => { } ) + it.for([true, false])( + 'clears abandoned startup when lookup eventually succeeds: %s', + async (succeeds) => { + const store = useDeploymentPickStore() + let finishListing = () => {} + vi.spyOn(store, 'loadOnce').mockReturnValue( + new Promise((resolve) => { + finishListing = resolve + }) + ) + const complete = vi.spyOn(bootstrapTracer, 'complete') + await mountGraphCanvas() + expect(useWorkspaceStore().spinner).toBe(true) + + cleanup() + await nextTick() + + expect(useWorkspaceStore().spinner).toBe(false) + expect(complete).toHaveBeenCalledExactlyOnceWith('failed') + + store.bootDeployment = succeeds ? null : undefined + finishListing() + await vi.advanceTimersByTimeAsync(0) + + expect(useWorkspaceStore().spinner).toBe(false) + expect(complete).toHaveBeenCalledExactlyOnceWith('failed') + expect(app.setup).not.toHaveBeenCalled() + } + ) + it('lets the replacement editor finish startup after unmount during lookup', async () => { const store = useDeploymentPickStore() let finishListing = () => {} diff --git a/src/components/graph/GraphCanvas.vue b/src/components/graph/GraphCanvas.vue index 503299d5ab8..f6dd1827f49 100644 --- a/src/components/graph/GraphCanvas.vue +++ b/src/components/graph/GraphCanvas.vue @@ -120,6 +120,10 @@ + +