Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/client/chat/createVirtualEnvTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class CreateVirtualEnvTool extends BaseTool<ICreateVirtualEnvToolParams>
createVirtualEnvironment({
interpreter: preferredGlobalPythonEnv.id,
workspaceFolder,
selectEnvironment: true,
}),
token,
);
Expand Down
10 changes: 9 additions & 1 deletion src/client/chat/installPackagesTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
LanguageModelToolResult,
PreparedToolInvocation,
Uri,
workspace,
} from 'vscode';
import { PythonExtension } from '../api/types';
import { IServiceContainer } from '../ioc/types';
Expand Down Expand Up @@ -58,7 +59,14 @@ export class InstallPackagesTool extends BaseTool<IInstallPackageArgs>

if (useEnvExtension()) {
const api = await getEnvExtApi();
const env = await api.getEnvironment(resourcePath);
// Normalize resourcePath to workspace folder for environment lookup.
// This ensures consistency with CreateVirtualEnvTool which creates environments
// for workspace folders, not individual files.
const workspaceFolder = resourcePath
? workspace.getWorkspaceFolder(resourcePath)
: workspace.workspaceFolders?.[0];
const envScope = workspaceFolder?.uri ?? resourcePath;
const env = await api.getEnvironment(envScope);
if (env) {
await raceCancellationError(api.managePackages(env, { install: options.input.packageList }), token);
const resultMessage = `Successfully installed ${packagePlurality}: ${options.input.packageList.join(
Expand Down
Loading