discourse-shared-edits/assets/javascripts/discourse/lib/shared-edits/protocol.js
Sam 50d9317272
FEATURE: yjs-based collaborative editing with state recovery and cursor sync
Major overhaul of the shared edits plugin to improve reliability, robustness,
and developer experience:

**Backend**
- Extract Revise service for cleaner controller orchestration
- Add StateValidator for base64/Yjs safety, corruption detection, and recovery
- Centralize protocol constants (Ruby + JS) to avoid hardcoded strings
- Add state hash sync verification and vector validation endpoints
- Harden security (guardian checks), error handling, and resource cleanup
- Resize shared edit columns migration; add state_hash column

**Frontend**
- Decompose shared-edit-manager into focused modules: yjs-document,
  markdown-sync, rich-mode-sync, network-manager, encoding-utils
- Add cursor overlay and caret coordinate tracking for selection sharing
- Add ProseMirror extension for rich-mode collaborative editing
- Cache-busted Yjs bundle loading via hashed filenames
- Fix scroll drift during sync

**Testing & Tooling**
- Extensive new specs: state_validator, revision_controller, model, revise service
- New Ember acceptance tests: cursor, lifecycle, sync flows
- Add support scripts: fake_writer (Playwright), state_corruptor, debug_recovery
- Add support/lint wrapper for full CI lint suite
- Update dependencies and rebuild Yjs/y-prosemirror bundles
2026-02-13 11:34:52 +11:00

19 lines
678 B
JavaScript

export const SHARED_EDITS_MESSAGE_ACTIONS = Object.freeze({
RESYNC: "resync",
});
export const SHARED_EDITS_ERRORS = Object.freeze({
BLANK_STATE_REJECTED: "blank_state_rejected",
COMMIT_FAILED: "commit_failed",
DISABLE_FAILED: "disable_failed",
INVALID_UPDATE: "invalid_update",
NEEDS_RECOVERY_TEXT: "needs_recovery_text",
NOT_INITIALIZED: "not_initialized",
POST_LENGTH_EXCEEDED: "post_length_exceeded",
RECOVERY_FAILED: "recovery_failed",
RECOVERY_NOT_NEEDED: "recovery_not_needed",
RESET_FAILED: "reset_failed",
STATE_DIVERGED: "state_diverged",
STATE_RECOVERED: "state_recovered",
STATE_RECOVERED_FROM_CLIENT: "state_recovered_from_client",
});