[BUG] Inserting an @-mention (claude-vscode.insertAtMention / Alt+K) steals focus to the Claude editor tab (still repro on 2.1.201)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet (see note on the closed/locked #56442 and the closed-as-duplicate #72882 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).
Filing history: This was previously reported in #72882, which a bot auto-closed as a duplicate of #56442. That was incorrect — #56442 is closed-as-completed and locked (its fix covered the accompanying Error: Webview is disposed crash, not the focus-steal), and #72882 could not be reopened via the API. Filing fresh so this stays tracked. Still reproduces on the current extension 2.1.201.
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
- #72882 — prior report of this exact bug, auto-closed as a duplicate and not reopenable via the API (locked target). This issue supersedes it.
- #56442 (v2.1.128) — same
insertAtMentionfocus-jump alongside aError: Webview is disposedcrash; closed as completed and locked. The crash appears resolved, but the focus-steal itself still reproduces on 2.1.201 — thereveal()call still omitspreserveFocus, so this looks like a regression / incomplete fix. - #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.