Live collaboration with Yjs over ActionCable

All editors now work on a server document at the same time instead of
taking turns behind an edit lock.

- The document's content is a sequence of Yjs updates (document_updates);
  DocumentChannel stores and relays them immediately, checks access on
  subscribe and again whenever links or memberships change.
- app/frontend/collab/: the store stays position-based; a binding maps it
  to a Yjs form with stable row/column ids, so a row inserted by one
  person doesn't misplace what another is typing. Remote changes are
  applied only after pending local ones went into Yjs.
- Per-person undo (Y.UndoManager), presence via awareness: the others'
  selections as coloured boxes with names, avatars in the toolbar.
- Existing JSON documents convert on first open, deterministically, so
  two people opening one at once end up with the same Yjs state.
- Editors compact the stored updates after 200 and keep a JSON snapshot
  current for export and duplicating. Edit lock and polling are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
wkh
2026-09-28 20:41:02 +02:00
co-authored by Claude Opus 5.5
parent e14bada114
commit 7fce972fdc
27 changed files with 1685 additions and 413 deletions
+5 -4
View File
@@ -22,10 +22,11 @@ Die App ist eine **Rails-8-Anwendung** mit dem Vue-Frontend unter
[`app/frontend/`](app/frontend/) (eingebunden über `vite_rails`). Ohne Konto
bleibt alles **im Browser** (IndexedDB). Mit Konto (Anmeldung per Magic Link,
kein Passwort) liegen Dokumente auf dem Server und lassen sich teilen – per
Link oder per Einladung, mit den Rollen „ansehen“ und „bearbeiten“. Solange
es keine Live-Zusammenarbeit gibt, bearbeitet immer nur ein Browser-Tab ein
Server-Dokument; alle anderen sehen es schreibgeschützt und folgen den
Änderungen. Details: [`docs/konzept-teilen-und-zusammenarbeit.md`](docs/konzept-teilen-und-zusammenarbeit.md).
Link oder per Einladung, mit den Rollen „ansehen“ und „bearbeiten“. Alle mit
Bearbeiten-Recht arbeiten **gleichzeitig** am selben Dokument: Änderungen
kommen über ActionCable sofort bei den anderen an (Yjs, siehe
[`app/frontend/collab/`](app/frontend/collab/)), jede Person hat ihr eigenes
Undo, und die Auswahl der anderen ist als farbiger Rahmen zu sehen. Details: [`docs/konzept-teilen-und-zusammenarbeit.md`](docs/konzept-teilen-und-zusammenarbeit.md).
Mails landen in der Entwicklung nicht im Postfach, sondern unter
<http://localhost:3000/letter_opener>. Produktion braucht `SMTP_ADDRESS`,