Comfy-Org / ComfyUI_frontend

Official front-end implementation of ComfyUI [Team travelling; No release between 2024-09-28 and 2024-09-30]
https://www.comfy.org/
GNU General Public License v3.0
468 stars 62 forks source link

[Feature Request]: Store settings server-side #1013

Closed christian-byrne closed 1 hour ago

christian-byrne commented 2 hours ago

Is there an existing issue for this?

What would your feature do ?

Settings would be centralized on the server.

Benefits:

Proposed workflow

  1. Settings are stored and loaded by the backend Already implemented
  2. Settings are accessed/changed via server's API, allowing GET/PATCH from frontend, backend, extension, custom node, etc.
  3. Settings fields can be configured/added in the pyproject.toml
huchenlei commented 2 hours ago

Is this feature about some backend configurations that can be hot-changed? such as load device, dtype, etc?

christian-byrne commented 2 hours ago

Is this feature about some backend configurations that can be hot-changed? such as load device, dtype, etc?

It's about storing all settings values on server instead of local storage.

huchenlei commented 2 hours ago

Is this feature about some backend configurations that can be hot-changed? such as load device, dtype, etc?

It's about storing all settings values on server instead of local storage.

Currently that is already the case for settings. They are eagerly pushing changes to settings.json. The issue now is only lacking of mechanism to sync settings across multiple browser tabs.

christian-byrne commented 2 hours ago

Can you briefly explain the system? I did not see the server endpoints for changing/acessing settings.

christian-byrne commented 2 hours ago

I see it is in user_manager.py. The frontend is accessing these settings via server as source of truth?

huchenlei commented 2 hours ago

Related code: https://github.com/Comfy-Org/ComfyUI_frontend/blob/9050591ff978efb6eb6d2ea65cc2c0195c1f4094/src/scripts/ui/settings.ts#L138-L156

In short we call api.storeSettings to update settings in the server side.

https://github.com/Comfy-Org/ComfyUI_frontend/blob/9050591ff978efb6eb6d2ea65cc2c0195c1f4094/src/scripts/api.ts#L572-L591

christian-byrne commented 2 hours ago

Thanks, I understand much better now. So settings are loaded from server, and changes are pushed to server.

Can they be GET from server on access as well? Instead of returning the client copy? It may be debounced. I think the server should be the source of truth.

christian-byrne commented 1 hour ago

The issue now is only lacking of mechanism to sync settings across multiple browser tabs.

Would it be solved by having the server manage the settings and accessing setting value on client side occurs through server API?

huchenlei commented 1 hour ago

The issue now is only lacking of mechanism to sync settings across multiple browser tabs.

Would it be solved by having the server manage the settings and accessing setting value on client side occurs through server API?

One thing we can do is using ws message to boardcast setting change to all clients.

christian-byrne commented 1 hour ago

Yes it seems that is good. I did not fully understand the trade offs before.

Selection_425

christian-byrne commented 1 hour ago

For this

  • Custom node developers can more easily communicate between backend and frontend bidirectionally
  • Custom node developers can create settings in the UI from the backend

There may be a better solution