Skip to content

fix(editor): prevent content loss during collaborative initialization - #100

Merged
LeoStehlik merged 1 commit into
masterfrom
fix/safe-collaborative-editor-initialization
Oct 5, 2026
Merged

LeoStehlik merged 1 commit into
masterfrom
fix/safe-collaborative-editor-initialization

Conversation

@LeoStehlik

Copy link
Copy Markdown
Contributor

Summary

Prevent a fresh collaborative editor from erasing existing page content during initialization. A provider's synced callback can occur while the editor view is still stale; even a no-op initial ID transaction can trigger a destructive Yjs write.

  • Wait for local persistence and remote sync before binding collaboration, and reject providers belonging to the previous page.
  • Defer initial ID generation, compare the full editor document against the configured Yjs fragment before writing, and skip no-op dispatches.
  • Handle already-synced providers, false sync events, bounded initialization retries, and timer/listener cleanup on destruction.
  • Retain upstream ID behaviour for normal editing and provider-less collaboration.
  • Add a repeatable regression command and a SHA-pinned, read-only GitHub Actions workflow.

Verification

Based on the current GitHub master (ead85ed), with its frozen lockfile and Tiptap 3.30.5. No dependency/lockfile changes.

  • pnpm test:editor-ext: 31/31 passed, including 10 real-editor/Yjs rich-content timing cases and 21 document/lifecycle guards.
  • pnpm --filter server test --runInBand: 156/156 passed across 27 suites.
  • NX_DAEMON=false pnpm exec nx run-many -t build -p client server @wrenlore/editor-ext --skip-nx-cache: all 3 production builds passed.
  • git diff --check: passed.
  • Workflow syntax/read-only permissions and scoped private-data scan: passed.

Tests use synthetic content only and do not connect to external services. Existing non-fatal bundle-size/dynamic-import and ts-jest warnings remain unchanged.

Scope

No database migrations, deployment changes, customer exports, credentials, environment-specific URLs, or importer artifacts are included. This is the permanent source-code fix; it does not redeploy any running instance.

@LeoStehlik
LeoStehlik merged commit 00fdf64 into master Oct 5, 2026
2 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