Do not create new chat session when an old chat session is deleted #669
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Previously deleting a chat session from the side panel on desktop, web app would sometimes result in also creating a new chat session
Fix
get_conversation_by_user
shouldn't return new conversation ifconversation with requested id not found.
It should only return new conversation if no specific conversation
is requested and no conversations found for user at all
Miscellaneous Improvements
not the "chat" api
Repro
Delete a new chat, this calls loadChat via window.onload which
calls server /chat/history API endpoint with conversationId set to
that of just deleted conversation sporadically
The call to GET chat/history API with conversationId set occurs
when window.onload triggers before the conversationId is deleted
by the delete button after the DELETE /chat/history API call (via race)
In such a scenario, get_conversation_by_user called by
chat/history API with conversationId of deleted conversation
returns a new conversation