fix: ProjectKey pulls fresh data on click, add debug logging

ProjectKey onMouseDown now triggers _syncFromSource + _refreshKeys so
clicking a relay always picks up source config changes. Added console
logs to notifyRelays and _refreshKeys for diagnosing sync issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-20 20:46:50 +01:00
parent 672b28e27f
commit 413e1c09e9
2 changed files with 14 additions and 2 deletions
+9 -2
View File
@@ -136,7 +136,11 @@ app.registerExtension({
const fileW = this.widgets?.find(w => w.name === "file_name"); const fileW = this.widgets?.find(w => w.name === "file_name");
const seqW = this.widgets?.find(w => w.name === "sequence_number"); const seqW = this.widgets?.find(w => w.name === "sequence_number");
if (!urlW?.value || !projW?.value || !fileW?.value) return; console.log(`[ProjectKey] _refreshKeys id=${this.id}: url="${urlW?.value}" project="${projW?.value}" file="${fileW?.value}" seq=${seqW?.value}`);
if (!urlW?.value || !projW?.value || !fileW?.value) {
console.log(`[ProjectKey] _refreshKeys: skipped (missing config)`);
return;
}
try { try {
const resp = await api.fetchApi( const resp = await api.fetchApi(
@@ -190,7 +194,7 @@ app.registerExtension({
app.graph?.setDirtyCanvas(true, true); app.graph?.setDirtyCanvas(true, true);
}; };
// --- Populate source dropdown on click (lazy refresh) --- // --- Sync + refresh on click (catches changes pushed from source) ---
const origOnMouseDown = nodeType.prototype.onMouseDown; const origOnMouseDown = nodeType.prototype.onMouseDown;
nodeType.prototype.onMouseDown = function (e, localPos, graphCanvas) { nodeType.prototype.onMouseDown = function (e, localPos, graphCanvas) {
origOnMouseDown?.apply(this, arguments); origOnMouseDown?.apply(this, arguments);
@@ -198,6 +202,9 @@ app.registerExtension({
if (srcWidget) { if (srcWidget) {
srcWidget.options.values = this._getSourceLabels(); srcWidget.options.values = this._getSourceLabels();
} }
// Always re-sync config from source and refresh keys on interaction
this._syncFromSource();
this._refreshKeys();
}; };
// --- Restore state on workflow load --- // --- Restore state on workflow load ---
+5
View File
@@ -11,15 +11,20 @@ app.registerExtension({
if (!sourceNode.graph?._nodes) return; if (!sourceNode.graph?._nodes) return;
const labelW = sourceNode.widgets?.find(w => w.name === "label"); const labelW = sourceNode.widgets?.find(w => w.name === "label");
if (!labelW?.value) return; if (!labelW?.value) return;
console.log(`[ProjectSource] notifyRelays: label="${labelW.value}", scanning ${sourceNode.graph._nodes.length} nodes`);
let matched = 0;
for (const node of sourceNode.graph._nodes) { for (const node of sourceNode.graph._nodes) {
if (node.type === "ProjectKey" && node._syncFromSource && node._refreshKeys) { if (node.type === "ProjectKey" && node._syncFromSource && node._refreshKeys) {
const srcW = node.widgets?.find(w => w.name === "source_label"); const srcW = node.widgets?.find(w => w.name === "source_label");
console.log(`[ProjectSource] ProjectKey id=${node.id} source_label="${srcW?.value}"`);
if (srcW?.value === labelW.value) { if (srcW?.value === labelW.value) {
matched++;
node._syncFromSource(); node._syncFromSource();
node._refreshKeys(); node._refreshKeys();
} }
} }
} }
console.log(`[ProjectSource] notifyRelays: matched ${matched} relays`);
} }
const origOnNodeCreated = nodeType.prototype.onNodeCreated; const origOnNodeCreated = nodeType.prototype.onNodeCreated;