IDE detection fails when CLAUDE_CODE_SSE_PORT becomes stale after extension restart

Resolved 💬 2 comments Opened Apr 1, 2026 by chenfeibo Closed May 9, 2026

Bug Description

/ide reports "No available IDEs detected" even though the VS Code extension is running and the lock file exists with a valid workspace match.

Environment

  • OS: Windows 11 ARM64
  • Shell: Git Bash (MSYS2) inside VS Code integrated terminal
  • Claude Code CLI: 2.1.89
  • VS Code: with Claude Code extension installed and running

Root Cause (traced through CLI source)

The IDE detection function (IN8/DN6) has a code path that silently skips valid IDEs when two conditions combine:

1. Stale CLAUDE_CODE_SSE_PORT environment variable

When the VS Code extension restarts (update, reload, etc.), it binds to a new port and updates the lock file (e.g., ~/.claude/ide/36706.lock). However, existing terminals retain the old CLAUDE_CODE_SSE_PORT value (e.g., 13103) set at terminal creation time. Port 13103 is now dead.

2. PID ancestor check fails as fallback

Because the port doesn't match, the code falls through to a PID ancestor traversal:

if (w) { // true when TERM_PROGRAM=vscode → ND()=true
    if (!(z !== null && H.port === z)) { // port mismatch → enters block
        if (!H.pid || !BZ7(H.pid)) continue;
        if (process.ppid !== H.pid) {
            if (!(await j()).has(H.pid)) continue; // ← fails here
        }
    }
}

The ancestor check (tB4) runs a PowerShell script that traverses Win32_Process from process.ppid upward:

$proc = Get-CimInstance Win32_Process -Filter "ProcessId=$pid" ...

This fails because:

  • The parent process may have exited (e.g., agency.exe launcher exits after spawning claude.exe, or MSYS2 intermediate bash processes are ephemeral)
  • If process.ppid is not in the Windows process table, the traversal returns empty immediately → ancestor set is {}has(vscodePid) returns false → IDE silently skipped via continue
  • The 3-second timeout is also tight — on ARM64, the PowerShell Get-CimInstance traversal takes ~2-2.5s warm

Result

The continue statement skips the IDE entry entirely (it's not even added as "unavailable"), so IN8(true) returns []. Both availableIDEs and unavailableIDEs are empty → "No available IDEs detected."

Reproduction

  1. Open VS Code with Claude Code extension
  2. Open an integrated terminal → CLAUDE_CODE_SSE_PORT=XXXX is set
  3. Reload VS Code window or wait for extension to restart (port changes)
  4. Run /ide in the existing terminal → "No available IDEs detected"
  5. Open a new terminal → /ide works (fresh env var matches new port)

Suggested Fixes

  1. Start ancestor traversal from process.pid instead of process.ppid — the current process always exists in the Windows process table
  2. Increase the PowerShell timeout from 3s to 5s+ (ARM64 Windows is slow to start PowerShell)
  3. Don't continue past the entire entry on PID check failure — still add it to the results as a candidate (perhaps with lower priority), since the lock file + workspace match is already strong evidence
  4. Fall back gracefully when CLAUDE_CODE_SSE_PORT is stale — if the port in the env var is not connectable, ignore it rather than triggering the stricter PID check path

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