Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
EhabY merged 10 commits intocoder:mainfromEhabY:fix-login-logout-in-multiple-windows
Oct 6, 2025

Conversation

EhabY
Copy link
Collaborator

Fixes#498

Comment on lines +292 to 314
if(!value){
returnnull;
}
client.setSessionToken(value);
try{
user=awaitclient.getAuthenticatedUser();
Copy link
CollaboratorAuthor

@EhabYEhabYSep 23, 2025
edited
Loading

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 thetoken is a blank string (like when this first opens)?

@mafredri
Copy link
Member

I tried out this PR and while I see a "you've been logged in" popup in multiple windows, the other windows are still stuck on this screen and there is no attempt to re-connect to the workspace:

image

I imagine this dialogue should be dismissed and a connection re-attempted? The user experience of selecting cancel is pretty bad (closes the workspace and gives you an empty window). I did not try what happens if I select "login".

@EhabY
Copy link
CollaboratorAuthor

I tried out this PR and while I see a "you've been logged in" popup in multiple windows, the other windows are still stuck on this screen and there is no attempt to re-connect to the workspace

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 🤔

@mafredri
Copy link
Member

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):

coder open vscode my-workspace.dev /home/coder/foo

and

coder open vscode my-workspace.dev /home/coder/bar

Now you should have two windows that are both. Make sure VS Code is set to restore previous windows after quitting.

Then:

  1. Quit VS Code
  2. Delete~/Library/Application Support/Code/.../session (it's in globalStorage, not at the machine right now so I can't give you full path)
  3. Open VS Code
  4. Both windows should show the ^aforementioned dialogue
  5. Perform log in on one of the windows
  6. Notice the dialogue does not disappear on the second

Does this help?

@EhabYEhabYforce-pushed thefix-login-logout-in-multiple-windows branch from9b0ba3e to05160e8CompareSeptember 25, 2025 09:09
@EhabY
Copy link
CollaboratorAuthor

EhabY commentedSep 25, 2025
edited
Loading

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 (seemicrosoft/vscode#2732). I can adjust our flow so we don't close the window if the user signs in in the meantime (whether they clickcancel,login orx). The logs in the other window show that the sign-in succeeded, so the real problem is our fallback when a login completes after the modal appears.

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?

@EhabYEhabYforce-pushed thefix-login-logout-in-multiple-windows branch from05160e8 toc7df45fCompareSeptember 25, 2025 13:01
@mafredri
Copy link
Member

Oh, that's unfortunate, but understandable (that the modals can't be dismissed).

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?

It's one option but I don't think it's a good one. It's fairly hidden for something that's required for your editor to start working.

I think updating the modal is the way forward. It could say something like "If you already performed login in another window, please use the cancel button."

image

This is what it looks like, after logging in from another window. See how it says "Opening remote" at the bottom, but nothing happens? I think it would be nice if we could make it successfully load the workspace in the background. Without looking at the actual code, perhaps we could do something along the lines ofawait Promise.race([loginmodal, loginevent]). If the workspace has loaded in the background, that's further confirmation for the user they can just hitcancel. Wdyt?

@EhabY
Copy link
CollaboratorAuthor

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:

You must log in to access ${workspaceName}. If you already performed login in another window, please close this popup.

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 (x,Cancel,Login) it will just dismiss the modal and show the already connected workspace. The flow for the modal interaction stays the same as before.

mafredri reacted with thumbs up emoji

@EhabYEhabYforce-pushed thefix-login-logout-in-multiple-windows branch 2 times, most recently from53432cb to569a462CompareSeptember 27, 2025 08:02
@EhabYEhabYforce-pushed thefix-login-logout-in-multiple-windows branch from67af845 to4def400CompareSeptember 29, 2025 12:57
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

Nice work@EhabY, the happy-path is now a pretty good user experience, thanks for implementing my proposal!

I noticed a situation where the login-into-other-windows functionality breaks.

  1. [Initial steps from previous repro]
  2. Select login in one (of two) windows
  3. Enter thewrong token (asdf), see a message like: "Failed to authenticate: You are ..."
  4. Enter thecorrect token -> Welcome in onlyone window
  5. In the other window, press login -> token prompt, press cancel -> close window, etc.

