From b115a0d44955e60d88f03cfd3ddc89e53bb34600 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sun, 21 Jun 2026 15:10:46 +0200 Subject: [PATCH] feat: detach-pool context menu Right-click 'Detach pool (new id)' assigns a fresh UUID so a cloned node gets its own independent pool. Co-Authored-By: Claude Opus 4.8 --- web/grid_image_pool.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/web/grid_image_pool.js b/web/grid_image_pool.js index efae58d..c690734 100644 --- a/web/grid_image_pool.js +++ b/web/grid_image_pool.js @@ -33,6 +33,11 @@ function getPoolId(node) { return (w?.value || "default").trim() || "default"; } +function newPoolId() { + return (crypto.randomUUID && crypto.randomUUID()) || + `p_${Date.now()}_${Math.floor(Math.random() * 1e6)}`; +} + // Hide the pool_id widget: it must still serialize (carries the per-node UUID // into the saved workflow) but should never be drawn or take vertical space. // In frontend 1.45 the switch is `widget.hidden` — isWidgetVisible() returns @@ -457,7 +462,7 @@ function setupGridNode(node) { const pw = poolWidget(node); hideWidget(node, pw); if (pw && (!pw.value || pw.value === "default")) { - pw.value = (crypto.randomUUID && crypto.randomUUID()) || `p_${Date.now()}_${Math.floor(Math.random() * 1e6)}`; + pw.value = newPoolId(); } // Our node draws its own grid; ComfyUI must never reserve/draw an output-image @@ -558,5 +563,23 @@ app.registerExtension({ if (this._gridRefresh) this._gridRefresh(); return r; }; + + // right-click "Detach pool (new id)" — a cloned node shares its source's + // pool_id; this gives it a fresh, independent pool. + const getExtraMenuOptions = nodeType.prototype.getExtraMenuOptions; + nodeType.prototype.getExtraMenuOptions = function (canvas, options) { + const r = getExtraMenuOptions?.apply(this, arguments); + const node = this; + options.push({ + content: "Detach pool (new id)", + callback: () => { + const w = poolWidget(node); + if (w) w.value = newPoolId(); + node._lastCount = -1; // force a resize on the next refresh + if (node._gridRefresh) node._gridRefresh(); + }, + }); + return r; + }; }, });