RTC: Prevent controlled block synchronization from intercepting undo - #80503
Conversation
|
Size Change: +13 B (0%) Total Size: 7.75 MB 📦 View Changed
|
|
Flaky tests detected in da96511. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29944099202
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
ingeniumed
left a comment
There was a problem hiding this comment.
Comments around the test need to be tweaked other LGTM
What?
This PR prevents entity-driven controlled block synchronization from adding derived changes to RTC undo history.
It also adds an end-to-end reproduction covering a post with a Navigation block where a delayed self-update previously intercepted a collaborator's first undo.
Follow-up to #78864.
Why?
RTC uses one global undo ordering across multiple Yjs documents. After a collaborator typed in the post body, the incoming round-trip update could cause the controlled Navigation block to emit a derived
wp_navigationentity edit. That edit was tracked on a separate Yjs document and placed above the user's typing in the global undo stack.As a result, pressing undo once popped an invisible Navigation update instead of removing the typed character. The feedback update could also clear redo.
How?
Controlled block setup, replacement, reset, and cleanup are already marked non-persistent because they reflect incoming entity state. This PR additionally marks those derived changes with
history: 'ignore'.useBlockSyncalready propagates that history mode asundoIgnore: true, so the derived Navigation update is excluded from Yjs undo history while direct user-authored Navigation edits remain tracked.Testing Instructions
Start the test environment if needed:
npm run wp-env-test start.Run:
Confirm the test passes and the delayed User B Navigation edit is logged with
undoIgnore=true.Run the hook unit tests:
For a manual check, run
RTC_WS_DELAY=50 npm run rtc:ws, open the same post in two administrator sessions, and include a Navigation block between paragraphs. Type one character in a paragraph as the second user, wait at least two seconds, and press undo once. The character should be removed and redo should remain available.Testing Instructions for Keyboard
Follow the manual steps above and use the platform undo shortcut (
Cmd+Zon macOS orCtrl+Zelsewhere). The typed character should be removed with one shortcut press.Screenshots or screencast
Not applicable; this changes undo-stack behavior without changing the UI.
Use of AI Tools
AI assistance: Yes
Tool: Codex
Used for: Investigating the RTC undo data flow, implementing the fix, running automated and manual verification, and drafting this description.