Skip to content
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

fix: disappearing message for unauthed user #201

Merged
merged 3 commits into from
Jul 13, 2023
Merged

fix: disappearing message for unauthed user #201

merged 3 commits into from
Jul 13, 2023

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Jul 12, 2023

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

  • Issue 1: Error message would show up and then disappear
  • Issue 2: User will need to restart VS Code to be signed in with the updated token

After: https://www.loom.com/share/db5f54bed1534e3ca28d469f41f37cc3?sid=89c30426-d2e0-4e50-8c16-d7fb6bee0dbe

  • Fix for Issue 1:
    • When signed into Cody App: get an error message saying the instance is not running
    • When signed into non-App instances: User will be logged out for being unauthenticated
  • Fix for issue 2:
    • Resign in with an updated token will not require restarting VS Code to be picked up
  • Other fixes:
    • Previously, signing out of Cody App that is no longer running would still show you that Cody App is running. Now you will see the correct status in the Signin page when you are signed out.

Test Plan

  1. Launch Cody from this branch
  2. Sign into a SG instance
  3. Remove the token you signed in with from the SG instance
  4. Ask Cody something, you should now be signed out for being an unauthenticated user
    a. before: you would stay signed in
  5. Sign out manually using the sign out button, and then resign in with a new token
  6. Ask Cody something, you should now get back the correct response
    a. before: continue getting error message for being an unauthenticated user

@abeatrix abeatrix changed the title fix: disappearing message for unauthed user WIP fix: disappearing message for unauthed user Jul 12, 2023
@abeatrix abeatrix requested a review from a team July 13, 2023 02:49
@abeatrix abeatrix changed the title WIP fix: disappearing message for unauthed user fix: disappearing message for unauthed user Jul 13, 2023
Copy link
Member

@valerybugakov valerybugakov left a comment

Choose a reason for hiding this comment

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

Oh, nice! I bumped into this problem too.

@abeatrix
Copy link
Contributor Author

abeatrix commented Jul 13, 2023

Oh, nice! I bumped into this problem too.

@valerybugakov thanks for reviewing!
It looks like this might be caused by the changes (secretStorage API) in the latest VS Code Version (v1.18.0) as the behavior is different when I use the same version of Cody (v0.4.3) with the last version of VS Code (v1.79.2), which is the version we released Cody on:
v1.80.2 Loom: https://www.loom.com/share/32c1826dab754e8fbf3256d83f87d44e
v1.79.2 Loom: https://www.loom.com/share/dae6fa0fbc394a58b48acf7624795d65
This is just unfortunate 😢

@abeatrix abeatrix merged commit 74a02c4 into main Jul 13, 2023
4 checks passed
@abeatrix abeatrix deleted the bee/unauth-bug branch July 13, 2023 20:53
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.

Bug: Message disappears for signed in users with auth errors
2 participants