feat: text gate protected mode — standalone text node (backend)
protected=True makes run() emit stored_text and ignore upstream with no pause; IS_CHANGED caches on stored_text when protected (NaN otherwise). text input is now optional so the node can run standalone. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+18
-7
@@ -22,26 +22,37 @@ class TextGate:
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
# `text` is optional so the node can run standalone in protected mode.
|
||||
# `protected` + `stored_text` are serializing widgets carrying the
|
||||
# authored text-node state (stored_text is hidden by the frontend).
|
||||
return {
|
||||
"required": {
|
||||
"text": ("STRING", {"forceInput": True}),
|
||||
},
|
||||
"optional": {
|
||||
"text": ("STRING", {"forceInput": True}),
|
||||
"signal": (ANY, {}),
|
||||
"protected": ("BOOLEAN", {"default": False}),
|
||||
"stored_text": ("STRING", {"default": "", "multiline": True}),
|
||||
},
|
||||
"hidden": {"unique_id": "UNIQUE_ID"},
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def IS_CHANGED(cls, **kwargs):
|
||||
return float("nan")
|
||||
def IS_CHANGED(cls, protected=False, stored_text="", **kwargs):
|
||||
# Protected = plain text node: cache on the authored text so downstream
|
||||
# only re-runs when it changes. Otherwise never cache (always pause).
|
||||
return stored_text if protected else float("nan")
|
||||
|
||||
def run(self, unique_id=None, text=None, signal=None,
|
||||
protected=False, stored_text=""):
|
||||
if protected:
|
||||
# Standalone text node: emit the authored text, ignore upstream, no
|
||||
# pause. Returns before importing comfy, so it stays import-safe.
|
||||
return (stored_text, signal)
|
||||
|
||||
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)
|
||||
gate_server.send_text(unique_id, text or "")
|
||||
try:
|
||||
edited = gate_bus.GateBus.wait_payload(
|
||||
unique_id, should_cancel=mm.processing_interrupted)
|
||||
|
||||
Reference in New Issue
Block a user