Make the plan collaborative and durable
Each room now owns a Y.Doc with a headless Lexical mirror bound to it, which is what lets the server validate an update rather than relay bytes it cannot read. Updates are grouped for five milliseconds, applied together, acknowledged to their sender and relayed to everyone else. The document is attached on the first open, so a room nobody has looked at costs a map entry. Yjs cannot undo a transaction, so a batch that leaves the document invalid cannot be rolled back. The document is rebuilt from its last known-good state under a fresh epoch and everyone re-opens; senders of a rejected batch are charged a strike and disconnected on the third within ten minutes. Persistence is canonical MDX plus a small JSON sidecar, debounced on an idle gap with a ceiling so continuous typing cannot postpone it forever. Yjs history is deliberately not kept: it would buy undo across a restart at the price of a binary checkpoint that could disagree with the source. A restart therefore resumes the content under a new epoch. Because that file is one a person can edit between runs, it is validated on the way back in. Lexical routes anything thrown inside an update to onError, which logs — so seeding carries its failure out by hand, or a corrupt snapshot would open as a silently empty plan. Empty rooms are evicted after a grace period rather than immediately, since a reload is a departure followed by an arrival, and nothing is written to disk until a plan has content.
Parente628de3
13 files changed+1729-17
StackedSplit