From 3dc91319a2f81006b334d706e5fc192b19efb948 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Fri, 20 Mar 2026 12:43:05 +0100 Subject: [PATCH] fix: notify relay nodes when source config changes When ProjectSource widgets (url, project, file, sequence_number) change, all ProjectKey nodes referencing that source now re-sync and refresh their key dropdown immediately. Co-Authored-By: Claude Opus 4.6 --- web/project_source.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/web/project_source.js b/web/project_source.js index 9bb9a51..0c11068 100644 --- a/web/project_source.js +++ b/web/project_source.js @@ -6,14 +6,43 @@ app.registerExtension({ async beforeRegisterNodeDef(nodeType, nodeData, app) { if (nodeData.name !== "ProjectSource") return; + // Notify all ProjectKey nodes referencing this source to re-sync + function notifyRelays(sourceNode) { + if (!sourceNode.graph?._nodes) return; + const labelW = sourceNode.widgets?.find(w => w.name === "label"); + if (!labelW?.value) return; + for (const node of sourceNode.graph._nodes) { + if (node.type === "ProjectKey" && node._syncFromSource && node._refreshKeys) { + const srcW = node.widgets?.find(w => w.name === "source_label"); + if (srcW?.value === labelW.value) { + node._syncFromSource(); + node._refreshKeys(); + } + } + } + } + const origOnNodeCreated = nodeType.prototype.onNodeCreated; nodeType.prototype.onNodeCreated = function () { origOnNodeCreated?.apply(this, arguments); + const node = this; + + // Hook all config widgets to notify relays on change + for (const name of ["manager_url", "project_name", "file_name", "sequence_number"]) { + const w = this.widgets?.find(w => w.name === name); + if (w) { + const origCb = w.callback; + w.callback = function (...args) { + origCb?.apply(this, args); + notifyRelays(node); + }; + } + } + // Update title when label changes const labelWidget = this.widgets?.find(w => w.name === "label"); if (labelWidget) { - const node = this; const origCallback = labelWidget.callback; labelWidget.callback = function (...args) { origCallback?.apply(this, args);