anthropics / anthropics/claude-code

[BUG] VS Code extension (Linux/Wayland): Alt+Tab back to a focused Claude Code panel leaves the VS Code menu bar focused, as if Alt had been pressed alone

Open
#95,114 0 comments 0 reactions 0 assignees View on GitHub
area:ide bug platform:linux platform:vscode
Dominant language
Python
Stars
145k
Forks
23.1k
PR merge metrics
PR metrics pending

Description

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) 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?

With the Claude Code panel focused in VS Code (prompt editor active, not terminal mode), switching to another application with Alt+Tab and then switching back with Alt+Tab leaves keyboard focus on the VS Code menu bar. The result is the same as pressing and releasing Alt alone while the window is already focused: the first menu title is highlighted, and the next keypress operates the menu instead of the prompt editor.

No key other than the Alt+Tab chord itself is involved. The Alt release that ends the chord appears to be treated as a bare Alt press-and-release, which is VS Code's default shortcut for focusing the custom menu bar.

This only happens when the Claude Code panel had focus before switching away. The same Alt+Tab round trip with a Monaco editor or the integrated terminal focused returns focus to where it was.

### What Should Happen?

After Alt+Tab back to VS Code, focus should return to the Claude Code prompt editor, where it was before switching away. The menu bar should only take focus when Alt is pressed and released on its own while the window already has focus.

### Error Messages/Logs

```shell
N/A
```

### Steps to Reproduce

1. Open the Claude Code panel in VS Code (webview panel, not terminal mode) and click into the prompt editor so it has focus.
2. Press Alt+Tab to switch to any other application.
3. Press Alt+Tab to switch back to VS Code.
4. Observe that the VS Code menu bar has keyboard focus (first menu title highlighted) instead of the prompt editor.
5. Press any key: it operates the menu rather than typing into the prompt.

No keypress restores focus to the prompt editor. Clicking into it with the mouse is the only way back.

### Claude Model

Not sure / Multiple models

### Is this a regression?

I don't know

### Last Working Version

_No response_

### Claude Code Version

2.1.274 (VS Code extension `anthropic.claude-code`)

### Platform

Anthropic API

### Operating System

Ubuntu/Debian Linux

### Terminal/Shell

Other

### Additional Information

Environment:

- VS Code 1.138.0 (x64), running natively on Wayland (`--ozone-platform=wayland`)
- Ubuntu 26.04.1 LTS, GNOME, Wayland session
- `window.titleBarStyle`, `window.menuBarVisibility`, `window.customMenuBarAltFocus`, and `window.enableMenuBarMnemonics` are all at their defaults

Related reports:

- #62368 is the closest match: after Alt+Tab back to the Claude Code prompt editor on Windows, a stale Alt state causes PrtSc and IME keys to focus the menu bar. Its author also noted that "ALT+TAB alone occasionally moves focus to the menu bar without any subsequent key press", which is exactly this report. That issue was auto-closed as stale and is now locked, so filing this one as instructed there. This report differs in that it is on Linux/Wayland and the menu bar takes focus directly from the Alt+Tab round trip, with no further keypress.
- #80743 (open) and #13982 (closed as stale) report the prompt editor losing focus after Alt+Tab back, on Windows. This may be the same underlying focus-restoration problem with a different landing spot for the focus.

Likely mechanism: the keyup for Alt that ends the Alt+Tab chord is delivered to the VS Code window after focus returns, while the matching keydown happened before focus left, so VS Code sees a bare Alt press-and-release and focuses the custom menu bar. Since a Monaco editor or the integrated terminal does not reproduce this, the difference points at the webview panel's focus handling on window focus-in rather than at the workbench as a whole.

_Drafted by Claude (Anthropic AI assistant)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce this on Ubuntu/Debian Linux under native Wayland with the Claude Code prompt editor focused, then compare Alt+Tab behavior with a Monaco editor and the integrated terminal. Inspect the webview panel's focus handling during window focus-in and verify that returning from Alt+Tab restores the prompt editor without focusing the VS Code menu bar.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, vscode
Domain
desktop-dev, developer-experience, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.