Skip to content

crdt-sync-plugin

Status: Completed (core functionality)


Obsidian plugin providing conflict-free sync using CRDT (Yjs). Supports three modes:

  • File-only: Sync via SMB/Dropbox/cloud storage
  • Hybrid: Server when available, file fallback
  • Server-only: Real-time WebSocket sync

obsidian-plugin/


FilePurpose
src/main.tsPlugin entry, settings, file hooks
src/crdt-state-manager.tsRead/write .crdt state files
src/file-sync-manager.tsDebounced save handling
src/presence-manager.tsTrack who’s editing what
src/identity.tsClient ID generation
manifest.jsonPlugin metadata
package.jsonDependencies (Yjs, diff-match-patch)

  • Yjs CRDT integration
  • File-based state storage (.crdt folder)
  • Background merge checking
  • Presence awareness (status bar)
  • Editing nudge suggestions
  • Settings UI for all modes
  • WebSocket server connection
  • Client ID generation
  • diff-match-patch for efficient updates
  • Conflict visualization UI
  • Mobile support
  • Binary file handling

User edits project.md
Plugin updates Y.Doc
Plugin saves .crdt/project.md.{clientId}.yjs
SMB/Dropbox syncs to other clients
Other client opens project.md
Plugin merges all .yjs files
project.md updated with merged content

Same as file-only, plus:

  • Connect to WebSocket server
  • Real-time updates when server available
  • Fall back to file sync when disconnected

interface CrdtSyncSettings {
clientId: string; // Auto-generated UUID
displayName: string; // User's name
syncMode: 'file-only' | 'hybrid' | 'server-only';
serverUrl: string; // ws://host:port
backgroundCheckInterval: number; // ms (default 3000)
debounceDelay: number; // ms (default 500)
crdtFolderName: string; // default '.crdt'
showPresence: boolean;
showPresenceNudge: boolean;
showSyncStatus: boolean;
showConflictNotifications: boolean;
}