Turns out some places in our code create document changes bypassing the daemon APIs.
It's alright for small changes like a few metadata attributes, but anything related with moves and block updates can become pretty messy.
Here are the places my agent found:
CLI block-diff: re-sends a whole level whenever its order changed.
auto-link.ts:143: re-moves every root block each time it links a child.
Apps/agents API (api-service.ts:18257): emits a move for every block at a level.
ApplyChange doesn’t dedup either, so stored changes really do contain no-op moves. The 1,962-repeat change noted in blob_change.go is one of these.
The CLI document update (cli/src/commands/document.ts:658–706), auto-link.ts:200–230 and the agents write tool (api-service.ts:16952) all do the same thing: read genesis and heads via ListChanges, build the ops themselves with createChangeOps, sign, then push with PublishBlobs.
Meanwhile /api/PrepareDocumentChange is on the same HTTP API they already talk to. It returns unsigned bytes, so the server never needs the key. The SDK even wraps it as client.publishDocument, and that’s what the web app uses.
@Untitled Contact @Untitled Contact why are we bypassing daemon API if we already use it for something else inside of the same code path anyway?
The agents tool is the worst: every write re-sends a ReplaceBlock for every block and a move for every level, with no diff against the current document.
Please let's fix it and make all those places use prepareDocumentChange Daemon API. It deduplicates redundant moves and block updates, and has the necessary CRDT metadata to do it. Let me know if there's any reason not to use it.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime