Skip to content

Commit

Permalink
[Backport vscode-v1.64.x] disable omnibox on dotcom (#6762)
Browse files Browse the repository at this point in the history
disable omnibox on dotcom

## Test plan

- connect to s2 and omnibox should work as intended. 
- connect to dotcom all the omnibox features should be hidden.

(cherry picked from commit 99faa39)

<!-- Required. See
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles.
-->

Co-authored-by: Naman Kumar <naman@outlook.in>
  • Loading branch information
umpox and thenamankumar committed Jan 28, 2025
1 parent 09a6684 commit feef731
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/shared/src/sourcegraph-api/clientConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Observable, Subject, interval, map, merge } from 'observable-fns'
import semver from 'semver'
import type { AuthStatus } from '..'
import { authStatus } from '../auth/authStatus'
import { editorWindowIsFocused } from '../editor/editorState'
import { logDebug, logError } from '../logger'
Expand Down Expand Up @@ -149,7 +150,9 @@ export class ClientConfigSingleton {
// linear.app/sourcegraph/issue/CODY-3745/codys-background-periodic-network-access-causes-2fa.
filter((_value): _value is undefined => editorWindowIsFocused()),
startWith(undefined),
switchMap(() => promiseFactoryToObservable(signal => this.fetchConfig(signal)))
switchMap(() =>
promiseFactoryToObservable(signal => this.fetchConfig(authStatus, signal))
)
)
: Observable.of(undefined)
),
Expand Down Expand Up @@ -183,7 +186,7 @@ export class ClientConfigSingleton {
return await firstValueFrom(this.changes.pipe(skipPendingOperation()), signal)
}

private async fetchConfig(signal?: AbortSignal): Promise<CodyClientConfig> {
private async fetchConfig(authStatus: AuthStatus, signal?: AbortSignal): Promise<CodyClientConfig> {
logDebug('ClientConfigSingleton', 'refreshing configuration')

try {
Expand Down Expand Up @@ -214,8 +217,11 @@ export class ClientConfigSingleton {
// Sourcegraph instances before 5.5.0 do not support the new /.api/client-config endpoint.
supportsClientConfig = insiderBuild || !semver.lt(siteVersion, '5.5.0')

const isDotCom =
!authStatus.authenticated ||
authStatus.endpoint.startsWith('https://sourcegraph.com')
// Enable OmniBox for Sourcegraph instances 6.0.0 and above or dev instances
omniBoxEnabled = insiderBuild || semver.gte(siteVersion, '6.0.0')
omniBoxEnabled = !isDotCom && (insiderBuild || semver.gte(siteVersion, '6.0.0'))
}

signal?.throwIfAborted()
Expand Down

0 comments on commit feef731

Please sign in to comment.