From f88e58dc04672a68490d4166f32aa1eb83e15eb8 Mon Sep 17 00:00:00 2001 From: Juan Treminio Date: Sat, 27 Jun 2026 20:01:19 -0600 Subject: [PATCH 1/2] let extensions see which node made each image --- .../ComfyUIBackend/ComfyUIAPIAbstractBackend.cs | 2 +- src/Text2Image/T2IEngine.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BuiltinExtensions/ComfyUIBackend/ComfyUIAPIAbstractBackend.cs b/src/BuiltinExtensions/ComfyUIBackend/ComfyUIAPIAbstractBackend.cs index abf94e193..0af2a2731 100644 --- a/src/BuiltinExtensions/ComfyUIBackend/ComfyUIAPIAbstractBackend.cs +++ b/src/BuiltinExtensions/ComfyUIBackend/ComfyUIAPIAbstractBackend.cs @@ -516,7 +516,7 @@ async Task doInterruptNow() ["comfy_index"] = index }; } - takeOutput(new T2IEngine.ImageOutput() { File = new Image(output[preBytes..], mediaType), IsReal = isReal, GenTimeMS = firstStep == 0 ? -1 : (Environment.TickCount64 - firstStep) }); + takeOutput(new T2IEngine.ImageOutput() { File = new Image(output[preBytes..], mediaType), IsReal = isReal, ComfyNodeId = string.IsNullOrEmpty(currentNode) ? null : currentNode, GenTimeMS = firstStep == 0 ? -1 : (Environment.TickCount64 - firstStep) }); } else { diff --git a/src/Text2Image/T2IEngine.cs b/src/Text2Image/T2IEngine.cs index c0fc4d84b..842fc8730 100644 --- a/src/Text2Image/T2IEngine.cs +++ b/src/Text2Image/T2IEngine.cs @@ -29,7 +29,7 @@ public record class PreGenerationEventParams(T2IParamInput UserInput); public static Action PostGenerateEvent; /// Paramters for . - public record class PostGenerationEventParams(MediaFile File, T2IParamInput UserInput, Action RefuseImage); + public record class PostGenerationEventParams(MediaFile File, T2IParamInput UserInput, Action RefuseImage, string ComfyNodeId = null); /// Extension event, fired after a batch of images were generated. /// Use "RefuseImage" to mark an image as removed. Note that it may have already been shown to a user, when the live result websocket API is in use. @@ -66,6 +66,9 @@ public Image Img /// An action that will remove/discard this file as relevant. public Action RefuseImage; + + /// The backend node id that produced this output, if known. + public string ComfyNodeId; } /// List of functions that take a pair of userinput and backend, and returns true if they can fit together, or false if the pair is not valid (add to user_input.RefusalReasons if so). @@ -221,7 +224,7 @@ string format(long t) copyInput.ExtraMeta["intermediate"] = "intermediate output"; } bool refuse = false; - PostGenerateEvent?.Invoke(new(img.File, copyInput, () => refuse = true)); + PostGenerateEvent?.Invoke(new(img.File, copyInput, () => refuse = true, img.ComfyNodeId)); if (refuse) { Logs.Info($"Refused an image."); From 3d8c33b60a8e376fa7c632fbbc3f35bf804d9e58 Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" Date: Sun, 28 Jun 2026 15:33:37 -0700 Subject: [PATCH 2/2] more generic labeling --- .../ComfyUIBackend/ComfyUIAPIAbstractBackend.cs | 2 +- src/Text2Image/T2IEngine.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/BuiltinExtensions/ComfyUIBackend/ComfyUIAPIAbstractBackend.cs b/src/BuiltinExtensions/ComfyUIBackend/ComfyUIAPIAbstractBackend.cs index 0af2a2731..ff883adb1 100644 --- a/src/BuiltinExtensions/ComfyUIBackend/ComfyUIAPIAbstractBackend.cs +++ b/src/BuiltinExtensions/ComfyUIBackend/ComfyUIAPIAbstractBackend.cs @@ -516,7 +516,7 @@ async Task doInterruptNow() ["comfy_index"] = index }; } - takeOutput(new T2IEngine.ImageOutput() { File = new Image(output[preBytes..], mediaType), IsReal = isReal, ComfyNodeId = string.IsNullOrEmpty(currentNode) ? null : currentNode, GenTimeMS = firstStep == 0 ? -1 : (Environment.TickCount64 - firstStep) }); + takeOutput(new T2IEngine.ImageOutput() { File = new Image(output[preBytes..], mediaType), IsReal = isReal, BackendInternalHint = currentNode, GenTimeMS = firstStep == 0 ? -1 : (Environment.TickCount64 - firstStep) }); } else { diff --git a/src/Text2Image/T2IEngine.cs b/src/Text2Image/T2IEngine.cs index 842fc8730..9c095f0d1 100644 --- a/src/Text2Image/T2IEngine.cs +++ b/src/Text2Image/T2IEngine.cs @@ -29,7 +29,7 @@ public record class PreGenerationEventParams(T2IParamInput UserInput); public static Action PostGenerateEvent; /// Paramters for . - public record class PostGenerationEventParams(MediaFile File, T2IParamInput UserInput, Action RefuseImage, string ComfyNodeId = null); + public record class PostGenerationEventParams(MediaFile File, T2IParamInput UserInput, Action RefuseImage, string BackendInternalHint = null); /// Extension event, fired after a batch of images were generated. /// Use "RefuseImage" to mark an image as removed. Note that it may have already been shown to a user, when the live result websocket API is in use. @@ -67,8 +67,8 @@ public Image Img /// An action that will remove/discard this file as relevant. public Action RefuseImage; - /// The backend node id that produced this output, if known. - public string ComfyNodeId; + /// Optional text identifying some internal hint from the backend, such as a Comfy Node ID. Format or content not guaranteed, use with caution and validation checks. + public string BackendInternalHint; } /// List of functions that take a pair of userinput and backend, and returns true if they can fit together, or false if the pair is not valid (add to user_input.RefusalReasons if so). @@ -224,7 +224,7 @@ string format(long t) copyInput.ExtraMeta["intermediate"] = "intermediate output"; } bool refuse = false; - PostGenerateEvent?.Invoke(new(img.File, copyInput, () => refuse = true, img.ComfyNodeId)); + PostGenerateEvent?.Invoke(new(img.File, copyInput, () => refuse = true, img.BackendInternalHint)); if (refuse) { Logs.Info($"Refused an image.");