From e29c23de8d3a15d321a1bfd7da697ad1e0cb454b Mon Sep 17 00:00:00 2001 From: Vito Date: Sat, 31 Oct 2026 18:56:42 +0000 Subject: [PATCH] chore(init): print a one-line startup banner (#574) Replace the version line, one Loaded line per node and the total with "[ComfyUI-PromptManager] Version: - tools loaded". Closes #573 --- __init__.py | 15 ++++++--------- tests/test_init_package.py | 13 +++++++++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/__init__.py b/__init__.py index 7482e606..d2e80c1a 100644 --- a/__init__.py +++ b/__init__.py @@ -435,12 +435,9 @@ except Exception as e: __all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"] -# Print startup message with loaded tools -print() -print(f"\033[94m[ComfyUI-PromptManager] Version:\033[0m {get_version()}") -for node_key, display_name in NODE_DISPLAY_NAME_MAPPINGS.items(): - # ASCII only: a Windows console using a legacy code page cannot print emoji, - # and a UnicodeEncodeError here would abort loading the whole node. - print(f" \033[94mLoaded:\033[0m {display_name}") -print(f"\033[94mTotal: {len(NODE_CLASS_MAPPINGS)} tools loaded\033[0m") -print() +# One startup line. ASCII only: a Windows console using a legacy code page +# cannot print emoji, and a UnicodeEncodeError here would abort loading the node. +print( + f"\033[94m[ComfyUI-PromptManager] Version:\033[0m {get_version()}" + f" - {len(NODE_CLASS_MAPPINGS)} tools loaded" +) diff --git a/tests/test_init_package.py b/tests/test_init_package.py index 01ab75b5..87646e36 100644 --- a/tests/test_init_package.py +++ b/tests/test_init_package.py @@ -390,7 +390,16 @@ class TestConsoleBanner(unittest.TestCase): stream.flush() banner = stream.buffer.getvalue().decode("cp1252") - self.assertIn("Loaded:", banner) + lines = [ + line + for line in banner.splitlines() + if "PromptManager" in line or "loaded" in line + ] + self.assertEqual(len(lines), 1, banner) + self.assertRegex( + lines[0], r"\[ComfyUI-PromptManager\] Version:.* \S+ - \d+ tools loaded$" + ) + self.assertNotIn("Loaded:", banner) class PriorFileHandler(logging.FileHandler): @@ -553,7 +562,7 @@ class TestPackageLoggerIsolation(unittest.TestCase): original_print = print def fail_banner(*args, **kwargs): - if any("Total:" in str(arg) for arg in args): + if any("tools loaded" in str(arg) for arg in args): captured["package"] = sys.modules[name] captured["handlers"] = [ h