Skip to content
Preptima
hardDesignScenarioMidSeniorStaff

Two people are typing in the same chat and one is on a train. What arrives, in what order, and what do you store?

Chat ordering with offline clients separates ephemeral typing indicators from durable messages. Messages need a server-assigned per-conversation sequence and a client-generated id for deduplication, so reconnecting phones replay outboxes without duplicates.

6 min readUpdated 2026-08-15

Answer

Short answer

For chat ordering with offline clients, never store typing indicators; treat them as expiring hints. Store messages with a server-assigned sequence per conversation for transcript order and a client-generated id for retry deduplication. A reconnecting phone replays its outbox, the server returns existing sequence numbers for duplicates, and clients sync from their last seen sequence.

Was this answer helpful?

Likely follow-ups

  • The two participants send messages in the same millisecond to different regional servers. What decides which sequence number each gets?
  • A user edits a message that a recipient has already read. What do you store, and what does the recipient see?
  • How would you show "delivered" without writing a row per message per recipient?
  • A client's outbox holds forty queued messages after a long flight. What order do you send them in, and what do you do if the tenth is rejected?

Related questions