Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/components/CloudButton.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import userEvent from '@testing-library/user-event'
import { render, screen, waitFor } from '@testing-library/vue'
import { fromPartial } from '@total-typescript/shoehorn'
Expand Down Expand Up @@ -249,6 +249,22 @@
expect(checkCloudCompatibility).toHaveBeenCalledTimes(2)
})

it('names the missing model loader and explains how to continue', async () => {
vi.mocked(checkCloudCompatibility).mockResolvedValue({
kind: 'unreadableModelLoader',
nodeType: 'ImpactCheckpointLoader'
})
render(CloudButton, { global: { plugins: [testI18n] } })

await userEvent.setup().click(screen.getByTestId('cloud-button'))

await waitFor(() =>
expect(useToast().toasts.map((toast) => toast.title)).toContain(
'Could not read the model settings for ImpactCheckpointLoader. Install the node pack that provides it, then try again.'
)
)
})

it('opens the dialog when Cloud is missing nodes or models', async () => {
vi.mocked(checkCloudCompatibility).mockResolvedValue({
kind: 'missing',
Expand Down
8 changes: 7 additions & 1 deletion src/components/CloudButton.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<template>
<Button
variant="secondary"
Expand Down Expand Up @@ -56,7 +56,13 @@
function showModal() {
const current = check.value
if (current.phase === 'failed') {
toast.error(t('openOnCloud.checkFailed'))
toast.error(
current.nodeType
? t('openOnCloud.missingLocalModelLoader', {
nodeType: current.nodeType
})
: t('openOnCloud.checkFailed')
)
return
}
void openRunOnCloudDialog(() => isMounted && check.value === current)
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4185,7 +4185,8 @@
"title": "Missing {count} model | Missing {count} models",
"unavailable": "Add these models to Comfy Cloud to run this workflow. Uploads from this ComfyUI are currently unavailable."
},
"checkFailed": "Could not check this workflow on Comfy Cloud. Try again."
"checkFailed": "Could not check this workflow on Comfy Cloud. Try again.",
"missingLocalModelLoader": "Could not read the model settings for {nodeType}. Install the node pack that provides it, then try again."
},
"selectionToolbox": {
"executeButton": {
Expand Down
7 changes: 5 additions & 2 deletions src/platform/openOnCloud/cloudCompatibilityApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,18 @@ describe(checkCloudCompatibility, () => {
expect(requestBody().node_types).toEqual(['ImpactWildcard', 'KSampler'])
})

it('returns no verdict when a loader that is not installed locally picked a model', async () => {
it('identifies a missing local loader that prevents the Cloud check', async () => {
const missing = new LGraphNode('ImpactCheckpointLoader')
missing.last_serialization = fromPartial({
type: 'ImpactCheckpointLoader',
widgets_values: ['sdxl.safetensors', 1]
})
workflowHas(missing)

await expect(checkCloudCompatibility()).resolves.toBeNull()
await expect(checkCloudCompatibility()).resolves.toEqual({
kind: 'unreadableModelLoader',
nodeType: 'ImpactCheckpointLoader'
})
expect(fetch).not.toHaveBeenCalled()
})

Expand Down
19 changes: 13 additions & 6 deletions src/platform/openOnCloud/cloudCompatibilityApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useModelStore } from '@/stores/modelStore'
import { useModelToNodeStore } from '@/stores/modelToNodeStore'
import { isModelFileName } from '@/platform/workflowErrors/missingModel/missingModelScan'
import { matchesWidgetName } from '@/utils/widgetBinding'
import type { CloudWorkflowVerdict } from '@/platform/openOnCloud/cloudWorkflowCheck'
import type { CloudWorkflowCheckResult } from '@/platform/openOnCloud/cloudWorkflowCheck'

const LINKED = Symbol('linked')

Expand Down Expand Up @@ -192,7 +192,6 @@ async function resolveUnmapped(
async function collectModels(
nodes: CheckedNode[]
): Promise<CompatibilityModel[] | null> {
if (nodes.some((node) => node.hasUnreadableModels)) return null
const { mapped, unmapped, hasLinkedModelInput } = scanModelInputs(nodes)
if (hasLinkedModelInput) return null
const resolved = await resolveUnmapped(unmapped)
Expand All @@ -203,8 +202,9 @@ async function collectModels(
return [...models.values()]
}

async function postCompatibilityCheck(): Promise<Response | null> {
const nodes = checkedNodes(app.rootGraph)
async function postCompatibilityCheck(
nodes: CheckedNode[]
): Promise<Response | null> {
const models = await collectModels(nodes)
if (!models) return null
const nodeTypes = [...new Set(nodes.map((node) => node.class_type))]
Expand All @@ -229,10 +229,17 @@ function giveUp(cause: unknown): null {
}

/** Resolves null when no verdict is available. */
export async function checkCloudCompatibility(): Promise<CloudWorkflowVerdict | null> {
export async function checkCloudCompatibility(): Promise<CloudWorkflowCheckResult> {
let body: unknown
try {
const response = await postCompatibilityCheck()
const nodes = checkedNodes(app.rootGraph)
const unreadableLoader = nodes.find((node) => node.hasUnreadableModels)
if (unreadableLoader)
return {
kind: 'unreadableModelLoader',
nodeType: unreadableLoader.class_type
}
const response = await postCompatibilityCheck(nodes)
if (!response) return null
if (!response.ok)
return giveUp(
Expand Down
11 changes: 8 additions & 3 deletions src/platform/openOnCloud/cloudWorkflowCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ export type CloudWorkflowVerdict =
| { kind: 'canOpen' }
| { kind: 'missing'; gaps: CloudWorkflowGaps }

export type CloudWorkflowCheckResult =
| CloudWorkflowVerdict
| { kind: 'unreadableModelLoader'; nodeType: string }
| null

export type CloudWorkflowCheckState =
| { phase: 'idle' }
| { phase: 'checking'; run: number }
| { phase: 'failed' }
| { phase: 'failed'; nodeType?: string }
| { phase: 'answered'; verdict: CloudWorkflowVerdict }

export type CloudWorkflowCheckEvent =
| { type: 'invalidated' }
| { type: 'started'; run: number }
| { type: 'failed'; run: number }
| { type: 'failed'; run: number; nodeType?: string }
| { type: 'answered'; run: number; verdict: CloudWorkflowVerdict }

export function reduceCloudWorkflowCheck(
Expand All @@ -32,7 +37,7 @@ export function reduceCloudWorkflowCheck(
return { phase: 'checking', run: event.run }
case 'failed':
return state.phase === 'checking' && state.run === event.run
? { phase: 'failed' }
? { phase: 'failed', nodeType: event.nodeType }
: state
case 'answered':
return state.phase === 'checking' && state.run === event.run
Expand Down
12 changes: 8 additions & 4 deletions src/platform/openOnCloud/stores/cloudWorkflowCheckStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ export const useCloudWorkflowCheckStore = defineStore(
async function check(): Promise<void> {
const run = ++lastRun
dispatch({ type: 'started', run })
const verdict = await checkCloudCompatibility()
dispatch(
verdict ? { type: 'answered', run, verdict } : { type: 'failed', run }
)
const result = await checkCloudCompatibility()
if (result?.kind === 'unreadableModelLoader') {
dispatch({ type: 'failed', run, nodeType: result.nodeType })
} else if (result) {
dispatch({ type: 'answered', run, verdict: result })
} else {
dispatch({ type: 'failed', run })
}
}

function invalidate() {
Expand Down
Loading