It's a bit strange to me that authentication is performed immediately after you've typed in your token, not when pressing [Enter]. (What if you're typing it manually.)

I'm also not sure why this breaks the login flow, perhaps a login attempt (even if failed) is considered a resolution of the promise.

@EhabY
Copy link
CollaboratorAuthor

EhabY commentedSep 30, 2025
edited
Loading

It's a bit strange to me that authentication is performed immediately after you've typed in your token, not when pressing [Enter]. (What if you're typing it manually.)

I think this is to provide feedback as soon as possible, VS Code allows this "validateInput" callback. If we want it on "Enter" only it might look a bit more awkward since we'd have to manually implement this validation.

I'm also not sure why this breaks the login flow, perhaps a login attempt (even if failed) is considered a resolution of the promise.

Hmmm, I tried the reproducer and it seems to work (no breakage), we should only show the "Welcome" message (and resolve the promise) if the token is correct anyway, otherwise it's like nothing has changed. Did you do something else in the meantime? 🤔

@EhabYEhabYforce-pushed thefix-login-logout-in-multiple-windows branch from4def400 to0ef2322CompareSeptember 30, 2025 12:53
@mafredri
Copy link
Member

I think this is to provide feedback as soon as possible, VS Code allows this "validateInput" callback. If we want it on "Enter" only it might look a bit more awkward since we'd have to manually implement this validation.

I kind of get it, but the current impl. is also kind of awkward when doing anything other than copy pasting. We can put that aside for now though, it's not relevant for this PR.

Hmmm, I tried the reproducer and it seems to work (no breakage), we should only show the "Welcome" message (and resolve the promise) if the token is correct anyway, otherwise it's like nothing has changed. Did you do something else in the meantime? 🤔

I can reproduce it quite reliably (even with your latest push). And it seems it's not even a requirement to enter the wrong token first. I'm not sure of the exact cause but I've managed to reproduce in various scenarios:

  1. Enter wrong token first, then correct
  2. Enter token fast (ready in clipboard)
  3. Enter token slowly (wait a longer time before paste)

@EhabY
Copy link
CollaboratorAuthor

EhabY commentedSep 30, 2025
edited
Loading

Hmmmm, to me this means it's one of two things: either we have a race where the 2nd window does not read the correctly entered configurations fast enough or that the session token has not changed (the latter is impossible if you deleted thesession file so we can rule it out).

Can I bother you one more time to test the latest push so we can rule out (1)? I sadly cannot reproduce so I'm not sure if this fixes it.

Also are you using Windows/Mac/Linux?

@mafredri
Copy link
Member

Thanks, I tested the new commit but there was no difference.

2nd window does not read the correctly entered configurations fast enough or that the session token has not changed (the latter is impossible if you deleted the session file so we can rule it out).

Glad you mentioned this because it seems to be exactly what's going on. I can reproduce the issue as long as I have the same token in my clipboard which I paste in, but if I grab a new token login works as expected. In either case the token is valid, it's just that in the bug scenario, the same token is used for all attempts.

Could it be that even when deleting thesession file, VS Code, or our extension, has some recollection of the old value and ignores the login in other windows because the value didn't change? It seems like the value shouldn't matter, jus that if there was an event, we can try to login.

@EhabY
Copy link
CollaboratorAuthor

Could it be that even when deleting thesession file, VS Code, or our extension, has some recollection of the old value and ignores the login in other windows because the value didn't change? It seems like the value shouldn't matter, just that if there was an event, we can try to login.

Oooh I think I might know where this goes wrong now, we store the session in two different ways, once as a file for the CLI to use (this is thesession that you deleted in your reproducer) and the other in the secrets (VS Code maintains that key-value pair internally). In this PR, we respond to session token secret change event since that is stored globally across different VS Code windows. In your case, the session token didn't change so there was no event, even though the CLIsession file was deleted (out of sync).

I don't want us to resort to file watchers but this should somehow be unified so there's one source of truth, I'll have a think and try to find an elegant solution 🤔

@EhabYEhabYforce-pushed thefix-login-logout-in-multiple-windows branch 2 times, most recently from70a6c4c tobbfb3d5CompareOctober 1, 2025 09:43
@EhabYEhabYforce-pushed thefix-login-logout-in-multiple-windows branch from2a1d50d to12c7c98CompareOctober 3, 2025 12:30
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

Awesome work@EhabY! In use, everything is behaving as I'd expect and the UX is so much better, thank you. I flagged a couple of things but mainly for your awareness, feel free to dismiss if they are non-issues.

EhabY reacted with rocket emoji
@EhabYEhabYforce-pushed thefix-login-logout-in-multiple-windows branch from223404c to820cb1cCompareOctober 6, 2025 10:11
@EhabYEhabY merged commit648360a intocoder:mainOct 6, 2025
2 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mafredrimafredrimafredri approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Improve consistency in client-side logout experience
2 participants
@EhabY@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp