Skip to content

Commit

Permalink
Add setContext notification for cody.serverEndpoint (#5918)
Browse files Browse the repository at this point in the history
## 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 sourcegraph/jetbrains#2382 is
needed.
It does not change anything on the Cody side.
  • Loading branch information
pkukielka authored Oct 17, 2024
1 parent 650b158 commit 5e87b71
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions vscode/src/services/AuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
clientCapabilities as getClientCapabilities,
isAbortError,
normalizeServerEndpointURL,
pluck,
resolvedConfig as resolvedConfig_,
setAuthStatusObservable as setAuthStatusObservable_,
startWith,
Expand Down Expand Up @@ -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)
}
})
)

Expand Down

0 comments on commit 5e87b71

Please sign in to comment.