From f4bfbd69c8557f4c3fc903714c33b0b0b8fcbf08 Mon Sep 17 00:00:00 2001 From: Solomon Date: Mon, 30 Jun 2025 13:24:21 +0100 Subject: [PATCH] Support windows sound notification (#17) * review-feedback: log current-directory fetching errors * review-feedback: document intential fire-and-forget of sound notifications * review-feedback: better PowerShell command pattern: using -Command with $args[0] parameter passing instead of string interpolation. * sync-version --- backend/src/execution_monitor.rs | 18 +++++++++--------- package.json | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/src/execution_monitor.rs b/backend/src/execution_monitor.rs index 0aaff304..37a9b1fd 100644 --- a/backend/src/execution_monitor.rs +++ b/backend/src/execution_monitor.rs @@ -73,6 +73,7 @@ async fn commit_execution_changes( /// Play a system sound notification async fn play_sound_notification(sound_file: &crate::models::config::SoundFile) { // Use platform-specific sound notification + // Note: spawn() calls are intentionally not awaited - sound notifications should be fire-and-forget if cfg!(target_os = "macos") { let sound_path = sound_file.to_path(); let _ = tokio::process::Command::new("afplay") @@ -102,18 +103,17 @@ async fn play_sound_notification(sound_file: &crate::models::config::SoundFile) } } else if cfg!(target_os = "windows") { let sound_path = sound_file.to_path(); - let absolute_path = std::env::current_dir() - .unwrap_or_else(|_| std::path::PathBuf::from(".")) - .join(&sound_path); + let current_dir = std::env::current_dir().unwrap_or_else(|e| { + tracing::error!("Failed to get current directory: {}", e); + std::path::PathBuf::from(".") + }); + let absolute_path = current_dir.join(&sound_path); if absolute_path.exists() { - let path_str = absolute_path.to_string_lossy().to_string(); let _ = tokio::process::Command::new("powershell") - .arg("-c") - .arg(format!( - r#"(New-Object Media.SoundPlayer "{}").PlaySync()"#, - path_str - )) + .arg("-Command") + .arg("(New-Object Media.SoundPlayer $args[0]).PlaySync()") + .arg(absolute_path.to_string_lossy().as_ref()) .spawn(); } else { // Fallback to system beep if sound file doesn't exist diff --git a/package.json b/package.json index 68efa600..098be6e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vibe-kanban", - "version": "0.0.24", + "version": "0.0.25", "private": true, "scripts": { "dev": "concurrently \"cargo watch -w backend -x 'run --manifest-path backend/Cargo.toml'\" \"npm run frontend:dev\"", @@ -25,4 +25,4 @@ "node": ">=18", "pnpm": ">=8" } -} \ No newline at end of file +}