This is a deeper question than this question.
When a chat message is sent in a decentralized system, there are multiple events happening in a row. If a message is sent through a routing server, such as in Facebook Messenger or Slack or most other messaging systems, these things happen in this order:
- Message is generated (the user presses "send")
- Message is sent to a server.
- Message is forwarded by the server to the recipient.
- Message is seen by the recipient.
In addition, these things happen, interleaved with the above:
- Sender learns from the server that the server has received the message.
- Sender learns from the server that the recipient has recieved the message.
- Sender learns from the server that the recipient has seen the message.
There's a lot of uncertainty in the ordering of these events, and there might be minutes, hours or even days between them.
Messenger gives the user some feedback by showing
- a blue cicle when 1 has happened (but not 7)
- a blue circle with a blue check when 7 has happened
- a blue dot with a white check when 8 has happened
- the profile picture of the recipient when 9 has happened
In addition, the ordering of multiple messages on multiple devices is uncertain. We can use techniques like vector clocks to figure out a partial ordering, but a total ordering is impossible to come by. It gets even harder when users' clocks are set incorrectly, or when messages are sent but take a hours to reach a server, maybe because the user has lost cell tower coverage.
There are two parts to this question:
When do we timestamp messages?
- When they're generated on a local device, meaning the time might be very incorrect because the local clock is incorrectly set.
- When the message reaches the first server, which means that it could be off by hours or days from when the message was actually sent.
- When the message is received by each recipient, meaning that it could differ from device to device.
- Not at all, meaning there are no timestamps for messages, which makes it hard to see if a message was sent weeks ago or just now, but also that this problem becomes much easier.
Second, in what order should the messages be shown?
- In the order of the timestamps, however they are decided.
- In the order of the vector clocks, which guarantees that some things happened before other things. Vector clock ties would be resolved by timestamps.
Ordering messages by timestamps means messages can sneak into the chat history minutes or weeks later, if the timestamp is generated on the user's device or the message is stuck in some server somewhere. Ordering things by vector clocks means that the order messages are shown on screen might not agree with their timestamps.
I want your thoughts from a user experience point of view. There are other important views, such as security, performance and mathematical correctness, but I do not want feedback from those perspectives at this time.