-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(core): improved timeout behavior #12470
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
EFF
left a comment
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 looks fine from 10000 meters above, I'm not so familiar with dialogue engine, I'd like to get @allardy's eye on it . Plus it might be useful for his current work
| // if there is no jump, so we don't want the timeout event to process the previous queue | ||
| // The reason to return the event is to persist any changes made to session state or context | ||
| // in the session timeout hook | ||
| fakeEvent.state.context = { ...session.context, queue: undefined } as IO.DialogContext |
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'm not so familiar with dialog engine, should queue be an empty array instead of undefined ?
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.
Should be undefined, an empty query will generate an error
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.
when the queue is undefined, the dialog engine will use the active flow/node to build the instruction queue
|
|
||
| this.fillContextForTransition(event, { currentFlow, currentNode, nextFlow: timeoutFlow, nextNode: timeoutNode }) | ||
|
|
||
| // Process the event with the new context, return to persist state changes |
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.
what if there is no timeoutNode/timeoutFlow ? we don't throw anymore >
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.
Yes, it will not throw an error since that, in my opinion, it can't be considered an error to not have a timeout flow/node; instead,
- if there is no jump (transition), return the event to have its state saved (If we modify the state in the timeout hook for example)
- if there was a jump in the timeout hook or timeout flow/node, process the event and save the state (including the context, which will make it possible to continue the conversation if desired).
The previous logic created an bug where changes made in the timeout hook to session state would not be saved unless we had a timeout node/flow
allardy
left a comment
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. I didn't test it out but the logic make sense
| // if there is no jump, so we don't want the timeout event to process the previous queue | ||
| // The reason to return the event is to persist any changes made to session state or context | ||
| // in the session timeout hook | ||
| fakeEvent.state.context = { ...session.context, queue: undefined } as IO.DialogContext |
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.
when the queue is undefined, the dialog engine will use the active flow/node to build the instruction queue
This PR fixes the conversation timeout behavior with the following items: