From 02f3933eda6a1ea46cbe8a2a0eb6a7342984673f Mon Sep 17 00:00:00 2001 From: Meisoftcoltd <38667978+Meisoftcoltd@users.noreply.github.com> Date: Sat, 27 Jun 2026 15:15:33 +0000 Subject: [PATCH] fix(logic): fix boolean string evaluation in stitcher and implement native lazy execution gate - Strict boolean evaluation for `is_flux_phase` applied in `IncrementalVideoStitcher` (loop.py). - Strict boolean evaluation for `is_flux_phase` applied in `SaveSceneKeyframe` (tools.py). - Added `Meisoft_LazyGate` node to `tools.py` for conditional branch evaluation using ComfyUI's lazy loading API (`check_lazy_status`). - Added `AnyType` implementation to support `ANY` wire connections on the lazy gate. - Registered the new node correctly in `__init__.py`. --- __init__.py | 1 + loop.py | 5 ++++- tools.py | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index 178cb3c..102e501 100644 --- a/__init__.py +++ b/__init__.py @@ -49,6 +49,7 @@ NODE_DISPLAY_NAME_MAPPINGS.update({ "SaveSceneKeyframe": "💾 Save Scene Keyframe", "LoadSceneKeyframe": "🖼️ Load Scene Keyframe", "LTXVSingleFrameInjector": "💉 LTXV Single Frame Injector", + "Meisoft_LazyGate": "🚦 Meisoft Lazy Gate", }) __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] diff --git a/loop.py b/loop.py index f30650b..bb94c74 100644 --- a/loop.py +++ b/loop.py @@ -744,6 +744,9 @@ class IncrementalVideoStitcher: def stitch(self, images, audio, current_loop_index, is_flux_phase=False): log_output = [] def _log(msg): print(msg); log_output.append(str(msg)) + + # 🛡️ FIX: Asegurar que is_flux_phase sea un booleano real + is_flux_bool = str(is_flux_phase).strip().lower() in ["true", "1", "t", "yes", "y"] from . import loop import os, folder_paths, torch, shutil, time from PIL import Image @@ -760,7 +763,7 @@ class IncrementalVideoStitcher: else: os.makedirs(cache_dir, exist_ok=True) - if is_flux_phase: + if is_flux_bool: _log(" -> 📸 Fase 1 activa. Ignorando imagen para la caché de vídeo.") return (images[-1:].clone(), audio, False, False, "\n".join(log_output)) diff --git a/tools.py b/tools.py index 9567166..f7cea19 100644 --- a/tools.py +++ b/tools.py @@ -2,7 +2,12 @@ import math import time import torch from . import register_node -from .switch_node import any_type +class AnyType(str): + def __ne__(self, __value: object) -> bool: + return False + +any_type = AnyType("*") + @register_node class PrimitiveDelay: @@ -460,7 +465,10 @@ class SaveSceneKeyframe: CATEGORY = "🔁 Sequential Batcher/Tools" def save(self, image, file_path, is_flux_phase=True): - if not is_flux_phase: + # 🛡️ FIX: Asegurar que is_flux_phase sea un booleano real + is_flux_bool = str(is_flux_phase).strip().lower() in ["true", "1", "t", "yes", "y"] + + if not is_flux_bool: return (image, file_path) # Bypass silencioso en Fase 2 import os, numpy as np @@ -573,3 +581,37 @@ class LTXVSingleFrameInjector: print(f"{'='*50}\n") return ({"samples": samples, "noise_mask": mask},) + +@register_node(display_name="🚦 Meisoft Lazy Gate") +class Meisoft_LazyGate: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "is_flux_phase": ("BOOLEAN", {"forceInput": True, "tooltip": "Conectar al Director"}), + }, + "optional": { + "flux_branch": (any_type,), + "ltx_branch": (any_type,), + } + } + + RETURN_TYPES = (any_type,) + RETURN_NAMES = ("active_branch",) + FUNCTION = "route" + CATEGORY = "🔁 Sequential Batcher/Logic" + + # 🛡️ LA MAGIA: ComfyUI solo evaluará la rama que devolvamos aquí. La otra se cancela. + def check_lazy_status(self, is_flux_phase, flux_branch=None, ltx_branch=None): + is_flux = str(is_flux_phase).strip().lower() in ["true", "1", "t", "yes", "y"] + if is_flux: + return ["flux_branch"] + else: + return ["ltx_branch"] + + def route(self, is_flux_phase, flux_branch=None, ltx_branch=None): + is_flux = str(is_flux_phase).strip().lower() in ["true", "1", "t", "yes", "y"] + if is_flux: + return (flux_branch,) + else: + return (ltx_branch,)