fix: disappearing message for unauthed user #201
Merged
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.
Close #200
Issue 1: Messages are removed for signed-in users when encountering an authentication error
Cause: when a user has encountered an authentication error (signin info becomes invalid during chat session) previously, we would log the user out of their account and clear their chat history with
this.clearAndRestartSession()
before re-authing them to log them out (re-auth fails because of issue 2)Fix: Do not clear chat session on error and display the unauth error properly.
issue 2: secretStorage.onDidChange is not working
Cause: It looks like there is a bug where re-signing in with the correct auth info would not update the config that is being used by the external clients, unless users reload VS Code. I digged into it deeper and noticed the onDidChange function in SecretStorage is no longer getting invoked when new changes is made, which I am not sure if this is a VS Code bug due to the recent change to their SecretStorage API.
Update: I noticed only the completion client is using the initial config info that contains the outdated sign in info but UI and embedding client are not, this is why users are not signed out because only the completion client was affected. need to investigate what could be the cause here
Update 2: confirmed the SecretStorage API change in v1.80.0 broke the onChange event Emitter which we rely on for the authentication step.
Fix: As the secretStorage.onDidChange is no longer getting invoked on change at the latest VS Code version, I have updated to fire the onChange event manually during the authentication step (the step that updates the token in secret storage) which seems to work perfectly.
Video Demos
Before: https://app.usertesting.com/c/98ec92b6-be01-4d51-a524-5dc6896f6c31?note_id=clip-8299601&shared_via=link&share_id=mjGfrgb0zO
After: https://www.loom.com/share/db5f54bed1534e3ca28d469f41f37cc3?sid=89c30426-d2e0-4e50-8c16-d7fb6bee0dbe
Test Plan
a. before: you would stay signed in
a. before: continue getting error message for being an unauthenticated user