Skip to content

test: port missing CRDT mint-reset coverage from #18403 - #19522

Merged
claude[bot] merged 1 commit into
mainfrom
test/port-crdt-mint-reset-coverage-18403
Sep 30, 2026
Merged

claude[bot] merged 1 commit into
mainfrom
test/port-crdt-mint-reset-coverage-18403

Conversation

@claude

@claude claude Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

PR #18403 is being closed in favor of #18700, whose projection.replaceOnNextFrame() mechanism fixes the same benign first-mint CRDT reset flicker more generally (any doc_reset, not just system: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 on main today:

  • 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 newer loadIntoBootWorkflow fixture 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:mint seq 1 doesn't clear, mid-turn mint does clear, non-1-seq mint still skips when the doc has zero nodes, and a bare follower_replaced always clears). #18700 deleted that entire decision (hasNodes, clearForReset, the system:mint carve-out) and now calls projection.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 for system: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 by arms a lineage replacement only for an explicit reset... plus the agentCrdtProjection.integration.test.ts case replaces the graph with the new lineage only when its first frame arrives after a reset.

    The fourth case — a follower_replaced with no preceding doc_reset (a deliberate workflow switch) still independently rebinding/clearing — turned out to be a real gap: every current test that dispatches follower_replaced does so right after a doc_reset, so the bare-switch path was untested in isolation even though main's onFollowerReplaced handles it unconditionally. This PR ports that one case, adapted to the current projectionState/replaceOnNextFrame mocks.

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

…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.
@claude
claude Bot requested a review from a team September 30, 2026 01:05
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 8e701e14-9425-48a4-834f-5224867aa0ac

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.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 09/30/2026, 01:07:04 AM UTC

Links

🧩 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 6790cccb00de791e692f36f4e0031a959e31b0e0

Full docs: ADR-DEVEX-LINT-0015

@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

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     
Flag Coverage Δ
billing-web-unit ?
unit 81.48% <ø> (+<0.01%) ⬆️
website-unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.
see 955 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.

@github-actions github-actions Bot added the risk:medium PR risk grade (advisory shadow check; grader-owned) label Sep 30, 2026
@christian-byrne christian-byrne added the cursor-review Trigger multi-model Cursor agent review on this PR label Sep 30, 2026

@christian-byrne christian-byrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@claude
claude Bot added this pull request to the merge queue Sep 30, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ 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).

Merged via the queue into main with commit 07779a1 Sep 30, 2026
120 checks passed
@claude
claude Bot deleted the test/port-crdt-mint-reset-coverage-18403 branch September 30, 2026 06:08
Penguinjanator pushed a commit to Penguinjanator/ComfyUI_frontend that referenced this pull request Oct 4, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor-review Trigger multi-model Cursor agent review on this PR risk:medium PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants