-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix: Refresh delay and improve performance by using patch strategy to update messages and interactions #84
Fix: Refresh delay and improve performance by using patch strategy to update messages and interactions #84
Conversation
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #84 +/- ##
==========================================
+ Coverage 89.15% 93.26% +4.10%
==========================================
Files 43 46 +3
Lines 1033 1218 +185
Branches 241 291 +50
==========================================
+ Hits 921 1136 +215
+ Misses 111 80 -31
- Partials 1 2 +1 ☔ View full report in Codecov by Sentry. |
* As in Olly, regenerate and send_message API will only response with the latest one interaction and messages to improve performance. | ||
* So we need to use patch to hanlde with the response. | ||
*/ | ||
case 'patch': |
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.
Seems the patch
action always follow receive
action. Shall we just merge patch
action to receive
action?
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.
the patch action always follow receive action
For now, yes because for send_message and regenerate action, we append dummy input message and when we do patch, we need to call receive
to remove the dummy message. But there are cases that we only call receive action without patch action.
Shall we just merge patch action to receive action
I'd say no because patch action can only do add/update, not able to "remove" a useless message/interaction. Only receive action can do that.
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.
You're right. I missed the case in loadChat
. The loadChat
will call receive action without patch.
My original thoughts was to refactor the receive action to accept patch messages and interactions like below code:
dispatch({
type: 'receive',
payload: {
messages: response.messages,
interactions: response.interactions,
patch: {messages, interactions}
},
});
We can add an optional patch parameter, and complete patch inside receive action.
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 am thinking if that's too much for a single action to do set
as well as patch
.
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Signed-off-by: SuZhou-Joe <[email protected]>
Description
[Describe what this change achieves]
Issues Resolved
[List any issues this PR will resolve]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.