Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
hitesh-1997 committed Jan 6, 2025
1 parent bee12bc commit 0f22a0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions vscode/src/autoedits/create-autoedits-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuthenticatedAuthStatus, 'authenticated' | 'endpoint'>
chatClient: ChatClient
}

export function createAutoEditsProvider({
config: { configuration },
authStatus,
chatClient,
}: AutoeditsItemProviderArgs): Observable<void> {
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 [
Expand Down
4 changes: 2 additions & 2 deletions vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0f22a0e

Please sign in to comment.