Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sequence ID for sorting activities #4203

Merged
merged 37 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f3fe91d
Move to TypeScript
compulim Feb 10, 2022
339ad9e
Fix typings
compulim Feb 12, 2022
6dac15c
Add typings
compulim Feb 12, 2022
1b3340a
Use sequence ID for outgoing activities
compulim Feb 14, 2022
ad03539
Move away from clientTimestamp
compulim Mar 11, 2022
9430792
Fix typings
compulim Mar 13, 2022
13fcf2b
Add typings
compulim Mar 13, 2022
70302c7
Use import type
compulim Mar 13, 2022
410f2c4
Use import type
compulim Mar 13, 2022
7cb0511
Use import type
compulim Mar 13, 2022
ecff59a
Fix null reference error
compulim Mar 14, 2022
eea93de
Fix test
compulim Mar 14, 2022
cb809ef
Fix test
compulim Mar 14, 2022
7772bb0
Fix tests
compulim Mar 14, 2022
d10333d
Fix test
compulim Mar 14, 2022
33fec97
Add tests
compulim Mar 14, 2022
c203bc2
Add test
compulim Mar 14, 2022
42ef46f
Fix timestamp flash issue
compulim Mar 15, 2022
d487888
Clean up
compulim Mar 15, 2022
d904c6d
Remove clockskew related code
compulim Mar 15, 2022
d5ac27d
Cleanup
compulim Mar 15, 2022
459478c
Update comment
compulim Mar 15, 2022
ae886ba
Add comments
compulim Mar 15, 2022
764aed5
Fix test
compulim Mar 15, 2022
938cdc1
Cleanup
compulim Mar 15, 2022
5f1c8f6
Cleanup
compulim Mar 15, 2022
d013c11
Cleanup
compulim Mar 15, 2022
8aea886
Add doc
compulim Mar 15, 2022
b6dbdb3
Add entry
compulim Mar 15, 2022
7dd9b00
Rename DirectLineActivity to WebChatActivity
compulim Mar 15, 2022
268d9f4
Cleanup
compulim Mar 15, 2022
24069fa
Cleanup
compulim Mar 15, 2022
7034f36
Cleanup
compulim Mar 15, 2022
2c4b65c
Cleanup
compulim Mar 15, 2022
1839ebf
Use plugin-transform-typescript
compulim Mar 29, 2022
81881be
Merge branch 'main' into feat-sequence-id
compulim Mar 29, 2022
dc12441
Merge branch 'main' into feat-sequence-id
compulim Apr 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Breaking changes

- A new `type WebChatActivity` is introduced in the `botframework-webchat-core` package
- If you are previously using the `type DirectLineActivity`, you may need to move to this new type
- All Web Chat APIs will use the newer `type WebChatActivity`
- The new `type WebChatActivity` is a well-defined type for handling activities inside Web Chat
- The existing `type DirectLineActivity` will be used solely for communicating with `type DirectLineJSBotConnection`, a.k.a. `botframework-directlinejs` package

### Fixed

