Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

voice.ts: showDesktopNotification spawns /usr/bin/osascript unconditionally — ENOENT on Linux

Open JElliottMiller opened this issue 6 months ago • 2 comments

Summary

Releases/v5.0.0/.claude/PAI/PULSE/VoiceServer/voice.ts:375-388 showDesktopNotification() unconditionally spawns /usr/bin/osascript (macOS-only). On Linux / WSL2 every voice notification fires a posix_spawn '/usr/bin/osascript' ENOENT in the daemon log. With Pulse cron jobs producing voice output, journal spam can reach one ENOENT every few seconds, drowning real signal.

Repro

# Linux/WSL2, PAI v5.0.0:
curl -X POST http://localhost:31337/notify \
  -H 'Content-Type: application/json' \
  -d '{"message":"test","voice_enabled":true}'

# Watch the journal:
journalctl --user -u pai-pulse --since "30 seconds ago" | grep osascript
# Output:
# error: ENOENT: no such file or directory, posix_spawn '/usr/bin/osascript'

The TTS HTTP request still returns 200 OK and audio bytes are generated, but the desktop-notification path crashes.

Current code (upstream main)

// voice.ts:375-388
async function showDesktopNotification(title: string, message: string): Promise<void> {
  // ... no platform check
  const proc = spawn("/usr/bin/osascript", ["-e", script])
  proc.on("exit", (code) => (code === 0 ? resolve() : reject(new Error(`osascript exited ${code}`))))
}

Expected

On non-darwin platforms, showDesktopNotification should either:

  • Early-return silently (no-op — voice itself still plays through playAudio), OR
  • Branch to a Linux equivalent — notify-send on Linux desktop, powershell.exe -c '...' shim on WSL2.

Early-return is the smallest reversible change and matches what PR #1116 does on the adjacent playAudio path for browser-audio-streaming.

Suggested fix (locally applied — 1 line)

 async function showDesktopNotification(title: string, message: string): Promise<void> {
+  if (process.platform !== "darwin") return
   const escapedTitle = title.replace(/"/g, '\\"')
   ...
   const proc = spawn("/usr/bin/osascript", ["-e", script])

Tested on WSL2 + systemd-user. ENOENT spam stopped immediately after restart; voice TTS audio playback (via locally-patched playAudio → mpv) continued working without notification.

Environment

  • PAI v5.0.0 (file unchanged in current main as of 2026-05-12)
  • Ubuntu 24.04 on WSL2, systemd-user supervisor

Related

  • #1186 — .cursor/rules/ ELOOP (also Linux-port issue)
  • #1159 — Bun.spawn(["bash", ...]) ENOENT (same general class of macOS-assumption bug)
  • PR #1116 (@Alessandro-Improta) — WebSocket browser audio streaming, addresses the audio side of the same macOS-only pattern in voice.ts
  • PR #1101 (@salaheldinaz) — local TTS fallback in voice.ts; could fold this guard in

JElliottMiller avatar May 12 '26 14:05 JElliottMiller

Picked up the platform guard in the upstream tree. PAI/PULSE/VoiceServer/voice.ts showDesktopNotification() now returns early on non-darwin platforms, after the existing voiceConfig.desktopNotifications check:

async function showDesktopNotification(title: string, message: string): Promise<void> {
  if (!voiceConfig.desktopNotifications) return
  // osascript is macOS-only; on Linux/WSL2 the spawn ENOENT's and floods journal
  if (process.platform !== "darwin") return
  // ...
}

Smallest reversible change — matches the pattern PR #1116 used on the adjacent playAudio path. TTS audio continues working through the audio code path; only the macOS-specific desktop notification call short-circuits.

Flows into the next release. Leaving open — the frozen Releases/v5.0.0/.claude/PAI/PULSE/VoiceServer/voice.ts snapshot isn't patched in this pass. Happy to take a PR for the v5.0.0 frozen-bundle fix if you want to help users still on that install.

(Linux notify-send equivalent and the WSL2 powershell-shim path you mentioned are worth doing eventually but they're a feature, not a fix — separate scope from the ENOENT silencing.)

danielmiessler avatar May 14 '26 17:05 danielmiessler

Following up on the previous comment — going to close this now. The fix is in the next-release source, so the open/shipped state was confusing.

If you're on v5.0.0 right now and want the ENOENT spam silenced immediately, the diff against Releases/v5.0.0/.claude/PAI/PULSE/VoiceServer/voice.ts is:

--- a/PAI/PULSE/VoiceServer/voice.ts
+++ b/PAI/PULSE/VoiceServer/voice.ts
@@ -373,7 +373,9 @@
 // ── macOS Desktop Notification ──

 async function showDesktopNotification(title: string, message: string): Promise<void> {
   if (!voiceConfig.desktopNotifications) return
+  // osascript is macOS-only; on Linux/WSL2 the spawn ENOENT's and floods journal
+  if (process.platform !== "darwin") return

   try {

PR against the v5.0.0 frozen snapshot still welcome. The full notify-send / WSL-powershell-shim work you mentioned is worth doing eventually but it's feature scope, separate from the ENOENT silencing.

danielmiessler avatar May 14 '26 17:05 danielmiessler