From f617c46aefb54739c657058bfb52f9ec3ee64e66 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sun, 21 Jun 2026 18:47:55 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20TextGate=20node=20=E2=80=94=20pause,=20?= =?UTF-8?q?editable=20pass-through,=20signal=20passthrough?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- gates/textgate.py | 40 ++++++++++++++++++++++++++++++++++++++++ tests/test_textgate.py | 11 +++++++++++ 2 files changed, 51 insertions(+) diff --git a/gates/textgate.py b/gates/textgate.py index c65c72a..3abcc7a 100644 --- a/gates/textgate.py +++ b/gates/textgate.py @@ -12,3 +12,43 @@ class AnyType(str): ANY = AnyType("*") + + +class TextGate: + CATEGORY = "Datasete Gates" + FUNCTION = "run" + RETURN_TYPES = ("STRING", ANY) + RETURN_NAMES = ("text", "signal") + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "text": ("STRING", {"forceInput": True}), + }, + "optional": { + "signal": (ANY, {}), + }, + "hidden": {"unique_id": "UNIQUE_ID"}, + } + + @classmethod + def IS_CHANGED(cls, **kwargs): + return float("nan") + + def run(self, text, unique_id, signal=None): + from . import gate_server + import comfy.model_management as mm + + gate_bus.GateBus.arm(unique_id) + gate_server.send_text(unique_id, text) + try: + edited = gate_bus.GateBus.wait_payload( + unique_id, should_cancel=mm.processing_interrupted) + except gate_bus.GateCancelled: + raise mm.InterruptProcessingException() + return (edited, signal) + + +NODE_CLASS_MAPPINGS = {"TextGate": TextGate} +NODE_DISPLAY_NAME_MAPPINGS = {"TextGate": "Text Gate (Manual Pass)"} diff --git a/tests/test_textgate.py b/tests/test_textgate.py index 90553e0..8feb4bf 100644 --- a/tests/test_textgate.py +++ b/tests/test_textgate.py @@ -1,7 +1,18 @@ # tests/test_textgate.py +import math + from gates import textgate def test_anytype_is_compatible_with_everything(): assert (textgate.ANY != "IMAGE") is False assert (textgate.ANY != "LATENT") is False assert isinstance(textgate.ANY, str) + +def test_textgate_io_shape(): + assert textgate.TextGate.RETURN_NAMES == ("text", "signal") + assert textgate.TextGate.RETURN_TYPES[0] == "STRING" + assert textgate.TextGate.RETURN_TYPES[1] == textgate.ANY + +def test_textgate_is_changed_nan(): + v = textgate.TextGate.IS_CHANGED(text="hi", unique_id="1") + assert math.isnan(v)