VS Code: Permission modal accidentally approved by typing keystrokes
Description
When Claude Code is working in the VS Code extension and requests a permission approval, the modal appears while the user is actively typing a prompt. Any keystroke being pressed at that moment — Enter, Space, 1, or 2 — can approve the action in the modal that just appeared. This happens because focus shifts to the modal at the exact moment the user is mid-keystroke.
Steps to Reproduce
- Open Claude Code in VS Code
- Start a task that involves subagents (e.g., Agent tool spawning)
- While Claude is working, begin typing a new prompt in the input field
- A permission modal appears (e.g., "Allow Bash command?")
- The keystroke you were typing (Enter, Space, 1, 2) gets captured by the modal
- The action is approved without intentional user consent
Expected Behavior
The permission modal should either:
- Not steal focus from the input field while the user is typing
- Require an explicit, deliberate action (e.g., a specific key combination or mouse click) rather than accepting single keystrokes that could be part of normal typing
- Have a brief input debounce/delay before accepting keystrokes after appearing
Actual Behavior
The modal appears and immediately accepts the next keystroke as a response, approving or denying the action based on whatever key the user was about to press.
Important Note
This does NOT occur when the user is already interacting with a modal (e.g., AskUserQuestion) — only when the permission modal appears unexpectedly during text input.
Workaround
Using a PermissionRequest hook in .claude/settings.json to programmatically resolve permission requests before the modal can appear:
"PermissionRequest": [
{
"matcher": "Edit|Write|Glob|Grep|Read|Agent",
"hooks": [{ "type": "command", "command": "echo '{\"decision\": \"allow\"}'", "timeout": 5000 }]
},
{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": "if echo \"$TOOL_INPUT\" | grep -qiE '(rm -rf|git push --force)'; then echo '{\"decision\": \"deny\"}'; else echo '{\"decision\": \"allow\"}'; fi", "timeout": 5000 }]
}
]
Environment
- Claude Code VS Code Extension
- Windows 10 Pro
- Occurs with both single-select and multi-option permission modals
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