From bd547dd5322f241986d4b3cee009957d405c7723 Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Tue, 9 Sep 2025 09:29:17 -0700 Subject: [PATCH] refactor(prompt_manager): optimize input change tracking --- prompt_manager.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/prompt_manager.py b/prompt_manager.py index 676661c..636dd41 100644 --- a/prompt_manager.py +++ b/prompt_manager.py @@ -485,11 +485,24 @@ class PromptManager(ComfyNodeABC): self.cleanup_gallery_system() @classmethod - def IS_CHANGED(cls, **kwargs): + def IS_CHANGED(cls, text="", category="", tags="", search_text="", + prepend_text="", append_text="", **kwargs): """ ComfyUI method to determine if node needs re-execution. + This method now properly tracks input changes to avoid unnecessary + re-execution while still ensuring prompts are saved when inputs change. + Returns: - NaN to force re-execution, ensuring prompts are always saved to database + A hash of the input values that changes when any input changes """ - return float("NaN") # Always execute + # Create a hash of all the text inputs that affect the output + # This ensures the node only re-executes when inputs actually change + import hashlib + + # Combine all text inputs that affect the conditioning output + combined = f"{text}|{category}|{tags}|{prepend_text}|{append_text}" + + # Return a hash that will change when inputs change + # Note: We don't include search_text as it doesn't affect the output conditioning + return hashlib.sha256(combined.encode()).hexdigest()