[BUG] Claude-code steals KeyBoard Focus without warning or delay -- causes user to type in wrong window prompt
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?
when claude is running background tasks and the user is typing into the prompt window, the background task can popup a decision window and instantly moves the keyboard focus into the decision window -- while the user is still typing as if they were in the prompt window, but ends up typing the remainder of their prompt into the decision window.
What Should Happen?
the popup should not grab keyboard focus until it has determined what the user is already doing with keyboard focus -- there needs to be a delay on inactivity for the prompt window typing, or some other debounce logic.
Error Messages/Logs
Steps to Reproduce
launch background tasks
manually type prompts, keep typing until background task presents a popup decision window
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.170
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
3 Comments
depending on IDE context, stealing keyboard focus is also a severe security concern if the user is typing a password/key at the time focus changes.
What needs to happen is maintain focus if the text editor is active has focus and user is actively typing. a status icon added to alert of decision requiring your attention and not force you to respond.
Current state is very dangerous for many reasons:
Permission prompts steal keyboard focus mid-typing and discard input
When a tool-approval prompt appears while I'm actively typing in the input box, focus switches to the prompt immediately and the partially-typed message is lost. This happens frequently in long sessions where the agent runs many tool calls.
Expected: if the user is actively typing / has focus in the input, the prompt should queue and not steal focus until the user chooses to switch to it - or at minimum preserve the in-progress draft.
Impact: loses work, breaks train of thought, and makes it risky to compose a longer message while the agent is working!!
Solution: If Prompt Editor has Text - Keyboard decisions disabled !! Simples :-) User deletes text or submits to regain Keyboard based decisions
Can you update the Issue to include " and wrongly make decisions based on current keyboard prompt editing / typing"