Skip to content

Commit c808434

Browse files
✨ remove extra env tool confirmation prompt
1 parent 82940c9 commit c808434

3 files changed

Lines changed: 43 additions & 32 deletions

File tree

src/client/chat/selectEnvTool.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { TerminalCodeExecutionProvider } from '../terminals/codeExecution/termin
2323
import {
2424
doesWorkspaceHaveVenvOrCondaEnv,
2525
getEnvDetailsForResponse,
26-
getToolResponseIfNotebook,
2726
IResourceReference,
2827
raceCancellationError,
2928
} from './utils';
@@ -120,39 +119,11 @@ export class SelectPythonEnvTool extends BaseTool<ISelectPythonEnvToolArguments>
120119
}
121120

122121
async prepareInvocationImpl(
123-
options: LanguageModelToolInvocationPrepareOptions<ISelectPythonEnvToolArguments>,
124-
resource: Uri | undefined,
122+
_options: LanguageModelToolInvocationPrepareOptions<ISelectPythonEnvToolArguments>,
123+
_resource: Uri | undefined,
125124
_token: CancellationToken,
126125
): Promise<PreparedToolInvocation> {
127-
if (getToolResponseIfNotebook(resource)) {
128-
return {};
129-
}
130-
const hasVenvOrCondaEnvInWorkspaceFolder = doesWorkspaceHaveVenvOrCondaEnv(resource, this.api);
131-
132-
if (
133-
hasVenvOrCondaEnvInWorkspaceFolder ||
134-
!workspace.workspaceFolders?.length ||
135-
options.input.reason === 'cancelled'
136-
) {
137-
return {
138-
confirmationMessages: {
139-
title: l10n.t('Select a Python Environment?'),
140-
message: '',
141-
},
142-
};
143-
}
144-
145-
return {
146-
confirmationMessages: {
147-
title: l10n.t('Configure a Python Environment?'),
148-
message: l10n.t(
149-
[
150-
'The recommended option is to create a new Python Environment, providing the benefit of isolating packages from other environments. ',
151-
'Optionally you could select an existing Python Environment.',
152-
].join('\n'),
153-
),
154-
},
155-
};
126+
return {};
156127
}
157128
}
158129

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
'use strict';
5+
6+
import { expect } from 'chai';
7+
import { CancellationTokenSource } from 'vscode';
8+
import { SelectPythonEnvTool } from '../../client/chat/selectEnvTool';
9+
10+
suite('Select Python Environment Tool', () => {
11+
test('Does not request confirmation before showing the environment picker', async () => {
12+
const tool = Object.create(SelectPythonEnvTool.prototype) as SelectPythonEnvTool;
13+
const tokenSource = new CancellationTokenSource();
14+
15+
try {
16+
const result = await tool.prepareInvocation(
17+
{ input: { resourcePath: '/workspace' } },
18+
tokenSource.token,
19+
);
20+
21+
expect(result.confirmationMessages).to.be.undefined;
22+
} finally {
23+
tokenSource.dispose();
24+
}
25+
});
26+
});

todo.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Project Tracker & Continuity Log
2+
3+
## Progress
4+
- [x] Forked `microsoft/vscode-python` to `Yashraj-Jangra/vscode-python` and cloned locally.
5+
- [x] Created feature branch `chat-avoid-redundant-env-tool-confirmation`.
6+
- [x] Updated `src/client/chat/selectEnvTool.ts` to return `{}` from `prepareInvocationImpl`, removing the redundant pre-invocation confirmation modal.
7+
- [x] Added unit test in `src/test/chat/selectEnvTool.unit.test.ts` to verify confirmation is not requested.
8+
- [x] Verified compilation (`npx tsc -p ./`), unit test execution (`mocha`), and linting (`npm run lint`).
9+
- [ ] Commit changes with clean human commit formatting.
10+
- [ ] Push feature branch to `Yashraj-Jangra/vscode-python` and submit PR to `microsoft/vscode-python`.
11+
12+
## Next Steps
13+
- Commit and push to GitHub fork.
14+
- Open PR on `microsoft/vscode-python`.

0 commit comments

Comments
 (0)