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

Clicking "Accounts" menu does not open the menu instantly #111398

Closed
bpasero opened this issue Nov 27, 2020 · 6 comments · Fixed by #176319
Closed

Clicking "Accounts" menu does not open the menu instantly #111398

bpasero opened this issue Nov 27, 2020 · 6 comments · Fixed by #176319
Assignees
Labels
authentication Issues with the Authentication platform bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders menus Menu items and widget issues verified Verification succeeded
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Nov 27, 2020

Update: reproduces in web + desktop

Steps to Reproduce:

  1. open a Codespace
  2. wait until it is loaded
  3. try various activity bar items that open menus (gear menu, accounts, main menu, home indicator)

=> 🐛 somehow the accounts menu only opens for me after a delay, as if something was resolved when clicking?

Kapture 2020-11-27 at 08 42 56

@bpasero bpasero added the web Issues related to running VSCode in the web label Nov 27, 2020
@bpasero bpasero added the menus Menu items and widget issues label Jan 29, 2021
@bpasero
Copy link
Member Author

bpasero commented Jan 29, 2021

This still reproduces @RMacfarlane @sbatten

@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Jan 29, 2021
@bpasero bpasero changed the title Accounts menu only opens after delay? Web: clicking "Accounts" menu does not open the menu instantly Jan 29, 2021
@TylerLeonhardt TylerLeonhardt added the authentication Issues with the Authentication platform label Jun 10, 2021
@sbatten
Copy link
Member

sbatten commented Oct 7, 2021

does this still repro? maybe its imperceptible to me?

@bpasero
Copy link
Member Author

bpasero commented Oct 9, 2021

Yeah still seems slightly delayed to me, can we not check the code and see if a longer running promise prevents the menu from showing?

@sbatten
Copy link
Member

sbatten commented Oct 11, 2021

looks like we fetch session info every time, so this probably adds some delay. @TylerLeonhardt maybe this can be cached and updated separately

protected override async resolveMainMenuActions(accountsMenu: IMenu, disposables: DisposableStore): Promise<IAction[]> {
await super.resolveMainMenuActions(accountsMenu, disposables);
const otherCommands = accountsMenu.getActions();
const providers = this.authenticationService.getProviderIds();
const allSessions = providers.map(async providerId => {
try {
const sessions = await this.authenticationService.getSessions(providerId);
const groupedSessions: { [label: string]: AuthenticationSession[]; } = {};
sessions.forEach(session => {
if (groupedSessions[session.account.label]) {
groupedSessions[session.account.label].push(session);
} else {
groupedSessions[session.account.label] = [session];
}
});
return { providerId, sessions: groupedSessions };
} catch {
return { providerId };
}
});
const result = await Promise.all(allSessions);
let menus: IAction[] = [];
const authenticationSession = this.environmentService.options?.credentialsProvider ? await getCurrentAuthenticationSessionInfo(this.environmentService, this.productService) : undefined;
result.forEach(sessionInfo => {
const providerDisplayName = this.authenticationService.getLabel(sessionInfo.providerId);
if (sessionInfo.sessions) {
Object.keys(sessionInfo.sessions).forEach(accountName => {
const manageExtensionsAction = disposables.add(new Action(`configureSessions${accountName}`, localize('manageTrustedExtensions', "Manage Trusted Extensions"), '', true, () => {
return this.authenticationService.manageTrustedExtensionsForAccount(sessionInfo.providerId, accountName);
}));
const signOutAction = disposables.add(new Action('signOut', localize('signOut', "Sign Out"), '', true, () => {
return this.authenticationService.removeAccountSessions(sessionInfo.providerId, accountName, sessionInfo.sessions[accountName]);
}));
const providerSubMenuActions = [manageExtensionsAction];
const hasEmbedderAccountSession = sessionInfo.sessions[accountName].some(session => session.id === (authenticationSession?.id));
if (!hasEmbedderAccountSession || authenticationSession?.canSignOut) {
providerSubMenuActions.push(signOutAction);
}
const providerSubMenu = disposables.add(new SubmenuAction('activitybar.submenu', `${accountName} (${providerDisplayName})`, providerSubMenuActions));
menus.push(providerSubMenu);
});
} else {
const providerUnavailableAction = disposables.add(new Action('providerUnavailable', localize('authProviderUnavailable', '{0} is currently unavailable', providerDisplayName)));
menus.push(providerUnavailableAction);
}
});
if (providers.length && !menus.length) {
const noAccountsAvailableAction = disposables.add(new Action('noAccountsAvailable', localize('noAccounts', "You are not signed in to any accounts"), undefined, false));
menus.push(noAccountsAvailableAction);
}
if (menus.length && otherCommands.length) {
menus.push(disposables.add(new Separator()));
}
otherCommands.forEach((group, i) => {
const actions = group[1];
menus = menus.concat(actions);
if (i !== otherCommands.length - 1) {
menus.push(disposables.add(new Separator()));
}
});
return menus;
}

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Oct 11, 2021

Yeah that seems like a reasonable ask since it goes to the extension host and back, today.

@bpasero bpasero changed the title Web: clicking "Accounts" menu does not open the menu instantly Clicking "Accounts" menu does not open the menu instantly Dec 6, 2022
@bpasero bpasero added important Issue identified as high-priority and removed web Issues related to running VSCode in the web labels Dec 6, 2022
@TylerLeonhardt TylerLeonhardt added this to the Backlog milestone Dec 6, 2022
@TylerLeonhardt TylerLeonhardt removed the important Issue identified as high-priority label Dec 6, 2022
@gjain-7
Copy link

gjain-7 commented Dec 16, 2022

This issue has existed since 2 years!
But only recently have I encountered this.

@TylerLeonhardt TylerLeonhardt modified the milestones: Backlog, March 2023 Mar 6, 2023
TylerLeonhardt added a commit that referenced this issue Mar 6, 2023
Before, we were calling out to the auth providers (thus going all the way to the extension host per provider)

Now, we cache the accounts and handle events for when accounts change.

This makes the account menu way snappier!

Fixes #111398
TylerLeonhardt added a commit that referenced this issue Mar 7, 2023
Before, we were calling out to the auth providers (thus going all the way to the extension host per provider)

Now, we cache the accounts and handle events for when accounts change.

This makes the account menu way snappier!

Fixes #111398
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Mar 7, 2023
@bpasero bpasero added the verified Verification succeeded label Mar 22, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
authentication Issues with the Authentication platform bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders menus Menu items and widget issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants