[BUG] VS Code terminal steals focus even when running Claude Code externally with /ide (terminal not open)

Open 💬 20 comments Opened Sep 15, 2025 by openclosure

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using Claude Code in an external terminal, while connected to VS Code with the /ide command, VS Code opens the integrated terminal and steals focus upon prompt submission in the external terminal.

What Should Happen?

With CLI running externally, VS Code should not reveal/focus the integrated terminal unless I explicitly open it.

Error Messages/Logs

2025-09-14 21:36:07.286 [info] Unregistered diagnostic client: client_5
2025-09-14 21:44:18.197 [info] New WS connection from: /
2025-09-14 21:44:18.198 [info] MCP server connected to transport
2025-09-14 21:44:18.198 [info] [DiagnosticStreamManager] Started streaming diagnostics
2025-09-14 21:44:18.198 [info] Registered diagnostic client: client_6
2025-09-14 21:44:19.296 [info] Closing all diff tabs in the editor...
2025-09-14 21:44:19.297 [info] Closed 0 diff tabs.
2025-09-14 21:44:19.871 [info] [DiagnosticStreamManager] Notifying 1 clients about diagnostics change for 1 files
2025-09-14 21:44:21.963 [info] WS client disconnected
2025-09-14 21:44:21.964 [info] [DiagnosticStreamManager] Unregistered client client_6. Total clients: 0
2025-09-14 21:44:21.964 [info] [DiagnosticStreamManager] Stopped streaming diagnostics
2025-09-14 21:44:21.964 [info] Unregistered diagnostic client: client_6
2025-09-14 21:45:02.704 [info] New WS connection from: /
2025-09-14 21:45:02.704 [info] MCP server connected to transport
2025-09-14 21:45:02.704 [info] [DiagnosticStreamManager] Started streaming diagnostics
2025-09-14 21:45:02.704 [info] Registered diagnostic client: client_7
2025-09-14 21:45:10.698 [info] Closing all diff tabs in the editor...
2025-09-14 21:45:10.698 [info] Closed 0 diff tabs.
2025-09-14 21:45:11.272 [info] [DiagnosticStreamManager] Notifying 1 clients about diagnostics change for 1 files

Steps to Reproduce

  1. Open VS Code with a workspace.
  2. Ensure the integrated terminal is closed.
  3. In an external terminal, run claude from the workspace root and connect with /ide.
  4. Type a prompt and press Enter.
  5. Tab back to VS Code and observe that the integrated terminal is now open.

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Unsure

Claude Code Version

1.0.113

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

Attached logs are from the CC extension in VS code.

GhostTTY Version Info:

Version: 1.1.3
Build: 9438
Commit: 889478f3

VS Code Version Info:

Version: 1.104.0 (Universal)
Commit: f220831ea2d946c0dcb0f3eaa480eb435a2c1260
Date: 2025-09-10T06:46:18.035Z
Electron: 37.3.1
ElectronBuildId: 12342881
Chromium: 138.0.7204.235
Node.js: 22.18.0
V8: 13.8.258.31-electron.0
OS: Darwin arm64 24.6.0

View original on GitHub ↗

21 Comments

github-actions[bot] · 10 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/1591
  2. https://github.com/anthropics/claude-code/issues/3419
  3. https://github.com/anthropics/claude-code/issues/6919

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

openclosure · 10 months ago

Not a duplicate. There are several references to this bug in JetBrains products but I haven't seen a report of this for VS Code/Cursor.

dzhlobo · 10 months ago

I can confirm the bug report, I observe the same behaviour.

I use latest Ghostty from main branch (version 0c63946bd, build 12105).

Claude Code version 1.0.112 (Claude Code).

VSCode version info:

Version: 1.104.0
Commit: f220831ea2d946c0dcb0f3eaa480eb435a2c1260
Date: 2025-09-10T06:46:18.035Z (5 days ago)
Electron: 37.3.1
ElectronBuildId: 12342881
Chromium: 138.0.7204.235
Node.js: 22.18.0
V8: 13.8.258.31-electron.0
OS: Darwin arm64 24.6.0
TouchSeyha · 8 months ago

Just confirming that this bug is still reproducible in November with Claude Code CLI 2.0.31.
The issue reported back in September seems to persist in the current release. But I'm using window platform.

