[BUG] AskUserQuestion popup steals focus mid-typing, causing a duplicate session to spawn
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?
Environment:
- Claude Code VS Code/VSCodium extension, version 2.1.210-linux-x64
- Editor: VSCodium on Linux
Symptom:
While typing a message to Claude Code, if an AskUserQuestion popup opens
around the same time (i.e. the assistant asks a clarifying question while
I'm still typing my next message), a second, entirely new Claude Code
session/tab gets created in the same VS Code window. Whatever I was
typing appears to land in that new, blank session instead of the one I
intended — the new session has no context from the conversation I was
actually having.
Because both sessions are rooted in the same workspace/repo, they then
independently make tool calls (file edits, git branch/checkout
operations, docker commands) against the same files at the same time,
with no awareness of each other. This produced real collisions: both
sessions edited the same source files differently, and one session
fetched/checked out an unrelated branch into the repo, temporarily
making tracked project files (a whole documentation/ directory) disappear
from the working tree, which understandably looked like data loss.
Confirmed via ps aux: two separate extension-hosted claude processes
were running concurrently, each with a different --resume=<session-id>
argument, both timestamped as having started during the same VS Code
session, both with tool-call activity against the same repo directory.
Impact:
- Duplicate, uncoordinated agent sessions editing the same repo
- Wasted work / conflicting edits between the two sessions
- Confusing, alarming apparent "data loss" that was actually just one
session having switched the working tree to a different git branch
- No warning or indication in the UI that a second session had opened
I don't have an exact minimal repro beyond "type a message right as a
question popup appears" - happy to provide more detail if useful.
What Should Happen?
Requested fix (either would resolve this):
- AskUserQuestion (and other tool-prompt popups) should not be able to
receive/steal keyboard input intended for the main chat compose box,
so a keystroke during that window can't trigger an unrelated action.
- If a new Claude Code session does get created while one is already
open and active in the same workspace/repo, surface a clear warning
(e.g. "another session is already active here") rather than silently
running both.
Error Messages/Logs
Steps to Reproduce
- Open a project in VS Code/VSCodium with the Claude Code extension
(v2.1.210) installed, and start a Claude Code chat session.
- Give Claude a task that runs for a while and involves multiple
back-and-forth turns (so there are several opportunities for it to
respond while you're still typing your next message).
- Continue typing in the chat input while Claude is composing/sending
its next response - in particular, try typing right around the
moment Claude calls the AskUserQuestion tool and its popup renders.
- Observe: instead of your keystrokes landing in the existing
conversation's input box, a second, separate Claude Code session/tab
opens in the same VS Code window. The text you were typing appears
to go to this new, contextless session instead of the original one.
- Confirm two sessions are both live and both rooted in the same
workspace by running, on Linux: ps aux | grep claude - two
claude processes show up, each with a different
--resume=<session-id> argument, both started during the same VS
Code window session.
- Give both sessions further instructions (or just let the new one
run) - both independently make tool calls (file edits, git
operations, docker commands) against the same repo with no
awareness of each other, causing conflicting edits.
I don't have a fully deterministic minimal repro (e.g. an exact
keystroke or exact timing) - it reproduced for me by ordinary use over
a long working session, correlating specifically with typing while an
AskUserQuestion popup was opening. If it turns out to reproduce with
any popup/tool-prompt rendering (not just AskUserQuestion specifically),
that would be useful to narrow down.
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
Claude Code Version: 2.1.210 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
- No custom keybindings are configured anywhere on this machine: neither
Claude Code's own ~/.claude/keybindings.json nor VSCodium's
~/.config/VSCodium/User/keybindings.json exist. This rules out a
personal/custom shortcut conflict as the cause - whatever triggers the
duplicate session happens with fully default keybindings, which
suggests it should reproduce on a stock install rather than being
specific to my configuration.
- Relevant setting: "claudeCode.preferredLocation": "panel" in VSCodium
User settings.json - the extension is configured to open in the panel
area rather than the sidebar. Might matter if this relates to how
panel-hosted webviews handle focus/keyboard events differently from
sidebar views.
- Editor build: VSCodium 1.105.17075 (codium snap package, classic
confinement), not Microsoft's official VS Code build - noting in case
this is specific to the open-source build's Electron/keybinding
defaults.
- No screenshot available - this happened during normal text-based
terminal/chat use, nothing visual to capture at the moment it occurred.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