From 0f22a0ef2588c8cb7850639131bc3c022394d5da Mon Sep 17 00:00:00 2001 From: hitesh-1997 Date: Mon, 6 Jan 2025 18:47:44 +0530 Subject: [PATCH] cleanups --- vscode/src/autoedits/create-autoedits-provider.ts | 10 ++++++++++ vscode/src/main.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/vscode/src/autoedits/create-autoedits-provider.ts b/vscode/src/autoedits/create-autoedits-provider.ts index d9b984cd94d2..7bbbfd2f47f9 100644 --- a/vscode/src/autoedits/create-autoedits-provider.ts +++ b/vscode/src/autoedits/create-autoedits-provider.ts @@ -5,31 +5,41 @@ import { type AuthenticatedAuthStatus, type ChatClient, NEVER, + type PickResolvedConfiguration, type UnauthenticatedAuthStatus, createDisposables, promiseFactoryToObservable, + skipPendingOperation, } from '@sourcegraph/cody-shared' import { AutoeditsProvider } from './autoedits-provider' import { autoeditsOutputChannelLogger } from './output-channel-logger' interface AutoeditsItemProviderArgs { + config: PickResolvedConfiguration<{ configuration: true }> authStatus: UnauthenticatedAuthStatus | Pick chatClient: ChatClient } export function createAutoEditsProvider({ + config: { configuration }, authStatus, chatClient, }: AutoeditsItemProviderArgs): Observable { + if (!configuration.experimentalAutoeditsEnabled) { + return NEVER + } + if (!authStatus.authenticated) { if (!authStatus.pendingValidation) { autoeditsOutputChannelLogger.logDebug('createProvider', 'You are not signed in.') } return NEVER } + return promiseFactoryToObservable(async () => { return await getAutoeditsProviderDocumentFilters() }).pipe( + skipPendingOperation(), createDisposables(documentFilters => { const provider = new AutoeditsProvider(chatClient) return [ diff --git a/vscode/src/main.ts b/vscode/src/main.ts index 63da5d60fe74..d245986adcc0 100644 --- a/vscode/src/main.ts +++ b/vscode/src/main.ts @@ -718,11 +718,11 @@ function registerAutoEdits(chatClient: ChatClient, disposables: vscode.Disposabl if (!shouldEnableExperimentalAutoedits(config, autoeditEnabled, authStatus)) { return NEVER } - const res = createAutoEditsProvider({ + return createAutoEditsProvider({ + config, authStatus, chatClient, }) - return res }), catchError(error => { logError('registerAutoedits', 'Error', error)