claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] IDE connection only works in VSCode's open folder directory, fails in subdirectories (v2.0.74)

Open elfenlieds7 opened this issue 1 month ago • 6 comments

Description

After upgrading to v2.0.74, Claude Code IDE connection only works when running claude in the exact directory that VSCode opened. Running claude in any subdirectory shows the extension is installed but fails to connect.

Environment

  • Claude Code version: 2.0.74
  • OS: Windows 11
  • IDE: VSCode / Cursor
  • Terminal: Integrated terminal

Steps to Reproduce

  1. Open VSCode/Cursor at ~/projects (parent folder)
  2. Run claude in ~/projects → IDE connects successfully
  3. cd into a subdirectory ~/projects/some-project
  4. Run claude → IDE extension shows installed but cannot connect

Expected Behavior

IDE connection should work in subdirectories of the opened workspace folder.

Actual Behavior

IDE connection only works in the exact directory VSCode opened. Subdirectories fail to connect.

Lock File Analysis

The lock file at ~/.claude/ide/*.lock shows:

{"workspaceFolders":["c:\Users\...\projects"]}

Only the root folder is registered. When running claude in a subdirectory, path matching fails.

Workaround

Downgrade to v2.0.72 where this worked correctly.

Possibly Related

This may be a regression. Previously subdirectory matching worked.

elfenlieds7 avatar Dec 20 '25 06:12 elfenlieds7

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/8559
  2. https://github.com/anthropics/claude-code/issues/12808
  3. https://github.com/anthropics/claude-code/issues/1411

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Dec 20 '25 06:12 github-actions[bot]

Update: After further testing, this is not a regression in v2.0.74. The same behavior exists in v2.0.72.

Clarification

This is actually a feature request rather than a bug.

Current behavior: IDE connection only works when cwd exactly matches one of the workspaceFolders in the lock file.

Expected behavior: IDE connection should work in subdirectories of any workspace folder.

Use Case

  1. Open VSCode at ~/projects (parent folder containing multiple repos)
  2. Can browse/edit all repos' code in one window
  3. Open terminal, cd into ~/projects/repo-a, run claude
  4. Expected: IDE connects (since repo-a is a subdirectory of workspace ~/projects)
  5. Actual: IDE shows "Installed VS Code extension" but doesn't connect

Suggested Fix

When checking if cwd matches a workspace folder, also check if cwd is a subdirectory of any workspace folder:

// Current: exact match only
workspaceFolders.includes(cwd)

// Suggested: also match subdirectories  
workspaceFolders.some(folder => cwd.startsWith(folder))

This would support the common workflow of opening a parent folder in VSCode and working on multiple projects within it.

elfenlieds7 avatar Dec 20 '25 06:12 elfenlieds7

Additional finding: Manually modifying the lock file does NOT work as a workaround.

What I tried

  1. Added all subdirectories to workspaceFolders in ~/.claude/ide/*.lock
  2. Fixed case sensitivity (changed c:\ to C:\)

Result

  • /ide command shows "Connected to Visual Studio Code" ✓
  • /status still shows "IDE: Installed VS Code extension" (not connected)
  • IDE features don't actually work - e.g., Edit tool doesn't trigger diff view in VSCode

Conclusion

The connection validation happens on both sides:

  • CLI side: checks lock file (can be fooled by manual edit)
  • Extension side: has its own validation that we can't bypass

This needs to be fixed in the extension itself to support subdirectory matching, not just the CLI.

elfenlieds7 avatar Dec 20 '25 06:12 elfenlieds7

Important update: This appears to be a regression, not a new feature request.

Evidence

Previously (possibly around v1.0.x or earlier v2.0.x), the following workflow worked:

  1. Open VSCode at parent folder ~/cursor-projects
  2. cd into subdirectory ~/cursor-projects/nexus (which has its own .venv)
  3. Run claude
  4. IDE connection worked - diff view appeared when editing files

Now with v2.0.72, the same workflow fails - IDE shows "Installed" but doesn't connect, no diff view.

Request

Please investigate if subdirectory matching was removed/broken in a recent version. This is a common workflow for developers working on multiple projects from a single VSCode window.

elfenlieds7 avatar Dec 20 '25 11:12 elfenlieds7

Update: Multi-root Workspace + Case Sensitivity Issue

I tried using a multi-root workspace as a workaround. This successfully adds all subdirectories to the lock file's :


However, IDE connection still fails due to case sensitivity mismatch:

Source Path
Lock file \ (lowercase )
CLI cwd \ (uppercase )

On Windows, path comparison should be case-insensitive, but the CLI's matching logic appears to be case-sensitive, causing the mismatch.

Conclusion: Even with multi-root workspace providing the correct , the case sensitivity bug prevents IDE connection from working in subdirectories.

elfenlieds7 avatar Dec 20 '25 11:12 elfenlieds7

Update: Extension-side validation confirmed

After fixing the case sensitivity in the lock file (changing c:\), running /ide` now reports "Connected to Visual Studio Code".

However, /status still shows "IDE: Installed VS Code extension" instead of "IDE: Connected to VS Code extension".

This confirms that validation happens on BOTH sides:

  1. CLI side: path matching against lock file (can be worked around by modifying lock file)
  2. Extension side: validates the connection request (cannot be bypassed)

The extension is rejecting connections from subdirectories even when they are listed in the multi-root workspace's workspaceFolders.

Root cause: The extension's validation logic doesn't properly handle subdirectory matching, even with multi-root workspaces.

elfenlieds7 avatar Dec 20 '25 11:12 elfenlieds7