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
Enable aws-serverless plugin.
Open workspace D:\00.PG (no SAM work required).
Run Agent that edits non-template files, or edit manually while Agent is active.
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.
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.