Skip to content

Add offline body-CRDT sync E2E coverage - #196

Merged
h4yfans merged 11 commits into
mainfrom
memry/add-offline-sync-e2e-test
Apr 10, 2026
Merged

Add offline body-CRDT sync E2E coverage#196
h4yfans merged 11 commits into
mainfrom
memry/add-offline-sync-e2e-test

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 10, 2026

Copy link
Copy Markdown
Collaborator

What

Add deterministic dual-device desktop E2E coverage for body-only note CRDT sync, and fix the sync/runtime gaps that the new coverage exposed.

Why

We needed reliable regression coverage for the core offline sync scenarios across two devices:

  • offline note creation
  • offline and mixed online/offline edits
  • concurrent same-note merges
  • reconnect-order variants
  • the explicit 2 notes / 4 edits cross-edit flow

Without this, the desktop app could regress on convergence behavior without a stable end-to-end signal.

How

  • Added a dual-device Electron E2E harness with isolated device identities and shared sync bootstrap.
  • Added deterministic test controls for network state, manual sync, note creation/open/edit/read helpers, and CRDT/writeback inspection.
  • Added body-CRDT E2E suites for create propagation, single-writer propagation, different-note concurrent edits, same-note merges, and coverage variants.
  • Fixed sync issues uncovered by the new tests, including:
    • CRDT seeding for existing-but-empty docs on note open
    • immediate CRDT snapshot push after successful update batches
    • reconnect pull coverage for inactive markdown notes
    • renderer autosave racing Yjs-owned note bodies
    • re-fetching already-applied CRDT sequences after snapshot replacement
    • full-sync CRDT catch-up when the index DB is unavailable in tests
  • Added and updated unit coverage for the new sync behavior.
  • Added the execution checklist in docs/superpowers/plans/2026-04-10-body-crdt-sync-e2e-checklist.md.

Type

  • fix — bug fix
  • feat — new feature
  • refactor — restructure without behavior change
  • style — visual/UI only
  • perf — performance improvement
  • test — adding or updating tests
  • chore — tooling, deps, config
  • docs — documentation only
  • ci — CI/CD changes

Test plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing (describe below)

Commands run:

  • pnpm test
  • pnpm --dir apps/sync-server exec vitest run schema/d1.test.ts
  • pnpm --dir apps/desktop exec vitest run --config config/vitest.config.ts src/main/sync/engine/crdt-sync-coordinator.test.ts
  • pnpm --dir apps/desktop exec vitest run --config config/vitest.config.ts src/main/sync/engine.test.ts -t "#given WS reconnect #when handleWsConnected fires"
  • pnpm --dir apps/desktop exec playwright test --config config/playwright.config.ts tests/e2e/body-crdt-create-propagation.e2e.ts
  • pnpm --dir apps/desktop exec playwright test --config config/playwright.config.ts tests/e2e/body-crdt-single-writer-edit.e2e.ts
  • pnpm --dir apps/desktop exec playwright test --config config/playwright.config.ts tests/e2e/body-crdt-different-note-edit.e2e.ts
  • pnpm --dir apps/desktop exec playwright test --config config/playwright.config.ts tests/e2e/body-crdt-same-note-merge.e2e.ts
  • pnpm --dir apps/desktop exec playwright test --config config/playwright.config.ts tests/e2e/body-crdt-coverage-variants.e2e.ts
  • pnpm --dir apps/desktop test:e2e -- dual-device-isolation.e2e.ts shared-sync-bootstrap.e2e.ts network-control.e2e.ts note-sync-helpers.e2e.ts manual-sync-smoke.e2e.ts body-crdt-create-propagation.e2e.ts

Checklist

  • Self-reviewed the diff
  • No hardcoded secrets or credentials
  • Files stay under ~500 LOC
  • Follows immutable data patterns

@h4yfans h4yfans changed the title [codex] Add offline body-CRDT sync E2E coverage Add offline body-CRDT sync E2E coverage Apr 10, 2026
@h4yfans
h4yfans marked this pull request as ready for review April 10, 2026 17:41
@h4yfans
h4yfans merged commit 96d1fdc into main Apr 10, 2026
3 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