From 5e87b7116c8a716e4a55174a4b7aa37275007b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kukie=C5=82ka?= Date: Thu, 17 Oct 2024 14:15:14 +0200 Subject: [PATCH] Add setContext notification for cody.serverEndpoint (#5918) ## Changes I've added `cody.serverEndpoint` context variable, which on the clients side is received through `window/didChangeContext` notification. We need it on the jetbrains side in few places, e.g. when we are checking if current account is a dotcom account. I think it might be better idea to replace this with a dedicated endpoint, but I'm not sure if `cody.activated` is currently used anywhere? @dominiccooney @sqs WDYT? ## Test plan Full QA with https://github.com/sourcegraph/jetbrains/pull/2382/ is needed. It does not change anything on the Cody side. --- vscode/src/services/AuthProvider.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/vscode/src/services/AuthProvider.ts b/vscode/src/services/AuthProvider.ts index 766f988f6e6..aa09019e8ac 100644 --- a/vscode/src/services/AuthProvider.ts +++ b/vscode/src/services/AuthProvider.ts @@ -16,7 +16,6 @@ import { clientCapabilities as getClientCapabilities, isAbortError, normalizeServerEndpointURL, - pluck, resolvedConfig as resolvedConfig_, setAuthStatusObservable as setAuthStatusObservable_, startWith, @@ -111,10 +110,21 @@ class AuthProvider implements vscode.Disposable { // Keep context updated with auth status. this.subscriptions.push( - authStatus.pipe(pluck('authenticated')).subscribe(authenticated => { + authStatus.subscribe(authStatus => { try { - vscode.commands.executeCommand('setContext', 'cody.activated', authenticated) - } catch {} + vscode.commands.executeCommand( + 'setContext', + 'cody.activated', + authStatus.authenticated + ) + vscode.commands.executeCommand( + 'setContext', + 'cody.serverEndpoint', + authStatus.endpoint + ) + } catch (error) { + logError('AuthProvider', 'Unexpected error while setting context', error) + } }) )