Summary
When context-mode runs through VS Code Copilot in a Windows-hosted VS Code window connected to a workspace via Remote-WSL, legitimate file reads inside the remote workspace can be rejected as outside the project root.
Example symptom (paths anonymized):
File access blocked: "/home/{userName}/source/{project}/scripts/{script}.sh"
resolves outside the project root (/mnt/c/Users/{userName}/AppData/Local/Programs/Microsoft VS Code)
Environment
- Host: Windows
- Remote environment: WSL
- Client: VS Code Copilot using context-mode as an MCP server
- context-mode version: 1.0.169
- The MCP server and its storage run inside WSL.
- No context-mode VS Code extension is required for this behavior.
Root cause hypothesis
The VS Code Copilot adapter falls back to process.env.VSCODE_CWD when determining the project directory. When VS Code is launched from a shortcut rather than from a terminal already positioned in the workspace, VSCODE_CWD can refer to the VS Code installation directory on the Windows host. In a Remote-WSL workspace this value is not the remote project root, so project-boundary checks are anchored to the installation directory.
Proposed fix
Treat known VS Code installation paths as invalid project roots for this fallback and continue to process.cwd(). The detection should support common cross-platform forms, including:
- Windows
Microsoft VS Code and Microsoft VS Code - Insiders installation paths
- macOS
Visual Studio Code.app and Insiders bundles
- Linux
/usr/share/code, /usr/share/code-insiders, /opt/code, and /opt/code-insiders
CLAUDE_PROJECT_DIR should retain priority, and ordinary workspace paths containing words such as code should not be rejected.
Reproduction outline
- Open a project in a Windows-hosted VS Code window using Remote-WSL.
- Launch VS Code from a shortcut or another working directory.
- Run a context-mode operation that reads a file in the remote workspace.
- Observe that the project-boundary check reports the VS Code installation directory as the project root.
Requested validation
Please add unit coverage for VS Code installation-path detection and for the adapter fallback cascade, then run the project test suite and typecheck.
All user names, project names, and local paths in this report are placeholders.
Summary
When context-mode runs through VS Code Copilot in a Windows-hosted VS Code window connected to a workspace via Remote-WSL, legitimate file reads inside the remote workspace can be rejected as outside the project root.
Example symptom (paths anonymized):
Environment
Root cause hypothesis
The VS Code Copilot adapter falls back to
process.env.VSCODE_CWDwhen determining the project directory. When VS Code is launched from a shortcut rather than from a terminal already positioned in the workspace,VSCODE_CWDcan refer to the VS Code installation directory on the Windows host. In a Remote-WSL workspace this value is not the remote project root, so project-boundary checks are anchored to the installation directory.Proposed fix
Treat known VS Code installation paths as invalid project roots for this fallback and continue to
process.cwd(). The detection should support common cross-platform forms, including:Microsoft VS CodeandMicrosoft VS Code - Insidersinstallation pathsVisual Studio Code.appand Insiders bundles/usr/share/code,/usr/share/code-insiders,/opt/code, and/opt/code-insidersCLAUDE_PROJECT_DIRshould retain priority, and ordinary workspace paths containing words such ascodeshould not be rejected.Reproduction outline
Requested validation
Please add unit coverage for VS Code installation-path detection and for the adapter fallback cascade, then run the project test suite and typecheck.
All user names, project names, and local paths in this report are placeholders.