Skip to content

Core Data: RTC cleanup edits matching persisted record on undo/redo - #79213

Closed
Mamaduka wants to merge 2 commits into
trunkfrom
fix/rtc-fully-undo-dirty-state
Closed

Mamaduka wants to merge 2 commits into
trunkfrom
fix/rtc-fully-undo-dirty-state

Conversation

@Mamaduka

Copy link
Copy Markdown
Member

What?

Fixes the same bug as in #77100, but when RTC is enabled.

Current problem

  1. Block move → editEntityRecord({ blocks, content: serializeBlocksFn }). content is a lazy function.
  2. applyPostChangesToCRDTDoc skips function values, so CRDT's blocks updates but content stays as the original, pre-move HTML.
  3. Peer update arrives. getChangesFromCRDTDoc emits content = <stale original HTML> (since getRawValue(fn) is undefined, diff sees a change).
  4. Fix sees incoming content matches persistedRecord.content.raw → clears the edit.
  5. Only blocks remains, which is transient → post not dirty → "Save draft" hidden.

Pre-fix this was masked: the stale value still got stored in edits, keeping the post dirty.

Suggested fixes (by Claude)

  1. Evaluate the content function in applyPostChangesToCRDTDoc so CRDT stores fresh content.
  2. Don't sync content when blocks is synced — let each peer serialize locally.

Testing Instructions

Testing Instructions for Keyboard

Same.

Screenshots or screencast

Use of AI Tools

Assisted by Claude.

@Mamaduka Mamaduka self-assigned this Jun 16, 2026
@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Package] Core data /packages/core-data [Feature] History History, undo, redo, revisions, autosave. [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration labels Jun 16, 2026
@github-actions

github-actions Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Size Change: +11 B (0%)

Total Size: 8.6 MB

📦 View Changed
Filename Size Change
build/scripts/core-data/index.min.js 31.8 kB +11 B (+0.03%)

compressed-size-action

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 0e7badd.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27600293968
📝 Reported issues:

@Mamaduka
Mamaduka force-pushed the fix/rtc-fully-undo-dirty-state branch from 0e7badd to 1bea129 Compare June 18, 2026 08:13
@Mamaduka Mamaduka closed this Aug 20, 2026
@Mamaduka
Mamaduka deleted the fix/rtc-fully-undo-dirty-state branch August 20, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] History History, undo, redo, revisions, autosave. [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Package] Core data /packages/core-data [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant