Repository navigation
Update your devices and self-hosted hubs for the co-editing and merge fixes; running daemons switch over the first time the updated bdrive runs. Client wire and local volume on-disk formats remain backward-compatible, and v0.18.10 hubs read the bare-sha ydoc/head/<path> records older hubs wrote.
Upgrade every hub process that shares a storage root together. v0.18.10 hubs write ydoc/head/<path> as JSON ({sha, win}), which a v0.18.9 or earlier hub process cannot read. During a mixed-version rollout or a rollback, that older process skips the newest stored room state and falls back to the per-blob CRDT history (ydoc/<sha>) or, when none matches, to fresh file bytes. Multi-instance self-hosted operators should not run v0.18.9 and v0.18.10 side by side on one storage root.
Changes
- Co-editing rooms seed from the newest stored state across hub processes.
ydoc/head/<path>now stores{sha, win}, wherewinis thewinKeyof the journal op that produced the stored room state. A head write with an olderwinis refused, so an older fold in any process can no longer move the head backwards, and a room whose file no longer matches the head seeds from the file.knows()merges the other state into a scratch copy and checks whether anything changed, so stored histories that contain deletions compare correctly. Empty rooms stay loaded for 2 minutes (collabRoomIdleTimeout), and the Redis relay keeps 30 minutes of updates (StreamRetention, up from ygo's 60-second default); a failed snapshot republishes the room's full state into the relay. - Outside writes merge into live rooms without losing concurrent typing.
moveDocLivecomputes the change on a private copy of one atomic room snapshot and applies only the resulting CRDT item delta, so keystrokes that arrive during the merge stay in place instead of shifting by stale character offsets. POST /api/p/<id>/ycollab/syncmerges browser edits into a room over HTTP. A browser without a connected socket sends its Yjs state, or its text with the base it started from;peekreads the room without writing. The hub answersokonly after storage holds the edit, waiting up to 8 seconds (ycollabSyncDurableWait), including for the lease holder in another process (snapshotMaxlowered to 6 seconds); otherwise it returns503and the browser keeps its edits.bdrive desktopproxies the route to the hub.- Concurrent text edits merge per hunk and per word.
internal/textmergeand its browser portfrontend/src/lib/merge3.tsdiff each side with Myers O(ND), so edits in different parts of a file merge as separate hunks (diff3). Two edits to the same line merge word by word when they change different words, and insertions at the same point are ordered by content, somerge(base, a, b)equalsmerge(base, b, a). The merge runs inPUT /api/p/<id>/upload/contenton a staleIf-Match(text up to 4 MiB;X-Bdrive-No-Mergeopts out), MCPwriteandediton an outdated sha, live room reconciliation, andinternal/syncer. - Hub writes record their base, and devices skip redundant merges. Conditional hub writes record the version they were built on in
Op.Base. The sync engine merges a losing op against the op that won, and when the result equals the winner's content, it fast-forwards without writing a duplicate op. - Browser co-editing keeps edits through slow joins, saves, and most tab closes. When the room has not answered after 2.5 seconds, the editor mounts a staging buffer (
onStalled, andstageDocinVisualEdit), checkpoints it overycollab/sync, and merges it three ways when the socket connects instead of dropping permanently into solo mode after 8 seconds.save()and offline room flushes are single-flight with sequence watermarks.Mod-ssaves immediately, andDonesaves every edit, including any typed during the save, before leaving, and stays in the editor if the save fails or opens a shrink confirmation.pagehidesends pending edits withkeepalivewhen the encoded HTTP request body is at most 60,000 bytes (KEEPALIVE_MAX_BYTES, below the browser's 64 KiB in-flightkeepalivelimit); a larger body goes out as a regularfetch, which the browser may cancel during unload, and delivery is never guaranteed once the browser tears the page down.pageshowresets the exit-send guard, so a page restored from the back/forward cache can flush again on a later close.VisualEditsplices only changed spans within an element, and post-savedroom snapshots advancesavedandbasewithout raising#peer-wrote. VisualEditflushes unacknowledged iframe edits through a same-origin exit worker when the tab closes. The editing iframe stayssandbox="allow-scripts"and is never given a session, token or URL.VisualEditstarts a dedicated Web Worker on the app's origin (editexit.worker.ts), keeps it current with the rendered source, the anchored ranges and what the file and document hold after every save, and hands the iframe only one end of aMessageChannel(bd-edit:port). The iframe streams each edit to the worker as it happens (bd-edit:span) and keeps no record of its own; the app tells the worker directly which patches it applied (ack), so all span and acknowledgement state lives in the worker. When the iframe unloads it postsbd-edit:exit, and the worker saves whatever is still unacknowledged, marking sent spans acknowledged only after a confirmed200 OKresponse (reconciling and retrying acrossbfcacherestores on5xxor network errors) while advancing each span's acknowledged sequence (ackedSeq) monotonically so a late response never rolls the merge ancestor backward. This exit save is best-effort and runs only once the worker has started and been armed with the anchored render. The worker splices only anchored, script-free spans onto the render, merges the result three ways with the current document, and saves it with the app's own cookie:POST /api/p/<id>/ycollab/syncon a hub orbdrive desktop, orPUT upload/contenton the latestIf-Matchin a plain folder, so it also works after earlier auto-saves. A same-word clash parks a conflict copy, an unconfirmed sharp shrink is not sent, and delivery is still subject to the browser's teardown limits (keepaliveup to 60,000 bytes).- The
VisualEditiframe talks to the app only over a sealed channel, and the exit worker re-arms after a back/forward-cache restore. The editable view now injects/inline-edit.jssynchronously before any script in the synced HTML file, so it captures the browser's ownMessageChannel,MessagePortmethods andEvent.isTrusted, uncurries theWeakMap,MapandSetbuiltins it uses, and freezes the DOM, Event, Range, Selection and geometry prototypes before page code can replace them. It opens a privateMessageChanneland sendsbd-edit:hellowith one port to the app once; every later editor message (ready, patch, port, flush, unlock) uses that channel instead ofwindow.postMessage, and an editor opens or changes only on a trusted user event. Pasted formatting is kept only from the trusted clipboard'stext/html. When a page comes back from the back/forward cache,VisualEditsends the exit workerrearmwith a fresh port, so an unacknowledged edit made after the restore is still saved when the tab closes again. VisualEditedits only the ranges the hub stamped, and page scripts cannot write into an open editor. The bootstrap tag now also carriesdata-src-ranges, the stampedstart,endlist the hub measured.inline-edit.jsreads and removes itsdata-src-*attributes at load, locksdata-bd-srcagainst page-script writes, and binds each stamped element once, refusing a duplicate or unstamped range. A page script that changes the element being edited (its own key or input listener,execCommand, any DOM write) is refused, and the frame reportsbd-edit:clobberedinstead of saving. Before anchoring a range or arming the exit worker,VisualEditchecks that the element's initial HTML matches the source slice, comparing both as an inert<template>parses them.- The
VisualEditeditor runs inside a closed shadow root.inline-edit.jsmounts the editor on an element inside a closed shadow root (attachShadow({ mode: "closed" }), captured at load) attached to a<span data-bd-shadow>inside the element being edited, and writes the edited inner HTML back to that element when the editor closes. Page scripts in the synced file getnullfor itsshadowRootand see events retargeted to the host, so they cannot reach the editor's live nodes through reflected properties such as a link'shref, through references saved before the editor opened, or through another frame's DOM setters, including during a real paste. Removing the edited element or the shadow host reportsbd-edit:clobbered, and nothing is saved.
Known limitations
- Simultaneous edits to the exact same word outside a live CRDT room (offline, CLI, or MCP) still park a
.bdrive-conflict-*copy so neither rewrite is dropped. - A
pagehideflush, or aVisualEditexit-worker save, whose encoded HTTP request body exceeds 60,000 bytes is sent as a regularfetchwithoutkeepalive, and the browser may cancel it during unload. - Hub processes on v0.18.9 or earlier cannot read the new JSON
ydoc/head/<path>records and fall back to the per-blob CRDT history (ydoc/<sha>) or, when none matches, to fresh file bytes, so a mixed-version rollout or rollback across processes sharing one storage root can skip the newest stored room state. - Windows builds remain unsupported (pre-existing Unix
flock/ signal dependencies ininternal/storeandinternal/daemon).