[Windows] Buffered keypress auto-approves plan/permission prompts after window switch or login
Status Open
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 4 comments · opened Jun 15, 2026
Environment: Windows 11, Claude Code VSCode extension, claude-sonnet-4-6
Steps to reproduce:
- Have a plan-mode approval prompt or permission dialog active in Claude Code
- Switch to another Windows application (or lock/unlock the screen)
- Return to Claude Code — a buffered Enter keypress auto-approves the prompt without user review
Expected: Approval prompts should require deliberate user input after focus returns.
Actual: Claude Code treats the buffered keypress as an approval and immediately begins executing the plan/action.
Impact: Work executes without explicit user consent, which is especially problematic for destructive or hard-to-reverse operations (file edits, git commits, etc.).
4 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Not a duplicate. The steps to reproduce are different. After switching windows or after logging in to Windows. The plan is auto approved.
The destructive-operation angle has a defense-in-depth mitigation worth knowing, even though the real fix is upstream (focus-return shouldn't consume a buffered keypress as approval).
**A
PreToolUsehook gates the tool call before the interactive prompt, so a stray buffered keypress can't approve past it. When a tool is about to run, PreToolUse hooks evaluate the resolved command first; a hook returning a deny decision blocks the call and no approval prompt is shown at all**. That ordering is what makes it robust here: for the destructive cases you call out (rm -rf,git pushto main,git reset --hard, writes outside the repo), a deny-hook on those patterns blocks them outright — so there is no prompt left for a buffered Enter to auto-approve.In other words: the interactive prompt is a UI gate (defeatable by input buffering, as you found); a hook is a programmatic gate on the actual command string (not defeatable by a stray keypress). It doesn't fix the buffering bug, but it removes the "destructive op runs without consent" consequence for the patterns you encode.
Minimal DIY version — a
PreToolUsematcher onBashthat denies your irreversible patterns:(
exit 2from a PreToolUse hook denies the call.) If you'd rather not hand-maintain the pattern list,npx cc-safe-setupinstalls a ready set of these deny-hooks at the user level — free, only needsjq.The upstream fix is still the right outcome: a pending plan-mode or permission dialog shouldn't accept a keypress buffered before focus returned. But encoding your destructive operations as hook denies means a buffered Enter can't trigger them in the meantime.
This needs an input-freshness boundary in the approval UI. Key events queued before the prompt becomes visible or before the window regains focus should be discarded; approval should require a new key-down/key-up sequence after the dialog activation epoch. For high-impact actions, a second distinct gesture or typed confirmation would further prevent accidental acceptance. This is worth testing with focus loss, auth redirects, key repeat, and buffered terminal input.