Skip to content

fix: winsound.PlaySound missing SND_SYNC flag - hook sounds cut off on Windows #52

@kuishou68

Description

@kuishou68

Bug: winsound.PlaySound missing SND_SYNC flag causes sounds to be cut off on Windows

Description

In .claude/hooks/scripts/hooks.py, the play_sound() function on Windows calls winsound.PlaySound without the SND_SYNC flag. The code comment explicitly says SND_SYNC should be used, but the flag is omitted from the actual call.

Affected Code

winsound.PlaySound(str(file_path),
                 winsound.SND_FILENAME | winsound.SND_NODEFAULT)
                 # Missing: | winsound.SND_SYNC

Code Comment vs Reality

The comment directly above this call reads:

# Note: Using SND_SYNC instead of SND_ASYNC because the script exits immediately after this call, which would terminate async playback before it completes

Despite this comment, SND_SYNC is not included in the flags. Without SND_SYNC, winsound.PlaySound defaults to asynchronous playback. Since the script exits right after, the sound is cut off immediately and never plays completely on Windows.

Fix

winsound.PlaySound(str(file_path),
                 winsound.SND_FILENAME | winsound.SND_NODEFAULT | winsound.SND_SYNC)

Impact

Hook sounds never play to completion on Windows — the script exits before the async audio thread finishes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions