Skip to content

[backport core/1.53] fix: preserve PrimitiveNode widget value on workflow load - #16857

Merged
DrJKL merged 1 commit into
core/1.53from
backport-16459-core-1.53
Sep 3, 2026
Merged

DrJKL merged 1 commit into
core/1.53from
backport-16459-core-1.53

Conversation

@christian-byrne

Copy link
Copy Markdown
Contributor

Manual backport of #16459 to core/1.53 — the automatic backport failed on cherry-pick conflicts.

  • Same fix: PrimitiveNode keeps its widget value on workflow load.
  • Conflicts were context-only (main-only widget-store code not in 1.53); resolved by applying only this PR's hunks.
  • Deliberately keeps 1.53's existing name-restore gating — does not carry in the opt-in semantics from Allow nodes to opt in, shadow after configure #16538, which is not backported.
Full context for agent readers

Source merge commit: 88fa815 (squash of #16459).

Conflict resolution:

  • src/lib/litegraph/src/LGraphNode.ts: added the exported createWidgetRestorationState helper and replaced the inline restoration block in configure() with a call to it. On main the helper computes restoreNamed: Boolean(named && (LiteGraph.namedValuesRestore || fallbackNames)); the || fallbackNames half comes from Allow nodes to opt in, shadow after configure #16538 (merged after the 1.53 cut, no backport label). This backport uses restoreNamed: 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 the setNodeScoped/clearNodeScoped helpers, switched the restoration map to them, removed the now-unused getPositionalRestoredWidgetValue. Did not bring in main-only onValueChange/WidgetValueChange code.
  • src/extensions/core/widgetInputs.ts and 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 typecheck clean; pnpm oxlint 0/0 and pnpm oxfmt --check clean on the four touched files.

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>
@christian-byrne christian-byrne added backport Backporting a PR onto a release candidate risk:xhigh PR risk grade (advisory shadow check; grader-owned) labels Sep 3, 2026
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

Deployment failed for project comfy-home-v1 with the following error:

You don't have permission to create a Preview Deployment for this Vercel project: comfy-home-v1.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

@christian-byrne christian-byrne added backport Backporting a PR onto a release candidate risk:xhigh PR risk grade (advisory shadow check; grader-owned) labels Sep 3, 2026
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (2)
  • [release]
  • [backport

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: c8ac014f-b8fb-4211-a22b-eef1a12ff0e5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@christian-byrne christian-byrne self-assigned this Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright: ✅ 1887 passed, 0 failed · 3 flaky

📊 Browser Reports
  • chromium: View Report (✅ 1866 / ❌ 0 / ⚠️ 3 / ⏭️ 4)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 18 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 09/03/2026, 10:38:59 PM UTC

Links

@github-actions github-actions Bot added the risk:R3 PR risk grade (advisory shadow check; grader-owned) label Sep 3, 2026
@DrJKL
DrJKL enabled auto-merge (squash) September 3, 2026 22:45
@DrJKL
DrJKL merged commit 346ed2f into core/1.53 Sep 3, 2026
129 of 130 checks passed
@DrJKL
DrJKL deleted the backport-16459-core-1.53 branch September 3, 2026 22:55
@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/extensions/core/widgetInputs.ts 93.75% 3 Missing ⚠️
src/lib/litegraph/src/LGraphNode.ts 83.33% 1 Missing and 1 partial ⚠️
@@              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     
Flag Coverage Δ
e2e 66.64% <85.93%> (+0.04%) ⬆️
unit 76.61% <95.08%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/stores/widgetValueStore.ts 95.29% <100.00%> (+0.06%) ⬆️
src/lib/litegraph/src/LGraphNode.ts 69.21% <83.33%> (+0.21%) ⬆️
src/extensions/core/widgetInputs.ts 95.07% <93.75%> (+6.18%) ⬆️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Backporting a PR onto a release candidate risk:R3 PR risk grade (advisory shadow check; grader-owned) risk:xhigh PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants