Skip to content

refactor: store-backed widget control system - #12816

Closed
DrJKL wants to merge 71 commits into
mainfrom
drjkl/systemic-controls
Closed

DrJKL wants to merge 71 commits into
mainfrom
drjkl/systemic-controls

Conversation

@DrJKL

@DrJKL DrJKL commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace the per-widget control-value closures with a store-backed, ECS-style control system: control status is a component keyed by WidgetId in the widget value store, and values advance via a System scoped to the queued graph.

Changes

  • What:
    • Add WidgetControlState component + registration/scoping in widgetValueStore (deferred like value registration; hasExecuted preserved across re-registration).
    • Add runWidgetControl System (graph-scoped via rootGraph.id, before/after phases).
    • Sync control + input-link state into the store via installWidgetControlHooks (node add/remove/connection change), restoring node callbacks on uninstall.
    • Consolidate control modules under core/graph/widgets/control/ (valueControl, controlWidgetMarker, useWidgetControlHooks).
    • Remove the old promotedWidgetControl special-casing in app.ts / widgets.ts.
  • Breaking: None for users; control now flows through store reactivity instead of widget.callback.

Review Focus

  • Graph scoping of runWidgetControl (all widgets, including subgraph interiors, key by rootGraph.id).
  • hasExecuted preservation on re-sync so before-mode "skip first run" isn't reset by connection changes.
  • Known first-draft limitations: link state reflected via hooks (links will become queryable entities later); dynamically added subgraph-interior nodes rely on the currentGraph reinstall.

Stacked on drjkl/no-promotions.

DrJKL and others added 30 commits June 2, 2026 17:40
…host widgets

Rename WidgetEntityId to WidgetId throughout, delete widgetValueIO in favor
of a WidgetId-native widgetValueStore, and represent subgraph promoted host
widgets as store-backed widget state addressed by input.widgetId. Migrate
runtime consumers (graph node manager, processed widgets, right-side panel,
price/error utilities) toward widget-id state.
…omotedWidgetView

The render-key prefix was cosmetic and the host-widget resolver's promoted-chain
following was unreachable (subgraph host widgets never populate node.widgets).
Reduce both to view-free lookups and drop the obsolete chain-following tests.
The type rename WidgetEntityId->WidgetId left the widget field still named
entityId. Drop the entityId aliases on IBaseWidget/BaseWidget/PromotedWidgetView
and SafeWidgetData, and read widget.widgetId everywhere. Source widget name from
widget state when present so promoted host widgets render their canonical
identity instead of stale data.
SubgraphNode.widgets is empty, so the host-wins semantics tests can no longer
find the view there. Construct it via createPromotedWidgetView, mirroring how
useGraphNodeManager builds the synth view.
Promoted host widgets no longer surface as views on the subgraph node, so
onWidgetChanged never receives one. Remove resolvePromotedExecId and clear
errors using the node's own execution id. Drop the obsolete test that drove
clearing through a host-side promoted view.
getInputSpecForWidget resolved promoted views to read the source widget's
options. With host widgets store-backed, build the input spec from the widget's
widgetId state options (default, etc.) instead of following a view.
The panel read promoted views off node.widgets, which is now empty. Build the
synth views from subgraph inputs carrying a widgetId (mirroring
useGraphNodeManager) so promoted rows, reorder, and demote work against
store-backed host widgets. Update tests to assert on promoted inputs.
draw.ts and BaseWidget.ts imported the LiteGraph singleton from the barrel,
which re-entered the barrel during BaseWidget initialization and evaluated
LegacyWidget extends BaseWidget before BaseWidget was defined (crashing any
entry that loaded a widget before the barrel, e.g. useGraphNodeManager tests).
Add a leaf litegraphInstance holder (type-only import) read at runtime via
litegraph(); the barrel constructs and registers the instance.
SubgraphNode.widgets is now always empty (host widgets are store-backed), and
widget state nodeId is the string parsed from the widget id. Fix the BaseWidget
nodeId assertion, drop the stale subgraphNode.widgets assertion in SubgraphIO
(inputs already cover it), and remove the obsolete manual-widget-injection test.
The impl now calls getWidget(widgetId(graphId, nodeId, name)); the test mock
still used the old three-arg signature and looked up by the wrong key. Extract
the widget name from the widget id.
Remove the obsolete test that drove mapping through a persistent promoted view
on node.widgets (now empty; duplicate-named distinct identity is covered
elsewhere). Skip the two-layer nested promotion test as a documented known
limitation pending multi-level resolution support.
Map promoted subgraph inputs to SafeWidgetData directly from input.widgetId,
the resolved interior source widget, and widget state, instead of constructing
an ephemeral PromotedWidgetView per input.
Replace the per-input PromotedWidgetView with a source descriptor built from
node inputs, and demote linked promotions by source via demotePromotedInput.
The nested-subgraph branch of resolveSourceWidget now returns a plain source
ref (name/type/options/value/widgetId) instead of a PromotedWidgetView;
getSlotFromWidget still locates the backing slot by widgetId.
Make resolveConcretePromotedWidget descend through subgraph inputs instead of
following synthetic widget views, so two-layer promotions resolve to the
deepest concrete widget. SubgraphNode assigns a widgetId to inputs whose source
is itself a promoted subgraph input, and dispatches the concrete interior
widget (not a view) on widget-promoted.
Remove the synthetic promoted-widget view class and PromotedWidgetViewManager.
Promoted host widgets are fully store-backed by widgetId, so the now-dead
isPromotedWidgetView branches over node.widgets/input._widget collapse to the
plain path. SubgraphNode loses its view machinery; getSlotFromWidget matches by
widgetId. Resolve the legacy selectedInput migration via resolveSubgraphInputTarget.

