ComfyUI_frontend icon indicating copy to clipboard operation
ComfyUI_frontend copied to clipboard

Tab-Graph-Prompt State Sync Issues

Open christian-byrne opened this issue 8 months ago • 5 comments

After a prompt is queued from the frontend, the backend will send various messages about the status of the job.

These status messages are used for various dynamic frontend components/features, such as:

  • in-node output displays (app.nodeOutputs)
  • latent previews displays (app.nodePreviewImages)
  • execution progress (progress bar)
  • currently executing node (browser title)

The frontend workspace can have multiple tabs, each corresponding to its own graph. The frontend does not currently make an attempt to associate each prompt/job with its initiating tab/graph. As a result, the frontend defaults to assuming the status messages relate to the active graph/tab, which can be wrong (e.g., you initiate a job with tab A, then switch to tab B, then get a status message about the job after switching).

This causes various minor (for now) bugs. For this issue, a more comprehensive solution seems necessary, as it will need to be maintainable and extendable in the future.

┆Issue is synchronized with this Notion page by Unito

christian-byrne avatar Apr 10 '25 00:04 christian-byrne

Sub issues from comfyanonymous/ComfyUI (can't transfer because repos have different owner):

  • https://github.com/comfyanonymous/ComfyUI/issues/7506
  • https://github.com/comfyanonymous/ComfyUI/issues/7468
  • https://github.com/comfyanonymous/ComfyUI/discussions/7648
  • https://github.com/comfyanonymous/ComfyUI/issues/8479
  • https://github.com/comfyanonymous/ComfyUI/issues/8959
  • https://github.com/comfyanonymous/ComfyUI/issues/9251

christian-byrne avatar Apr 10 '25 00:04 christian-byrne

Working on extension that uses the affecting and affected mechanisms and I have a chance to observe the problem up close. Backend websocket messages from PromptServer don't include information about worklow the server is currently processing (i.e. workflow id). On front-end similarly the events are dispatched globally and consumed by nodes on whatever workflow is currently active. Other than node type, events do not include any other identifying information or option to filter out events that shouldn't be consumed.

I reckon on server side solution might be trivial by just adding workflow id to messages. On front end it might require more serious consideration. I believe the easiest approach would be by dispatching frontend api events only when active workflow ID matched the id of the workflow from server message?

QuietNoise avatar May 11 '25 08:05 QuietNoise

I reckon on server side solution might be trivial by just adding workflow id to messages.

That's a good suggestion. The only hiccup might be that there could be cases where there are multiple tabs with the same workflow. We may need a new concept along the lines of "tab" or "workspace".

christian-byrne avatar May 12 '25 20:05 christian-byrne

Yes. Multiple browser tabs is another landmine I'm trying to wrap my head around. I.e. we can have same workflows open in multiple tabs overwriting each other when saving to the file, and when you open new tab it recreates the last workspace adding another copy of these open workflows to the "whose gona last in the saved file" race. Multi session is always a headache for any software, justifies writing a book about it on its own 😂

P.S. The good thing is that every generated PNG is workflow's save file, so at least in this department eveyone is covered since they recover any historical version of the prompt and generated PNGs serve as is cover image :D

QuietNoise avatar May 12 '25 21:05 QuietNoise

I had to go back to an October 2024 release in the end. I rely heavily upon multiple browser tabs to work on different workflows. I'm not interested in saving all images especially when generating large batches. If I like the look of an image in the ImagePreview window, I'd click it to expand then right click to Save. Looks like no one ever realized this beautiful way of working! and thus missed a trick with the latest UI updates :)

nadimaj avatar May 21 '25 09:05 nadimaj

Before posting, I did a quick search here for tab-related issue, I think this https://github.com/rookiepsi/comfyui-extended/issues/3#issuecomment-2965026477 might be a part of this, where comfyui-extended preview nodes don't retain their visual data, but seem to cache it.

brknsoul avatar Jun 12 '25 07:06 brknsoul

comfyui-extended preview nodes don't retain their visual data, but seem to cache it

This part is only loosely related - it is simply that tabs are unloaded when not active, and the state of those preview nodes isn't ever persisted anywhere.

webfiltered avatar Jun 20 '25 20:06 webfiltered