Skip to content

feat: enhance getVenvForWorkspace to prioritize persisted selections#1397

Merged
eleanorjboyd merged 2 commits intomicrosoft:mainfrom
eleanorjboyd:copilot/steady-penguin
Mar 25, 2026
Merged

feat: enhance getVenvForWorkspace to prioritize persisted selections#1397
eleanorjboyd merged 2 commits intomicrosoft:mainfrom
eleanorjboyd:copilot/steady-penguin

Conversation

@eleanorjboyd
Copy link
Member

getVenvForWorkspace() in src/managers/builtin/venvUtils.ts](src/managers/builtin/venvUtils.ts#L64-L65 unconditionally returns process.env.VIRTUAL_ENV if set, ignoring the user's explicitly saved workspace selection. This PR switches that ordering

fixes microsoft/vscode-python#25867

@eleanorjboyd eleanorjboyd self-assigned this Mar 25, 2026
@eleanorjboyd eleanorjboyd added the bug Issue identified by VS Code Team member as probable bug label Mar 25, 2026
@eleanorjboyd eleanorjboyd requested a review from Copilot March 25, 2026 18:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates getVenvForWorkspace() to prioritize the user’s persisted workspace venv selection over process.env.VIRTUAL_ENV, and adds unit tests to lock in the intended precedence and fallback behavior.

Changes:

  • Reorders resolution logic to check persisted workspace selection before VIRTUAL_ENV.
  • Clears stale persisted entries when the stored venv path no longer exists.
  • Adds a unit test suite covering precedence, fallback, and stale data scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/managers/builtin/venvUtils.ts Reorders venv selection priority and adds safer fallback logic for VIRTUAL_ENV.
src/test/managers/builtin/venvUtils.getVenvForWorkspace.unit.test.ts Introduces tests verifying persisted selection precedence, VIRTUAL_ENV fallback, and stale entry cleanup.

@eleanorjboyd eleanorjboyd merged commit ba93146 into microsoft:main Mar 25, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Venv is not being remembered

3 participants