Skip to content

fix(collab): stop plugin reconfigure from wiping cursor awareness - #1237

Merged
kptdobe merged 6 commits into
mainfrom
collabfx
Aug 13, 2026
Merged

fix(collab): stop plugin reconfigure from wiping cursor awareness#1237
kptdobe merged 6 commits into
mainfrom
collabfx

Conversation

@kptdobe

@kptdobe kptdobe commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a real bug in blocks/edit/prose/index.js: applyDelayedPlugins reconfigures ProseMirror's plugin list once lazily-loaded chunks resolve, which gives the plugins array a new identity and makes ProseMirror destroy+recreate every plugin view — including y-prosemirror's cursor plugin, whose destroy handler unconditionally nulls the local awareness cursor field. A user editing before that promise resolves had their collab cursor silently wiped until their next selection change. Fixed by dispatching a no-op transaction right after updateState to force the recreated plugin views through an update pass.
  • Fixes the flaky Collab cursors in multiple editors e2e test: pins hasFocus() on both pages so cursor broadcast isn't gated on which page/tab holds real browser focus (only one can at a time), and replaces flat timeouts with deterministic waits (plus a bounded retry) on the actual yjs awareness state.
  • Fixes a second, unrelated flake in edit.spec.js's "Add code mark" test (reproduces on main too, confirmed not caused by the above): Playwright/CDP occasionally drops a single keypress in a run of counted ArrowLeft/ArrowRight presses, leaving the cursor off by one before the code-mark backticks get typed (codeode ). Now verifies the cursor actually landed where expected via ProseMirror's own selection state, and presses the same key again to close the gap if one got dropped.

Test plan

  • Ran the collab e2e test 20+ times locally against the real backend; consistently passing after the focus + reconfigure fixes (was ~30% flaky before)
  • Ran the full edit.spec.js suite 9+ times locally; consistently passing after the arrow-key drift fix (previously flaky ~1-in-3 runs)
  • npx eslint clean on all changed files

🤖 Generated with Claude Code

applyDelayedPlugins reconfigures ProseMirror's plugin list once its
lazily-loaded chunks resolve. Because the plugins array gets a new
identity, ProseMirror destroys and recreates every plugin view -
including y-prosemirror's cursor plugin, whose destroy handler
unconditionally nulls the local awareness 'cursor' field. A user
editing before that resolves had their collab cursor silently wiped
until their next selection change. Dispatch a no-op transaction right
after reconfiguring to force the recreated plugin views through an
update pass.

Also fixes the flaky multi-window collab e2e test: pins hasFocus()
on both pages so cursor broadcast isn't gated on which page/tab holds
real browser focus, and replaces flat timeouts with a deterministic
wait (plus bounded retry) on the actual yjs awareness state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@aem-code-sync

aem-code-sync Bot commented Aug 12, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

Playwright/CDP occasionally drops a single keypress in a run of
keyboard.press('ArrowLeft'/'ArrowRight') calls, leaving the cursor off
by one before the code-mark backticks get typed - producing flaky
failures unrelated to the collab cursor bug (reproduces on main too).
Verify the cursor actually landed where expected via ProseMirror's own
selection state after each movement loop, and press the same key again
to close the gap if a keypress got dropped, instead of trusting the
count blindly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comment thread blocks/edit/prose/index.js
kptdobe and others added 2 commits August 12, 2026 15:26
@kptdobe
kptdobe merged commit 79e2c81 into main Aug 13, 2026
3 checks passed
@kptdobe
kptdobe deleted the collabfx branch August 13, 2026 08:04
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.

2 participants