Comfy-Org / Comfy-Org/ComfyUI_frontend

Events triggered by menu items before and after execution

Open
#6,248 3 comments 0 reactions 0 assignees View on GitHub
Public API
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues and checked the recent builds/commits

### What problem are you experiencing?

I'm author of [Anything Everywhere](https://github.com/chrisgoringe/cg-use-everywhere).

I'd like to be able to ensure that Anything Everywhere responds appropriately when the main menu items are selected.

For instance: Users have reported that when they export to API, the resulting workflow doesn't work. This is because the exported workflow doesn't have the links Anything Everywhere creates (which are only actually added to the prompt on submission). With the events proposed, AE could add those links for an export as well.

There are many other potential uses of such events, and having them implemented will avoid custom node hack solutions which are fragile and end up upsetting end users :)

### When does this problem occur?

In the particular, when exporting to API a workflow using Anything Everywhere links.

### How often do you encounter this problem?

Rarely

### How much does this problem affect your workflow?

Causes moderate inconvenience

### Current workarounds

In the particular: Anything Everywhere has a 'convert to real links' feature that can be used before exporting. But there is no way for the Anything Everywhere code to know that an export is underway, so the user has to be aware of the issue and trigger the conversion manually.

### Ideas for solutions (Optional)

The Comfy frontend has an excellent event broadcasting mechanism. Ideally, all the actions in the main menu would trigger a pair of events, one before execution and one after, with the menu item and any other relevant information included in the event.

Something like

`events.dispatch("menu-selection-initiated", { data })`

and

`events.dispatch("menu-selection-completed", { data })`

This would allow Anything Everywhere to listen for these events and identify when an export is being requested; it would also be a general solution that could be used by many custom node authors.

### Additional context

_No response_

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-6248-Events-triggered-by-menu-items-before-and-after-execution-2966d73d365081f783fac462911d0b00) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.