[BUG] Cmd+W closes two tabs at once in VSCode extension (Antigravity)
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?
Description:
- This bug occurs when using the Claude Code VSCode extension (Antigravity). Pressing Cmd+W closes two Claude-related tabs at once instead of one. Regular file tabs are not affected.
- When pressing Cmd+W, Claude Code related tabs close 2 at a time
- Regular file tabs are not affected (close normally one at a time)
- Removing VSCode keybindings for Terminal: Kill Active Terminal did not help
- Modifying ~/.claude/keybindings.json did not help
- OS: macOS
What I tried (none of these worked):
Removed "Terminal: Kill the Active Terminal" keybinding for Cmd+W in VSCode
Set meta+w: null in ~/.claude/keybindings.json
Uninstalled the Claude Code extension and closed all running Claude instances — the leftover Claude-related tabs still closed in pairs
VSCode version:
Antigravity Version: 1.19.5
VSCode OSS Version: 1.107.0
Commit: 6adfc1a7e4a1a9af62bc45e8f2d7e6a97b7a9756
Date: 2026-02-26T07:23:14.771Z
Electron: 39.2.3
Chromium: 142.0.7444.175
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Darwin arm64 25.2.0
Language Server CL: 875527528
Extension version:
Installation
Identifier
anthropic.claude-code
Version
2.1.49
Last Updated
5 days ago
Size
221.30MB
What Should Happen?
Pressing Cmd+W should close only one tab at a time, same as with regular file tabs.
Error Messages/Logs
Steps to Reproduce
- Open VSCode with the Claude Code extension (Antigravity) installed
- Open a Claude Code tab (start a new conversation)
- Open a few regular file tabs alongside the Claude Code tab
- Focus on a Claude Code related tab
- Press Cmd+W
- Observe that two tabs close at once instead of one
Note: Regular file tabs close normally (one at a time). This issue only affects Claude Code related tabs.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
Claude Code: 2.1.59 Model: Claude Opus 4.6
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
6 Comments
Are you sure it closes two at a time always?
I'm experiencing a very similar issue - Cmd+W closes more than 1 tab very often but not always.
I assume this is because it's not debouncing the keypresses enough. So it's registering more than 1 keypress.
Same issue here. Cmd+W often closes two Claude tabs at once (macOS). Very disruptive!
+1 — can confirm this is still happening on v2.1.96 (macOS, Darwin 25.2.0).
Also want to share a related finding: Cmd+N has the same class of bug — it opens two Claude Code tabs instead of one.
Root cause investigation for Cmd+N
The extension registers a single keybinding in
package.json:Only one keybinding is registered, so the duplication appears to be inside the
newConversationcommand handler itself (possibly firing in both sidebar and editor tab contexts simultaneously).Workaround for Cmd+N (confirmed working)
enableNewConversationShortcutin the Claude Code extension settingskeybindings.json:This uses
claude-vscode.editor.open("Open in New Tab") instead ofclaude-vscode.newConversation, which avoids the double-tab issue entirely.No similar workaround found for Cmd+W yet — since the extension doesn't register a Cmd+W keybinding, the double-close seems to happen internally when the extension handles the tab close event.
Doesn't happen when the Close command is executed through the Command Palette, does Claude Code registers its own Cmd+W internally, maybe?
Confirming this repro on my end.
Repro: focus an existing Claude tab →
cmd+Nto open a new Claude tab →cmd+W→ both the new tab and the previously focused Claude tab close.Versions:
Same root cause, different symptom — adding navigation key data
I filed #61382 for what turns out to be the same underlying bug pattern, on a different key:
Cmd+Wcloses two Claude Code tabs at once (workbench.action.closeActiveEditorfires twice).Cmd+Option+Right/Leftadvances two tabs at once (workbench.action.nextEditor/previousEditorfires twice).I'll close #61382 in favor of this thread since the root cause is the same — sharing the additional findings here so they can be acted on together.
Smoking gun (from #61382, but applies identically to
Cmd+W)VSCode's Developer Troubleshooting log (
Cmd+Shift+P→Developer: Toggle Keyboard Shortcuts Troubleshooting) shows two dispatches per keypress, ~8 ms apart:The first dispatch is the normal keydown event. The second is the macOS native menu accelerator firing the same command. This pattern is identical for
Cmd+W,Cmd+Option+Arrow, and presumably any other shortcut that maps to a command which is also a menu item.Why it's Claude Code specific
When focus is in a regular editor (Monaco), VSCode handles
event.preventDefault()so the menu accelerator is suppressed. When the Claude Code webview is in the keypress lifecycle (focused, or just present in the editor group cycle on macOS),preventDefault()is not called, and the menu accelerator fires the command a second time.This is consistent with other Claude Code webview / keyboard quirks already reported:
Cmd+Escdoesn't blur input in Claude Code panel)Cmd+H,Cmd+Mblocked when Claude panel is focused)Workaround that actually works (not the obvious one)
My first attempt was the obvious
whenguard:This does NOT work. VSCode's macOS menu service registers native menu accelerators WITHOUT evaluating
whenclauses — it just looks up which key is bound to a given command and registers that key as the accelerator regardless of context. The menu accelerator keeps firing the second dispatch.Removing the default binding explicitly with
-workbench.action.nextEditorthen re-adding with awhenguard also doesn't work for the same reason — as long as the user binding'scommandfield still namesworkbench.action.nextEditor, the menu picks it up.What works: wrap the command in
runCommandsso the binding'scommandfield is no longer recognised as related to the menu item:After a full VSCode restart (
Cmd+Qand relaunch —Reload Windowis insufficient because the macOS menu cache doesn't refresh), the second dispatch is gone:The same pattern should work for
Cmd+W:(Untested for
Cmd+Wspecifically — would be useful for @Go-Jinhan to confirm.)Suggested extension-side fix
The Claude Code webview should call
event.preventDefault()on intercepted keydown events that map to commands the host is going to handle — at minimum the navigation-class shortcuts (alt+arrow,alt+cmd+arrow,cmd+pageup/pagedown,ctrl+tab) and the close-tab shortcut (cmd+w).Equivalent alternative: route navigation keys through VSCode's host via
postMessagerather than letting the native menu accelerator dispatch a second copy.Environment
0958016b2af9f09bb4257e0df4a95e2f90590f9f)anthropic.claude-code-2.1.145-darwin-arm64