Skip to content

Fix wrong account selected - #8869

Merged
alexr00 merged 1 commit into
mainfrom
alexr00/classic-piranha
Jul 31, 2026
Merged

Fix wrong account selected#8869
alexr00 merged 1 commit into
mainfrom
alexr00/classic-piranha

Conversation

@alexr00

@alexr00 alexr00 commented Jul 31, 2026

Copy link
Copy Markdown
Member

Fixes #8789

Copilot AI review requested due to automatic review settings July 31, 2026 12:35
@alexr00
alexr00 enabled auto-merge (squash) July 31, 2026 12:35
@alexr00 alexr00 self-assigned this Jul 31, 2026
@alexr00
alexr00 merged commit 36b92f9 into main Jul 31, 2026
8 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses multi-account authentication selection issues (Issue #8789) by ensuring the extension prefers the workspace-selected account when resolving existing auth sessions, and by refreshing repositories/views when auth sessions change so the UI/data stays consistent with the active account.

Changes:

  • Add findExistingSession to prefer the workspace-selected account before considering broader-scope sessions (prevents “wrong account wins” when another account has broader scopes).
  • Refresh repositories, PR views, issues, and notifications on auth-session changes, and clear relevant user caches when updating repositories.
  • Add unit tests covering multi-account session resolution across legacy/default/additional scope sets.
Show a summary per file
File Description
src/test/github/credentials.test.ts Adds tests validating preferred-account session resolution and fallback behavior across scope sets.
src/notifications/notificationsProvider.ts Ensures the notifications auth provider is cleared when no provider is authenticated.
src/issues/stateManager.ts Adds an auth-change refresh path that clears cached issue data and refreshes (or fires change) based on auth state.
src/github/repositoriesManager.ts Replaces credential-cache clearing with refreshRepositories() to re-enumerate repositories and clear per-user caches.
src/github/folderRepositoryManager.ts Adds optional cache-clearing in repo updates and avoids using global-state user caches during forced refreshes.
src/github/credentials.ts Introduces findExistingSession and updates session-change handling to trigger consumer updates on account/session changes.
src/extension.ts Hooks auth-session change events to refresh repositories, PR state, tree, issues, and notifications.

Review details

Suppressed comments (1)

src/github/folderRepositoryManager.ts:767

  • When clearCache skips global-state and deletes _fetchAssignableUsersPromise, an in-flight promise started before the clear can still resolve later and overwrite _assignableUsers, write global-state caches, and fire _onDidChangeAssignableUsers with stale data. Add an identity check so only the currently-tracked promise writes results back after completion.
		const globalStateAssignableUsers = clearCache ? undefined : await this.getCachedFromGlobalState<IAccount>('assignableUsers');

		if (!this._fetchAssignableUsersPromise) {
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines 733 to 737
async getMentionableUsers(clearCache?: boolean): Promise<{ [key: string]: IAccount[] }> {
if (clearCache) {
delete this._mentionableUsers;
delete this._fetchMentionableUsersPromise;
}
@alexr00
alexr00 deleted the alexr00/classic-piranha branch July 31, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple accounts doesn't work for any but the first account added

4 participants