Compare commits

...
Author SHA1 Message Date
Claude eda45eaa6f docs: Queue overview with batch widget pointer and Ctrl actions; mention Move to Outputs in README 2026-11-22 19:20:13 +00:00
Claude 8310c95f95 docs: add Gallery controls overview image to the README 2026-11-22 15:16:09 +00:00
Claude 43cd6660ae docs: refresh Queue controls overview (new header buttons, accurate pointers) 2026-11-22 15:06:37 +00:00
m0rtus59 99f1dcf2e4 Merge pull request #17 from m0rtus59/fix/gallery-toggle-register-unregister
Fix 'Enable Output Gallery Sidebar' toggle
2026-11-22 18:52:20 +05:00
Claude 22b2fdc748 Fix 'Enable Output Gallery Sidebar' toggle: register/unregister the tab instead of hiding its button
The setting hid the tab button by scanning the sidebar DOM for the first button
whose data-tab-id, title or icon looked like the gallery, once, and (on startup)
after a fixed 50ms. The sidebar renders asynchronously and re-renders on its own,
so the button reappeared after reload, and the loose match could hide a different
tab's button. Now the tab is registered only while the setting is on and
unregistered when it is turned off, so state no longer depends on DOM timing.
A disabled gallery also no longer builds its view at startup.
2026-11-22 09:54:00 +00:00
4 changed files with 49 additions and 42 deletions
+3 -1
View File
@@ -10,7 +10,7 @@ A compact and powerful layout overhaul for ComfyUI that makes generation results
* **Left or right side:** Choose which side the sidebar appears on in ComfyUI settings.
* **Simplified mouse-friendly workflow** with drag-and-drop support and convenient actions for moving results back into the workflow, opening files, and managing outputs. Hold `Ctrl` for extra actions such as opening an image's location or deleting it directly from your device.
* **Simplified mouse-friendly workflow** with drag-and-drop support and convenient actions for moving results back into the workflow, opening files, and managing outputs. Hold `Ctrl` for extra actions such as opening an image's location, deleting it directly from your device, or moving a temporary image to your Outputs folder.
<img src="assets/controls.png" alt="ComfySidebar controls overview">
@@ -20,6 +20,8 @@ A compact and powerful layout overhaul for ComfyUI that makes generation results
* **Output Gallery sidebar:** Browse files and subfolders directly from your ComfyUI `output` directory without leaving the interface. Features dedicated cards for images, videos, audio, and 3D assets (`.glb`/`.gltf`), breadcrumb navigation, filename and prompt metadata search across subfolders, and persistent sorting.
<img src="assets/gallery.png" alt="ComfySidebar Gallery controls overview">
* **Hotkeys on any keyboard layout:** Shortcuts such as `Q`, `Ctrl+Q` and `Alt+R` keep working while a non-Latin layout (for example Russian) is active. Non-Latin keys are treated as the Latin key in the same physical position, and typing in text fields is not affected. Can be turned off with **Fix non-ASCII keybinds** in the settings.
* **Runtime preview mode** combined with workflow overview makes ComfyUI practical for running and monitoring workflows in a more streamlined, queue-oriented way.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 789 KiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

+46 -41
View File
@@ -73,21 +73,10 @@ function setupKeydownShortcuts() {
document.addEventListener("keydown", activeKeydownHandler, true);
}
function setGalleryButtonVisible(visible) {
try {
const buttons = document.querySelectorAll(".side-bar-button, [data-tab-id]");
for (const btn of buttons) {
if (btn.getAttribute("data-tab-id") === "classic-comfy-gallery" ||
btn.getAttribute("title")?.includes("Gallery") ||
btn.querySelector(".pi-folder")) {
btn.style.display = visible ? "" : "none";
break;
}
}
} catch (e) {
console.warn("[ComfySidebar] Error toggling gallery tab button:", e);
}
}
// Assigned in setup(): registers/unregisters the Gallery sidebar tab to match the
// "Enable Output Gallery Sidebar" setting. Null until setup() has run (the setting's
// initial onChange fires earlier, in init(), when there is nothing to toggle yet).
let syncGalleryTab = null;
function registerSettings() {
app.ui.settings.addSetting({
@@ -124,7 +113,7 @@ function registerSettings() {
type: "boolean",
defaultValue: true,
onChange: (val) => {
setGalleryButtonVisible(val ?? true);
syncGalleryTab?.(val ?? true);
}
});
@@ -468,32 +457,47 @@ app.registerExtension({
}
});
const galleryContainer = setupGalleryView();
app.extensionManager.registerSidebarTab({
id: "classic-comfy-gallery",
icon: "pi pi-folder",
title: t("Gallery"),
tooltip: t("Gallery (Outputs)"),
type: "custom",
render: (el) => {
document.querySelectorAll(".comfy-sidebar-scroll-top-btn").forEach(btn => { btn.style.display = "none"; });
const scrollParent = getScrollContainer(el);
if (activeSidebarTab === "queue" && scrollParent) {
queueScrollPos = scrollParent.scrollTop;
}
activeSidebarTab = "gallery";
el.replaceChildren(galleryContainer);
requestAnimationFrame(() => {
const sp = getScrollContainer(el);
if (sp) sp.scrollTop = galleryScrollPos;
});
}
});
// The Gallery tab is only registered while the setting is enabled. Hiding its
// button in the DOM was unreliable: the sidebar renders asynchronously and
// re-renders on its own, so the button came back (or the wrong one was hidden).
let galleryContainer = null;
let galleryTabRegistered = false;
const isGalleryEnabled = getSetting("Comfy Sidebar.Enable Gallery", true);
if (!isGalleryEnabled) {
setTimeout(() => setGalleryButtonVisible(false), 50);
}
const registerGalleryTab = () => {
if (galleryTabRegistered) return;
galleryContainer ||= setupGalleryView();
app.extensionManager.registerSidebarTab({
id: "classic-comfy-gallery",
icon: "pi pi-folder",
title: t("Gallery"),
tooltip: t("Gallery (Outputs)"),
type: "custom",
render: (el) => {
document.querySelectorAll(".comfy-sidebar-scroll-top-btn").forEach(btn => { btn.style.display = "none"; });
const scrollParent = getScrollContainer(el);
if (activeSidebarTab === "queue" && scrollParent) {
queueScrollPos = scrollParent.scrollTop;
}
activeSidebarTab = "gallery";
el.replaceChildren(galleryContainer);
requestAnimationFrame(() => {
const sp = getScrollContainer(el);
if (sp) sp.scrollTop = galleryScrollPos;
});
}
});
galleryTabRegistered = true;
};
const unregisterGalleryTab = () => {
if (!galleryTabRegistered) return;
if (activeSidebarTab === "gallery") activeSidebarTab = "queue";
app.extensionManager.unregisterSidebarTab?.("classic-comfy-gallery");
galleryTabRegistered = false;
};
syncGalleryTab = (enabled) => (enabled ? registerGalleryTab() : unregisterGalleryTab());
syncGalleryTab(getSetting("Comfy Sidebar.Enable Gallery", true));
requestAnimationFrame(() => {
applySidebarOverride();
@@ -501,6 +505,7 @@ app.registerExtension({
},
destroy() {
syncGalleryTab = null;
for (const fn of cleanupFns.splice(0)) {
try { if (typeof fn === "function") fn(); } catch (e) {}
}