The structural isPromotedWidgetView guard and PromotedWidgetView type remain in
promotedWidgetTypes for the right-panel parameter components, pending their
store-driven rewrite.
Build store-backed parameter rows for a subgraph node's promoted inputs from
node.inputs, unified with ordinary node widgets: display resolves through the
host widgetId and value writes go through widgetValueStore. Route the panel's
value write through widgetId so promoted inputs persist.
The promoted host widget is no longer a synthetic view; reduce the type to the
promoted-source shape and rename the structural guard to isPromotedWidget.
buildPromotedWidget read the store value at build time, so the row-list computed
reactively rebuilt on every edit, producing new descriptor objects and churning
getStableWidgetRenderKey — re-rendering the whole panel. Read type/value/options
through live getters instead so identity stays stable and value updates in place.
Add src/core/graph/subgraph/promotedInputWidget.ts as the single
projection from a subgraph input slot to an ordinary store-backed
widget descriptor, and route useGraphNodeManager through it
(promotedInputWidgets + the shared safeWidgetMapper), deleting the
hand-rolled promotedInputToSafeWidget.

A projected widget name is now the input slot name (stable, unique,
the widgetId derives from it); the interior source widget name is
carried separately on SafeWidgetData (sourceWidgetName) only for
missing-model lookups, which key by the interior name. Drop the
redundant slotName and promotedLabel fields.
Replace the hand-rolled promoted-widget builders in TabSubgraphInputs
(buildPromotedWidget/getPromotedWidgets) and SubgraphEditor
(buildPromotedDescriptors + PromotedDescriptor) with promotedInputWidgets
/promotedInputWidget. SubgraphEditor rows now carry the projected widget
plus the host input slot and resolve their interior source on demand for
demote/re-promote, so no source identity is denormalized onto the rows.
…Widget

Replace the isPromotedWidget duck-type and the source fields read off
widget objects with widgetPromotedSource(node, widget) in WidgetActions
(isLinked/handleHideInput) and SectionWidgets (isWidgetShownOnParents).
getInputSpecForWidget now resolves the real interior node-definition spec
for a subgraph node instead of fabricating one from store options, and
renameWidget collapses to a widgetId-keyed label-only write that never
touches name/widgetId. Delete the now-unused PromotedWidget type and
isPromotedWidget guard.
resolveSourceWidget builds the nested-subgraph source widget via
promotedInputWidget instead of a hand-rolled `as IBaseWidget` literal
carrying source fields. Consolidate the two bespoke promoted-widget test
helpers in promotionUtils.test into one thin wrapper over the real
projection, dropping the synthetic source-field shapes. PromotedWidgetSource
is now confined to the migration/schema layer where promotion sources are
persisted tuples rather than link-derivable.
getPromotedWidgets inspected widget.sourceNodeId/sourceWidgetName on
node.widgets, a denormalization the store-backed WidgetId refactor
removed, so it returned empty for every promoted widget. Resolve
promoted widgets from node.inputs by widgetId and walk the subgraph
input link for source identity, mirroring promotedInputWidgets and
resolveSubgraphInputTarget. Public helper API is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	src/composables/graph/useErrorClearingHooks.test.ts
#	src/composables/graph/useErrorClearingHooks.ts
DrJKL and others added 4 commits June 10, 2026 23:13
…tled

Creating the DOMWidgetImpl during clone/configure used a transient node id,
seeding wrong nested values and leaking duplicate DOM widgets. Guard on graph
membership so the real widget is built on the post-settle resolution pass.

