@@ -455,39 +455,13 @@ export class CredentialStore extends Disposable {
455455 }
456456
457457 /**
458- * Check if there are multiple GitHub accounts signed in to VS Code.
459- * This helps detect if the user might be using the wrong account for a repository.
458+ * Check if the user is authenticated and might benefit from checking account preferences.
459+ * Note: Due to VS Code API limitations, we cannot directly check if multiple accounts are available.
460+ * This method returns true if the user is authenticated, as they may have multiple accounts
461+ * configured in VS Code that they can switch to via the "Manage Account Preferences" command.
460462 */
461- public async hasMultipleAccounts ( authProviderId : AuthProvider ) : Promise < boolean > {
462- try {
463- // Try different scope combinations to find all possible sessions
464- const scopesToCheck = [ SCOPES_WITH_ADDITIONAL , SCOPES_OLD , SCOPES_OLDEST ] ;
465- const foundSessions = new Set < string > ( ) ;
466-
467- for ( const scopes of scopesToCheck ) {
468- try {
469- const session = await vscode . authentication . getSession ( authProviderId , scopes , { silent : true } ) ;
470- if ( session ) {
471- foundSessions . add ( session . account . id ) ;
472- }
473- } catch {
474- // Ignore errors for individual scope checks
475- }
476- }
477-
478- // If we found sessions with different account IDs, there are multiple accounts
479- // However, the current API limitations mean we can only detect one session at a time
480- // So we use a different approach: check if there are accounts available to switch to
481- // by checking the account property on the session
482-
483- // For now, we'll assume if the user is authenticated, there might be multiple accounts
484- // The VS Code API doesn't easily expose all accounts, but the manage preferences command
485- // will show the user if they have multiple accounts configured
486- return foundSessions . size > 0 ;
487- } catch ( e ) {
488- Logger . error ( `Error checking for multiple accounts: ${ e } ` , CredentialStore . ID ) ;
489- return false ;
490- }
463+ public async isAuthenticatedForAccountPreferences ( authProviderId : AuthProvider ) : Promise < boolean > {
464+ return this . isAuthenticated ( authProviderId ) ;
491465 }
492466
493467 /**
@@ -498,8 +472,13 @@ export class CredentialStore extends Disposable {
498472 * @returns true if the user chose to manage account preferences, false otherwise
499473 */
500474 public async showWrongAccountModal ( repoName : string , authProviderId : AuthProvider ) : Promise < boolean > {
501- const currentUser = await this . getCurrentUser ( authProviderId ) ;
502- const accountName = currentUser ?. login ?? vscode . l10n . t ( 'your current account' ) ;
475+ let accountName : string ;
476+ try {
477+ const currentUser = await this . getCurrentUser ( authProviderId ) ;
478+ accountName = currentUser ?. login ?? vscode . l10n . t ( 'your current account' ) ;
479+ } catch {
480+ accountName = vscode . l10n . t ( 'your current account' ) ;
481+ }
503482
504483 const manageAccountPreferences = vscode . l10n . t ( 'Manage Account Preferences' ) ;
505484 const result = await vscode . window . showErrorMessage (
0 commit comments