Skip to content

test: fix rebind assertion in follower_replaced CRDT test - #19584

Merged
claude[bot] merged 7 commits into
mainfrom
fix/crdt-follower-replaced-test-rebind-assertion
Oct 3, 2026
Merged

claude[bot] merged 7 commits into
mainfrom
fix/crdt-follower-replaced-test-rebind-assertion

Conversation

@claude

@claude claude Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #19522: fixes a test-quality gap in useAgentCrdtFollower.test.ts that Cursor's review bot correctly identified (review 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.ai/code/session_018MwRoaxpVReK7UMkaC5NxA


Generated by Claude Code

Follow-up to #19522. Cursor review flagged that the test asserted
bind was "lastCalledWith" the SAME follower object throughout, so it
could not distinguish a correct rebind from a stale one. Mirror the
sibling doc_reset test's pattern: assign a genuinely different
follower object before dispatching follower_replaced and assert bind
was called with that new object. Also retitle the test (workflowId
never actually changed, so "a deliberate workflow switch" was
misleading) and assert replaceOnNextFrame is not armed on this path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MwRoaxpVReK7UMkaC5NxA
@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: 04842560-5d21-44c1-ba40-55cd09578948

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
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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: 10/03/2026, 05:16:28 PM 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 b16e68a9188a82f3d9089c3ca5542146e769f71b

Full docs: ADR-DEVEX-LINT-0015

@claude
claude Bot marked this pull request as ready for review September 30, 2026 06:43
@claude
claude Bot requested a review from a team September 30, 2026 06:43
@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label Sep 30, 2026
@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   #19584      +/-   ##
==========================================
- Coverage   85.18%   83.72%   -1.47%     
==========================================
  Files        2414     2422       +8     
  Lines      136302   145180    +8878     
  Branches    36903    39923    +3020     
==========================================
+ Hits       116114   121553    +5439     
- Misses      19716    23252    +3536     
+ Partials      472      375      -97     
Flag Coverage Δ
billing-web-unit ?
unit 82.42% <ø> (+0.89%) ⬆️

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

@christian-byrne christian-byrne added the cursor-review Trigger multi-model Cursor agent review on this PR label Oct 3, 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 1 finding(s).

Severity Count
🟢 Low 1

Panel: 8/8 reviewers contributed findings.

@christian-byrne christian-byrne added cursor-review Trigger multi-model Cursor agent review on this PR and removed cursor-review Trigger multi-model Cursor agent review on this PR labels Oct 3, 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.

Round 2 — ledger: 1 prior finding(s) across 1 round(s) (0 never answered).

Found 2 finding(s).

Severity Count
⚪ Nit 2

Panel: 8/8 reviewers contributed findings.

@christian-byrne christian-byrne added cursor-review Trigger multi-model Cursor agent review on this PR and removed cursor-review Trigger multi-model Cursor agent review on this PR labels Oct 3, 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.

Round 3 — ledger: 3 prior finding(s) across 2 round(s) (0 never answered).

Found 2 finding(s).

Severity Count
🟢 Low 1
⚪ Nit 1

Panel: 8/8 reviewers contributed findings.

@christian-byrne christian-byrne added cursor-review Trigger multi-model Cursor agent review on this PR and removed cursor-review Trigger multi-model Cursor agent review on this PR labels Oct 3, 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.

Round 4 — ledger: 5 prior finding(s) across 3 round(s) (0 never answered).

Found 2 finding(s).

Severity Count
🟢 Low 1
⚪ Nit 1

Panel: 8/8 reviewers contributed findings.

@christian-byrne christian-byrne added cursor-review Trigger multi-model Cursor agent review on this PR and removed cursor-review Trigger multi-model Cursor agent review on this PR labels Oct 3, 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.

Round 5 — ledger: 6 prior finding(s) across 3 round(s) (0 never answered).

Found 3 finding(s).

Severity Count
🟡 Medium 1
🟢 Low 2

Panel: 8/8 reviewers contributed findings.

@christian-byrne christian-byrne added cursor-review Trigger multi-model Cursor agent review on this PR and removed cursor-review Trigger multi-model Cursor agent review on this PR labels Oct 3, 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.

Round 6 — ledger: 7 prior finding(s) across 3 round(s) (3 never answered).

Found 3 finding(s).

Severity Count
🟡 Medium 1
⚪ Nit 2

Panel: 8/8 reviewers contributed findings.

@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 5a74242dfdf88981b2fc892f833162ad46f11d6b against current production follower-switch ordering and all six Cursor rounds. The test now drives the real reactive wf-1→wf-2 switch, mirrors synchronous follower_replaced emission from subscribe, pins wf-1 unbind, wf-2 bind-before-subscribe intent, strict replacement identity, discard-before-rebind ordering, zeroed applied state despite a nonzero replacement counter, and no reset arm. Local exact-file proof: NODE_OPTIONS=--no-experimental-webstorage pnpm vitest run src/workbench/extensions/agent/crdt/useAgentCrdtFollower.test.ts (88/88). Mutation proof: binding a captured stale follower fails this case at the strict identity assertion. Hosted checks are green or still settling from this exact head; do not merge until all required checks complete. No remaining code finding.

@claude
claude Bot added this pull request to the merge queue Oct 3, 2026
Merged via the queue into main with commit afb90a2 Oct 3, 2026
97 checks passed
@claude
claude Bot deleted the fix/crdt-follower-replaced-test-rebind-assertion branch October 3, 2026 17:40
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:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants