Skip to content

VS Code Remote-WSL project root incorrectly anchored to VS Code install directory #1032

Description

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

  1. Open a project in a Windows-hosted VS Code window using Remote-WSL.
  2. Launch VS Code from a shortcut or another working directory.
  3. Run a context-mode operation that reads a file in the remote workspace.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions