skip to content

A team wiki editor merges an hour of offline train edits cleanly, but two people rewrote the same paragraph; what should the page show them, and how does it know?

level: seniorimportance: should knowfreq 38%

answer

  1. converged is not the same as right
  2. unsynced operations plus their base version
  3. overlap by block identity
  4. flag in place, never block
  5. comments whose anchor text vanished

basics

~20 s

Converged is not correct: the paragraph now holds both rewrites. After syncing, find blocks where your offline edits and others' concurrent edits overlap, mark them in place with who else edited, and offer both versions to compare, without blocking editing.

solid answer

~50 s

A converged merge can still be wrong: both deletes applied and both inserts survived, so the paragraph holds both rewrites. The client can detect it — it kept its unsynced operations and the base version they were made on, so on sync every remote operation it had not seen before its own edits is concurrent with them. Map both sets to block identities (paragraph, heading, list item, table cell); the overlap is the collision set. Merge first, then mark those blocks in place: name the other author, highlight the paragraph and offer to compare each author's version; keep comments whose anchor text vanished as detached in the side panel; merge non-overlapping changes silently with a short summary. Show the same marker to the colleague who stayed online. Never keep only the last-synced rewrite, never block with a modal per change, and don't lock paragraphs — a lock cannot reach a laptop with no connection.

code

json · 10 lines
json
{
  "blockId": "para-7f3a",
  "kind": "concurrentRewrite",
  "localBase": 18204,
  "mergedAt": 18391,
  "authors": ["me", "u-481"],
  "replacedShare": { "me": 0.92, "u-481": 0.85 },
  "versionsBeforeMerge": { "me": "v-local-1", "u-481": "v-18377" },
  "status": "unresolved"
}

go deeper

for a junior

Recall that an automatic merge can produce a page that is identical everywhere yet still not what either author meant.

for a middle

Explain how unsynced operations and their base version let the client find remote edits concurrent with its own, and why blocks are the unit to compare.

for a senior

Design the per-case UX — rewrite, edit versus delete, table cell, detached comment — keeping it non-modal and telling both authors.

for a principal

Set the threshold between flagging and silent merging, and choose whether collisions become comment threads, notifications or both, given how rarely they occur.

## What the merge actually did Two people open the same paragraph of a **team wiki page**. One is on a train for an hour; both rewrite the paragraph. On reconnect the merge converges — every replica ends up identical — but converged is not correct. Each person deleted the old sentences and typed new ones; both deletes apply and both inserts survive, so the paragraph now holds **both rewrites**, in an order neither author chose. Nothing failed, nobody was asked, and the result reads badly. Other collisions are quieter: - one person changed a heading's text while the other deleted the heading; - both set the same table cell, so one value is kept and the other is gone from view; - an inline comment's anchor text was deleted by the other person's rewrite. The offline write queue for records and its replay belong to the caching and offline question; this one is about the shared page. ## How the page knows The client already holds what it needs. While offline it keeps its **unsynced operations** and the **base version** they were made on. When it syncs, every incoming remote operation it had not seen before making its own edits is **concurrent** with them. Map both sets to **blocks** (paragraph, list item, heading, table cell) by each block's identity: 1. collect the blocks the unsynced local operations touched; 2. collect the blocks the concurrent remote operations touched, with their authors; 3. the intersection is the **collision set**; everything else merged without overlap. The server has seen every author's updates, so it can also attach the collision set to the sync response, sparing a slow laptop the work and guaranteeing both authors see the same set. The server can compute the same set for the other author, who may have been online the whole time and deserves to know too. Granularity matters: two people editing different sentences of one long paragraph may be fine, while two rewrites of a short paragraph almost never are, so a useful rule also weighs how much of the block each side replaced. ## What each case should show | Collision | What the page shows | |---|---| | same paragraph rewritten by both | highlight it, name the other author, offer "compare versions" | | heading edited by one, deleted by the other | a notice with the deleted heading's last text and "restore" | | same table cell set by both | the kept value, the other value and who set each | | comment anchor text deleted | the comment kept as detached in the side panel, quoting its text | | different blocks only | merged silently; "12 changes from others while you were offline" | "Compare versions" shows each author's version of the block as it was just before the merge — the returning client can rebuild its own from its base plus its operations, and the other side's comes from history. Either author resolves it by editing the paragraph; the resolution is an ordinary edit everyone sees. After sync, announce "Two paragraphs need your review" once through a polite status message and make every marker reachable by keyboard, so a screen-reader user learns of collisions too. ## Flag, don't block - **Merge first, ask afterwards.** Research prototypes of local-first editors found conflicts rarer than feared, partly because people avoid editing the same section at the same time; a modal per change punishes the common case. - Keep the markers **non-modal** and persistent until someone resolves or dismisses them, so closing the tab does not lose the warning. - Briefly highlight text others changed while you were away, so the returning user sees what moved. - Do not keep only the last-synced rewrite: that throws away an hour of someone's work without telling them. - Do not lock paragraphs: a lock cannot be granted to a laptop with no connection. ## Telling the other person The colleague who stayed online sees their paragraph suddenly doubled. Give them the same marker, and record the collision as a comment thread on the block mentioning both authors, so the conversation about which wording wins happens on the page, beside the inline comments that already live there. Once one of them edits the paragraph into a single version and resolves the thread, the markers clear for everyone.

  • Could the editor warn people before they start editing a paragraph someone else is in?
    Online, yes: a soft marker such as 'Ana is editing this paragraph' lets people coordinate themselves. It cannot replace detection after the fact, because the person on the train sees nobody else and the warning never reaches them.
  • Where should collision markers live, and for how long?
    With the page on the server, not only in one tab's memory, so both authors see them across reloads and devices. They stay until someone resolves or dismisses them; resolving is just editing the block into one version and closing the thread.

  • The merge converged, so there is nothing to tell the users.
  • Show a blocking dialog for every remote change after reconnecting.
  • Keep whichever rewrite synced last and discard the other.
  • Lock each paragraph while someone edits it so collisions cannot happen offline.
  • Save a conflicted copy of the whole page for the user to merge by hand.