-
Notifications
You must be signed in to change notification settings - Fork 290
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
Chat: preserve unsent chat messages when switching tabs #5847
base: main
Are you sure you want to change the base?
Conversation
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.
Found a few problems. I think all problems come from the nature of syncing state.
Instead I would try to avoid working with transcripts but instead add persisted state
(localstorage) in human message editor component. (Save typed text in local storage by chat and transcript ID and reset it on message submit)
Recorded a loom with problematic behavior
https://github.com/user-attachments/assets/b69a7650-7511-4992-a3c6-cf3d183ae449
) | ||
|
||
// Reset transcripts on new transcript change. | ||
useEffect(() => { |
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 think this is the most weak spot of this change, syncing state might be very fragile and unsafe.
I guess because of this we have UI flashes, I checked it manually and I was able to see some UI
delays (when you submit the message but don't see the loading UI below the input)
The main case with switching from the welcome chat screen to history and back to chat produces
a chat UI with no welcome UI
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 main case with switching from the welcome chat screen to history and back to chat produces
a chat UI with no welcome UI
It was the expected behavior to me because the user has already typed something in with the updated state, so transcript.length is no longer 0, which would not trigger the welcome message. I agree it's confusing though. will update it to change that.
@@ -76,9 +123,10 @@ export const CodyPanel: FunctionComponent< | |||
<TabContainer value={view} ref={tabContainerRef}> | |||
{view === View.Chat && ( | |||
<Chat | |||
transcript={activeTranscript ?? transcript} |
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 think the activeTranscript ?? transcript won't work when we want to preserve input text in the follow up message
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.
we are only saving the input text state but we don't want to use it until the user has switched to another tab.
This way we won't be re-rendering the transcript every time the state has changed, as we are still serving the same transcript up front if that makes sense?
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.
Yeah, but do we want to preserve text in the following scenario?
- you open a new chat
- you type something in the textbox but don't submit it
- you switch to the history tab or prompts tab
- you switch back to the chat UI
- your text has been preserved!
- now you submit the message
- and you type something in the follow-up
- you switch to another tab again
- you switch back
- Does the follow-up textbox have preserved text from step 7.?
CLOSE https://linear.app/sourcegraph/issue/CODY-3890/switching-tabs-with-an-unsent-chat-message-causes-the-unsent-message
Description: This PR addresses the issue where switching tabs with an unsent chat message causes the unsent message to be lost. The changes implement a mechanism to store and restore the state of unsent messages, ensuring a better user experience when navigating between different views in the Cody extension.
Cause of the issue: Previously, when users switched tabs (e.g., from Chat to History), the state of unsent messages in the chat input was not preserved. This resulted in users losing their draft messages when they returned to the Chat tab.
How these changes resolve the issue:
Test plan
Updated unit tests and story for Chat & Transcript.
Changelog
Chat: preserve unsent chat messages when switching tabs.