-
Notifications
You must be signed in to change notification settings - Fork 32
Improve consistency in client-side login/logout experience #590
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
base: main
Are you sure you want to change the base?
Conversation
if (!value) { | ||
return null; | ||
} | ||
client.setSessionToken(value); | ||
try { | ||
user = await client.getAuthenticatedUser(); |
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.
Should we attempt to get the authenticated user when the token
is a blank string (like when this first opens)?
Can you provide a reproducible for this? I am not sure what's special about some windows that they do not respond to the change 🤔 |
@EhabY Sure, I'll write down what I did. Open two VS Code windows to the same workspace (different folders in the same workspace, whilst logged in):
and
Now you should have two windows that are both. Make sure VS Code is set to restore previous windows after quitting. Then:
Does this help? |
9b0ba3e
to
05160e8
Compare
Yes, thanks for the detailed reproducer! I can see the issue now: VS Code modals aren't dismissible without user action, which is by design (see microsoft/vscode#2732). I can adjust our flow so we don't close the window if the user signs in in the meantime (whether they click Do keep in mind that we cannot change the content of the modal once it's shown, so we either go for something less intrusive or just handle the fallback correctly. Using the status bar for messages which need to be updated / dismissed is suggested there as the recommended approach in the issue I mentioned. What do you think? |
05160e8
to
c7df45f
Compare
I like this idea. Updating the modal to clearly indicate that a login happens in another window, plus adding background login capability, would be a solid improvement. I think this is possible but I'll be careful to avoid any racey conditions. I think the following makes sense: Description:
Then it's a race between two conditions as you said, 1. Login event, 2. Modal interaction. In the case of a login event, if the user clicks anything ( |
53432cb
to
569a462
Compare
src/remote.ts
Outdated
// Try to detect any login event that might happen after we read the current configs | ||
this.createLoginDetectionPromise(); | ||
// Get the URL and token belonging to this host. | ||
const { url: baseUrlRaw, token } = await this.cliManager.readConfig( | ||
parts.label, | ||
); | ||
|
||
// It could be that the cli config was deleted. If so, ask for the url. | ||
if ( | ||
!baseUrlRaw || | ||
(!token && needToken(vscode.workspace.getConfiguration())) | ||
) { | ||
const result = await this.vscodeProposed.window.showInformationMessage( | ||
"You are not logged in...", | ||
const showLoginDialog = async (message: string) => { | ||
const dialogPromise = this.vscodeProposed.window.showInformationMessage( |
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 could move the createLoginDetectionPromise
into the showLoginDialog
but we have a window of opportunity between creating the promise and the user ALREADY logging in. Not sure if this could ever happen
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.
Moved there for now so we do not forget to set the promise before potentially resolving
67af845
to
4def400
Compare
Fixes #498