Presence tells others that a person may be viewing or editing a record. It is a short-lived signal, not a lock or proof that the person still holds an editor open. Give presence an expiry and treat disconnects as uncertain. Durable writes still need a server version, and concurrent edits need a conflict policy. Non-overlapping fields may be mergeable when the server validates each field against the same base version; two edits to the same field need a user decision or a domain-specific rule. A timestamp alone is a weak conflict resolver when clocks differ or an important edit would be silently overwritten.
Collaborative Conflicts and Presence Expiry
Working case
Reviewers 29 and 62 open case 47. Reviewer 29 changes status; reviewer 62 types a private note. Their presence indicators refresh every few seconds, but a laptop sleep leaves reviewer 29 looking active until the lease expires. Both submit from version 6. The server accepts the first write as version 7 and rejects or merges the second according to field ownership. The note is never discarded merely because status changed; the UI shows the current server value beside the local intent. Presence informs collaboration, while the versioned mutation governs the record.
Implementation boundary
function conflictFields(local, remote) {
return Object.keys(local).filter(field => remote[field] !== undefined && remote[field] !== local[field]);
}
console.log(conflictFields({ status: "resolved", note: "check seal" }, { status: "open" }).join(","));
// Output: statusThe helper detects differing values in two objects, but real three-way merge also needs the shared base to distinguish concurrent edits from preexisting differences. Store base, local, and current server versions for a repair view. Validate each merged write server-side; the client cannot approve its own conflict resolution. Presence updates should be rate-limited, scoped to authorized collaborators, and expire automatically without requiring a perfect disconnect event. Avoid showing private details in the presence channel. If the product needs exclusive editing, implement an explicit server lease with renewal and expiry, plus a visible takeover path; a colored avatar is not that lease.
Cost and boundaries
Presence heartbeats add O(u) events per interval for u active editors, and naive fan-out to every collaborator can approach O(u²) delivery in a busy room. Rate limits, coalescing, and room scope reduce that load. A three-way field comparison costs O(f) for f fields, while rich-text merging can be much harder and may need a specialized data model. Server leases add writes and renewal traffic and can block progress when devices sleep. Measure false-active duration, conflict frequency, repair completion, and time lost to blocked editing rather than assuming more presence messages mean better collaboration.
Failure trace
A presence avatar stays visible after a laptop loses connectivity, and the app treats it as an edit lock. Other reviewers cannot fix the case until an operator clears stale state. Give presence a short expiry and keep any real lease on the server. Another implementation applies last-write-wins by client timestamp; reviewer 62 has a clock three minutes ahead, so the note replaces reviewer 29’s later status without warning. Use server versions and a field-aware conflict view. If a merged result cannot be justified, preserve both intents and ask for a decision.
Verification
- Presence expires after a missing heartbeat and never acts as an implicit lock.
- Same-field edits preserve both local intent and current server value.
- Client clock skew cannot silently choose the winning edit.
Practice drill
Open case 47 in two sessions at version 6. Edit different fields and verify the chosen merge policy; then edit the same field and require explicit resolution. Sleep one client without a disconnect event and time the presence expiry. Change the device clock and confirm it cannot win a server version conflict by timestamp. Attempt presence subscription from an unauthorized account and inspect that no case details leak. If a server lease is added, let it expire and test a safe takeover without losing the original editor’s unsaved text.
Decision note
Let expiring presence inform people; let versioned server writes decide durable state.
Common Mistakes
- Treating a presence indicator as an exclusive edit lease.
- Using client timestamps to overwrite meaningful concurrent edits.
- Merging without a shared base version.
Connected lessons
Cross-Tab and Offline Data Coordination; Cross-Tab Invalidation and Version Checks; Offline Outbox, Idempotency, and Replay; Snapshot, Delta Cursor, and Gap Recovery; Conditional Writes and Lost-Update Prevention; Live Update Reconnect and Event Ordering; Async Status Announcements and Focus.
Apply and check
Build Project: multi-tab offline case review and review Web Development: operations and sync decisions quiz.
