Skip to content

fix(root): judge the document after the drag ends, not in the same tick - #891

Merged
mobeenabdullah merged 1 commit into
mainfrom
fix/judge-the-document-after-the-drag-ends
Aug 17, 2026
Merged

mobeenabdullah merged 1 commit into
mainfrom
fix/judge-the-document-after-the-drag-ends

Conversation

@mobeenabdullah

Copy link
Copy Markdown
Collaborator

What

Two canvas assertions read state in the same tick as the action they observe. One is a false green and is the reason for this PR; the other is a false red that would survive the feature arriving.

The false green — acceptance.spec.ts, "leaves the document and the editor intact when Escape cancels"

await driver.cancel();
expect(await driver.readTreeShape(), "Escape changes nothing").toEqual(before);

An unpolled read asserting the absence of change. Reading early guarantees the assertion passes, whether or not a mutation lands a commit later — so a canvas that corrupts the document on Escape passes this test. It carries no test.fail, so it is an active, passing test nobody is looking at, and it is the guard for the exact property its own title claims.

Measured: it is the only read-and-assert-in-one-tick site in the suite — grep -c "expect(await driver\.\|expect(await chrome\." gives acceptance.spec.ts:1 and 0 in scenarios. An outlier, not a house style.

expect.poll cannot fix it, which is the trap: polling retries until a condition becomes TRUE, and "unchanged" is already true at t=0, so a poll returns immediately having waited for nothing. What is needed is a barrier, and the drag ending is the right one — a property of the system rather than a duration someone guessed.

The barrier is load-bearing rather than decorative. Measured on this canvas: immediately after cancel() the source still reports aria-grabbed="true", and it clears by +100ms. So the assertion now waits out a window the old code read straight through.

What it does not close, stated rather than implied: a mutation arriving well after the drag has ended is still outside this barrier. It closes the window where a commit from the drag itself is in flight, which is the case that produced the false green.

The false red — scenarios.spec.ts, scenario 5 (keyboard move)

await driver.keyboardInsert("down");
const moved = await driver.readTreeShape();   // same tick

A reorder lands on a React commit after the drop resolves. readTreeShape is already polled after an asynchronous mutation in three other places in this suite, one of them spelling out the reason. Now waits, ending early the moment the tree differs.

Measured before changing it, and the marker is honest: with focus asserted on the target first (nx-flat-0, tabindex=0, role=button), the tree is byte-identical at 0, 100, 300, 1000 and 2000ms. B-14 is genuinely unbuilt. The change is so the case reports the arrival — as written it would keep saying "no keyboard move path at all" after keyboard dragging landed.

Notes

Test-only, so no changeset. tsc --noEmit clean; both suites 21 passed.

Local canvas e2e on current main needs pnpm --filter @nextlyhq/builder... build first — plugin-page-builder's dist imports @nextlyhq/builder/shell since #865, and a stale builder dist throws at dist/admin/index.js:1134 with every case timing out on mountTree. It reads exactly like a broken canvas.

@mobeenabdullah

Copy link
Copy Markdown
Collaborator Author

@codex please review this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mobeenabdullah, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Limit details: You’ve used all 1 included review currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 112ef730-e4cb-41cf-a873-22d587bea282

📥 Commits

Reviewing files that changed from the base of the PR and between 510dff9 and 46a7959.

📒 Files selected for processing (2)
  • e2e/tests/canvas/acceptance.spec.ts
  • e2e/tests/canvas/scenarios.spec.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@mobeenabdullah
mobeenabdullah merged commit 0489453 into main Aug 17, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant