Repository navigation
[backport core/1.53] fix: preserve PrimitiveNode widget value on workflow load - #16857
Conversation
PrimitiveNode now keeps its serialized widget value and control mode after reload. Regression coverage reproduces the stale-target overwrite, the reroute path, and a cross-type leak. <details><summary>Full context for agent readers</summary> Workflow loading creates a PrimitiveNode widget after node configuration, so the target widget copy overwrote the primitive's serialized value. The control widget had the same symptom from a different cause: the restore read `widgetValueStore`, which `LGraphNode.configure` clears in its own `finally` before `_createWidget` ever runs, so `control_after_generate` always fell back to `fixed`. - Capture the serialized `widgets_values` and output type in `onConfigure`, chaining to `super` so handlers installed on `LGraphNode.prototype` still run. - Reapply index 0 after the target widget copy, including the asset-widget path, and consume the capture once the widget is built rather than on a lifecycle callback that several creation paths skip. - Bind the capture to the serialized output type, so a value cannot land on a widget of a different type and reach the backend through `applyToGraph`. - Restore the serialized control and filter values after widget creation. This covers both the `addValueControlWidgets` fallback and inputs that declare `control_after_generate`, which build their own control widget. Only values the control widget offers are written back. - Normalise `widgets_values` through `Array.from` the way base `configure` does, since custom nodes are documented to replace it with an array-like object. - Treat `recreateWidget` with no existing widgets as a first build. That is the only widget-creation path a Primitive feeding a Reroute has. - Remove `getPositionalRestoredWidgetValue`, which had no reachable caller left. - `widgetInputs.test.ts`: 32 passed. Every new test was run against the pre-fix code first and fails there. - `pnpm typecheck`, `pnpm knip`, `pnpm lint` (0 errors): passed. - CI green at `ab37448da5`. Restoration state lives on the `PrimitiveNode` instance rather than in `widgetValueStore`, which ADR 0003/0008 would prefer. The store mechanism could not work as written, because `LGraphNode.configure` clears the restoration entry before the primitive builds its widget. This needs a call: accept the instance field, or widen the restoration lifetime in the store and put it back there. Known gaps left out of scope: `widgets_values_named` is ignored when `LiteGraph.namedValuesRestore` is enabled, and a restored value is not range-checked against the rebuilt widget. Checklist item: #15973 Original review: #15924 (comment) Fixes #16007 </details>
|
Deployment failed for project comfy-home-v1 with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
🎭 Playwright: ✅ 1887 passed, 0 failed · 3 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## core/1.53 #16857 +/- ##
=============================================
+ Coverage 83.29% 83.32% +0.02%
=============================================
Files 2023 2023
Lines 117023 117059 +36
Branches 33039 33051 +12
=============================================
+ Hits 97474 97539 +65
+ Misses 19193 19171 -22
+ Partials 356 349 -7
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 25 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Manual backport of #16459 to
core/1.53— the automatic backport failed on cherry-pick conflicts.Full context for agent readers
Source merge commit: 88fa815 (squash of #16459).
Conflict resolution:
src/lib/litegraph/src/LGraphNode.ts: added the exportedcreateWidgetRestorationStatehelper and replaced the inline restoration block inconfigure()with a call to it. On main the helper computesrestoreNamed: Boolean(named && (LiteGraph.namedValuesRestore || fallbackNames)); the|| fallbackNameshalf comes from Allow nodes to opt in, shadow after configure #16538 (merged after the 1.53 cut, no backport label). This backport usesrestoreNamed: Boolean(named && LiteGraph.namedValuesRestore), which is exactly what 1.53 already does, so non-Primitive node behavior on the release branch is unchanged.src/stores/widgetValueStore.ts: added thesetNodeScoped/clearNodeScopedhelpers, switched the restoration map to them, removed the now-unusedgetPositionalRestoredWidgetValue. Did not bring in main-onlyonValueChange/WidgetValueChangecode.src/extensions/core/widgetInputs.tsand its test applied cleanly.Verification on the branch:
pnpm vitest run src/extensions/core/widgetInputs.test.ts src/stores/ src/lib/litegraph/src/LGraphNode.test.ts→ 55 files, 1232 passed, 1 skipped;pnpm typecheckclean;pnpm oxlint0/0 andpnpm oxfmt --checkclean on the four touched files.