ComfyUI_frontend icon indicating copy to clipboard operation
ComfyUI_frontend copied to clipboard

Adjust the logic in handleFile function of app.ts

Open mirabarukaso opened this issue 1 week ago • 3 comments

Prerequisites

  • [x] I am running the latest version of ComfyUI
  • [x] I have searched existing issues to make sure this isn't a duplicate
  • [x] I have tested with all custom nodes disabled (see how)

What happened?

In the current logic, the parameters are positioned too early. This causes images saved using the Image Saver node with A1111 compatibility to fail to load the workflow correctly. Since the code first detects the presence of the parameters, it attempts to read them in A1111 compatibility mode instead of using the prompt correctly to load the workflow.

It is recommended that the priority of parameters is lowered to the very end so that compatibility mode is only used for evaluation if all preceding checks fail.

I traced back through the versions and discovered that, although this issue has probably been present for long time, bug it appeared after today I updated to latest ComfyUI.

https://github.com/Comfy-Org/ComfyUI_frontend/blob/c57ceaf8265fd9b7f6b180967652cdbef8722c27/src/scripts/app.ts#L1421

  async handleFile(file: File, openSource?: WorkflowOpenSource) {
    const fileName = file.name.replace(/\.\w+$/, '') // Strip file extension
    const workflowData = await getWorkflowDataFromFile(file)
    if (!workflowData) {
      this.showErrorOnFileLoad(file)
      return
    }

    const { workflow, prompt, parameters, templates } = workflowData

    if (templates) {
      this.loadTemplateData({ templates })
    }

    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)
      return
    }
	
	if (parameters) {
      // Note: Not putting this in `importA1111` as it is mostly not used
      // by external callers, and `importA1111` has no access to `app`.
      useWorkflowService().beforeLoadNewGraph()
      importA1111(this.graph, parameters)
      useWorkflowService().afterLoadNewGraph(
        fileName,
        this.graph.serialize() as unknown as ComfyWorkflowJSON
      )
      return
    }

    this.showErrorOnFileLoad(file)
  }

Steps to Reproduce

  1. Update to latest start comfyui
  2. Load 2025-11-27-150211_3065179543.png in to comfyui
  3. Shows the A1111 workflow
  4. Load 2025-11-27-150211_3065179543 - Copy.png which has simply change parameters in tExt to marameters
  5. Shows the correct workflow
Image Image

Incorrect Workflow

2025-11-27-150211_3065179543.png 2025-11-27-150211_3065179543.png

Image

Correct Workflow

2025-11-27-150211_3065179543 - Copy.png 2025-11-27-150211_3065179543 - Copy.png

Image

How is this affecting you?

Feature doesn't work as expected

ComfyUI Frontend Version

1.34.0

Browser

Edge

Console Errors


Logs

System Info

Checkpoint files will always be loaded safely.
Total VRAM 24576 MB, total RAM 130756 MB
pytorch version: 2.9.0+cu130
Enabled fp16 accumulation.
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA TITAN RTX : cudaMallocAsync
Enabled pinned memory 58840.0
working around nvidia conv3d memory bug.
Using sage attention
Python version: 3.13.9 (tags/v3.13.9:8183fa5, Oct 14 2025, 14:09:13) [MSC v.1944 64 bit (AMD64)]
ComfyUI version: 0.3.75
ComfyUI frontend version: 1.34.0
[Prompt Server] web root: C:\Users\oOkami\AppData\Roaming\Python\Python313\site-packages\comfyui_frontend_package\static
Total VRAM 24576 MB, total RAM 130756 MB
pytorch version: 2.9.0+cu130
Enabled fp16 accumulation.
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA TITAN RTX : cudaMallocAsync
Enabled pinned memory 58840.0

Additional Context

No response

┆Issue is synchronized with this Notion page by Unito

mirabarukaso avatar Nov 27 '25 06:11 mirabarukaso