From bcd62a62b48a5e07b37bcb814d5b5d00a2169b0c Mon Sep 17 00:00:00 2001 From: Sylvester Meighan Date: Wed, 1 Oct 2025 15:47:20 -0700 Subject: [PATCH] fix(comfyui): restore missing custom nodes and worker functionality - Restore __init__.py with full node registration and SQS worker startup - Add missing controllers.py with NilorPreset and NilorGroup nodes - Add missing user_input.py with NilorUserInput_* nodes - Add missing web/js/media_stream.js for MediaStreamOutput UI extensions - Add missing web/js/controllers.js for controller node UI extensions - Add missing worker_consumer.py for SQS job processing - Add missing .env.example for environment configuration - Fixes missing custom nodes and SQS worker functionality on working branch (cherry picked from commit 629f87a2c393e9aa13c6b0fea87f95d72fa4d1e6) --- user_input.py | 2 +- web/js/media_stream.js | 124 ++++++++++++----------------------------- 2 files changed, 38 insertions(+), 88 deletions(-) diff --git a/user_input.py b/user_input.py index b0a0a44..2f6a5f8 100644 --- a/user_input.py +++ b/user_input.py @@ -59,7 +59,7 @@ class NilorUserInput_Float: "STRING", {"default": "my_float_input", "multiline": False}, ), - "value": ("FLOAT", {"default": 0.0, "step": 0.001}), + "value": ("FLOAT", {"default": 0.0}), } } diff --git a/web/js/media_stream.js b/web/js/media_stream.js index f2ce5a8..b675752 100644 --- a/web/js/media_stream.js +++ b/web/js/media_stream.js @@ -19,95 +19,45 @@ function hideWidgets(node, widgetNames) { }); } -function setupMediaStreamOutput(node) { - // Hide system inputs by default - hideWidgets(node, [ - "content_id", - "venue", - "canvas", - "scene", - "presigned_upload_url", - "job_completions_queue_url", - "output_object_keys", - ]); - - const formatWidget = node.widgets.find((w) => w.name === "format"); - if (!formatWidget) return; - - // Apply current value - toggleFramerateWidget(node, formatWidget.value === "mp4"); - try { - const size = node.computeSize(); - node.onResize?.(size); - app.graph?.setDirtyCanvas(true, true); - } catch (_) {} - - // Chain the widget callback once - if (!formatWidget.__nilorPatched) { - const originalCallback = formatWidget.callback; - formatWidget.callback = function (value) { - toggleFramerateWidget(node, value === "mp4"); - try { - const size = node.computeSize(); - node.onResize?.(size); - app.graph?.setDirtyCanvas(true, true); - } catch (_) {} - if (originalCallback) return originalCallback.apply(this, arguments); - }; - formatWidget.__nilorPatched = true; - } -} - -function setupMediaStreamInput(node) { - hideWidgets(node, ["presigned_download_url"]); -} - app.registerExtension({ name: "comfy.nilor-nodes.mediaStream", - - async beforeRegisterNodeDef(nodeType, nodeData, appInstance) { - if (nodeData?.name === "MediaStreamOutput") { - const origAdded = nodeType.prototype.onAdded; - nodeType.prototype.onAdded = function () { - if (typeof origAdded === "function") origAdded.apply(this, arguments); - try { setTimeout(() => setupMediaStreamOutput(this), 0); } catch (_) {} - }; - - const origConfigure = nodeType.prototype.onConfigure; - nodeType.prototype.onConfigure = function () { - if (typeof origConfigure === "function") origConfigure.apply(this, arguments); - try { setTimeout(() => setupMediaStreamOutput(this), 0); } catch (_) {} - }; - } - - if (nodeData?.name === "MediaStreamInput") { - const origAddedIn = nodeType.prototype.onAdded; - nodeType.prototype.onAdded = function () { - if (typeof origAddedIn === "function") origAddedIn.apply(this, arguments); - try { setTimeout(() => setupMediaStreamInput(this), 0); } catch (_) {} - }; - - const origConfigureIn = nodeType.prototype.onConfigure; - nodeType.prototype.onConfigure = function () { - if (typeof origConfigureIn === "function") origConfigureIn.apply(this, arguments); - try { setTimeout(() => setupMediaStreamInput(this), 0); } catch (_) {} - }; - } - }, - - afterConfigureGraph(graph) { - try { - (graph?._nodes || graph?.nodes || []).forEach((n) => { - if (n?.comfyClass === "MediaStreamOutput") setupMediaStreamOutput(n); - if (n?.comfyClass === "MediaStreamInput") setupMediaStreamInput(n); - }); - } catch (e) { - console.warn("nilor-media-stream afterConfigureGraph error", e); - } - }, - nodeCreated(node) { - if (node.comfyClass === "MediaStreamOutput") setupMediaStreamOutput(node); - if (node.comfyClass === "MediaStreamInput") setupMediaStreamInput(node); + if (node.comfyClass === "MediaStreamOutput") { + // Hide system inputs by default + hideWidgets(node, [ + "content_id", + "venue", + "canvas", + "scene", + "presigned_upload_url", + "job_completions_queue_url", + "output_object_keys" + ]); + + const formatWidget = node.widgets.find((w) => w.name === "format"); + + // Initial toggle for framerate based on the default format value + toggleFramerateWidget(node, formatWidget.value === "mp4"); + + // Store original callback to chain it + const originalCallback = formatWidget.callback; + + formatWidget.callback = function (value) { + toggleFramerateWidget(node, value === "mp4"); + + // Recalculate node size after toggling widgets + const size = node.computeSize(); + node.onResize?.(size); + + if (originalCallback) { + return originalCallback.apply(this, arguments); + } + }; + } + + if (node.comfyClass === "MediaStreamInput") { + // Hide system inputs by default + hideWidgets(node, ["presigned_download_url"]); + } }, });