Skip to content

Conversation

@ishubham21
Copy link

@ishubham21 ishubham21 commented Jan 11, 2024

Issue Description

Currently, when a bot starts streaming messages, it does not reflect on the Channel UI. The reason for the same is that here we are using message?.updatedAt as our dependency. Now, for some reason, updatedAt is coming out to be 0, causing the dependency to have no impact. Have updated it to message to make sure it works fine. Though, the root of problem still lies in message.updatedAt coming out to be 0.

Replication

  • Run the local storybook server
  • In the Message component src/modules/Channel/components/Message/index.tsx, add a log to output the message prop.
  • Go to the integrated group channel storybook link
  • Use the application ID and your user id to enter into the application
  • Make sure one of the participants of the channel is an AI bot.
  • Give the bot some prompts
  • Observe the console for message logs. You'll find that for all the message that a bot streams, the message.updatedAt is coming out to be 0.

Screenshots

Screenshot 2024-01-11 at 7 10 08 PM

Object

{
    "_iid": "**********",
    "channelType": "group",
    "messageType": "user",
    "mentionType": "users",
    "mentionedUsers": [],
    "mentionedUserIds": [],
    "metaArrays": [],
    "extendedMessage": {},
    "createdAt": 1704978949209,
    "updatedAt": 0,
    "channelUrl": "sendbird_group_channel_******f46",
    "data": "{\"metadatas\": [], \"respond_mesg_id\": 6962747609, \"not_valid\": false, \"stream\": false}",
    "customType": "",
    "mentionedMessageTemplate": "",
    "parentMessage": null,
    "silent": false,
    "isOperatorMessage": false,
    "threadInfo": null,
    "reactions": [],
    "appleCriticalAlertOptions": null,
    "scheduledInfo": null,
    "suggestedReplies": null,
    "myFeedback": null,
    "myFeedbackStatus": "NO_FEEDBACK",
    "forms": null,
    "_isContinuousMessages": false,
    "_scheduledStatus": null,
    "messageId": 6962747867,
    "parentMessageId": 0,
    "ogMetaData": null,
    "reqId": "",
    "replyToChannel": false,
    "errorCode": 0,
    "sender": {
        *****
    },
    "sendingStatus": "succeeded",
    "message": "Hello! How can I assist you today?",
    "messageParams": null,
    "translations": {},
    "translationTargetLanguages": [],
    "messageSurvivalSeconds": -1,
    "plugins": [],
    "_poll": null
}

messageText: message?.message,
});
}, [message?.updatedAt]);
}, [message]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ishubham21 Thanks for your contribution and the detailed explanation. I see your point.

Suggested change
}, [message]);
}, [message?.message]);

I wonder ^ this would this fix your issue too. I think this value will be updated when the streaming message is coming.
The reason I'm asking is, putting the whole object in the dependency array is not an optimal way in terms of performance.

Copy link
Author

@ishubham21 ishubham21 Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AhyoungRyu
Definitely this will fix the issue we are facing. This PR was just an indicative solution - the root cause lies with updatedAt not being set properly.
If we proceed with this change, can we do this for scroll events as well? I believe they too have their dependencies set as updatedAt and thus might need an update as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if you're talking about this part, will make the change as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AhyoungRyu yes that’s the part. Thank you for pointing it out. Should I push the update, or sendbird team will do it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'll do that. Thanks for confirming it :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ishubham21 Since we're not accepting the code change from outside at the moment, I made a separate PR based on yours. #928
We're aiming to publish a new version this afternoon. We'll let you know once it's out.

Thanks again :)

AhyoungRyu added a commit that referenced this pull request Jan 19, 2024
> This change is originally made by @ishubham21 at
#916. Please refer
to this PR for more detailed background.

`message.updateAt` won't be updated if the message is coming from a bot
especially in streaming. Its value gets just `0`. I added one more field
`message.message` to the dependency array so we can make sure the hook
is being executed again.

Thanks @ishubham21
@AhyoungRyu AhyoungRyu closed this Jan 19, 2024
@bang9 bang9 added the Merged Indicating the merging of external contributors' pull requests label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged Indicating the merging of external contributors' pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants