refactor(prompt_manager): optimize input change tracking

This commit is contained in:
Vito Sansevero
2025-09-09 09:29:17 -07:00
parent 8f01bc1541
commit bd547dd532
+16 -3
View File
@@ -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()