Skip to content

Commit bf25102

Browse files
eleanorjboydCopilot
andcommitted
Avoid redundant Python environment tool confirmation
The environment picker already requires an explicit user choice, so an additional tool confirmation blocks Allow All sessions unnecessarily. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 66ff9a4 commit bf25102

2 files changed

Lines changed: 30 additions & 32 deletions

File tree

src/client/chat/selectEnvTool.ts

Lines changed: 4 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
} from './utils';
2928
import { ITerminalHelper } from '../common/terminal/types';
@@ -113,39 +112,12 @@ export class SelectPythonEnvTool extends BaseTool<ISelectPythonEnvToolArguments>
113112
}
114113

115114
async prepareInvocationImpl(
116-
options: LanguageModelToolInvocationPrepareOptions<ISelectPythonEnvToolArguments>,
117-
resource: Uri | undefined,
115+
_options: LanguageModelToolInvocationPrepareOptions<ISelectPythonEnvToolArguments>,
116+
_resource: Uri | undefined,
118117
_token: CancellationToken,
119118
): Promise<PreparedToolInvocation> {
120-
if (getToolResponseIfNotebook(resource)) {
121-
return {};
122-
}
123-
const hasVenvOrCondaEnvInWorkspaceFolder = doesWorkspaceHaveVenvOrCondaEnv(resource, this.api);
124-
125-
if (
126-
hasVenvOrCondaEnvInWorkspaceFolder ||
127-
!workspace.workspaceFolders?.length ||
128-
options.input.reason === 'cancelled'
129-
) {
130-
return {
131-
confirmationMessages: {
132-
title: l10n.t('Select a Python Environment?'),
133-
message: '',
134-
},
135-
};
136-
}
137-
138-
return {
139-
confirmationMessages: {
140-
title: l10n.t('Configure a Python Environment?'),
141-
message: l10n.t(
142-
[
143-
'The recommended option is to create a new Python Environment, providing the benefit of isolating packages from other environments. ',
144-
'Optionally you could select an existing Python Environment.',
145-
].join('\n'),
146-
),
147-
},
148-
};
119+
// The environment picker requires an explicit user selection before making any change.
120+
return {};
149121
}
150122
}
151123

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+
});

0 commit comments

Comments
 (0)