Compare commits

...
5 Commits
Author SHA1 Message Date
m0rtus59 398c8c4adc Merge pull request #16 from m0rtus59/feature/about-version-badge
Show ComfySidebar build version in About panel
2026-11-19 22:07:51 +05:00
m0rtus59 2b265aaf40 Fix version string parsing 2026-11-19 21:56:36 +05:00
m0rtus59 9567209ce4 Fix pyproject version parsing 2026-11-19 21:56:29 +05:00
m0rtus59 a83c0f82ea Show build version in ComfyUI About panel 2026-11-19 21:56:15 +05:00
m0rtus59 a13030b96b Expose extension version and commit metadata 2026-11-19 21:56:13 +05:00
2 changed files with 64 additions and 0 deletions
+41
View File
@@ -2,6 +2,7 @@ import asyncio
import filecmp
import os
import platform
import re
import shutil
import subprocess
import sys
@@ -290,6 +291,46 @@ _LOCALES_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "locale
_ALLOWED_LOCALE_FILES = {"main.json", "settings.json"}
def _get_extension_build_info():
"""Read the package version and the checked-out Git commit for the About panel."""
version = "unknown"
commit = "unknown"
try:
pyproject_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "pyproject.toml")
with open(pyproject_path, "r", encoding="utf-8") as f:
pyproject = f.read()
project_match = re.search(r"(?ms)^\[project\]\s*(.*?)(?=^\[|\Z)", pyproject)
if project_match:
version_match = re.search(r'(?m)^\s*version\s*=\s*"([^"]+)"', project_match.group(1))
if version_match:
version = version_match.group(1)
except (OSError, UnicodeError):
pass
try:
result = subprocess.run(
["git", "rev-parse", "--short=7", "HEAD"],
cwd=os.path.dirname(os.path.realpath(__file__)),
capture_output=True,
text=True,
check=True,
timeout=2
)
candidate = result.stdout.strip()
if re.fullmatch(r"[0-9a-fA-F]{7,40}", candidate):
commit = candidate[:7]
except (OSError, subprocess.SubprocessError):
pass
return {"version": version, "commit": commit}
@PromptServer.instance.routes.get("/comfy-sidebar/version")
async def version_handler(request):
return web.json_response(_get_extension_build_info())
@PromptServer.instance.routes.get("/comfy-sidebar/locales/{lang}/{filename}")
async def locale_file_handler(request):
lang = request.match_info.get("lang", "").strip()
+23
View File
@@ -19,6 +19,28 @@ import { getScrollContainer } from "./utils/utils.js";
import { store } from "./core/store.js";
import { getSetting, setSetting } from "./core/settings.js";
// The About panel supports extension-provided badges. Resolve build metadata before
// registering the extension so the badge is part of its initial registration.
let aboutPageBadges = [];
try {
const response = await fetch("/comfy-sidebar/version", { cache: "no-store" });
if (response.ok) {
const { version, commit } = await response.json();
if (version && version !== "unknown") {
const hasCommit = typeof commit === "string" && /^[0-9a-f]{7}$/i.test(commit);
aboutPageBadges = [{
label: `Comfy Sidebar v${version}${hasCommit ? ` (${commit})` : ""}`,
url: hasCommit
? `https://github.com/m0rtus59/ComfyUI-ComfySidebar/commit/${commit}`
: "https://github.com/m0rtus59/ComfyUI-ComfySidebar",
icon: "icon-[lucide--github]"
}];
}
}
} catch (error) {
console.warn("[ComfySidebar] Could not load version information for the About panel:", error);
}
let isInitialized = false;
let activeKeydownHandler = null;
let cleanupFns = [];
@@ -301,6 +323,7 @@ function setupWorkflowTabsPositionWatcher() {
app.registerExtension({
name: "ComfySidebar.ClassicRestore",
aboutPageBadges,
async init() {
await initI18n();