From c808434a3541adfb4ed614bda98267ebeff7ab26 Mon Sep 17 00:00:00 2001 From: Yashraj Jangra <84060578+Yashraj-Jangra@users.noreply.github.com> Date: Fri, 7 Aug 2026 14:41:44 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20remove=20extra=20env=20tool=20confi?= =?UTF-8?q?rmation=20prompt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/chat/selectEnvTool.ts | 35 ++---------------------- src/test/chat/selectEnvTool.unit.test.ts | 26 ++++++++++++++++++ todo.md | 14 ++++++++++ 3 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 src/test/chat/selectEnvTool.unit.test.ts create mode 100644 todo.md diff --git a/src/client/chat/selectEnvTool.ts b/src/client/chat/selectEnvTool.ts index 834bcd315944..ab08973609a7 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, raceCancellationError, } from './utils'; @@ -120,39 +119,11 @@ 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'), - ), - }, - }; + 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(); + } + }); +}); diff --git a/todo.md b/todo.md new file mode 100644 index 000000000000..ce8a9f05eed3 --- /dev/null +++ b/todo.md @@ -0,0 +1,14 @@ +# Project Tracker & Continuity Log + +## Progress +- [x] Forked `microsoft/vscode-python` to `Yashraj-Jangra/vscode-python` and cloned locally. +- [x] Created feature branch `chat-avoid-redundant-env-tool-confirmation`. +- [x] Updated `src/client/chat/selectEnvTool.ts` to return `{}` from `prepareInvocationImpl`, removing the redundant pre-invocation confirmation modal. +- [x] Added unit test in `src/test/chat/selectEnvTool.unit.test.ts` to verify confirmation is not requested. +- [x] Verified compilation (`npx tsc -p ./`), unit test execution (`mocha`), and linting (`npm run lint`). +- [ ] Commit changes with clean human commit formatting. +- [ ] Push feature branch to `Yashraj-Jangra/vscode-python` and submit PR to `microsoft/vscode-python`. + +## Next Steps +- Commit and push to GitHub fork. +- Open PR on `microsoft/vscode-python`.