Skip to content

Fix undo and redo after collaboration upgrade - #3851

Draft
jelkes1 wants to merge 1 commit into
superdoc:mainfrom
jelkes1:codex/fix-collaboration-undo-redo-history
Draft

Fix undo and redo after collaboration upgrade#3851
jelkes1 wants to merge 1 commit into
superdoc:mainfrom
jelkes1:codex/fix-collaboration-undo-redo-history

Conversation

@jelkes1

@jelkes1 jelkes1 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • detect the editor's active history backend whenever a history snapshot is read
  • switch existing local history adapters to Yjs after upgradeToCollaboration() attaches collaboration in place
  • add regression coverage for the late collaboration upgrade path

Root cause

EditorHistorySnapshotAdapter cached whether the editor was collaborative in its constructor. The unified history coordinator creates the adapter while the editor is still local, so an instance later upgraded with upgradeToCollaboration() continued reading the removed ProseMirror history stack. Undo and redo depths therefore remained zero even when the Yjs UndoManager contained entries, leaving both controls disabled.

Impact

Editors upgraded from local mode to collaboration now expose the Yjs undo/redo depths to the unified history coordinator and toolbar.

Validation

  • vitest history adapter, coordinator, and PresentationEditor suites: 199 passed, 5 skipped
  • vitest upgrade-collaboration.test.js: 14 passed
  • Prettier check for both changed files: passed
  • git diff --check: passed

The package-wide types:check remains red on existing unrelated JS/TS migration errors across the package; no reported error points to either changed file.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants