Fix remote terminal env var collection using wrong workspace scope#293628
Conversation
|
I manually verified this fixes microsoft/vscode-python-environments#986 by using the Test Resolver. |
|
@anthonykim1 is the right person to review this and should be able to get to this tmr- there are some failing checks so if you have time for those I can approve more CI runs. |
There was a problem hiding this comment.
Pull request overview
Fixes remote terminal environment variable collection scoping in remote/devcontainer multi-root workspaces by deriving the workspace folder from the terminal’s initial CWD (instead of the last active editor workspace), improving correctness for workspace-scoped env var contributors like Python.
Changes:
- Add workspace-folder resolution for env var collection scoping based on
initialCwd. - Fall back to the previously provided
activeWorkspaceFolderwhen no workspace folder matches the CWD.
|
Thank you for taking a look at this!
I checked the logs, and the two failures seem to be related to temporary networking issues with GitHub when installing dependencies. Maybe a rerun might fix them, considering tests passed on Mac and Windows. |
|
ah yes good catch- rerunning. AI comments you can ignore if you don't think they are applicable- I sometimes find them helpful |
|
Thanks for looking into this and creating the PR. Maybe the better fix could be here: Instead we could have where we use: vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts Lines 382 to 391 in c13b565 |
Yes, definitely! Thanks for the suggestion. |
Remote terminals used last active editor workspace instead of the terminal's actual CWD, activating the wrong Python environment in multi-root workspaces. Fixes microsoft/vscode-python-environments#986
Add tests to getWorkspaceForTerminal
dfb6d5f to
9b98350
Compare
Fixes microsoft/vscode-python-environments#986
Hi @eleanorjboyd and @anthonykim1. I gave it a try at fixing the
shellStartupissue reported here. I'd appreciate it if you could review this PR.In remote/devcontainer multi-root workspaces, env var collections were scoped to whichever workspace folder the user last had open in the editor, not the terminal's actual workspace folder. So if you had
proj1/main.pyopen and created a terminal forproj2, you'd getproj1's Python venv activated.The local terminal path already handles this correctly by resolving the workspace folder from the terminal's CWD (
getWorkspaceForTerminal). The remote path just usedgetLastActiveWorkspaceRoot()unconditionally. There's even a TODO in the codebase noting that "last active workspace is known to be unreliable".The fix matches
initialCwdagainst workspace folders on the server side before applying env var collections, falling back to the old behavior when the CWD doesn't match anything.