[BUG] `AskUserQuestion` Steals Focus and Triggers Unintended Selection
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?
In Claude Code (VSCode/Cursor IDE integration), when the agent invokes AskUserQuestion, the response prompt forcibly captures keyboard focus without any user action. If the user is actively typing — either in an open file or composing a follow-up message in the input queue — the next keystroke is interpreted as a response selection, triggering an unintended option pick.
Actual Behavior
- Focus is immediately and silently captured on prompt render.
- Any in-flight keystrokes select and confirm an option unintentionally.
- The user must stop execution, instruct the agent to revert, and re-answer the question — losing flow and context.
Impact
High. Interrupts active editing, causes incorrect agent decisions, and requires manual session recovery. Particularly disruptive during longer agentic runs where the user continues working while the agent processes.
What Should Happen?
Expected Behavior
- The
AskUserQuestionprompt should appear visually and notify the user (e.g. via a badge, sound, or highlight) without stealing keyboard focus. - The user should be required to explicitly click into or tab to the prompt before keystrokes are interpreted as selections.
Suggested Fix / Feature Request
- Do not auto-focus the
AskUserQuestioninput on render. - Visually indicate the pending question (e.g. pulsing border, status bar notification) and wait for deliberate user focus before accepting keyboard input.
- Optionally: add a short grace period (e.g. 500ms) before enabling keystroke capture, to absorb in-flight input.
Error Messages/Logs
Steps to Reproduce
- Start an agentic session that will call
AskUserQuestionat some point. - While the agent is processing, begin typing in an open editor tab or the message input field.
- Observe that when
AskUserQuestionrenders, keyboard focus is immediately captured by the selection prompt. - The next character typed (e.g. a letter or number) selects a response option and submits it.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.56 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Cursor
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