diff --git a/__init__.py b/__init__.py index 4517963..4847872 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,5 @@ import logging +import threading from aiohttp import web from server import PromptServer @@ -25,7 +26,11 @@ def on_prompt_handler(json_data): if ct: class_types.add(ct) if class_types: - tracker.record_usage(class_types, mapper) + threading.Thread( + target=tracker.record_usage, + args=(class_types, mapper), + daemon=True, + ).start() except Exception: logger.warning("nodes-stats: error recording usage", exc_info=True) return json_data diff --git a/js/nodes_stats.js b/js/nodes_stats.js index da60b00..169e57b 100644 --- a/js/nodes_stats.js +++ b/js/nodes_stats.js @@ -1,5 +1,15 @@ import { app } from "../../scripts/app.js"; +// Bar chart with nodes icon +const STATS_ICON = ` + + + + + + +`; + app.registerExtension({ name: "comfyui.nodes_stats", @@ -25,8 +35,11 @@ app.registerExtension({ ); const btn = document.createElement("button"); - btn.textContent = "Node Stats"; + btn.innerHTML = STATS_ICON; + btn.title = "Node Stats"; btn.onclick = () => showStatsDialog(); + btn.style.cssText = + "display:flex;align-items:center;justify-content:center;padding:6px;background:none;border:none;cursor:pointer;color:var(--input-text,#ddd);"; const menu = document.querySelector(".comfy-menu"); if (menu) {