diff --git a/vscode/src/auth/auth.ts b/vscode/src/auth/auth.ts index ad9e94b48c2b..3ec8e22f099a 100644 --- a/vscode/src/auth/auth.ts +++ b/vscode/src/auth/auth.ts @@ -385,7 +385,7 @@ export async function signOut(endpoint: string): Promise { await Promise.all([secretStorage.deleteToken(endpoint), localStorage.deleteEndpoint(endpoint)]) - authProvider.signout() + authProvider.signout(endpoint) } /** diff --git a/vscode/src/chat/chat-view/ChatController.ts b/vscode/src/chat/chat-view/ChatController.ts index 38cc6699d239..584a82af39e3 100644 --- a/vscode/src/chat/chat-view/ChatController.ts +++ b/vscode/src/chat/chat-view/ChatController.ts @@ -477,6 +477,9 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv } else { await showSignOutMenu() } + // Send config to refresh the endpoint history list. + // TODO: Remove this when the config for webview is observable, see getConfigForWebview. + await this.sendConfig(currentAuthStatus()) break } if (message.authKind === 'switch') { diff --git a/vscode/src/services/AuthProvider.ts b/vscode/src/services/AuthProvider.ts index c93928556911..e2f9aedb9072 100644 --- a/vscode/src/services/AuthProvider.ts +++ b/vscode/src/services/AuthProvider.ts @@ -45,6 +45,7 @@ class AuthProvider implements vscode.Disposable { */ private lastValidatedAndStoredCredentials = new Subject() + private lastEndpoint: string | undefined private hasAuthed = false @@ -113,6 +114,7 @@ class AuthProvider implements vscode.Disposable { this.subscriptions.push( authStatus.subscribe(authStatus => { try { + this.lastEndpoint = authStatus.endpoint vscode.commands.executeCommand( 'setContext', 'cody.activated', @@ -167,7 +169,10 @@ class AuthProvider implements vscode.Disposable { this.refreshRequests.next() } - public signout(): void { + public signout(endpoint: string): void { + if (this.lastEndpoint !== endpoint) { + return + } this.lastValidatedAndStoredCredentials.next(null) this.status.next({ authenticated: false, diff --git a/vscode/webviews/components/AccountSwitcher.tsx b/vscode/webviews/components/AccountSwitcher.tsx index 0a2ebb713984..86f4a0d7cf15 100644 --- a/vscode/webviews/components/AccountSwitcher.tsx +++ b/vscode/webviews/components/AccountSwitcher.tsx @@ -28,7 +28,7 @@ export const AccountSwitcher: React.FC = ({ setLoading, }) => { type PopoverView = 'switch' | 'remove' | 'add' - const [getPopoverView, serPopoverView] = useState('switch') + const [getPopoverView, setPopoverView] = useState('switch') const [isOpen, setIsOpen] = useState(false) const [endpointToRemove, setEndpointToRemove] = useState(null) @@ -47,7 +47,7 @@ export const AccountSwitcher: React.FC = ({ setIsOpen(open) if (!open) { setEndpointToRemove(null) - serPopoverView('switch') + setPopoverView('switch') setAddFormData(() => ({ endpoint: 'https://', accessToken: '', @@ -79,7 +79,7 @@ export const AccountSwitcher: React.FC = ({ variant="ghost" onClick={() => { setEndpointToRemove(endpoint) - serPopoverView('remove') + setPopoverView('remove') }} > @@ -102,7 +102,7 @@ export const AccountSwitcher: React.FC = ({ key={'add-account'} variant="ghost" onClick={() => { - serPopoverView('add') + setPopoverView('add') }} >