Rewrite subgraph tests to assert user-visible textboxes instead of internal
graph state.

Amp-Thread-ID: https://ampcode.com/threads/T-019eb3aa-6bcd-7528-857c-1ff02c329af3
Co-authored-by: Amp <amp@ampcode.com>
Covers the fresh interactive-add path alongside the existing load and clone
coverage. The prior conversion test only checked internal promoted-widget
state; this asserts the user-visible textbox appears exactly once, catching
both a missing widget and the duplicate-DOM-widget leak.

Amp-Thread-ID: https://ampcode.com/threads/T-019eb3aa-6bcd-7528-857c-1ff02c329af3
Co-authored-by: Amp <amp@ampcode.com>
Replace per-widget control closures with an ECS-style component in the
widget value store. Control state is keyed by WidgetId, registration is
deferred like value registration, and values advance via a System scoped
to the queued graph.

- Add WidgetControlState component + store registration/scoping
- Add runWidgetControl System (graph-scoped, before/after phases)
- Sync controls + link state via installWidgetControlHooks
- Move control modules under core/graph/widgets/control
- Remove promotedWidgetControl special-casing

Amp-Thread-ID: https://ampcode.com/threads/T-019eb9d7-e812-7259-99c1-5188944fae57
Co-authored-by: Amp <amp@ampcode.com>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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: CHILL

Plan: Pro

Run ID: 7b4b7f22-b49c-4f97-aafc-198ee006ba7e

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch drjkl/systemic-controls

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

@codecov

codecov Bot commented Jun 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.69892% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/types/simplifiedWidget.ts 0.00% 2 Missing ⚠️
src/composables/graph/useGraphNodeManager.ts 83.33% 1 Missing ⚠️
src/core/graph/widgets/widgetControlSystem.ts 97.14% 1 Missing ⚠️
@@                   Coverage Diff                   @@
##           drjkl/no-promotions   #12816      +/-   ##
=======================================================
+ Coverage                61.71%   61.74%   +0.03%     
=======================================================
  Files                     1453     1454       +1     
  Lines                    74819    74831      +12     
  Branches                 19465    19462       -3     
=======================================================
+ Hits                     46174    46206      +32     
+ Misses                   28292    28272      -20     
  Partials                   353      353              
Flag Coverage Δ
unit 61.74% <95.69%> (+0.03%) ⬆️

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

Files with missing lines Coverage Δ
.../core/graph/widgets/control/controlWidgetMarker.ts 100.00% <100.00%> (ø)
...rc/core/graph/widgets/control/syncWidgetControl.ts 100.00% <100.00%> (ø)
src/core/graph/widgets/control/valueControl.ts 98.52% <100.00%> (ø)
src/scripts/app.ts 24.35% <100.00%> (+0.12%) ⬆️
src/scripts/widgets.ts 12.72% <ø> (+1.61%) ⬆️
src/stores/widgetValueStore.ts 100.00% <100.00%> (ø)
src/composables/graph/useGraphNodeManager.ts 66.87% <83.33%> (+0.10%) ⬆️
src/core/graph/widgets/widgetControlSystem.ts 97.14% <97.14%> (ø)
src/types/simplifiedWidget.ts 16.66% <0.00%> (ø)
🚀 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.

@DrJKL
DrJKL requested a review from AustinMroz June 12, 2026 15:22
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

✅ Created PR with unit tests: #12817

DrJKL and others added 9 commits June 12, 2026 11:41
Replace the ~180-line widget-control hooks installer with control
registration that piggybacks on widget value registration.

- Register control in BaseWidget.setNodeId and SubgraphNode._setWidget
  (thread interior node), deriving control/filter ids from nodeId + name
- Resolve link-fed suppression live in runWidgetControl via one graph pass
- Delete useWidgetControlHooks + GraphCanvas wiring, setInputLinked, and
  WidgetState.inputLinked
- Move isValueControlWidget into the controlWidgetMarker leaf module

Amp-Thread-ID: https://ampcode.com/threads/T-019eb9d7-e812-7259-99c1-5188944fae57
Co-authored-by: Amp <amp@ampcode.com>
Render widget control from the store WidgetControlState keyed by the
widget's own widgetId instead of scanning linkedWidgets, so regular and
promoted widgets resolve control uniformly without tracing into a
subgraph interior.

On promotion, mint an independent host-local control (and filter) entity
seeded once from the interior widget, then queried/advanced purely by its
own ids. Persist the host control mode via a dedicated
properties.promotedControls entry, serialized and restored on configure.

linkedWidgets remains only as a construction-time discovery detail; its
non-control uses (bounding-box subwidgets, widget<->input conversion,
group nodes) are untouched.

