Repository navigation
fix(agent): don't let CRDT reconcile clobber a fresher live widget value - #18347
claude[bot] wants to merge 2 commits into
Conversation
…565/PM-1268) Drops the it.fails wrapper on the PM-1303/PM-1310 "hypothesis C" regression test in ecsFollowerAdapter.promptReconcile.test.ts. A catch-up reconcile (reconcileNode/reconcileNodeFields -> applyWidgetValues) still replays every widget from the doc snapshot unconditionally, so it clobbers a prompt the user just typed with the doc's stale, pre-edit value. This commit makes the existing regression genuinely fail in CI; the fix follows in the next commit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BikjqCAiAR4ezQorLJxxfv
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
🌾 Fallow: ❌ FailedFallow 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. Fallow gates on new findings in changed files only, so everything below was introduced or moved by this PR (7 changed files).
Pre-existing findings are baselined in Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since be12830ba0b4f186aa0e25ea59d0a15ca676c372
Full docs: ADR-DEVEX-LINT-0015 🎭 Playwright: ✅ 2076 passed, 0 failed · 1 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook📦 Bundle: 9.96 MB gzip 🔴 +689 BDetailsSummary
Category Glance App Entry Points — 3.87 kB (baseline 3.87 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.46 MB (baseline 1.46 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Status: 2 added / 2 removed / 1 unchanged Views & Navigation — 132 kB (baseline 132 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 14 added / 14 removed / 4 unchanged Panels & Settings — 639 kB (baseline 639 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 10 added / 10 removed / 18 unchanged User & Accounts — 37.9 kB (baseline 37.9 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 6 added / 6 removed / 5 unchanged Editors & Dialogs — 126 kB (baseline 126 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 7 added / 7 removed / 1 unchanged UI Components — 123 kB (baseline 123 kB) • ⚪ 0 BReusable component library chunks
Status: 7 added / 7 removed / 9 unchanged Data & Services — 3.88 MB (baseline 3.88 MB) • 🔴 +1.68 kBStores, services, APIs, and repositories
Status: 13 added / 13 removed / 3 unchanged Utilities & Hooks — 577 kB (baseline 577 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 19 added / 19 removed / 19 unchanged Vendor & Third-Party — 17.4 MB (baseline 17.4 MB) • ⚪ 0 BExternal libraries and shared vendor chunks Status: 18 unchanged Other — 17.8 MB (baseline 17.8 MB) • ⚪ 0 BBundles that do not match a named category
Status: 74 added / 74 removed / 228 unchanged ⚡ Performance
🧩 Custom Nodes Ecosystem Matrix: ✅ PassedExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight
On a pin-bump PR, a red gate means the ecosystem moved — not that your diff broke something. That is what the bump PR is for. Outside a pin bump or a cold rebuild of the unpinned tail, a red means the diff. Note the corpus size and the executed count are different numbers, and the verdict is against the executed count: roughly 3,100 of ~5,100 packs ship no extension-shaped JS and are 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 |
Widgets whose live value last changed without a RemoteMutationContext (a human edit, or any write that bypassed setValue's context param) are now tracked as "locally dirty" in widgetValueStore.ts. A plain node's reconcileNode -> applyWidgetValues (graphMutations.ts) skips writing a dirty widget instead of blindly replaying the doc's stale snapshot over it, then clears the mark: the skip is one-shot protection against the snapshot that predated the edit, not a standing block on ever picking up a later, genuinely newer remote value. An explicit single-widget setWidget op is unaffected, since it never goes through applyWidgetValues. The guard is deliberately left off reconcileNodeFields (used only for subgraph hosts): a host's promoted widgets are wired by SubgraphNode's own projection (promotedWidgetStoreProjection.ts), which writes them directly (no RemoteMutationContext) as a routine, structural part of attaching the host - not a human edit - so the same "no context" signal would misfire there and was confirmed to regress the agentSubgraphFollower host-widget suite in testing. Also adds a second regression case (Jo Zhang's report, PM-1524): editing an existing node's prompt directly, with no generation and no progress-text widget in the picture, hits the same clobber. Fixes PM-1565 (child of PM-1268); this is the PM-1303/PM-1310 "hypothesis C" mechanism. Claude-Session: https://claude.ai/code/session_01BikjqCAiAR4ezQorLJxxfv
This comment has been minimized.
This comment has been minimized.
|
Superseded by #18361 — this branch's history couldn't be corrected in place (stripping a |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #18347 +/- ##
==========================================
+ Coverage 83.28% 84.28% +1.00%
==========================================
Files 2981 2280 -701
Lines 146683 129808 -16875
Branches 39783 33206 -6577
==========================================
- Hits 122161 109414 -12747
+ Misses 23241 20100 -3141
+ Partials 1281 294 -987
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 714 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…lue (#18361) <!-- ccr-slack-attribution --> _Requested by **Christian Byrne** · [Slack thread](https://comfy-organization.slack.com/archives/C0BGH348Z0C/p1790044084487469?thread_ts=1790044084.487469&cid=C0BGH348Z0C)_ Supersedes #18347, whose branch history could not be corrected in place (removing a `Co-Authored-By` trailer and reducing complexity both required rewriting already-pushed commits, which needs a force-push this session cannot perform). This PR has the same content on a clean, freshly-pushed branch. #18347 is being closed in favor of this one. ## Before An agent (or a person) edits a node's prompt widget — for example a Flux.2 Image node's `text` field — and the canvas correctly shows the new prompt for a moment. Then, without any further action from the user, the box silently reverts to an old prompt from earlier in the session. Refreshing the page does not fix it, because the stale value lives in the same shared CRDT document that gets re-read on load. ## After Editing a widget's live value, whether typed by a person or set by the agent, now survives the very next "catch-up" reconcile even when that reconcile's doc snapshot predates the edit. The widget keeps showing what was actually typed until a real remote write for that same widget lands. ## How it works ComfyUI_frontend's agent panel mirrors the shared workflow document into the canvas through an ECS-style CRDT follower (`ecsFollowerAdapter.ts` / `graphMutations.ts`). A full reconcile runs on the first frame of a session and after any frame whose batch failed to commit — both are ordinary, frequent occurrences (opening a tab, an unrelated generation-progress heartbeat arriving right after a race). That reconcile's `applyWidgetValues` replayed **every** widget from the doc snapshot onto the live node unconditionally, with no check for whether the live value had already moved on. If the snapshot predated a just-typed prompt, the reconcile silently overwrote it. The fix adds a per-widget "locally dirty" marker in `widgetValueStore.ts`: any value change that lands without a `RemoteMutationContext` (a human edit, or any write that bypasses the CRDT commit pipeline) marks that widget dirty; the next context-carrying write for that widget clears it. `graphMutations.ts`'s `applyWidgetValues`, called from the plain-node `reconcileNode` path, now skips writing a widget that is marked dirty instead of blindly replaying the doc's value over it, then clears the mark — a one-shot protection against the one stale catch-up reconcile, not a standing block on ever picking up a later, genuinely newer remote value. An explicit, single-widget `setWidget` op (an intentional remote write) is untouched, since it never goes through `applyWidgetValues`. The guard is deliberately **not** applied to `reconcileNodeFields` (used only for subgraph hosts): a host's promoted widgets are wired by `SubgraphNode`'s own projection (`promotedWidgetStoreProjection.ts`), which writes them directly with no `RemoteMutationContext` as a routine, structural part of attaching the host, not a human edit. Applying the same guard there was confirmed (via testing) to regress the `agentSubgraphFollower` host-widget suite, since host widgets never get any other kind of write to clear the mark. The `addNode`/`reconcileNode`/`replaceNode` branch of `graphMutations.ts`'s `commit()` was extracted into its own `commitUpsertNode()` helper to keep `commit()`'s complexity down, and direct unit tests were added in `graphMutations.test.ts` covering the guard's one-shot skip-then-trust-again behavior and `reconcileNodeFields`'s deliberate non-guarding. This is the PM-1303/PM-1310 "hypothesis C" mechanism: a pre-existing regression test (`ecsFollowerAdapter.promptReconcile.test.ts`) already reproduced it end-to-end against a real Yjs doc and a real litegraph node, marked `it.fails` until now. A second case (Jo Zhang's report, PM-1524 — editing an existing node's prompt directly, no generation in flight) was added alongside it. Refs [PM-1565](https://linear.app/comfyorg/issue/PM-1565) and its parent [PM-1268](https://linear.app/comfyorg/issue/PM-1268). ## Red-Green Verification | Commit | Purpose | |--------|---------| | `test: prove CRDT reconcile clobbers a fresher live widget value` | Drops `it.fails`, proving the regression test genuinely fails on `main` today | | `fix: don't let CRDT reconcile clobber a fresher live widget value` | Adds the per-widget dirty guard; the same test now passes | 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01BikjqCAiAR4ezQorLJxxfv --- _Generated by [Claude Code](https://claude.ai/code/session_01BikjqCAiAR4ezQorLJxxfv)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Christian Byrne · Slack thread
Before
An agent (or a person) edits a node's prompt widget — for example a Flux.2 Image node's
textfield — and the canvas correctly shows the new prompt for a moment. Then, without any further action from the user, the box silently reverts to an old prompt from earlier in the session. Refreshing the page does not fix it, because the stale value lives in the same shared CRDT document that gets re-read on load.After
Editing a widget's live value, whether typed by a person or set by the agent, now survives the very next "catch-up" reconcile even when that reconcile's doc snapshot predates the edit. The widget keeps showing what was actually typed until a real remote write for that same widget lands.
How it works
ComfyUI_frontend's agent panel mirrors the shared workflow document into the canvas through an ECS-style CRDT follower (
ecsFollowerAdapter.ts/graphMutations.ts). A full reconcile runs on the first frame of a session and after any frame whose batch failed to commit — both are ordinary, frequent occurrences (opening a tab, an unrelated generation-progress heartbeat arriving right after a race). That reconcile'sapplyWidgetValuesreplayed every widget from the doc snapshot onto the live node unconditionally, with no check for whether the live value had already moved on. If the snapshot predated a just-typed prompt, the reconcile silently overwrote it.The fix adds a per-widget "locally dirty" marker in
widgetValueStore.ts: any value change that lands without aRemoteMutationContext(a human edit, or any write that bypasses the CRDT commit pipeline) marks that widget dirty; the next context-carrying write for that widget clears it, even when the value doesn't otherwise change (a plainObject.iscomparison would otherwise miss that clear).graphMutations.ts'sapplyWidgetValues— the function bothreconcileNodeandreconcileNodeFieldsfunnel through — now skips writing a widget that is marked dirty, instead of blindly replaying the doc's value over it. An explicit, single-widgetsetWidgetop (an intentional remote write) is untouched by this change, since it never goes throughapplyWidgetValues.This is the PM-1303/PM-1310 "hypothesis C" mechanism: a pre-existing regression test (
ecsFollowerAdapter.promptReconcile.test.ts) already reproduced it end-to-end against a real Yjs doc and a real litegraph node, markedit.failsuntil now.Refs PM-1565 and its parent PM-1268.
Red-Green Verification
test: prove CRDT reconcile clobbers a fresher live widget valueit.fails, proving the regression test genuinely fails onmaintodayfix: ...🤖 Generated with Claude Code
https://claude.ai/code/session_01BikjqCAiAR4ezQorLJxxfv