systems · sub-star
nexus_editor
real-time collaborative editor with CRDTs over websockets, no locking.
readme
A collaborative text editor that resolves concurrent typing without locks or a server deciding who typed first. Every character gets a fractional position between its neighbours, so operations commute: replicas that have seen the same edits hold the same text, whatever order the edits arrived in. The Go relay just forwards operations it never parses.
artifact
doc:
simulated crdt merge: two clients insert at fractional indices; replicas converge.
signal log
- positions are digit strings, not floats: typing into the same gap halves a float every keystroke and collides after about 50, while a string just grows a digit.
- characters sort on (position, siteId), so concurrent inserts into one gap still get an order every replica agrees on.
- deletes are tombstones, so a delete that arrives before its insert still wins; both operations are idempotent, so replay after a reconnect is safe.
- a randomized three-replica test with reordered and duplicated delivery found a real bug: retyping into a gap reused a deleted character’s key, and every other replica dropped it.
- edits come from diffing the text box, so typing anywhere, backspace, cut and paste all work, and remote edits keep your cursor on its character.
- runs stay whole: a character typed right after your own previous one extends that character’s position, so two people typing into the same spot no longer converge on letters shuffled together. a test fails without it.
built with
TypeScriptReactGoWebSockets