Repository navigation
test: port missing CRDT mint-reset coverage from #18403 - #19522
Conversation
…g reset PR #18403 (closed in favor of #18700's more general projection.replaceOnNextFrame() fix) tested that a bare follower_replaced frame with no preceding doc_reset still independently rebinds the follower and clears applied state, rather than assuming a prior reset already made that decision. #18700 removed the branch that reused a prior reset's decision, but no test in the current suite dispatches follower_replaced without a preceding doc_reset, so this call path was untested in isolation. Port that case, adapted to the current projectionState/replaceOnNextFrame mocks.
|
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 |
🎨 Storybook: ✅ Built — View Storybook🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measureExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight 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: ✅ PassedFallow 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 6790cccb00de791e692f36f4e0031a959e31b0e0
Full docs: ADR-DEVEX-LINT-0015 |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #19522 +/- ##
==========================================
+ Coverage 84.29% 84.91% +0.62%
==========================================
Files 3287 2340 -947
Lines 158435 134288 -24147
Branches 43067 34321 -8746
==========================================
- Hits 133549 114030 -19519
+ Misses 23056 19893 -3163
+ Partials 1830 365 -1465
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
christian-byrne
left a comment
There was a problem hiding this comment.
Reviewed exact head 824e45b against current main and the landed #18700 follower path. The carrier is scoped to the surviving bare follower_replaced case and does not revive store-first apply or reconciliation. Local full-file proof: NODE_OPTIONS=--no-experimental-webstorage pnpm test:unit src/workbench/extensions/agent/crdt/useAgentCrdtFollower.test.ts (88/88). Mutation proof: removing the follower_replaced reset/rebind body makes the new case fail at updatesApplied (expected 0, received 3). No findings; no product commit needed.
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Found 3 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 1 |
| 🟢 Low | 1 |
| ⚪ Nit | 1 |
Panel: 8/8 reviewers contributed findings.
| expect(status().updatesApplied).toBe(0) | ||
| expect(projectionState.discardPending).toHaveBeenLastCalledWith('wf-1') | ||
| expect(projectionState.bind).toHaveBeenCalledTimes(2) | ||
| expect(projectionState.bind).toHaveBeenLastCalledWith( |
There was a problem hiding this comment.
🟡 Medium — bridge().follower is never swapped for a replacement doc before the follower_replaced dispatch, so bind is re-called with the identical object it was first bound to and this assertion holds whether the handler rebinds to the replacement or keeps observing the destroyed document — the exact regression onFollowerReplaced exists to prevent. Assign a replacement the way the sibling test at ~1146 does (bridge().follower = { updatesApplied: 0, doc: replacementDoc }) and assert the new doc rather than the same reference; note the real AgentCrdtProjection.bind early-returns when a workflow is already bound to that same follower, so this scenario would be a no-op outside the module mock. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial).
There was a problem hiding this comment.
Confirmed — valid finding. bridge().follower is never reassigned before the follower_replaced dispatch in this test, so bind is re-called with the same reference and the assertion can't distinguish a correct rebind from a stale one, unlike the sibling test at ~1146 which does swap the follower object. This PR already merged, so not fixing it here; a small standalone follow-up (swap bridge().follower to a distinct object before dispatch and assert against it, per the sibling test's pattern) would close the gap and could also cover the workflowId-switch and replaceOnNextFrame-not-called points raised in the other two comments.
Generated by Claude Code
| // No doc_reset precedes this: unlike the reset-then-replace flow above, | ||
| // there is no armed replacement for this workflow to reuse. The switch | ||
| // must still rebind and clear applied state on its own. | ||
| dispatchFrame('follower_replaced', { workflowId: 'wf-1' }) |
There was a problem hiding this comment.
🟢 Low — The test is named for "a deliberate workflow switch" but no switch is performed: workflowId stays 'wf-1', subscribe is never re-driven, and bridge().subscribedWorkflowId stays 'wf-1', so the composable's subscription intent and the bridge's send reality never diverge. Since onFollowerReplaced gates on intent precisely because a replacement arriving while the socket is down leaves the bridge's reality null, setting bridge().subscribedWorkflowId = null before the dispatch (or driving the retarget through a fake subscribe that mints the new follower) would cover that distinction instead of the trivial case. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial).
| // must still rebind and clear applied state on its own. | ||
| dispatchFrame('follower_replaced', { workflowId: 'wf-1' }) | ||
|
|
||
| expect(status().updatesApplied).toBe(0) |
There was a problem hiding this comment.
⚪ Nit — The premise that distinguishes this case from the reset-then-replace test above — that no lineage replacement is armed — is never asserted, leaving the remaining assertions a duplicate of that test's second half. Adding expect(projectionState.replaceOnNextFrame).not.toHaveBeenCalled() would catch the no-reset path spuriously arming a replacement, which would flip the next frame's apply mode to 'replace'. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).
…19584) ## Summary Follow-up to Comfy-Org#19522: fixes a test-quality gap in `useAgentCrdtFollower.test.ts` that Cursor's review bot correctly identified ([review comment](Comfy-Org#19522 (comment))). ## Changes - **What**: In the test `a follower_replaced ... still rebinds and clears applied state` (around line 705 on `main`), `bridge().follower` was never reassigned to a different object before the `follower_replaced` dispatch. That meant the assertion `expect(projectionState.bind).toHaveBeenLastCalledWith('wf-1', bridge().follower)` compared the same object reference to itself — it could pass even if the rebind logic used a stale follower, so it couldn't actually distinguish a correct rebind from a broken one. **Before**: the test asserted `bind` was last called with `bridge().follower`, read *after* the dispatch, which is always the same object the test started with (nothing in the test ever changes it). A regression that rebinds using a captured/stale follower reference instead of the live one would still pass this assertion. **After**: mirroring the sibling `doc_reset`-then-`follower_replaced` test a few hundred lines down (which does `bridge().follower = { updatesApplied: 0, doc: replacementDoc }` before dispatching), this test now assigns a genuinely new follower object to `bridge().follower` before dispatching `follower_replaced`, and asserts `bind` was called with *that* new object. This actually exercises the rebind. Also addressed, both flagged in the same review: - Retitled the test: it was called "...(a deliberate workflow switch)..." but `workflowId` never changed (stayed `'wf-1'` throughout), so that scenario wasn't actually exercised. Retitled to "a follower_replaced for the same workflow with no preceding doc_reset (e.g. a resubscribe swap)..." to match what it actually tests. - Added `expect(projectionState.replaceOnNextFrame).not.toHaveBeenCalled()` to assert this path deliberately does not arm a lineage replacement, distinguishing it from the reset-then-replace sibling test. - **Breaking**: none. - **Dependencies**: none. ## Review Focus - Confirmed the fix actually catches the regression the original assertion missed: temporarily changed `onFollowerReplaced` in `useAgentCrdtFollower.ts` to rebind with a stale/captured follower reference instead of the live `bridge.follower`, ran the suite, saw both this test and the sibling `doc_reset` test fail, then reverted the change. `git diff` confirms only the test file changed in the final commit. - All 88 tests in `useAgentCrdtFollower.test.ts` pass; `eslint`/`oxlint`/`typecheck:app` (run via the pre-commit hook) are clean on the changed file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018MwRoaxpVReK7UMkaC5NxA --- _Generated by [Claude Code](https://claude.ai/code/session_018MwRoaxpVReK7UMkaC5NxA)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Christian Byrne <cbyrne@comfy.org>
PR #18403 is being closed in favor of #18700, whose
projection.replaceOnNextFrame()mechanism fixes the same benign first-mint CRDT reset flicker more generally (anydoc_reset, not justsystem:mint).I compared every test case #18403 added, against its state right before the branch's last merge-from-main (commit
f6fcac1a76), to what exists onmaintoday:browser_tests/tests/agent/agentFirstMintResetSweepsTemplate.spec.ts— main's version (via the add/add conflict resolution) is the same single repro test, just using the newerloadIntoBootWorkflowfixture helper. No coverage lost.src/workbench/extensions/agent/crdt/useAgentCrdtFollower.test.ts— fix: don't sweep the agent canvas on a benign first-mint CRDT reset #18403 added ~4 cases exercising the actor/seq/hasNodes()-based skip logic (system:mintseq 1 doesn't clear, mid-turn mint does clear, non-1-seq mint still skips when the doc has zero nodes, and a barefollower_replacedalways clears).#18700deleted that entire decision (hasNodes,clearForReset, thesystem:mintcarve-out) and now callsprojection.replaceOnNextFrame()unconditionally for every reset, deferring the actual graph swap until real frame data arrives. Three of the four cases only tested that now-deleted, actor/seq-specific branching and can't be meaningfully ported — asserting "does not clear forsystem:mint" would just be false against current code, and the general "reset defers replacement, doesn't clear immediately" behavior they were guarding is already covered byarms a lineage replacement only for an explicit reset...plus theagentCrdtProjection.integration.test.tscasereplaces the graph with the new lineage only when its first frame arrives after a reset.The fourth case — a
follower_replacedwith no precedingdoc_reset(a deliberate workflow switch) still independently rebinding/clearing — turned out to be a real gap: every current test that dispatchesfollower_replaceddoes so right after adoc_reset, so the bare-switch path was untested in isolation even though main'sonFollowerReplacedhandles it unconditionally. This PR ports that one case, adapted to the currentprojectionState/replaceOnNextFramemocks.Ran
pnpm vitest run src/workbench/extensions/agent/crdt/locally: 56 files, 738 tests (737 passed, 1 pre-existing expected-fail), including the new case. Lint/typecheck ran clean via the repo's pre-commit hook.🤖 Generated with Claude Code
https://claude.ai/code/session_018MwRoaxpVReK7UMkaC5NxA
Generated by Claude Code