Skip to content

fix: execute Stop hooks before processing pending notifications#1344

Open
lewis617 wants to merge 2 commits into
mainfrom
worktree-warm-swift-mountain
Open

fix: execute Stop hooks before processing pending notifications#1344
lewis617 wants to merge 2 commits into
mainfrom
worktree-warm-swift-mountain

Conversation

@lewis617

@lewis617 lewis617 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

When a background task notification is pending at the time the AI finishes responding, Wave would skip Stop hooks and directly restart the loop to process the notification. This caused ~/.wave/settings.json Stop hooks (e.g. send_assistant_message.sh) to not execute.

Root Cause

In aiManager.ts, the finally block checked notificationQueue.hasPending() before executing Stop hooks. If notifications were pending, Stop hooks were skipped entirely.

Fix

Align with Claude Code, which fires Stop hooks unconditionally when the AI finishes responding (no queue checks in the !needsFollowUp path). Move the notificationQueue check to after Stop hooks execution, so:

  1. Stop hooks always fire when AI completes
  2. Pending notifications are then dequeued and injected
  3. The loop restarts to process the notifications
  4. Stop hooks fire again after the notification turn completes

Test

  • New test: verifies Stop hooks execute even when notifications are pending
  • All 3152 existing tests pass

lewis617 added 2 commits July 7, 2026 13:22
Align with Claude Code which fires Stop hooks unconditionally when AI
finishes responding. Previously, pending background task notifications
would skip Stop hooks, causing settings.json Stop hooks (e.g.
send_assistant_message.sh) to not execute.

Move the notificationQueue check to after Stop hooks execution so that
hooks always fire, and notifications are processed in the next loop
iteration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant