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
Copy link
Contributor

@DrJKL DrJKL Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this, an image for ants?

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions browser_tests/tests/loadWorkflowInMedia.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test.describe('Load Workflow in Media', () => {
'edited_workflow.webp',
'no_workflow.webp',
'large_workflow.webp',
'workflow_prompt_parameters.png',
'workflow.webm',
// Skipped due to 3d widget unstable visual result.
// 3d widget shows grid after fully loaded.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 30 additions & 9 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,21 @@ export class ComfyApp {
}
}

// Use parameters as fallback when no workflow exists
if (prompt) {
try {
const promptObj =
typeof prompt === 'string' ? JSON.parse(prompt) : prompt
if (this.isApiJson(promptObj)) {
this.loadApiJson(promptObj, fileName)
return
}
} catch (err) {
console.error('Failed to parse prompt:', err)
}
// Fall through to parameters as a last resort
}

// Use parameters strictly as the final fallback
if (parameters) {
// Note: Not putting this in `importA1111` as it is mostly not used
// by external callers, and `importA1111` has no access to `app`.
Expand All @@ -1481,18 +1495,25 @@ export class ComfyApp {
return
}

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

this.showErrorOnFileLoad(file)
}

// @deprecated
isApiJson(data: unknown) {
return _.isObject(data) && Object.values(data).every((v) => v.class_type)
isApiJson(data: unknown): data is ComfyApiWorkflow {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Remove @deprecated tag or provide migration path.

The method is marked as deprecated but is actively used in the new prompt-handling code (line 1475). Either remove the deprecation tag if the method is still needed, or provide an alternative and update the calling code.

🤖 Prompt for AI Agents
In src/scripts/app.ts around line 1502, the type-guard method isApiJson is
marked @deprecated but is still used by the new prompt-handling code (caller at
~line 1475); remove the @deprecated annotation if this API is intended to
remain, or instead add/implement the recommended replacement function and update
the caller(s) to use that new API; ensure the signature/behavior matches the
caller expectations (or adjust the caller) and update any JSDoc/tsdoc to reflect
the chosen migration path.

if (!_.isObject(data) || Array.isArray(data)) {
return false
}
if (Object.keys(data).length === 0) return false

return Object.values(data).every((node) => {
if (!node || typeof node !== 'object' || Array.isArray(node)) {
return false
}

const { class_type: classType, inputs } = node as Record<string, unknown>
const inputsIsRecord = _.isObject(inputs) && !Array.isArray(inputs)
return typeof classType === 'string' && inputsIsRecord
})
}
Comment on lines 1501 to 1517
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Clarify @deprecated tag on actively-used method.

The isApiJson method is marked @deprecated (line 1501) but is used in new code at line 1475. Either remove the deprecation tag or add a comment explaining why it's deprecated yet still used internally (e.g., "deprecated for external use only").

🤖 Prompt for AI Agents
In src/scripts/app.ts around lines 1501 to 1517, the isApiJson method is
annotated with @deprecated but is still invoked elsewhere (e.g., line 1475);
update the source so the annotation matches intent: either remove the
@deprecated tag if the method remains supported and used, or replace it with a
clear comment like "// deprecated for external use only — retained for internal
compatibility" and keep/adjust visibility or JSDoc to indicate internal-only
usage; ensure the comment/JSDoc appears immediately above the method to clarify
why it remains in the codebase.


loadApiJson(apiData: ComfyApiWorkflow, fileName: string) {
Expand Down
Loading