Local-first and P2P

Optimistic UI for Community Posting: the 4 Conflict Cases Nobody Handles

Stale auth, removed parent, rate limit, content rejection. The four cases optimistic UIs need to handle without losing the user's content.

In short

Optimistic UI is the practice of updating the UI before the server confirms. It's correct most of the time. The four cases it must handle gracefully: stale auth, removed parent thread, rate limit, content moderation rejection. Skip any of the four and you ship 'my reply disappeared' bug reports.

Local-first software is no longer a fringe architectural opinion. Linear, Figma, Replicache, Yjs and Automerge made it the default mental model for any client-heavy app where latency and ownership matter. Community software is the next workload to make the shift, and Optimistic UI for Community Posting sits exactly inside that shift. The essay that follows is for the engineers and platform leads who already know latency-first UX is correct and want the schema, the conflict-resolution rule, and the operational tooling to make it real.

The four cases

CaseWhat happensHow to handle
Stale authToken expired between optimistic post and API callRefresh token; retry; on hard fail, surface 'session expired, sign in again'
Removed parent threadMod deleted the thread the user was replying toSurface 'parent thread was removed'; offer to convert reply to standalone
Rate limitUser hit per-user cooldownSurface 'wait N seconds'; retry on countdown expiry
Content moderationServer rejected (banned word, policy)Surface specific reason; allow edit-and-retry
The user's content is sacred. An optimistic UI that loses content because the server rejected for a reason the UI didn't anticipate is a UI that destroys user trust.

Rollback UX

When the optimistic post fails permanently, the UI should: (1) keep the user's content visible, (2) mark it with a 'couldn't post' indicator, (3) offer 'retry' and 'discard' buttons, (4) preserve the content in a draft if the user navigates away.

What ships in Dium

Sync queue with five states (pending / in_flight / retry / failed / done). Idempotency keys on every write. Cross-tab coordination via BroadcastChannel. The user's content survives every conflict case we've encountered in production.

Why local-first matters for community workloads now

Three forces aligned in 2025-2026. Browser storage quotas finally became reliable enough to lean on. WebRTC interop reached the point where browser-to-browser transfers are a real product affordance, not a demo. Privacy regulation tightened to the point where "we never had your file on our server" became a procurement asset, not a footnote. Optimistic UI for Community Posting sits in the intersection. The platforms that ship the architecture now win the buyers who shop on data exhaust over the next two renewal cycles.

The engineering frame

Treat the user's device as the first source of truth for the user's own state. Drafts, read marks, local notes, the cached feed: all of it lives in IndexedDB and renders before any network round trip. The server becomes a peer that helps reconcile, not the primary store. This inversion sounds extreme until you build it; once shipped it makes everything else cheaper, including the privacy story, the offline story, and the operator-sovereignty narrative for self-host buyers.

Last-write-wins reconciliation with per-record version stamps handles 99.7% of community workloads at one-tenth the cost of CRDTs. Reach for CRDTs only when you have a specific co-edited record (shared agendas, co-authored Broadcasts) that demands them. Resist the temptation to ML-ify or distributed-systems-ify the architecture before the workload asks for it; the simpler model wins on debuggability and ships in months instead of quarters.

A pattern from the field

We see the same pattern across the operators we work with. The teams who treat Optimistic UI for Community Posting as an upstream design decision: encoded in the platform's defaults, surfaced in the operator dashboard, and audited as a standing line item in the quarterly review: see the downstream metrics move within 60-90 days. The teams who treat it as a setting to revisit later watch their dashboards flatline through three quarters before they reopen the question. The difference is rarely talent or budget; it is the willingness to make the decision once, document it, and let the rest of the platform compose around it. The cost of revisiting later is paid in the metric you would have moved if you had not been firefighting the symptom.

Failure modes we have shipped and recovered from

  • Treating IndexedDB as a trust boundary and storing JWTs there. XSS becomes a one-step compromise; it is not subtle.
  • Skipping schema versioning on day one and trying to retrofit migrations after the first production incident.
  • Letting the sync queue grow unbounded when the server is unreachable, then watching browsers OOM in the field.
  • Ignoring the storage quota until 80% triggers an eviction storm during peak event traffic.
  • Shipping a reconcile rule that is "mostly" deterministic and discovering the non-determinism only when two users argue about whose version of a draft is correct.
IndexedDB is the application cache. The user's drafts live there. The user's identity does not. Treat the cache as compromised by default, because if XSS happens, it is.

What to ship this sprint

Audit your slowest write path. Time it from button-press to UI-confirm. If it is over 500ms, you have the easiest and highest-impact local-first fix available. Invert the order: optimistic local update first, network round-trip second, sync queue handles the reconciliation. The same write that took 1.2 seconds will land under 100ms perceived. Members who used to hesitate before posting will post; the contribution rate will move within the same week. That single inversion is the gateway drug to the rest of the architecture.

The takeaway

Local-first is the architectural shift that converted Linear and Figma into the products their categories now compare themselves to. The community-software category has not made the shift yet, broadly. The platforms that make it next compete on a UX that pure-fetch competitors structurally cannot match, on a privacy story the regulatory environment is about to require, and on a sovereignty narrative that opens enterprise procurement. Optimistic UI for Community Posting is one of the load-bearing pieces. Ship it correctly once and the rest of the architecture follows.