Skip to content

Fixing getTranscript loop on reconnection flow #57

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

Merged
merged 3 commits into from
Apr 11, 2025

Conversation

mliao95
Copy link
Contributor

@mliao95 mliao95 commented Apr 11, 2025

Issue Number:

Description:

What are the changes? Why are we making them?

This PR fixes an unexpected getTranscript loop regarding the re-connection flow. The issue stems from an unexpected behavior where calling getTranscript in the forward direction will always return the last item and a nextToken even if there are no more messages.

This PR fixes this issue by changing the conditional to add another check to see whether the last returned message is already within the internal transcript. If it is, we already know that we have fetched all available messages.


Functional backward compatibility:

Does this change introduce backwards incompatible changes? [YES/NO]

NO

Does this change introduce any new dependency? [YES/NO]

NO


Testing:

Is the code unit tested?

YES

Have you tested the changes with a sample UI (e.g. Android Mobile Chat Example)?

List manual testing steps:

  • Add Steps below:

Here are a list of manual test cases to run through:

  • Initiating chat and connecting with an agent
  • Retrieving transcript
  • Disconnecting from chat
  • Sending a message to the agent
    • See typing bubbles on agent side
    • See read/delivered receipt on client side
    • Receiving a message from the agent
    • See typing bubbles on client side
    • See read/delivered receipt on agent side
    • Sending an attachment to the agent (try .txt, .pdf, .jpg)
    • Preview the attachment on click
    • Receiving an attachment from the agent
    • Preview the attachment on click
  • Close the application (Without ending chat) → open app again → Start chat → Should Retrieve transcript from a previous chat session

@mliao95 mliao95 requested a review from a team as a code owner April 11, 2025 19:46
private suspend fun fetchTranscriptWith(startPosition: StartPosition?) {
getTranscript(startPosition = startPosition,
scanDirection = ScanDirection.FORWARD,
sortKey = SortKey.ASCENDING,
maxResults = 30,
maxResults = 100,
Copy link

Choose a reason for hiding this comment

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

what made us to increase the maxResults ? will not increase the response object size & latency ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will only return a larger object/latency if there are more messages, and if there are more messages, it would be better to have one API call vs. two smaller API calls.

Since this logic is to fetch messages that are missing during disconnection, we wouldn't want to retrieve only part of the missing messages.

spenlep-amzn
spenlep-amzn previously approved these changes Apr 11, 2025
spenlep-amzn
spenlep-amzn previously approved these changes Apr 11, 2025
haomingli2020
haomingli2020 previously approved these changes Apr 11, 2025
agarwhi
agarwhi previously approved these changes Apr 11, 2025
@mliao95 mliao95 dismissed stale reviews from agarwhi, haomingli2020, and spenlep-amzn via cde4e15 April 11, 2025 22:28
@spenlep-amzn spenlep-amzn removed the request for review from jagadeeshaby April 11, 2025 23:19
@mliao95 mliao95 merged commit 9c2b2c5 into main Apr 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants