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:
@@ -16,3 +16,31 @@ def test_textgate_io_shape():
|
||||
def test_textgate_is_changed_nan():
|
||||
v = textgate.TextGate.IS_CHANGED(text="hi", unique_id="1")
|
||||
assert math.isnan(v)
|
||||
|
||||
|
||||
def test_textgate_text_input_is_optional():
|
||||
it = textgate.TextGate.INPUT_TYPES()
|
||||
assert "text" in it["optional"]
|
||||
assert "protected" in it["optional"]
|
||||
assert "stored_text" in it["optional"]
|
||||
|
||||
|
||||
def test_textgate_protected_returns_stored_text_without_pause():
|
||||
# protected mode must return the stored text directly — no GateBus, no comfy
|
||||
out = textgate.TextGate().run(
|
||||
unique_id="1", text="from upstream", signal="sig",
|
||||
protected=True, stored_text="my authored text",
|
||||
)
|
||||
assert out == ("my authored text", "sig")
|
||||
|
||||
|
||||
def test_textgate_is_changed_protected_returns_stored_text():
|
||||
v = textgate.TextGate.IS_CHANGED(
|
||||
unique_id="1", protected=True, stored_text="frozen")
|
||||
assert v == "frozen"
|
||||
|
||||
|
||||
def test_textgate_is_changed_not_protected_is_nan():
|
||||
v = textgate.TextGate.IS_CHANGED(
|
||||
unique_id="1", protected=False, stored_text="ignored")
|
||||
assert math.isnan(v)
|
||||
|
||||
Reference in New Issue
Block a user