microsoft / microsoft/BotFramework-WebChat
Use activity.replyToId as a hint for sorting
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 1.6k
- Avg merge
- 22h 58m
- Merged PRs (30d)
- 2
Description
Feature Request
In addition of using activity.timestamp, we could also use activity.replyToId.
But also note that activity.id and activity.replyToId could be undefined/null.
Additional Context
This is not trivial to solve due to Direct Line protocol issue that is out of our control.
- Bot activities are in random order due to distributed nature of the system
- Although activity ID seems monotonic increasing, protocol team do not recommend us to use it for sorting, i.e. we can't use it
- Thus, there are only 2 fields we can use for sorting:
timestampandreplyToId
Currently, we are sorting based on timestamp. For incoming activities, we receive this timestamp field. For outgoing activities, we receive this timestamp field after the server successfully sent the activity. This also means, after the bot completely processed the activity.
As the system is distributed, outgoing activities may not receive "server-blessed" timestamp before the bot response. Thus, Web Chat need to use local clock for timestamp before receiving server-blessing.
We know there may be clock skew (especially when client set to wrong time zone).
Thus, in our previous PR, we attempted to measure/correct the clock skew between client and server. But it's not perfect since there could be milliseconds differences (bigger on mobile devices), user may see jitter of messages as recorded by @Slayouth.
Emulator works because the timestamp field is always local clock.
[Enhancement]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Web Chat code that currently sorts activities using activity.timestamp, then trace how incoming and outgoing activities are represented before server timestamps arrive. Define how activity.replyToId should influence ordering when activity.id or replyToId is null or undefined, and verify that the resulting behavior avoids the reported message jitter.
Written by the indexing model from the issue text.
Assessment
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100