Amp-Thread-ID: https://ampcode.com/threads/T-019eb9d7-e812-7259-99c1-5188944fae57
Co-authored-by: Amp <amp@ampcode.com>
Remove the separate promoted-control registration and persistence paths.
A promoted controllable widget now mints host-local control/filter widgets
that are plain store-backed host widgets surfaced by SubgraphNode.widgets in
order [target, control, filter], registered through the same
syncWidgetControl used by every node and persisted through the same
widgets_values array (controls have widget.serialize default).

configure() restores in one ordered pass with legacy detection for older
target-only widgets_values, preserving the quarantine override. Deletes
promoteWidgetControl and the properties.promotedControls schema/serialize/
restore special-casing.

linkedWidgets remains only a construction-time discovery detail.

Amp-Thread-ID: https://ampcode.com/threads/T-019eb9d7-e812-7259-99c1-5188944fae57
Co-authored-by: Amp <amp@ampcode.com>
Widget control state (mode, filter, hasExecuted) is now an ECS component
keyed by the target widget's WidgetId in widgetValueStore, replacing the
control/filter widget entities and the IS_CONTROL_WIDGET marker.

- Defer control registration like value registration: widgets carry a
  transient controlConfig, registered in BaseWidget.setNodeId.
- Preserve the positional [target, mode, filter?] widgets_values layout via
  serialize/configure interleaving (no control widgets resurrected).
- Promotion copies the interior control component once onto the host target,
  then diverges independently; no promoted/non-promoted distinction.
- Remove controlWidgetMarker, syncWidgetControl, the GraphCanvas control-label
  sweep, and control-widget creation in addValueControlWidget(s).

Amp-Thread-ID: https://ampcode.com/threads/T-019eb9d7-e812-7259-99c1-5188944fae57
Co-authored-by: Amp <amp@ampcode.com>
Collapse the distributed control lifecycle under
src/core/graph/widgets/control/: merge registration and positional
(de)serialization into widgetControl.ts, and move widgetControlSystem.ts
into the same folder. valueControl.ts stays a pure leaf (widgetState.ts
imports its type) and runWidgetControl stays separate so litegraph
serialization does not transitively import settingStore.

Reuse the canonical applyControlValues bridge in widgetInputs.ts,
replacing two hand-rolled positional [mode, filter] decode blocks so the
layout is decoded in one place instead of three.

Amp-Thread-ID: https://ampcode.com/threads/T-019ec02d-e454-72b9-bf54-3c2912898cc8
Co-authored-by: Amp <amp@ampcode.com>
- Collapse setControlMode/setControlFilter/setControlExecuted into one
  updateWidgetControl(targetId, patch) store action
- Remove dead after-mode hasExecuted write in runWidgetControl
- Un-export internal-only WidgetControlPhase and ValueControlTarget
- Replace 'as never' cast with 'as ValueControlMode'

Amp-Thread-ID: https://ampcode.com/threads/T-019ec073-d520-774a-9529-5b6b932336e8
Co-authored-by: Amp <amp@ampcode.com>
Base automatically changed from drjkl/no-promotions to main June 16, 2026 23:36
@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measure

Executes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight ecosystem-matrix shard checks are a harness self-test; the pack verdict is matrix-verdict.

This candidate changes nothing the matrix measures, so every expensive stage was skipped.

Reproduce locally
# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
  npx vitest run --config vitest.matrix.config.mts

Full docs: scripts/registry-census/README.md

🌾 Fallow: ✅ Passed

Fallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened.

No new findings in the changed files.

Reproduce locally
# the base the gate compared against
npx fallow audit --root . --quiet --format json \
  --changed-since 0859c16eb97db188f25f4fbc500d34302cc5129e

Full docs: ADR-DEVEX-LINT-0015

@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Sep 23, 2026
@christian-byrne

Copy link
Copy Markdown
Contributor

This draft now has zero changed files against main. Its changed-file overlap with the merged graph-API rewrite #18700 is therefore 0 of 0: the rewrite did not leave any patch here to adapt. The durable disposition is close this empty historical carrier, or reconstruct a new current-base change if the original widget-control intent is still needed.

@christian-byrne

Copy link
Copy Markdown
Contributor

Closing as a proven no-op: this PR's head tree (db9cf4333312baf8eec06bd6b142ced069653d4e) is byte-identical to its merge-base tree with main (0859c16eb97db188f25f4fbc500d34302cc5129e), verified via git diff across the merge-base. The branch's own history shows a later merge reverting the 147 files this PR had changed, so the diff against current main is empty. No test coverage or behavior change survives to land. Closing without merge.

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

Labels

risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants