fix(lib): CRDT list append, remove, move, unique merge, markdown LoroText - #1311
Open
joepio wants to merge 4 commits into
Open
fix(lib): CRDT list append, remove, move, unique merge, markdown LoroText#1311joepio wants to merge 4 commits into
joepio wants to merge 4 commits into
Conversation
push() rewrote the whole Loro list (TS deleted every item and re-inserted; Rust minted a new container), so concurrent appends duplicated the shared prefix. Append with list.push instead. set() / replaceListItems still rewrite in place. Rust set_property reuses list identity so a full replace does not fork a second list. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
joepio
marked this pull request as ready for review
August 27, 2026 06:06
Membership remove was still set(filtered), JSON objects were LWW strings, and live LORO_SYNC only ran in the document editor. Resource.removeItems / remove_array_item delete matching Loro list elements by CRDT id. set_property and TS object writes reuse LoroMap identity. useArray exposes remove; share, tags, ontology, chat, and private-drive lists use push/remove. Canvas and AI chat live-sync the resource doc without TipTap cursors. Tracked in planning/loro-crdt-write-paths.md. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
Canvas erase deletes stroke containers by id instead of rewriting the list from a stale snapshot. Resource-array drag uses moveListItem. Unique arrays tag resourceArrayUnique and drop duplicates after import. Empty lists persist a dummy op so later appends share identity. Markdown and description write LoroText (prefix/suffix splice). AI stream tokens persist on first chunk and onFinish updates that resource instead of minting a second one. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
pushListItem wrote the new item into the cache first, so the first getLoroDoc() seeded the list from that cache and then appended again. Append first, matching push(). Also satisfy oxfmt/tsc on unique-dedupe keys and list-move no-op padding. Co-authored-by: joepmeindertsma <joepmeindertsma@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resource.push()used to rewrite the whole Loro list. This PR makes array membership, unique-set merge, markdown, canvas erase, and AI stream tokens use real CRDT ops.Write APIs
push()/Resource::push—list.appendon the existing containerremoveItems/remove_array_item— delete matching elements by CRDT positionmoveListItem—list.delete+list.insert(InputResourceArray drag)removeListItemsById— canvas erase bycid:…, not a stale-index rewriteresourceArrayUniqueand drop duplicate subjects after importdescriptionisLoroText(prefix/suffix splice)set()/replaceListItems()stay the explicit replace pathCall sites
onFinishupserts instead of minting a second messageLORO_SYNCof canvas, AI chat, and each message/part (useLoroDocSync/useLoroSyncForest)Tests
resource.test.ts: concurrent push/remove, unique dedupe, empty-list persist, markdown merge, move, delete-by-idloro.rs/resources.rs: same on the Rust sideFormat-level leftovers (not this PR): Loro
MovableListcontainer type, PropVals dual-write / Flutter undo (loro-source-of-truth.md). Human chatrooms stay parent-pointer + query.See
planning/loro-crdt-write-paths.md.