From 4b19ad0a1d5d860251ed238629e1e6bd891c9bd6 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 4 Apr 2026 13:24:13 +0200 Subject: [PATCH] feat: display live value on ProjectKey output for INT/FLOAT/BOOL Returns ui value alongside result for numeric/boolean types so JS onExecuted can show e.g. '42 seed' on the output slot, matching the BinaryIndexDecoder inline display style. Co-Authored-By: Claude Sonnet 4.6 --- project_loader.py | 10 ++++++---- web/project_key.js | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/project_loader.py b/project_loader.py index 63817c0..6830b41 100644 --- a/project_loader.py +++ b/project_loader.py @@ -299,13 +299,15 @@ class ProjectKey: val = data.get(key_name, "") if key_type == "INT": - return (to_int(val),) + result = to_int(val) + return {"ui": {"value": [str(result)]}, "result": (result,)} elif key_type == "FLOAT": - return (to_float(val),) + result = to_float(val) + return {"ui": {"value": [f"{result:.4g}"]}, "result": (result,)} elif isinstance(val, bool): - return (str(val).lower(),) + return {"ui": {"value": [str(val).lower()]}, "result": (str(val).lower(),)} elif isinstance(val, (int, float)): - return (val,) + return {"ui": {"value": [str(val)]}, "result": (val,)} else: return (str(val),) diff --git a/web/project_key.js b/web/project_key.js index 04eeed2..5e54ec2 100644 --- a/web/project_key.js +++ b/web/project_key.js @@ -201,6 +201,17 @@ app.registerExtension({ app.graph?.setDirtyCanvas(true, true); }; + // --- Show live value on output slot after execution (INT/FLOAT/BOOL only) --- + nodeType.prototype.onExecuted = function (output) { + if (!output?.value?.[0] === undefined || !this.outputs.length) return; + const val = output.value?.[0]; + if (val === undefined) return; + const keyWidget = this.widgets?.find(w => w.name === "key_name"); + const name = keyWidget?.value || this.outputs[0].name; + this.outputs[0].label = `${val} ${name}`; + app.graph?.setDirtyCanvas(true, true); + }; + // --- Highlight all ProjectKey nodes sharing the same key_name on select --- nodeType.prototype.onSelected = function () { const keyWidget = this.widgets?.find(w => w.name === "key_name");