-
Notifications
You must be signed in to change notification settings - Fork 209
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
Handle network disconnection #107
Handle network disconnection #107
Conversation
@abeatrix Can I have a review, please? |
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 left some comments inline with some minor change request, the rest looks good to me!
Will defer to tim on the design :D
vscode/src/chat/ChatViewProvider.ts
Outdated
case 'settings': | ||
await this.authProvider.auth(message.serverEndpoint, message.accessToken, this.config.customHeaders) | ||
case 'settings': { | ||
const endpoint = message.serverEndpoint.length ? message.serverEndpoint : this.config.serverEndpoint |
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.
Can you tell me more about this change?
This is called when a user input the endpoint and access token manually, so it doesn't make sense to me to replace them with the ones from this.config if those are not available 👀
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.
Okay so when reload
button is clicked, we need to get the token and endpoint to initiate the Re-LOGIN
for the user. So, this change handles both reload
cases and when sign-in
is done manually. But I think it would be BEST to do it in a separate message protocol. LMK, what do you think?
vscode/src/chat/ChatViewProvider.ts
Outdated
@@ -386,8 +389,18 @@ export class ChatViewProvider implements vscode.WebviewViewProvider, vscode.Disp | |||
if (isAbortError(err)) { | |||
return | |||
} | |||
// check first if search error is due to any network issue | |||
if (isNetworkError(err)) { | |||
void this.sendErrorToWebview( |
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.
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.
It would be good to have both of them, as ENOTFOUND error as error assistant response shows up. So, this won't be much clear for the user as to why this is happening, so it would be better to include both. LMK, if you agree to this?
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.
Yea let's see what tim thinks but what what you suggested makes sense to me :)
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.
Sure, will wait for him to confirm.
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.
@toolmantim What about this?
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 outputting it into the chat as a bot response is enough, we don't need an additional error at the top also. We could restyle the error bot responses to be red or make it clearer, but that can happen in a follow-up.
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.
That sounds good to me. To mention, for now, there's an implementation of ErrAssistantResponse to show in the chat so after removing this webview error that would be displayed in case of an error.
return ( | ||
<> | ||
<div className={styles.error}> | ||
<p>{AUTH_ERRORS.NETWORK_ERROR}</p> |
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 like this! Maybe we can show the endpoint address to let the user know which instance is having network issue?
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.
That would be a good add on, I will update it.
<> | ||
<div className={styles.error}> | ||
<p>{AUTH_ERRORS.NETWORK_ERROR}</p> | ||
<VSCodeButton className={styles.button} type="button" onClick={handleReload}> |
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.
maybe update the button styles to have full width like the rest of the buttons in the login page? Will defer to @toolmantim who will be back next week from his PTO :)
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.
Yes, we can have that so it would be align to the style with all other buttons.
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'd love us to move away from the-full width buttons… but it's good to be consistent. But given it's an error state, I'm okay with just leaving this as a normal button w/ inherent width.
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.
Got it, thanks @toolmantim
@abeatrix Thanks for the review! Can network errors be handled when the Sign In is done using Cody App? I tried this but couldn't get a working solution. |
@toolmantim Can you please look at this and add your comments about the flow and the button CSS so I can make those changes? |
Left an in-line comment. Also adding @umpox as reviewer as he's working on refactoring the chat view that could be related 😃 |
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.
See inline comment.
Will defer to @umpox for final approval as this made changes in the refactoring work he is working on.
vscode/src/chat/ChatViewProvider.ts
Outdated
await this.authProvider.auth(message.serverEndpoint, message.accessToken, this.config.customHeaders) | ||
case 'settings': { | ||
const endpoint = message.serverEndpoint.length ? message.serverEndpoint : this.config.serverEndpoint | ||
const token = message.accessToken.length ? message.accessToken : this.config.accessToken |
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.
What if the user manually input a new endpoint but didn't provide an access toke? That means we will try to log the user in with the access token from this.config that is meant to use with the endpoint in this.config?
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, agree that would be the case here based on the implementation logic. It would be better to separate this in different messages as reload
, in which we check the config values and login
the user. WDYT, LMK?
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 separating this into reload
is a good idea 👍
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.
Left a couple of comments!
vscode/webviews/Error.tsx
Outdated
NETWORK_ERROR: | ||
'Due to network-related problems, Cody cannot be reached. Try again after checking it! Once your connection is restored, attempt a reload.', |
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.
NETWORK_ERROR: | |
'Due to network-related problems, Cody cannot be reached. Try again after checking it! Once your connection is restored, attempt a reload.', | |
NETWORK_ERROR: | |
'Connection failed due to a network problem. Please check your internet connection and try again.', |
Small copy change to make this a bit simpler
vscode/src/chat/ChatViewProvider.ts
Outdated
await this.authProvider.auth(message.serverEndpoint, message.accessToken, this.config.customHeaders) | ||
case 'settings': { | ||
const endpoint = message.serverEndpoint.length ? message.serverEndpoint : this.config.serverEndpoint | ||
const token = message.accessToken.length ? message.accessToken : this.config.accessToken |
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 separating this into reload
is a good idea 👍
can you resolve the merge conflicts before we check out the branch please? Thanks! |
@abeatrix Resolved the conflicts and updated the code as per the refactor of ChatView. |
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.
worked as expected! Thanks @deepak2431 !!
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.
🚀
This PR closes #43. It handles the network error for the DOTCOM instance. It handles the server disconnection due to network issues by adding an appropriate message. Also, add a reload button to return when the user is back in the network.
Test plan
All tests have passed.
REC-20230725162020.mp4