feat: TextGate node — pause, editable pass-through, signal passthrough
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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)"}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user