[BUG] Inserting an @-mention (claude-vscode.insertAtMention / Alt+K) steals focus to the Claude editor tab
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet (see note on the closed/locked #56442 below)
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
Triggering the "Insert @-Mention Reference" command (claude-vscode.insertAtMention, default Alt+K) from a focused code editor inserts the @file#lines reference into the Claude prompt correctly, but then activates and focuses the Claude editor tab, pulling the cursor out of the code file. Focus should stay in the editor after inserting the reference.
This only happens when the Claude session is presented as an editor tab. In the sidebar presentation it does not steal focus (the reveal is guarded on panelTab, which is only set for the editor-tab path — see root cause).
Update (2026-07-06): Still reproduces on the current extension 2.1.201. This issue was auto-closed as a duplicate of #56442, but that issue is closed-as-completed and locked, and its fix does not cover this focus-steal — the root cause is still present in the shipped bundle (re-verified below). Reopening per the auto-close comment's own instruction ("If this is incorrect, please re-open this issue or create a new one").
What Should Happen?
The @file#lines reference is inserted into the Claude input, and focus remains in the code editor.
Steps to Reproduce
- Open a Claude Code session as an editor tab (not the sidebar).
- Focus a code file and optionally select some lines.
- Press
Alt+K(or any key bound toclaude-vscode.insertAtMention). - The
@file#linesreference is inserted — and focus jumps to the Claude editor tab.
Root Cause (traced in the bundled extension.js, re-confirmed on v2.1.201)
claude-vscode.insertAtMention itself contains no focus/reveal call — it only fires an EventEmitter with the @file string. The focus change is in the per-session comm object's subscription to that event. The bundled extension.js shipped in 2.1.201 still contains (minified):
// session comm subscription to the at-mention event
),s((E)=>{
if (this.send({ type:"request", channelId:"", requestId:"", request:{ type:"insert_at_mention", text:E } }),
this.panelTab)
this.panelTab.reveal(); // preserveFocus not passed → defaults to false
})
WebviewPanel.reveal(viewColumn?, preserveFocus?) defaults preserveFocus to false, so the tab is revealed and focused. panelTab is only defined for the editor-tab presentation (the sidebar path passes void 0 for that argument), which is why the sidebar is unaffected. All three .reveal() calls in the current bundle omit the preserveFocus argument.
Suggested Fix
Pass preserveFocus = true:
if (this.panelTab) this.panelTab.reveal(undefined, true);
The sibling command claude-code.insertAtMentioned (Cmd+Alt+K) routes through the same handler and has the same behavior.
Related
Closely related to #56442 (v2.1.128), which reported the same insertAtMention focus-jump alongside a Error: Webview is disposed crash. That issue is closed as completed and locked. The crash appears resolved, but the focus-steal itself still reproduces on 2.1.201 — the reveal() call still omits preserveFocus, so this looks like a regression / incomplete fix of #56442. Filing/keeping this separate since #56442 is locked. Also related: #23300 (same "insert @-mention no longer keeps focus" theme, but JetBrains, opposite direction).
Claude Code Version
anthropic.claude-code extension 2.1.201 (darwin-arm64)
Platform
Claude Max / Pro (subscription)
Operating System
macOS 26.5.1 (25F80), Apple M2 Pro (arm64)
Environment
- VS Code 1.127.0 (arm64)
Is this a regression?
Partial — the accompanying crash from #56442 seems fixed, but the focus-steal persists and is still present in 2.1.201.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