ComfyUI_frontend icon indicating copy to clipboard operation
ComfyUI_frontend copied to clipboard

[Feature Request]: How to change the defaultGraph

Open WouterGlorieux opened this issue 1 year ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What would your feature do ?

Hello, I'm the guy that made a template on Runpod.io for a one-click deploy of ComfyUI with Flux.1 dev.

I'm making this issue because recently there were some changes about the frontend and how it loads the defaultGraph. It used to be a .js file in the ComfyUI repo, but it is now changed to refer to the ComfyUI_frontend repo and it is now a .ts file.

Here is my problem, I need the UI to start up with my own custom workflow because this is a one-click template and everyone that currently uses it is loving the fact that it just works without having to do anything. This used to work because I could simply overwrite the original defaultGraph.js in the source code.

However, I'm now trying to update the template to the latest version but this no longer works because I can no longer find the defaultGraph file anywhere. From what I can tell the ComfyUI_frontend is now a compiled object or something?

Is there some way I can still change the defaultGraph.ts file somewhere on my computer? Where would I find this file? If this is not possible, then my only option will be to freeze the template on runpod in a state just before these changes, which means there would no longer be any updates.

Kind regards, Wouter Glorieux

Proposed workflow

  1. Go to ....
  2. Press ....
  3. ...

Additional information

No response

WouterGlorieux avatar Aug 30 '24 17:08 WouterGlorieux

If anyone is also trying to do something like this, I found a workaround. It's hacky AF, but it works. https://github.com/ValyrianTech/ComfyUI_with_Flux/blob/main/comfyui-with-flux/replaceDefaultGraph.py

WouterGlorieux avatar Sep 01 '24 20:09 WouterGlorieux

If anyone is also trying to do something like this, I found a workaround. It's hacky AF, but it works. https://github.com/ValyrianTech/ComfyUI_with_Flux/blob/main/comfyui-with-flux/replaceDefaultGraph.py

You probably don't want to do that as the build hash changes for every frontend release

huchenlei avatar Sep 01 '24 22:09 huchenlei

If you need to overwrite the default graph you can use ComfyUI-Custom-Scripts. Or you want to implement yourself you can reference the source code here: https://github.com/pythongosssss/ComfyUI-Custom-Scripts/blob/da87f6112daa8f37b293b12fc7ab260ff835e301/web/js/workflows.js#L294

huchenlei avatar Sep 01 '24 22:09 huchenlei

Yeah, looking at the name of the asset file I also suspected it would be a temporary fix, I guess next time I'll just have to add some code to figure out the new file. I'm already using ComfyUI-Custom-Scripts, but that still requires someone to click the load default button, on the very first startup it still used the defaultGraph.

WouterGlorieux avatar Sep 01 '24 23:09 WouterGlorieux

Yeah, looking at the name of the asset file I also suspected it would be a temporary fix, I guess next time I'll just have to add some code to figure out the new file. I'm already using ComfyUI-Custom-Scripts, but that still requires someone to click the load default button, on the very first startup it still used the defaultGraph.

If your need is to hijack the initial load, I would recommend you look at https://github.com/Comfy-Org/ComfyUI_frontend/blob/8ba5da14bc65d1c4d88bd17ffc6836cc1a3c15ed/src/scripts/app.ts#L1881-L1901

By setting Comfy.PreviousWorkflow in LocalStorage, you can change the initial load workflow. You just need to inject your script in index.html to modify localstorage, before the whole app's setup function.

huchenlei avatar Sep 02 '24 00:09 huchenlei

I will try support modify default workflow in a less hacky way later, but for now you can try approach this task with localStorage overwrite.

huchenlei avatar Sep 02 '24 00:09 huchenlei

imagehttps://github.com/pythongosssss/ComfyUI-Custom-Scripts

toyxyz avatar Sep 03 '24 02:09 toyxyz

I'm not the original poster, but I do use their one-click installer for cloud services. While modifying localStorage by injecting an early-loaded script into the html is certainly one approach, wouldn't it be nice for all Comfy users to be able to just swap out one JSON file for another?

A hard-coded default workflow seems awfully prone to becoming outdated the moment it's deployed, given how quickly things are moving in this space. I realize that I could be spending this time opening a PR and maybe I will when I find the time, but in the meantime please take this as a suggestion for improvement from someone who appreciates this tool and all the work that has gone into it.

greeze avatar Feb 05 '25 18:02 greeze