Files
ComfyUI-Dataset-Gates/docs/plans/2026-06-26-textgate-run-from-here-design.md
T
Ethanfel b90d1befe6 fix: text gate sticky edit by intent, not upstream-text comparison
Run-from-here now preserves the edited text via an explicit _tgKeepEdit flag
set when the button is pressed, instead of comparing incoming vs last text.
A non-deterministic upstream (random/seeded prompt) regenerates text on every
re-queue, which made the old comparison clobber the edit. Normal toolbar Queue
still shows fresh upstream text.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 09:58:32 +02:00

61 lines
2.8 KiB
Markdown

# Text Gate — "Run from here" + sticky edit (design)
**Goal:** Bring the Text Gate to parity with the Image Gate's "Run from here"
affordance, plus a text-specific touch: keep the user's edited text across
re-runs ("start from there").
**Scope:** Frontend only — `web/text_gate.js`. No changes to `gates/textgate.py`,
`gates/gate_bus.py`, or `gates/gate_server.py`. The gate already re-arms and
re-pauses on every run (`GateBus.arm``wait_payload`) and `IS_CHANGED` returns
`NaN`, so re-queuing the prompt is enough to "resume": cached upstream means the
gate re-pauses near-instantly.
## State machine
The node currently has no explicit state. Add three:
- **idle** — before the first run. Pass shown, Run-from-here hidden.
- **paused** — socket `datasete-textgate-show` arrived. Textarea editable &
populated, **▶ Pass** shown, **Run from here** hidden, status `edit, then Pass`.
- **passed** — after Pass click. Textarea keeps the edited text, **Pass** hidden,
**▶ Run from here** shown, status `passed — Run from here to re-run`.
**Run from here** click → `app.queuePrompt(0, 1)` with `app.queuePrompt(0)`
fallback — copied verbatim from the Image Gate's `queueFromHere`.
## Sticky edited text (by intent, not text comparison)
The Image Gate keeps its mask sticky; the Text Gate keeps its text. Stickiness is
keyed off **which action triggered the run**, not a text comparison — because the
upstream feeding `text` is often non-deterministic (random/seeded prompts), so a
text comparison would wrongly clobber the edit on every Run-from-here.
- The "Run from here" button sets `node._tgKeepEdit = true` before re-queuing.
- On the next re-pause (`datasete-textgate-show`):
- if `node._tgKeepEdit`**keep** the current textarea value and clear the
flag, so the gate re-emits *your* edited text downstream.
- else (a normal toolbar Queue) → overwrite the textarea with the incoming
upstream text.
Net: Run-from-here always preserves your edit; a deliberate full Queue shows the
fresh upstream text. `_tgKeepEdit` is per-session (not serialized).
**Out of scope:** re-queuing still recomputes non-cacheable upstream nodes — that
is inherent to ComfyUI and identical for the Image Gate. With intent-based
stickiness the regenerated text is simply ignored, so it can't change the result;
to skip the compute, Bypass (Ctrl+B) the upstream node manually.
## Verification
- `node --check web/text_gate.js` (no JS test harness in the repo — consistent
with the other `web/*.js`).
- Manual: pause → edit → Pass → button appears → Run-from-here re-pauses showing
your edited text → downstream re-runs; change something upstream → new input
shows.
## Dropped (YAGNI)
- A separate "↺ reset to input" button — the upstream-change detection covers the
stale-edit footgun.
- Any backend auto-pass / bypass mode — not requested.