fix(windows): use -EncodedCommand so PowerShell playback args never contain spaces - #101
Merged
mohak34 merged 1 commit intoSep 16, 2026
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The fix is small, well-scoped to Windows playback, and the new PowerShell invocation correctly avoids the spawn-time -Command parsing failure described in the PR.
Pull request overview
This PR fixes Windows sound playback by changing the PowerShell invocation to use -EncodedCommand, avoiding argument/quoting issues that occur when spawning powershell -Command programmatically from Node.js/Bun. The change is localized to the Windows sound path in src/sound.ts and aligns with the root-cause described in the PR metadata.
Changes:
- Build a PowerShell script that inlines the WAV path as a single-quoted string (escaping
'as''). - Base64-encode the script as UTF-16LE and execute it via
powershell -EncodedCommandto ensure spawned args contain no spaces.
File summaries
| File | Description |
|---|---|
src/sound.ts |
Updates Windows sound playback to run PowerShell via UTF-16LE base64 -EncodedCommand to prevent quoting/argument concatenation failures. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, sounds never play — desktop notifications appear fine, but audio silently fails. Affected versions: 0.2.8 (npm latest) and current
main.Note: this repository restricts issue creation for non-contributors, so I'm reporting via this PR.
Root cause
playOnWindows()passes two arguments containing spaces topowershell -Commandviachild_process.spawn():After Windows command-line conversion, the quoting is lost.
powershell.exe -Commandconcatenates everything after it into one script string, producing:The child exits 1,
runCommand()rejects, andplaySound()'s catch block swallows the error — so notifications show but nothing is ever heard.Minimal repro (fails identically under Bun 1.4.0 and Node.js):
Running the same command manually from an interactive shell works (the outer shell quotes args correctly), which is why this only breaks when spawned programmatically.
Fix
Use
-EncodedCommandso every argument handed tospawn()is space-free:-EncodedCommandexpects UTF-16LE base64 per PowerShell spec'')-NoProfile/-NonInteractiveVerification
Environment: Windows 11, OpenCode 1.18.21 (Bun runtime), valid PCM WAV files.
dist/index.jswith this change: notifications + sounds both workbun run typecheck✓bun test: 90 pass, 0 fail ✓Secondary suggestion: consider logging a warning instead of silently swallowing errors in
playSound()'s catch — this failure mode was hard to diagnose precisely because it was silent.