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

Cody stops responding when token is deleted/expired #50973

Closed
mrnugget opened this issue Apr 21, 2023 · 6 comments
Closed

Cody stops responding when token is deleted/expired #50973

mrnugget opened this issue Apr 21, 2023 · 6 comments
Assignees
Labels
cody/vscode cody needs-design Design requests - add to 'design priorities' project, add a deadline, if possible..

Comments

@mrnugget
Copy link
Contributor

When Cody can't talk to the Sourcegraph backend we currently don't give any indication of that to the user.

To reproduce:

  • Setup Cody in VS Code
  • Start a conversation
  • Delete token on Sourcegraph instance
  • Send another message to Cody

What happens: cursor keeps blinking

What I want to see: error/notice that cody doesn't work anymore

(I think that @eseliger has looked into this a bit with rate limiting, but not sure)

@vdavid
Copy link
Contributor

vdavid commented Apr 21, 2023

I think we could still improve the experience by introducing a much shorter timeout for the first byte to arrive (then let the response take long if there's data coming)

@abeatrix
Copy link
Contributor

The changes I made in #50748 should also cover this if I understand correctly. When a user update their access token or url that are invalid they will be logged out automatically with error message.

@mrnugget
Copy link
Contributor Author

I think they might only cover the case when you start VS Code and the token is invalid. I just replicated the behaviour on main:

  • Start Cody, set access token, start talking to Cody
  • Delete access token on Sourcegraph instance

Cody then gets stuck in the blinking cursor:

screenshot_2023-04-21_14 47 25@2x

And in the background this message is logged:

Error retrieving embeddings: Error: accessing Sourcegraph GraphQL API: Error: HTTP status code: 401
    at /Users/thorstenball/work/sourcegraph/client/cody-shared/src/sourcegraph-api/graphql/client.ts:176:29
    at processTicksAndRejections (/Users/thorstenball/work/sourcegraph/lib/internal/process/task_queues.js:96:5)
    at CodebaseContext.getEmbeddingsContextMessages (/Users/thorstenball/work/sourcegraph/client/cody-shared/src/codebase-context/index.ts:53:41)
    at ChatQuestion.getContextMessages (/Users/thorstenball/work/sourcegraph/client/cody-shared/src/chat/recipes/chat-question.ts:37:45)
    at Interaction.hasContext (/Users/thorstenball/work/sourcegraph/client/cody-shared/src/chat/transcript/interaction.ts:43:33)
    at Transcript.getLastInteractionWithContextIndex (/Users/thorstenball/work/sourcegraph/client/cody-shared/src/chat/transcript/index.ts:48:32)
    at Transcript.toPrompt (/Users/thorstenball/work/sourcegraph/client/cody-shared/src/chat/transcript/index.ts:57:49)
    at ChatViewProvider.executeRecipe (/Users/thorstenball/work/sourcegraph/client/cody/src/chat/ChatViewProvider.ts:248:24)
    at ChatViewProvider.onHumanMessageSubmitted (/Users/thorstenball/work/sourcegraph/client/cody/src/chat/ChatViewProvider.ts:216:9)
    at ChatViewProvider.onDidReceiveMessage (/Users/thorstenball/work/sourcegraph/client/cody/src/chat/ChatViewProvider.ts:100:17) {vslsStack: Array(10), stack: 'Error: accessing Sourcegraph GraphQL API: Err…ent/cody/src/chat/ChatViewProvider.ts:100:17)', message: 'accessing Sourcegraph GraphQL API: Error: HTTP status code: 401'}

This we should surface to the user.

@danielmarquespt danielmarquespt added the needs-design Design requests - add to 'design priorities' project, add a deadline, if possible.. label Apr 21, 2023
@abeatrix
Copy link
Contributor

abeatrix commented Apr 21, 2023

@mrnugget I just built from main but can't reproduce it. it will log the user out right away when the access token is invalid. Can you try pulling the changes from the latest main and see if the issue persists?
auth
Edit: if it is still not working as i described for you i can look into it 🙇

@abeatrix
Copy link
Contributor

abeatrix commented Apr 21, 2023

Ohhhhh i missed the important part of your message about deleting the token on sourcegraph instance and not on VS Cody!!!! ignore my last message, I can get a pr for that!

Edit: PR #51005

@abeatrix abeatrix self-assigned this Apr 21, 2023
abeatrix added a commit that referenced this issue Apr 25, 2023
RE #50973
#50307

Current Issue: When the token become invalid during the chat session, it
does not log users out and not displaying any error message

Solution: Log the user out for invalid login credentials during the chat
session.

More detail in Loom:
https://www.loom.com/share/cfd51d7cd97e49989af77c8d2e103973

Updated: Display error message in frontend
https://www.loom.com/share/4a4ef8a298e241c9af220ad116a4d5be

Example:
<img width="1088" alt="image"
src="https://user-images.githubusercontent.com/68532117/234289394-e8d3fd57-3051-4f11-8d6c-36275dde02a4.png">

Shout out to @eseliger for his PR on sending error messages to chat
client!

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

All tests have passed and tested locally. See changes in the attached
loom video above
@abeatrix
Copy link
Contributor

Closing with #51005

image

VolhaBakanouskaya pushed a commit to VolhaBakanouskaya/sourcegraph-public that referenced this issue Jun 30, 2023
RE sourcegraph/sourcegraph#50973
sourcegraph/sourcegraph#50307

Current Issue: When the token become invalid during the chat session, it
does not log users out and not displaying any error message

Solution: Log the user out for invalid login credentials during the chat
session.

More detail in Loom:
https://www.loom.com/share/cfd51d7cd97e49989af77c8d2e103973

Updated: Display error message in frontend
https://www.loom.com/share/4a4ef8a298e241c9af220ad116a4d5be

Example:
<img width="1088" alt="image"
src="https://user-images.githubusercontent.com/68532117/234289394-e8d3fd57-3051-4f11-8d6c-36275dde02a4.png">

Shout out to @eseliger for his PR on sending error messages to chat
client!

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

All tests have passed and tested locally. See changes in the attached
loom video above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cody/vscode cody needs-design Design requests - add to 'design priorities' project, add a deadline, if possible..
Projects
None yet
Development

No branches or pull requests

4 participants