Fix menu button to use new ComfyUI menu API

The legacy .comfy-menu is hidden in newer ComfyUI versions.
Updated createMenuButton to use the new ComfyButton/ComfyButtonGroup
components from ComfyUI's UI system, matching how ComfyUI-Manager
implements its button.

The button now appears in the top menu bar next to the Manager button.
Falls back to legacy menu for older ComfyUI versions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ben Finklea
2026-01-24 23:05:07 -06:00
co-authored by Claude Opus 4.5
parent 9256a1c87c
commit 77e81efa2d
+45 -3
View File
@@ -29,8 +29,50 @@ class ModelSyncPanel {
await this.refreshData();
}
createMenuButton() {
// Wait for menu to be available
async createMenuButton() {
const self = this;
// Try to add new-style button first (ComfyUI 2024+)
try {
const { ComfyButton } = await import("../../scripts/ui/components/button.js");
const { ComfyButtonGroup } = await import("../../scripts/ui/components/buttonGroup.js");
// Wait for app.menu to be available
const waitForMenu = () => {
return new Promise((resolve) => {
const check = () => {
if (window.app?.menu?.settingsGroup) {
resolve(true);
} else {
setTimeout(check, 100);
}
};
check();
// Timeout after 10 seconds
setTimeout(() => resolve(false), 10000);
});
};
const menuReady = await waitForMenu();
if (menuReady && window.app?.menu?.settingsGroup) {
const syncButton = new ComfyButton({
icon: "sync",
action: () => self.toggle(),
tooltip: "Model Sync - Track and sync model updates",
content: "Model Sync",
classList: "comfyui-button comfyui-menu-mobile-collapse"
});
const syncGroup = new ComfyButtonGroup(syncButton.element);
window.app.menu.settingsGroup.element.before(syncGroup.element);
console.log("[ModelSync] New-style menu button added");
return;
}
} catch (e) {
console.log("[ModelSync] New-style menu not available, trying legacy:", e.message);
}
// Fall back to old-style button
const tryCreateButton = () => {
const menu = document.querySelector(".comfy-menu") || document.querySelector(".comfyui-menu");
if (!menu) {
@@ -51,7 +93,7 @@ class ModelSyncPanel {
// Insert into menu
menu.appendChild(button);
console.log("[ModelSync] Menu button added");
console.log("[ModelSync] Legacy menu button added");
};
tryCreateButton();