dhaern · 8 months ago

Claude Code v2.0.36 and confirming this bug AGAIN, can you work a bit more instead doing nothing please?

github-actions[bot] · 7 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

etrippler · 7 months ago

This issue is still occuring!

Jay-523 · 7 months ago

Able to reproduce this issue with warp and cursor

MartinLoeper · 6 months ago

I think the best workaround here would be to just introduce a new vscode extension setting to opt-out of the current behaviour which seems to open the terminal panel and focus it.

ankit-kapur · 6 months ago

Still occurring, please fix

dcrew44 · 5 months ago

Still occurring, please fix

JoshChapnick · 5 months ago

Still running into this - please fix

ezeqviel · 5 months ago

issue persists on 2.1.42

jdvolk · 4 months ago

also confirming this. is there a way to disconnect clude-cli from the claude extention in vs code?

Nick-Lucas · 3 months ago

Happening for me on 2.1.79

yurukusa · 3 months ago

The focus-stealing happens because the /ide connection triggers VS Code to open/activate its terminal panel. Workarounds:
Workaround 1 — Prevent terminal auto-focus in VS Code:

// VS Code settings.json
{
  "terminal.integrated.focusAfterRun": "none",
  "terminal.integrated.showExitAlert": false
}

This prevents VS Code from auto-focusing the terminal panel when Claude Code sends commands through the IDE integration.
Workaround 2 — Use a separate VS Code window:
Keep your code in one VS Code window and let Claude's /ide connection go to a different window. Focus changes in the second window won't interrupt your work in the first.
Workaround 3 — Don't use /ide, use file paths instead:
If you primarily need Claude to edit files, it can do so via the Edit/Write tools without IDE integration:

<!-- CLAUDE.md -->
Edit files directly using the Edit tool. Do not use IDE integration.

The /ide connection is mainly useful for features like "go to definition" and inline diffs. If you don't need those, skipping /ide avoids the focus issue entirely.
Workaround 4 — Use the VS Code extension instead of external terminal + /ide:
The Native UI mode in the extension handles IDE integration without the focus-stealing issue, since Claude runs inside VS Code natively.

barafael · 3 months ago

now, (for me), it happens _twice_, on startup. That's quite disruptive.

dmcconachie · 3 months ago

https://github.com/anthropics/claude-code/issues/7618#issuecomment-4159655672

(1) does not work; see https://github.com/anthropics/claude-code/issues/23713 for an explanation

(2) This is very awkward; now I'm juggling 3 windows (VSCode 1 where I do my work, VSCode 2 whose only purpose is to feed context to CC, an external terminal running claude code). Also VSCode doesn't really like to have 2 windows open to the same project as far as I know, though I haven't tried it in some time. Historically the only way I've managed to do it was to have one window open to the folder, one window open to a VSCode workspace in the same folder.

(3) That also defeats the entire purpose of having ide integration. "Don't use the thing" is not a workaround

(4) Also defeats the entire purpose of /ide integration

PhilChen-6765 · 2 months ago

Still reproducible on Claude Code v2.1.126 / VS Code Claude Code extension v2.1.126 (macOS).

Environment

  • OS: macOS
  • External terminal: Ghostty
  • Claude Code CLI: v2.1.126
  • VS Code with Claude Code extension v2.1.126

Reproduction

  1. Run claude in Ghostty
  2. /ide → "Connected to Visual Studio Code"
  3. Send any prompt — even one that doesn't trigger any tool call
  4. VS Code's integrated terminal panel pops open / steals focus
  5. Happens on every prompt

New finding — narrows down the trigger
The pop-up only happens if at least one integrated terminal instance already exists in the current VS Code
session. Specifically:

| State of VS Code's integrated terminal | Pop-up on prompt? |
|---|---|
| Never opened in this VS Code session | ✅ No pop-up |
| Opened before, then hidden (Cmd+J) | ❌ Pops back |
| Opened and visible | ❌ Steals focus |

Workaround: restart VS Code and never manually open an integrated terminal. The pop-up does not occur as long as no
terminal instance exists.

grubstarstar · 1 month ago

This used to work a few weeks ago for me. Certainly way after the opening of this ticket. But it's been doing it every time for the last few weeks. I don't know the exact version.

samehhashy · 17 days ago

Almost a year later and this is still an issue.