IDE detection fails when CLAUDE_CODE_SSE_PORT becomes stale after extension restart
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.exelauncher exits after spawningclaude.exe, or MSYS2 intermediate bash processes are ephemeral) - If
process.ppidis not in the Windows process table, the traversal returns empty immediately → ancestor set is{}→has(vscodePid)returnsfalse→ IDE silently skipped viacontinue - The 3-second timeout is also tight — on ARM64, the PowerShell
Get-CimInstancetraversal 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
- Open VS Code with Claude Code extension
- Open an integrated terminal →
CLAUDE_CODE_SSE_PORT=XXXXis set - Reload VS Code window or wait for extension to restart (port changes)
- Run
/idein the existing terminal → "No available IDEs detected" - Open a new terminal →
/ideworks (fresh env var matches new port)
Suggested Fixes
- Start ancestor traversal from
process.pidinstead ofprocess.ppid— the current process always exists in the Windows process table - Increase the PowerShell timeout from 3s to 5s+ (ARM64 Windows is slow to start PowerShell)
- Don't
continuepast 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 - Fall back gracefully when
CLAUDE_CODE_SSE_PORTis stale — if the port in the env var is not connectable, ignore it rather than triggering the stricter PID check path
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