-
Notifications
You must be signed in to change notification settings - Fork 283
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
Bot Change Detection #2044
Bot Change Detection #2044
Conversation
Pull Request Test Coverage Report for Build 125410
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Leaving the approval to those more familiar with Adaptive Dialogs and its requirements.
assert(results.status === DialogTurnStatus.complete, `results.status should be 'complete' not ${ results.status }`); | ||
assert(results.result === undefined, `results.result should be undefined, not ${ results.result }`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid having to add descriptive error messages, this could be simplified to
assert(results.status === DialogTurnStatus.complete, `results.status should be 'complete' not ${ results.status }`); | |
assert(results.result === undefined, `results.result should be undefined, not ${ results.result }`); | |
assert.strictEqual(results.status, DialogTurnStatus.complete); | |
assert.strictEqual(results.result, undefined); |
@@ -143,6 +143,8 @@ export class AdaptiveDialog<O extends object = {}> extends DialogContainer<O> { | |||
public async beginDialog(dc: DialogContext, options?: O): Promise<DialogTurnResult> { | |||
this.onPushScopedServices(dc.context); | |||
try { | |||
await this.checkForChanges(dc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await this.checkForChanges(dc); [](start = 8, length = 35)
Should checking for changes be built into the dialog context itself? It's the thing that is orchestrating switching between dialogs isn't it? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -11,5 +11,6 @@ export class DialogEvents { | |||
static readonly repromptDialog = "repromptDialog"; | |||
static readonly cancelDialog = "cancelDialog"; | |||
static readonly activityReceived = "activityReceived"; | |||
static readonly versionChanged = "dialogChanged"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dialogChanged [](start = 38, length = 13)
name doesn't match variable name? #Closed
// Simply return the id + number of steps to help detect when new steps have | ||
// been added to a given waterfall. | ||
return `${this.id}:${this.steps.length}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should be a method.
This requires that the langauge supports virtual properties. For example, WaterfallDialog derives from Dialog and so needs to "override" the base version because it's a property. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
*/ | ||
protected async checkForVersionChange(dc: DialogContext): Promise<void> { | ||
const current = dc.activeDialog.version; | ||
dc.activeDialog.version = this.dialogs.getVersion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.dialogs.getVersion(); [](start = 33, length = 27)
Instead of this call put this into virtual GetInternalVersion()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes microsoft/botframework-sdk#5495
Description
These changes add logic to automatically detect that a bots dialogs have changed since a persisted dialog stack was started. A hash code is stored with each persisted container dialog that is then checked on each subsequent execution.
When a change is detected a new 'dialogChanged' event is raised which the bot can optionally handle to deal with the change in some custom way. If that event isn't handled and error will be thrown which will trigger the bots standard error handling logic.
note:
WaterfallDialog
does not currently support change detection as there's no great way to do this. You can check for the number of steps to change but that's about it.Specific Changes
DialogSetchangeHash
property.ContainerDialog.checkForChanges()
method.ComponentDialog
to call new method.AdaptiveDialog
to call new method.Testing
Added unit tests to cover the new feature.