- Fixes [#4102](https://github.com/microsoft/BotFramework-WebChat/issues/4102). Fixed `cldr-data-downloader` package not working properly on Windows, by [@compulim](https://github.com/compulim) in PR [#4223](https://github.com/microsoft/BotFramework-WebChat/pull/4223)
- Fixes [#4232](https://github.com/microsoft/BotFramework-WebChat/issues/4232). Added `blob:` to allowed protocol list for file attachment UI (`<FileContent>`), by [@compulim](https://github.com/compulim) in PR [#4233](https://github.com/microsoft/BotFramework-WebChat/pull/4233)
- Fixes [#4204](https://github.com/microsoft/BotFramework-WebChat/issues/4204). Sort using `activity.channelData['webchat:sequence-id']` and fallback to epoch time of `activity.timestamp`, by [@compulim](https://github.com/compulim), in PR [#4203](https://github.com/microsoft/BotFramework-WebChat/pull/4203)

### Changed

Expand Down Expand Up @@ -108,8 +117,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Fixes [#4196](https://github.com/microsoft/BotFramework-WebChat/issues/4196). Should render/mount to a detached DOM node without errors, by [@compulim](https://github.com/compulim), in PR [#4197](https://github.com/microsoft/BotFramework-WebChat/issues/4197)

## [4.15.0] - 2022-03-03

### Breaking changes

- New [`Map` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) polyfill is required for IE11 when using NPM version of Web Chat:
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
162 changes: 0 additions & 162 deletions __tests__/clockSkew.js

This file was deleted.

10 changes: 6 additions & 4 deletions __tests__/html/activityGrouping.disableTimestamp.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@
type: 'message'
},
{
channelData: { clientActivityID: '2.1', clientTimestamp: -300001, state: 'sending' },
channelData: { clientActivityID: '2.1', state: 'sending', 'webchat:sequence-id': -300000.999 },
from: { role: 'user' },
localTimestamp: -300001,
text: 'Elit adipisicing laborum sit anim.',
type: 'message'
},
{
channelData: { clientActivityID: '2.2', clientTimestamp: -5001, state: 'sending' },
channelData: { clientActivityID: '2.2', state: 'sending', 'webchat:sequence-id': -300000.998 },
from: { role: 'user' },
localTimestamp: -5001,
text: 'Nostrud enim enim ipsum pariatur commodo.',
type: 'message'
},
Expand Down Expand Up @@ -91,7 +93,7 @@
await host.snapshot();

directLine.activityDeferredObservable.next({
channelData: { clientActivityID: '2.1', clientTimestamp: -300001, state: 'sent' },
channelData: { clientActivityID: '2.1', state: 'sent' },
from: { role: 'user' },
id: '2.1',
text: 'Elit adipisicing laborum sit anim.',
Expand All @@ -100,7 +102,7 @@
});

directLine.activityDeferredObservable.next({
channelData: { clientActivityID: '2.2', clientTimestamp: -5001, state: 'sent' },
channelData: { clientActivityID: '2.2', state: 'sent' },
from: { role: 'user' },
id: '2.2',
text: 'Nostrud enim enim ipsum pariatur commodo.',
Expand Down
13 changes: 6 additions & 7 deletions __tests__/html/activityGrouping.groupingActivityStatus.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@
role: 'bot'
},
id: '1.1',
text:
'Enim labore laboris Lorem qui exercitation adipisicing labore excepteur commodo reprehenderit velit.',
text: 'Enim labore laboris Lorem qui exercitation adipisicing labore excepteur commodo reprehenderit velit.',
timestamp: -120002,
type: 'message'
},
Expand All @@ -121,7 +120,6 @@
},
{
channelData: {
clientTimestamp: -6001,
// "send failed" is actually ignored and treated as "sending".
// As long as this field is not "sent", we will consider it is "sending" or "send failed".
state: 'send failed'
Expand All @@ -130,6 +128,7 @@
role: 'user'
},
id: '4.0',
localTimestamp: -6001,
text: 'A retry prompt must show on this activity.',
timestamp: -6001,
type: 'message'
Expand All @@ -154,20 +153,20 @@
role: 'user'
},
id: '5.1',
text:
'The timestamp is shown because the next activity is not sent. When it is sent, the timestamp will be hidden.',
text: 'The timestamp is shown because the next activity is not sent. When it is sent, the timestamp will be hidden.',
timestamp: -5001,
type: 'message'
},
{
channelData: {
clientTimestamp: -3001,
state: 'sending'
state: 'sending',
'webchat:sequence-id': -5000.999
},
from: {
role: 'user'
},
id: '6.0',
localTimestamp: -3001,
text: 'This activity is being sent.',
timestamp: -3001,
type: 'message'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,44 @@

await host.windowSize(undefined, 1280, document.getElementById('webchat'));

const activityStatusMiddleware = () => next => (...args) => {
const [
{
activity: {
from: { role }
},
sendState,
sameTimestampGroup
}
] = args;
const activityStatusMiddleware =
() =>
next =>
(...args) => {
const [
{
activity: {
from: { role }
},
sendState,
sameTimestampGroup
}
] = args;

if (sendState === 'sending') {
return (
<span className="activity-status">
<span className="activity-status__sending">Sending&hellip;</span>
</span>
);
} else if (sendState === 'send failed') {
// Custom retry logic can be added when rendering the "Send failed." status.
return (
<span className="activity-status">
<span className="activity-status__send-failed">Send failed.</span>
</span>
);
} else if (!sameTimestampGroup) {
return (
<span className="activity-status">
<span className="activity-status__timestamp-pretext">{role === 'user' ? 'User at ' : 'Bot at '}</span>
{next(...args)}
</span>
);
}
if (sendState === 'sending') {
return (
<span className="activity-status">
<span className="activity-status__sending">Sending&hellip;</span>
</span>
);
} else if (sendState === 'send failed') {
// Custom retry logic can be added when rendering the "Send failed." status.
return (
<span className="activity-status">
<span className="activity-status__send-failed">Send failed.</span>
</span>
);
} else if (!sameTimestampGroup) {
return (
<span className="activity-status">
<span className="activity-status__timestamp-pretext">{role === 'user' ? 'User at ' : 'Bot at '}</span>
{next(...args)}
</span>
);
}

return next(...args);
};
return next(...args);
};

WebChat.renderWebChat(
{
Expand All @@ -85,14 +88,16 @@
type: 'message'
},
{
channelData: { clientActivityID: '2.1', clientTimestamp: -20001, state: 'sending' },
channelData: { clientActivityID: '2.1', state: 'sending', 'webchat:sequence-id': -30000.999 },
from: { role: 'user' },
localTimestamp: -20001,
text: 'This message should have status "Send failed".',
type: 'message'
},
{
channelData: { clientActivityID: '2.2', clientTimestamp: 0, state: 'sending' },
channelData: { clientActivityID: '2.2', state: 'sending', 'webchat:sequence-id': -30000.998 },
from: { role: 'user' },
localTimestamp: 0,
text: 'This message should have status "Sending...", then turn to "Send failed".',
type: 'message'
}
Expand Down
3 changes: 2 additions & 1 deletion __tests__/html/avatar.emptyInitials.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@
type: 'message'
},
{
channelData: { clientTimestamp: -300001, state: 'sent' },
channelData: { state: 'sent' },
from: { role: 'user' },
id: '2.0',
localTimestamp: -300001,
text: 'Incididunt amet occaecat enim ullamco voluptate proident.',
timestamp: -300001,
type: 'message'
Expand Down
Loading