diff --git a/src/client/chat/selectEnvTool.ts b/src/client/chat/selectEnvTool.ts index 9eeebdfc1b56..55cb1b959be2 100644 --- a/src/client/chat/selectEnvTool.ts +++ b/src/client/chat/selectEnvTool.ts @@ -23,7 +23,6 @@ import { TerminalCodeExecutionProvider } from '../terminals/codeExecution/termin import { doesWorkspaceHaveVenvOrCondaEnv, getEnvDetailsForResponse, - getToolResponseIfNotebook, IResourceReference, } from './utils'; import { ITerminalHelper } from '../common/terminal/types'; @@ -113,39 +112,12 @@ export class SelectPythonEnvTool extends BaseTool } async prepareInvocationImpl( - options: LanguageModelToolInvocationPrepareOptions, - resource: Uri | undefined, + _options: LanguageModelToolInvocationPrepareOptions, + _resource: Uri | undefined, _token: CancellationToken, ): Promise { - if (getToolResponseIfNotebook(resource)) { - return {}; - } - const hasVenvOrCondaEnvInWorkspaceFolder = doesWorkspaceHaveVenvOrCondaEnv(resource, this.api); - - if ( - hasVenvOrCondaEnvInWorkspaceFolder || - !workspace.workspaceFolders?.length || - options.input.reason === 'cancelled' - ) { - return { - confirmationMessages: { - title: l10n.t('Select a Python Environment?'), - message: '', - }, - }; - } - - return { - confirmationMessages: { - title: l10n.t('Configure a Python Environment?'), - message: l10n.t( - [ - 'The recommended option is to create a new Python Environment, providing the benefit of isolating packages from other environments. ', - 'Optionally you could select an existing Python Environment.', - ].join('\n'), - ), - }, - }; + // The environment picker requires an explicit user selection before making any change. + return {}; } } diff --git a/src/test/chat/selectEnvTool.unit.test.ts b/src/test/chat/selectEnvTool.unit.test.ts new file mode 100644 index 000000000000..298931598705 --- /dev/null +++ b/src/test/chat/selectEnvTool.unit.test.ts @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +'use strict'; + +import { expect } from 'chai'; +import { CancellationTokenSource } from 'vscode'; +import { SelectPythonEnvTool } from '../../client/chat/selectEnvTool'; + +suite('Select Python Environment Tool', () => { + test('Does not request confirmation before showing the environment picker', async () => { + const tool = Object.create(SelectPythonEnvTool.prototype) as SelectPythonEnvTool; + const tokenSource = new CancellationTokenSource(); + + try { + const result = await tool.prepareInvocation( + { input: { resourcePath: '/workspace' } }, + tokenSource.token, + ); + + expect(result.confirmationMessages).to.be.undefined; + } finally { + tokenSource.dispose(); + } + }); +});