[BUG] VS Code extension: focus loop between visible Claude tabs still present in 2.1.280 (up to 3,600 webview_focused/s)

Status Open
Reported on v2.1.280
Maintainer reply None cached
Activity 5 comments · opened Sep 27, 2026

What happened

With several Claude Code tabs visible side by side (4 editor groups, one Claude tab each), keyboard focus ping-pongs between the Claude tabs on its own. The selected chat keeps jumping and typed text lands in the wrong session.

This is the same bug as #71809 and bugs 1 and 3 of #79770. Both were auto-closed as stale, but it still happens on 2.1.280.

Evidence from the extension log

Each loop shows as a burst of {"type":"webview_focused"} requests in Claude VSCode.log. One day on one machine:

| Window (ext host) | Burst | Events | Peak |
|---|---|---|---|
| exthost2 | 12:37:43–12:38:17 | 4,410 | 190/s |
| exthost3 | 15:00:12–15:01:10 | ~8,000 | 3,623/s |
| exthost6 | 15:14:52–15:24:28 | ~20,000 | 274/s |
| exthost8 | 15:29:24–15:30:11 | ~7,400 | 447/s |

A calm window logs single-digit webview_focused events per hour.

Likely cause

In webview/index.js, several window focus listeners move focus into the chat input when the webview gets focus, for example:

window.addEventListener("focus",()=>{z.notifyWebviewFocused(),T("window")})
// and
K0=()=>{setTimeout(Z1,0)}; window.addEventListener("focus",K0)   // Z1 -> input.focus() when activeElement is body

These run in every visible Claude webview, not only the active one. When VS Code regains OS focus (Alt-Tab back) or a tab closes and reveals a Claude panel, two or more visible webviews each re-focus themselves and keep re-triggering each other.

Suggested fix

Only the active panel should re-focus its input on window focus. Alternatively, ignore programmatic focus that arrives within a short time of a sibling panel's focus (re-entrancy guard or debounce).

Workaround

A tiny local extension that, on window.onDidChangeWindowState blur with 2+ Claude tabs visible, parks focus on workbench.action.focusStatusBar, then refocuses the Claude group after the window regains focus. Keeping only one Claude tab visible also avoids it.

Environment

  • Extension: anthropic.claude-code 2.1.280 (linux-x64, Remote-SSH)
  • VS Code: 1.138.0, Windows 11 client, Linux server
  • claudeCode.preferredLocation: panel, 4 Claude tabs in 4 editor groups

View original on GitHub ↗

4 Comments

teodor-georgiev · 17 days ago

Update: still happens on 2.1.283, and it doesn't need a window blur. A storm (~2,000 webview_focused in 17 s, peak 206/s) started while one session was running a tool, with no Alt-Tab, so the blur-based workaround from the report doesn't help.

The loop comes from two delayed self-focus handlers in webview/index.js. Both schedule input.focus() with setTimeout(...,0) on every window focus event, in every visible Claude webview:

window.addEventListener("focus",()=>{z.notifyWebviewFocused(),T("window")})        // T -> setTimeout(... Z.emit(""))
X1=()=>{if(!document.activeElement||document.activeElement===document.body)P0()},K0=()=>{setTimeout(X1,0)};
window.addEventListener("focus",K0)

Webview A gets focus, VS Code moves focus to webview B, then A's timeout fires and pulls focus back into A's iframe. B's handler then does the same, and it repeats.

Local fix I'm testing: remove the T("window") call and make K0 a no-op, keeping notifyWebviewFocused(). Clicking the input still focuses it normally.

X-Titouan · 8 days ago

Still happening on 2.1.289 (Cursor 3.21 / VS Code base 1.128, Linux, Wayland). Same setup: several Claude tabs visible side by side in separate editor groups; typed text lands in the other sessions.

michal-sronkowski · 8 days ago

Also hitting this on Windows 11, Claude Code 2.1.289, VS Code 1.140.
Setup: 6-9 Claude tabs, each in its own editor group side by side.
The cursor in the chat input jumps between 2-3 visible sessions in a loop and typing is impossible.
Esc and Alt+Tab don't stop it; opening a new VS Code window does.

quentin-decre · 8 days ago

Still happening on 2.1.291 (VS Code 1.140.0, Windows 11 + WSL2 remote). Setup: 4 Claude tabs, each in its own editor group side by side. Focus keeps jumping between the chat inputs on its own, with the focus state of the inputs flickering. Keeping only one Claude tab visible avoids it.

Showing cached comments. Read the full discussion on GitHub ↗