[Bug] aws-serverless PostToolUse hook steals window focus on Windows during unrelated edits

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Environment

  • Cursor 3.7.42 (5702c9cfca656d8710fad58402fe37f14345e3a0, x64)
  • Windows 10.0.26200
  • Plugin: aws-serverless (cursor-public)
  • Hook: PostToolUse → scripts/validate-template.sh (matcher: Edit|Write)

Summary
The aws-serverless plugin registers a global PostToolUse hook that runs validate-template.sh after every Agent Edit/Write. Even when editing unrelated files (e.g. Markdown in KUBARIO/, not SAM templates), Cursor repeatedly jumps to the foreground and interrupts manual editing in other apps/tabs.

The script exits early unless the file matches *template.yaml|*template.yml, but the hook still runs (shell spawn / systemMessage), which seems to steal focus on Windows.

Steps to Reproduce

  1. Enable aws-serverless plugin.
  2. Open workspace D:\00.PG (no SAM work required).
  3. Run Agent that edits non-template files, or edit manually while Agent is active.
  4. Cursor window repeatedly activates.

Expected: PostToolUse hooks run in background without stealing OS focus; SAM hooks should not affect unrelated workspaces.
Actual: Frequent foreground activation; disruptive during normal editing.

Workaround: Disable aws-serverless plugin when not using SAM.

Suggested fix

  • Cursor: do not foreground window when running PostToolUse hooks / systemMessage.
  • Plugin: narrow hook scope to SAM projects / template.yaml only.

Operating System

Windows 10/11

Version Information

Version: 3.7.42 (user setup)
VS Code Extension API: 1.105.1
Commit: 5702c9cfca656d8710fad58402fe37f14345e3a0
Date: 2026-06-15T19:39:42.738Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
xterm.js: 6.1.0-beta.256
OS: Windows_NT x64 10.0.26200

Does this stop you from using Cursor

No - Cursor works, but with this issue

hey @Takeshi_Honda again, this seems like a known issue with the plugins itself, it’s documented in this forum here :

and also in the github there :

Hey @Takeshi_Honda,

The focus stealing isn’t really a defect in the aws-serverless plugin. On Windows, when a hook command runs, Cursor launches the script process in a way that can briefly pop a console window and pull focus to the foreground. The plugin’s validate-template.sh does exit early for non-template files, but the process still has to launch first, so that early exit can’t prevent the flash. That’s why it happens even on unrelated edits.

@Tom_Coustols is right that this is a known one. To build on that: it’s a Cursor-side Windows behavior rather than something specific to aws-serverless. We’ve seen the same focus-stealing reported on Windows with other extensions and hooks, so narrowing the hook’s matcher would only cut down how often it fires, not stop the flash itself. (The GitHub issue linked above is a separate problem with that plugin around paths that contain spaces, not this focus-steal.)

Your workaround is the right call: disabling aws-serverless when you’re not doing SAM work fully stops it. If you’d rather keep the plugin on, the trade-off is the occasional flash on edits, since the hook is defined by the plugin and any local edit to it gets overwritten on the next update.

This is a known issue on our side and our team is aware of it. There’s no Cursor setting to suppress it today, so the workaround above is the best option for now. I’ll follow up here if that changes.