Files
vibe-kanban/crates/local-deployment
Louis Knight-Webb 21d175bccc Play notification sound when approval needed (vibe-kanban) (#1463)
* The implementation is complete. Here's a summary of the changes:

## Summary

Added notification sound when approval is needed, using the same notification system as task finalization.

**Files modified:**

1. **`crates/services/src/services/approvals/executor_approvals.rs`**
   - Added `config: Arc<RwLock<Config>>` field to `ExecutorApprovalBridge`
   - Added imports for `Config`, `NotificationService`, and `RwLock`
   - Added notification call in `request_tool_approval()` after creating the approval request

2. **`crates/local-deployment/src/container.rs`**
   - Passed `self.config.clone()` to `ExecutorApprovalBridge::new()`

When an approval is requested, the notification will display:
- **Title:** "Approval Needed"
- **Message:** "Tool '{tool_name}' requires approval"

The notification uses the user's configured sound file and respects their notification settings (sound enabled/disabled, push enabled/disabled).

* Cleanup script changes for task attempt af6bac2d-a3ba-4c6a-ae35-3a54bd05212f

* Done! Here's a summary of the refactored implementation:

## Summary

Refactored `NotificationService` to hold config internally and added approval notification sound:

**Files modified:**

1. **`crates/services/src/services/notification.rs`**
   - Added `config: Arc<RwLock<Config>>` field
   - Added `new(config)` constructor
   - Changed `notify` and `notify_execution_halted` from static to instance methods
   - Added internal `send_notification` helper method

2. **`crates/services/src/services/container.rs`**
   - Updated `finalize_task` trait method to accept `&NotificationService` instead of `&Arc<RwLock<Config>>`
   - Removed unused `Config` import

3. **`crates/local-deployment/src/container.rs`**
   - Added `notification_service: NotificationService` field to `LocalContainerService`
   - Initialize service in `new()` with config
   - Updated all `finalize_task` calls to pass `&self.notification_service`
   - Updated `ExecutorApprovalBridge::new()` to pass `notification_service`

4. **`crates/services/src/services/approvals/executor_approvals.rs`**
   - Replaced `config: Arc<RwLock<Config>>` with `notification_service: NotificationService`
   - Updated constructor and notification call to use the service

The notification uses the user's configured sound and settings, and triggers when a tool requires approval.

* Cleanup script changes for task attempt af6bac2d-a3ba-4c6a-ae35-3a54bd05212f

* Done! The refactoring is complete. Here's a summary:

## Summary

Refactored `NotificationService` to be accessed via the `ContainerService` trait, making it cleaner:

**Changes made:**

1. **`crates/services/src/services/container.rs`**
   - Added `fn notification_service(&self) -> &NotificationService` to the trait
   - Simplified `finalize_task` signature to `(&self, share_publisher, ctx)` - removed the notification_service parameter
   - `finalize_task` now calls `self.notification_service().notify_execution_halted(ctx)`

2. **`crates/local-deployment/src/container.rs`**
   - Implemented `fn notification_service(&self) -> &NotificationService` returning `&self.notification_service`
   - Updated all 4 `finalize_task` call sites to use the simplified signature

The notification service is now a first-class member of the `ContainerService` trait, following the same pattern as `db()`, `git()`, and `share_publisher()`.

* Cleanup script changes for task attempt af6bac2d-a3ba-4c6a-ae35-3a54bd05212f

* Done! Here's a summary of all the changes:

## Final Summary

**Feature implemented:** Play notification sound when approval is needed.

**Files modified:**

1. **`crates/services/src/services/notification.rs`**
   - Added `config: Arc<RwLock<Config>>` field and `new()` constructor
   - Removed `notify_execution_halted` method (moved application logic out)
   - Kept only generic `notify(title, message)` method

2. **`crates/services/src/services/container.rs`**
   - Added `fn notification_service(&self) -> &NotificationService` to trait
   - Moved notification logic into `finalize_task`:
     - Skip notification if process was killed
     - Build title/message based on execution status
     - Call `self.notification_service().notify(...)`

3. **`crates/local-deployment/src/container.rs`**
   - Added `notification_service: NotificationService` field
   - Implemented `notification_service()` accessor
   - Simplified `finalize_task` calls (removed notification_service parameter)
   - Pass `notification_service.clone()` to `ExecutorApprovalBridge`

4. **`crates/services/src/services/approvals/executor_approvals.rs`**
   - Added `notification_service: NotificationService` field
   - Calls `self.notification_service.notify("Approval Needed", ...)` when approval is requested

The `NotificationService` is now a clean, reusable service that only handles notifications without any application-specific logic.

* Cleanup script changes for task attempt af6bac2d-a3ba-4c6a-ae35-3a54bd05212f
2025-12-09 09:57:42 +00:00
..