Repository navigation
Conversation
- Added support for merging external writes (from agents or REST) into live collaborative rooms. - Introduced `mergeExternalChange` function to handle block-level three-way merges. - Created tests for various scenarios of external writes, including conflict resolution and block insertion. - Updated `CollabHub` to process `doc.updated` and `task.updated` events, applying changes to the Y.Doc. - Enhanced the subscriber to route content change events to the collaboration logic. - Added utility functions for parsing content changes from event payloads.
There was a problem hiding this comment.
Important
The block-level merge approach is sound, but two correctness edges can silently drop a block (an editor's keystroke, or an agent's inserted block) and the external path skips the room's size budget. Details inline.
Reviewed changes
Full read of the diff at 9eac4f4, cross-checked against the API's activity payloads (services/api/internal/service/activity/service.go), the web BlockNote schema and the client save path.
- Block merge (
collab-blocks.ts, new) — three-way merge of the event's old/new BlockNote JSON into the liveY.Doc: id recovery by content alignment, inserts after the previous sibling, guarded replace/delete, conflicts keeping the room's copy, all in one transaction. Server-side stub specs mirror the web schema. - Hub integration (
collab.ts) —parseContentChangereadsdoc.updated.content/task.updated.descriptionout of the activity payload;handleContentEvent/applyExternalskip when no room exists, when the room is unseeded, or when the actor is a room member, then broadcast the diff to every editor. - Subscriber — optional
onContentChangeinvoked fromrouteEventfor the two topics, wired to the hub inindex.ts. - Dependency and docs —
@blocknote/[email protected]added toservices/realtime; README replaces the "REST writes are not merged" note with the new behaviour and its limits. - Tests — merge scenarios (live edit preserved, conflict, editor echo, inserts, guarded deletes, id-less/invented ids, nesting, empty-doc fill), hub broadcast/actor/no-room cases, and the subscriber routing hook.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
|
Line-level findings (the details referenced in the review above; inline anchoring failed on submit, so they are collected here)
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the delta since the prior pullfrog review at 9eac4f4 (commit be9469f), which resolves all three earlier findings.
- Id recovery tightened —
resolveIdsnow pairs a gap of leftover blocks positionally only when both sides have equally many left, so an inserted block can no longer inherit an edited neighbour's id. A regression test covers[A, B] -> [X, A', B]with a live edit onA. - External merges serialized and ordered after pending edits —
handleContentEventchains merges per room viaexternalChains, andapplyExternalnow awaits editor updates still waiting on their access check before reading the room, so in-flight keystrokes land first. A test holds an update on the access gate and asserts the merge sees it. - Byte budget applied to external writes —
applyExternalchecksMAX_ROOM_BYTESagainst the new content before merging and counts the emitted update bytes afterwards, with a test that spends the budget first. - Docs updated — the realtime README now describes the pending-update wait and the shared byte budget.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — minor docs and test suggestions inline.
Reviewed changes
This run reviewed the delta since the prior pullfrog review at be9469f (commit fc4994a).
- Similarity pairing for id-less gaps —
alignnow pairs a leftover gap with unequal counts usingpairBySimilarity(shared text prefix/suffix,SIMILAR = 0.5) instead of leaving it unpaired, so an id-less save can change a block while the room carries BlockNote's trailing empty block; equal-count gaps keep positional pairing. - Unit coverage — two new cases cover a live edit with id-less stored content and a live edit next to the trailing empty paragraph.
- E2E coverage — new feature scenarios and a spec cover an agent's REST write reaching both editors, a live edit surviving the write, an id-less insert, and a task description.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the delta since the prior pullfrog review at fc4994a (commit 440b03b), which addresses the three earlier minor suggestions.
- README merge rules corrected — the id-recovery bullet now describes equal-count positional pairing and similarity pairing for unequal gaps, matching
align/pairBySimilarity. - Live-edit coverage for the id-less insert scenario — the feature scenario and spec now type
LIVE-into the first paragraph with saves held, then assert the member's text survives the agent's insert. - Deterministic stored-doc assertion — the agent-write spec now makes a local edit after releasing the held save so the merged document is persisted, instead of assuming the debounce beats the merge.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes
This run reviewed the delta since the prior pullfrog review at 440b03b (commit cbf9bf5), which hardens the external-write merge against duplicate inserts and unbounded alignment work.
- Added seed-race dedupe —
mergeExternalChangereturns early when the room's shape already matches the write, andinsertBlockskips an added block when a same-shaped sibling exists thatoldandnewdo not know. - Capped alignment work per merge —
MAX_ALIGN_CELLSis now a shared budget across bothresolveIdspasses and every recursion level, and the LCS and similarity tables use typed arrays. - Stopped hoisting inserts whose parent was deleted live — such a block is dropped and counted as a conflict instead of landing at the document root.
- Required four characters before two blocks pair by similarity —
MIN_SIMILAR_LENkeeps very short blocks from being taken for edits of each other. - Split merge notices from errors — conflicts and skips now go through a new
onNotice(info) callback wired inserver.ts; unexpected errors keeponError. - Extended unit coverage — seed-race dedupe, repeated and short-block cases, plus a schema-name parity check against the web editor schema.
ℹ️ Schema drift guard never runs in CI
collab-blocks.test.ts now reads apps/web/src/components/shared/blocknote-schema.tsx to catch stub-schema drift, but realtime-pr-ci.yml only runs Biome, tsc and the Docker build, and its path filter covers services/realtime/** alone. A web schema change therefore cannot fail the realtime workflow, so the guard only fires when someone runs bun test locally.
Technical details
# Schema drift guard not gated by CI
## Affected sites
- `.github/workflows/realtime-pr-ci.yml:49-56` — no `bun test` step.
- `.github/workflows/realtime-pr-ci.yml:5-7` — path filter excludes the web schema.
- `services/realtime/src/collab-blocks.test.ts:280-298` — the parity assertion.
## Required outcome
- A drift between the stub specs and the web schema fails a required check (add a test step and include the web schema file in the path filter).deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes
This run reviewed the delta since the prior pullfrog review at cbf9bf5 (commit 8e3ee3c), which closes the two inline findings and the CI-gating gap.
- Position-aware dedupe — a candidate room block must sit immediately after the previous sibling's room copy and is consumed at most once, so identical additions are no longer collapsed onto one live sibling; skipped additions are counted as
duplicatesand surfaced throughonNotice, and their children are no longer descended into. - New merge tests — the short-block case now uses an unequal gap with a live edit so it exercises
MIN_SIMILAR_LEN, plus cases for a blank-paragraph insert, repeated identical additions, and the seeded collapse. - Test gate in CI —
realtime-pr-ci.ymlnow runsbun testand triggers on the web editor schema, so stub-schema drift fails a check.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the delta since the prior pullfrog review at 8e3ee3c (commit 5bfcd4d), which closes the one open thread from that review.
- Insert anchor resolves deduped siblings — in
insertBlock, the scan for a previous surviving sibling now maps eachsiblings[k].idthroughaliasbefore looking it up in the room's group, so an addition that follows a deduplicated addition is inserted after the room's copy of it instead of before it. - Regression test — a new merge case (
old [alpha],new [alpha, TODO, NEW], room[alpha, TODO, tail]) asserts one duplicate, no conflicts, and the write's orderalpha, TODO, NEW, tail.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Problem
When an agent (or MCP / a script) saves a doc or task description over REST while people are editing it, the live Yjs room never sees that write, and the editors' next save overwrites it. Neither side is told, and the agent's change is lost.
Change
services/realtimenow folds such writes into the live room.doc.updated/task.updatedwith the changed field's old and new BlockNote JSON, so no API change is needed.subscriber.tshands those events toCollabHub.handleContentEvent.collab-blocks.ts(new) does a block-level three-way merge: base = old content, theirs = new content, ours = the liveY.Doc.type), so missing or invented ids are recovered by aligning siblings on content.CollabHub.applyExternalapplies the merge in one transaction and broadcasts the diff to every editor. It is a no-op when the room is not open or not seeded yet.@blocknote/coreto the realtime service, with server-side stub specs for the custom blocks and inline contents. These must stay in sync withapps/web/src/components/shared/blocknote-schema.tsx.Known limits
Testing
bun testinservices/realtime(79 pass),tsc --noEmit,biome check.