Files
malkuthro-ComfyUI-Koolook/docs/automations
6f158c9020 fix(nodes): Easy_LoadVideo empty-branch degrade (bundles #243 publish-tab cleanup) (#244)
* docs(setups): add setup runner quickstart runbook

Standalone reference for opening the published-setup mockup frontend
(setup runner simulator): the `<comfy-address>/koolook/setup_runner_simulator.html`
URL pattern, the live-registry vs setup-file (inspect-only) load paths,
and demo mode.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(sidebar): close throwaway workflow tabs left by publish capture

Publishing a setup captures ComfyUI's API-format prompt by loading the
graph onto the canvas (graphToPrompt) and reloading the prior canvas.
In current Comfy each loadGraphData spawns an "Unsaved Workflow" tab, so
every publish left two stray tabs behind.

captureWorkflowApiPrompt now snapshots the open workflows before capture
and, afterward, re-activates the user's original tab and closes whatever
the capture opened, via app.extensionManager.workflow. All of it is
guarded and best-effort: the workflow-store API is Comfy-version
specific, so if it is absent capture still succeeds and behavior falls
back to today (no crash, no broken publish).

Covered by a source-pattern test. Needs live verification against the
1.45 frontend (dev-sync) to confirm the closeWorkflow API shape.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(nodes): Easy_LoadVideo degrades to empty on an unselected folder branch

When an upstream mode switch routes a path into Easy_LoadVideo, both the
EXR sequence loader and the video loader execute eagerly. On the EXR
branch the video loader was handed a folder (no filename) and raised
ValueError, crashing the whole prompt -- even though that branch is
discarded downstream. Lenient sequence loaders just ignore a wrong-type
path; the video loader was the only one that hard-failed.

_compose_input_video_path now returns EMPTY_BRANCH_SENTINEL instead of
raising when input_path resolves to an existing directory. load_video
turns that into a correctly-shaped empty result (IMAGE zeros,
frame_count 0, empty AUDIO, empty video_info) matching VHS_LoadVideoPath
returns, so the dead branch no longer crashes the prompt. VALIDATE_INPUTS
and IS_CHANGED handle the sentinel too. A path that does not exist is
still a genuine mistake and keeps raising.

torch is imported lazily in the empty-result builder so the path logic
stays importable/testable without torch.

Covered by unit tests for the sentinel (absolute + relative dirs), the
still-raises case, and a load_video integration test that asserts the
empty result and that the loader never runs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(setups): expose prompt as an always-on field in the publish frontend

The publish surface modelled `prompt` as a 4th source mode (mutually
exclusive with EXR/QT/Img) and hid it (visible:false), so a published
setup couldn't offer "pick a source AND describe the shot". This makes
prompt a standalone, always-on input.

- published_surface.js: prompt becomes visible + standalone + multiline,
  rendered independently of the source switch; the author's prompt-widget
  text is surfaced as a `placeholder` hint (submitted default is empty so
  an untouched hint is never sent), with a `help` line. The switch
  excludes standalone fields from its source options.
- setup_runner_simulator.js: renders always-on standalone inputs alongside
  the selected source (textarea + placeholder + help), includes them in the
  run payload, and updates the demo setup.
- setup_runner_simulator.html: .field-help styling.
- contract doc: documents the always-on prompt behaviour.
- launch.json: portability fix (hardcoded C:\Python313 -> python).

Contract test updated + a new test asserting prompt is always-on, carries
the placeholder, and is excluded from the switch source options (runs on
CI where Node is available). Behaviour verified in the runner simulator
(demo mode) in a browser: textarea + hint, EXR/QT/Img-only switch, prompt
stays visible across source changes, payload includes the typed prompt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(setups): mirror always-on prompt field in the Python publish inference

The publish surface is inferred server-side in Python (koolook_setups.py
_infer_app_surface, called by publishSetup), which overrides the client.
The earlier change only updated the JS (published_surface.js), so
re-publishing still produced the old surface with a hidden prompt.

Mirror the JS here: prompt is a standalone, always-on input (visible +
multiline) with the author's prompt-widget text as a placeholder hint and
an empty submitted default; it is excluded from the source switch options.
Keeps koolook_setups.py and published_surface.js in sync.

Registry test updated to the new shape. Server + publish-contract suites
green (115); full non-sidebar suite green (530).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(setups): keep the runner simulator polling through long renders

The poller used a fixed 30s total budget, so a multi-minute render (e.g.
428s) timed out mid-run with "Timed out waiting for run" even though
ComfyUI was still rendering and the run later landed as succeeded.

timeoutMs is now a "no-progress" window: while ComfyUI keeps reporting the
run as queued/running, the deadline is pushed forward, so a long-but-active
render never spuriously times out; only a stalled/vanished run gives up.
Default raised 30s -> 120s. The run status line shows elapsed seconds while
active so a long wait visibly ticks instead of looking frozen.

Happy path (queued -> running -> succeeded) unchanged; verified in the
runner simulator (demo mode) in a browser.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(setups): serve simulator assets with no-store so dev-syncs take effect

The runner-simulator HTML/JS route returned no cache headers, so browsers
cached the assets and kept running stale JS after a dev-sync -- e.g. the
old 30s poller persisted client-side even though the server was serving
the long-render fix, which looked like "the fix didn't land". Serve these
dev-synced assets with Cache-Control: no-store so a normal reload always
picks up the current code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* test(setups): add live run/poll smoke check for the published-setup API

tools/check_setup_run.py queues a published setup through the same routes
the runner simulator uses and polls the run endpoint with the same
deadline-extension logic, printing the status timeline. Lets us self-verify
end-to-end run tracking against a live ComfyUI (e.g. "does a long render
reach succeeded?") without driving the browser UI.

Used it to confirm the run/poll server flow is correct (terminal status
detected in ~2s; run-000001 reported succeeded), isolating the simulator's
earlier "Timed out" to stale browser cache rather than a server bug.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(nodes): Koolook_NextVersion auto-detects the next output version

Adds filesystem-aware version auto-detection so a re-run lands on a fresh
version instead of failing with "Output file already exists and overwrite
is disabled" (the real EasyAIPipeline failure seen on the RMGB setup).

- koolook_versioning.next_version_token(directory, name, ...): scans for
  existing <name>_vNNN files AND sequence-folders (handles name_v002.png,
  name_v002.0001.exr, name_v003/), returns highest+1 zero-padded; missing/
  empty dir -> start (v001); exact base-name match so other shots never
  bump this one; empty name matches bare vNNN; configurable prefix/padding.
- Koolook_NextVersion node (Koolook/Publish): folder + name -> next version
  token. Wire once into both the EXR and video version inputs so branches
  stay in sync. IS_CHANGED returns NaN to re-scan every run.

Tested: helper edge cases + node registration/run. Preflight clean (20
node IDs). Full non-sidebar suite green (539).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* feat(nodes): 'auto' version keyword for EasyAIPipeline + Easy_VideoCombine

No new node or wiring needed: type 'auto' (or 'next') in the version field
and the node scans its own output folder for existing <name>_vNNN entries
and writes the next free version -- fixing "Output file already exists and
overwrite is disabled" without manual version bumps.

- koolook_versioning.is_auto_version(): detects the auto/next keyword.
- EasyAIPipeline (build_pipeline_outputs): on auto, scans the version-folder
  parent (base, or base/shot/method when subfolders are on) for vNNN dirs and
  picks the next; version computed after path segments so the scan dir is known.
- Easy_VideoCombine: on auto, resolves the token after the output dir + name
  root are composed, scanning that dir for <name>_vNNN outputs.
- Non-auto/typed/wired tokens and disable_versioning are unchanged.

Tests: is_auto_version keywords + EasyAIPipeline auto (v003 after v001/v002,
v001 first run). Full non-sidebar suite green (542), preflight clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* refactor(nodes): drop redundant Koolook_NextVersion node

The 'auto' version keyword on EasyAIPipeline + Easy_VideoCombine covers
auto-detection without any new node or wiring, so the standalone
Koolook_NextVersion node is redundant. Remove it (and its node test) to keep
the node list clean; the shared next_version_token helper stays (the 'auto'
keyword uses it).

Node-ID count back to 19; full non-sidebar suite green (541), preflight clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(tools): satisfy security gate for setup smoke check

* fix(pr244): address verified review findings

* fix(video): fail if relative auto-version scan root is unavailable

---------

Co-authored-by: Cristian Predut <cristian.predut@x.baconcph.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: AI Machine <ai.machine@x.baconcph.com>
2026-06-19 00:10:59 +02:00
..

Automations

AI-managed ComfyUI iteration loops. Each automation module is one self-contained workflow: own ComfyUI session, own workflow JSON, own narrative, own findings — typically focused on one specific generation task (a single-stage render path, an audio-driven lip-sync, an upscale recipe, etc.). The same diffusion model can host several modules side by side; one folder per task, not one per model.

The agent's role inside each module is the same: watch the maintainer's workflow edits, score feedback, render tracking cards via /make-card, and — when the task needs it — modify code in forks/ or scripts/.

Want the visual walkthrough? → index.html presents the setup and loop as an HTML overview.

Already know the loop? → CHEATSHEET.md (one page, dense bullets).

Where things live

In the repo

ComfyUI-Koolook/
├── .env                                     gitignored — your machine's config
│                                            (KOLOOK_AUTOMATIONS_WORK_DIR=…)
├── .env.example                             committed template — documents the var
├── .claude/skills/make-card/
│   └── SKILL.md                             the `/make-card` slash command
├── scripts/
│   ├── make_card.py                         renders a card PNG from workflow JSON
│   └── watch_cards.py                       optional polling watcher
├── forks/                                   ← any modified upstream node code an
│                                            automation needs (e.g. whatdreamscost_koolook/)
└── docs/automations/
    ├── README.md                            you are here
    ├── CONVENTIONS.md                       cross-cutting loop contract
    ├── CHEATSHEET.md                        one-page reminder
    └── LTX-2.3/                             grouping by diffusion model
        ├── base-1step/                       ← one automation module
        │   ├── README.md                     loop entry point for this task
        │   ├── handoff-checklist.md
        │   ├── findings.md                   locked-in conclusions for THIS task
        │   ├── backstory/                    narrative that produced the module
        │   └── example-cards/                rendered cards from past runs
        └── audio-lipsync/                    ← another automation module, same model
            ├── README.md
            ├── handoff-checklist.md
            ├── findings.md
            ├── backstory/
            └── runs/                         per-render snapshots in the repo
                ├── LOOP.md                   per-task iteration protocol
                └── log.md                    rolling table of runs

The model-name folder (LTX-2.3/) is only a grouping — it doesn't carry shared docs of its own. Each automation under it is independent (own README, own findings). Model-architecture facts that genuinely apply to every module on that model can live in any one module's findings.md and be cross-linked from siblings (or lifted to a shared file later if a third module materialises and the duplication is real).

Per-project working folder (lives outside the repo)

Pointed at by KOLOOK_AUTOMATIONS_WORK_DIR in .env. One folder per project. Holds:

<working folder>/                            e.g. JOBS/<client>/<scene>/ComfyUI-working-folder
├── <workflow>.json                          ← user content — ComfyUI workflow export
├── <workflow>.mp4                           ← user content — rendered video
├── …more JSONs/MP4s as you iterate
└── _AI/                                     ← AI-managed — written by make_card.py
    ├── card.png                             stable tracking card (overwritten each run)
    └── iterations.md                        append-only log, one row per render

The _AI/ split lets you wipe agent artifacts without touching user content (or vice-versa). You can delete _AI/ to reset the history; you can delete the JSONs and MP4s without losing the iteration log.

For automations that ship in-repo runs/ snapshots (the audio-lipsync module does this — because the iteration touches fork code, not just widgets), the snapshots live inside the module folder. The _AI/iterations.md outside-the-repo log is still the authoritative running record; the in-repo runs/log.md is the condensed cross-machine summary.

What lives here

Module Model Status Task
LTX-2.3/base-1step/ LTX 2.3 active Single-stage render: brief once, sample 8 steps, no Phase-2 upscale. Model-generated audio.
LTX-2.3/audio-lipsync/ LTX 2.3 active Audio-file-driven lip-sync. Modified LTXDirector (Prompt-Relay paper σ + relay_overrides widget). Ships a fork at forks/whatdreamscost_koolook/.

The pattern (every module looks like this)

  1. One working folder per project holds everything for the iteration: workflow JSON + rendered video at the root (user content), plus an _AI/ subfolder for the agent-managed card + iterations log.
  2. Three named Text Multiline nodes inside the ComfyUI workflow form the data contract:
    • Working_Folder_PATH — authoritative output path.
    • OVERLAY - INFO — the run params summary + free-text BASE (notes): for what changed this run.
    • OVERLAY - FEEDBACK — observations on the rendered video + score lines (motion: 4/5, sync: 5/5, sharp: 4/5).
  3. The /make-card skill (or scripts/make_card.py directly) reads the latest JSON in the working folder, extracts every parameter, renders _AI/card.png, and appends a row to _AI/iterations.md. Cards travel alongside the video into the NLE for side-by-side comparison.
  4. Code modifications go in forks/ when a module needs to alter an upstream node. The agent edits the fork file in the repo; the maintainer runs dev-sync to copy it into the live install. See ../../forks/README.md.
  5. Findings get promoted from per-run notes into the module's findings.md when a knob's behaviour is stable enough to lock in (≥ 3 confirming runs).

Full cross-cutting contract: CONVENTIONS.md.

Starting a new automation module

  1. Pick a folder name — short, lowercase, hyphen-separated, descriptive of the task (e.g. LTX-2.3/two-stage-upscale/, wan-2.1/i2v-from-still/). The model-name grouping is optional but recommended once there are 2+ modules on the same model.
  2. Copy LTX-2.3/base-1step/README.md and handoff-checklist.md to the new folder as templates.
  3. Rewrite the task scope paragraph at the top. Replace task-specific node names, parameter sets, and finding placeholders with the new module's.
  4. Add a row to the "What lives here" table above.
  5. If the module needs to modify upstream node code, run the add-external-fork skill first to register the fork properly; then the module can reference forks/<name>_koolook/.
  6. The cross-cutting tooling (scripts/make_card.py, .claude/skills/make-card/) is module-agnostic — no changes needed there unless the new module needs different fields extracted from its workflow.