Skip to content
Merged
Changes from 2 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
44 changes: 34 additions & 10 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,13 @@
}

let reset_invalid_values = false
if (!graphData) {
// Use explicit validation instead of falsy check to avoid replacing
// valid but falsy values (empty objects, 0, false, etc.)
if (
!graphData ||
typeof graphData !== 'object' ||
Array.isArray(graphData)
) {
graphData = defaultGraph
reset_invalid_values = true
}
Comment thread
DrJKL marked this conversation as resolved.
Expand Down Expand Up @@ -1432,6 +1438,33 @@
this.loadTemplateData({ templates })
}

// Check workflow first - it should take priority over parameters
// when both are present (e.g., in ComfyUI-generated PNGs)
if (workflow) {
let workflowObj: ComfyWorkflowJSON
try {
workflowObj =
typeof workflow === 'string' ? JSON.parse(workflow) : workflow
} catch (err) {
console.error('Failed to parse workflow:', err)
this.showErrorOnFileLoad(file)
}

// Validate workflow is a proper object
if (
typeof workflowObj !== 'object' ||

Check failure on line 1455 in src/scripts/app.ts

View workflow job for this annotation

GitHub Actions / collect

Variable 'workflowObj' is used before being assigned.

Check failure on line 1455 in src/scripts/app.ts

View workflow job for this annotation

GitHub Actions / setup

Variable 'workflowObj' is used before being assigned.
Array.isArray(workflowObj)
) {
console.error('Invalid workflow structure')
} else {
await this.loadGraphData(workflowObj, true, true, fileName, {
openSource
})
return
}
}
Comment thread
r-vage marked this conversation as resolved.

// Use parameters as fallback when no workflow exists
if (parameters) {
Comment thread
DrJKL marked this conversation as resolved.
// Note: Not putting this in `importA1111` as it is mostly not used
// by external callers, and `importA1111` has no access to `app`.
Expand All @@ -1444,15 +1477,6 @@
return
}

if (workflow) {
const workflowObj =
typeof workflow === 'string' ? JSON.parse(workflow) : workflow
await this.loadGraphData(workflowObj, true, true, fileName, {
openSource
})
return
}

if (prompt) {
const promptObj = typeof prompt === 'string' ? JSON.parse(prompt) : prompt
this.loadApiJson(promptObj, fileName)
Expand Down
Loading