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: log user out on invalid session + display error in-chat #51005

Merged
merged 4 commits into from
Apr 25, 2023

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Apr 21, 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:
image

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

Test plan

All tests have passed and tested locally. See changes in the attached loom video above

@abeatrix abeatrix requested a review from sqs April 24, 2023 18:51
Copy link
Contributor

@mrnugget mrnugget left a comment

Choose a reason for hiding this comment

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

I like the new check!

client/cody/src/chat/ChatViewProvider.ts Outdated Show resolved Hide resolved
@abeatrix abeatrix changed the title cody: log user out on invalid login during session cody: log user out on invalid login dsession Apr 25, 2023
@abeatrix abeatrix changed the title cody: log user out on invalid login dsession cody: log user out on invalid login session Apr 25, 2023
@abeatrix abeatrix requested a review from eseliger April 25, 2023 13:22
@abeatrix abeatrix changed the title cody: log user out on invalid login session cody: log user out on invalid session + display error in-line Apr 25, 2023
@sg-e2e-regression-test-bob

Bundle size report 📦

Initial size Total size Async size Modules
0.00% (0.00 kb) 0.00% (+0.17 kb) 0.00% (+0.17 kb) 0.00% (0)

Look at the Statoscope report for a full comparison between the commits 9130ebd and 123ed1b or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@abeatrix abeatrix changed the title cody: log user out on invalid session + display error in-line cody: log user out on invalid session + display error in-chat Apr 25, 2023
Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

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

Added an inline comment about how to resume after an error. It doesn't block this PR but I was wondering about it as I looked at the code, maybe you have some thoughts there :)

Does this need extra logic for cody in the web?

void this.sendLogin(false)
this.clearAndRestartSession()
}
this.onCompletionEnd()
Copy link
Member

Choose a reason for hiding this comment

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

If an error occurs, that means that there will be an empty assistant message in the transcript. Do we want to simply continue with that, or restart before the failure?
Ex:

H: Hi
A: Hi!
H: What is X
A: <error>

Should the new transcript for another submission after the error be

H: Hi
A: Hi!
H: What is X
H: Oh an error, ok. What is X?
A: It is X!

or

H: Hi
A: Hi!
H: What is X
A: ''
H: Oh an error, ok. What is X?
A: It is X!

If it's the latter, I think we should attach the error to the message in the transcript so it's also persisted that we later know that the errored message produced an empty response and why (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i've replaced the empty assistant message with:

text: 'Failed to generate response due to server error.',

So the flow will be like:

H: Hi 
A: Hi! 
H: What is X 
A: Failed to generate response due to server error.
H: Oh an error, ok. What is X? 
A: It is X!

Does this address your concern? If not I can open a new PR for this, just lmk :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i've replaced the empty assistant message with:

text: 'Failed to generate response due to server error.',

So the flow will be like:

H: Hi 
A: Hi! 
H: What is X 
A: Failed to generate response due to server error.
H: Oh an error, ok. What is X? 
A: It is X!

Does this address your concern? If not I can open a new PR for this, just lmk :D

Copy link
Member

Choose a reason for hiding this comment

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

Does this send that failure message in the transcript to the LLM or is that hidden from there? Just curious, might confuse the LLM 😬

But otherwise that sounds great, thank you @abeatrix!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's included in speaker.text is sent to LLM and hidden from user, and what's included in speaker.displayText is displayed to user, but hidden from LLM (if i not mistaken 😆 )

Example:

// Stuff the prompt mixins at the start of the human text.
// Note we do not reflect them in displayText.
return { ...humanMessage, text: `${mixins}\n\nConversation starts here:\n\n${humanMessage.text}` }

I hope this makes sense 😄

@abeatrix abeatrix merged commit 59ea528 into main Apr 25, 2023
25 checks passed
@abeatrix abeatrix deleted the bee/cody-auth-fix branch April 25, 2023 20:38
abeatrix added a commit that referenced this pull request Apr 25, 2023
re-add `this.isMessageInProgress = false` that was removed by mistake in
my last PR:
#51005

## Test plan

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

Minor change. Same test cases, all passing.
VolhaBakanouskaya pushed a commit to VolhaBakanouskaya/sourcegraph-public that referenced this pull request Jun 30, 2023
re-add `this.isMessageInProgress = false` that was removed by mistake in
my last PR:
sourcegraph/sourcegraph#51005

## Test plan

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

Minor change. Same test cases, all passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants