f12272d002
- docs/capabilities/INDEX.md - docs/capabilities/comfyui.md - python/functions/browser/comfyui_export_workflow_ui.md - python/functions/browser/comfyui_export_workflow_ui.py - python/functions/browser/comfyui_load_workflow_ui.md - python/functions/browser/comfyui_load_workflow_ui.py - python/functions/browser/comfyui_queue_prompt_ui.md - python/functions/browser/comfyui_queue_prompt_ui.py - python/functions/browser/comfyui_refresh_nodes_ui.md - python/functions/browser/comfyui_refresh_nodes_ui.py - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
64 lines
2.2 KiB
Python
64 lines
2.2 KiB
Python
"""Refresca los combos del grafo de ComfyUI desde la UI via CDP.
|
|
|
|
Llama `app.refreshComboInNodes()`, que vuelve a pedir GET /object_info al server
|
|
y actualiza los combos de todos los nodos (lista de checkpoints, loras, vaes,
|
|
samplers) sin recargar la pagina. Util tras descargar modelos nuevos con
|
|
comfyui_download_model para que aparezcan en los CheckpointLoaderSimple sin un
|
|
F5. Compone cdp_eval.
|
|
|
|
Funcion impura: hace red (CDP WebSocket) y refresca estado de la UI.
|
|
"""
|
|
import json
|
|
|
|
try: # ejecucion directa del archivo / fn run (browser/ en sys.path[0])
|
|
from cdp_eval import cdp_eval
|
|
except ImportError: # importado como paquete (sys.path = python/functions)
|
|
from browser.cdp_eval import cdp_eval
|
|
|
|
|
|
def comfyui_refresh_nodes_ui(
|
|
*,
|
|
port: int = 9222,
|
|
server_url_substr: str = "8188",
|
|
timeout_s: float = 15.0,
|
|
) -> dict:
|
|
"""Refresca los combos (checkpoints/loras/vae) de los nodos del grafo.
|
|
|
|
Args:
|
|
port: puerto de remote debugging del Chrome diario. Default 9222.
|
|
server_url_substr: substring de la URL de la pestana de ComfyUI.
|
|
timeout_s: timeout de la conexion CDP en segundos.
|
|
|
|
Returns:
|
|
dict {ok: bool, refreshed: bool, error: str}. refreshed True si
|
|
app.refreshComboInNodes resolvio sin excepcion.
|
|
"""
|
|
expr = (
|
|
"(async function(){"
|
|
" if(!window.app || typeof app.refreshComboInNodes!=='function'){"
|
|
" return {refreshed:false, error:'window.app.refreshComboInNodes no disponible en la pestana'};"
|
|
" }"
|
|
" try{ await app.refreshComboInNodes(); return {refreshed:true, error:''}; }"
|
|
" catch(e){ return {refreshed:false, error:String(e)}; }"
|
|
"})()"
|
|
)
|
|
r = cdp_eval(
|
|
expr,
|
|
port=port,
|
|
target_url_substr=server_url_substr,
|
|
await_promise=True,
|
|
timeout_s=timeout_s,
|
|
)
|
|
if not r["ok"]:
|
|
return {"ok": False, "refreshed": False, "error": r["error"]}
|
|
val = r["value"] or {}
|
|
return {
|
|
"ok": bool(val.get("refreshed")),
|
|
"refreshed": bool(val.get("refreshed")),
|
|
"error": val.get("error", ""),
|
|
}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(json.dumps(comfyui_refresh_nodes_ui(), ensure_ascii=False, indent=2))
|