Repository navigation
Fix focused notification sound playback - #1855
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughNotification sound playback now retains NSSound instances until playback completes, centralizes selected vs preview playback, and routes suppressed external-delivery notifications to a feedback handler that runs the selected sound and optional custom command. Test hooks were added to exercise suppressed-feedback behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant Store as TerminalNotificationStore
participant Defaults as UserDefaults / NotificationSoundSettings
participant Sound as NSSound (system)
participant Cmd as Shell / Custom Command
Note over Store,Defaults: Notification arrives for terminal
Store->>Store: determine shouldSuppressExternalDelivery
alt suppressed
Store->>Store: resolvedNotificationTitle(for:)
Store->>Defaults: request selected sound / command
Defaults->>Sound: playSelectedSound (via playSound)
Sound-->>Store: playback finished (delegate)
Store->>Cmd: run configured custom command (with resolved title)
else deliver externally
Store->>SystemNotificationCenter: schedule user notification
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes two related bugs in focused-terminal notification handling: (1) it corrects a logical inversion ( Key changes:
Concern: Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant T as Terminal
participant NS as TerminalNotificationStore
participant AF as AppFocusState
participant SFH as suppressedFeedbackHandler
participant NDH as notificationDeliveryHandler
participant NSS as NotificationSoundSettings
participant UN as UNNotificationCenter
T->>NS: addNotification(tabId, surfaceId, ...)
NS->>AF: isAppFocused() + isFocusedPanel?
AF-->>NS: shouldSuppressExternalDelivery
alt shouldSuppressExternalDelivery == true (app focused on that terminal)
NS->>SFH: suppressedNotificationFeedbackHandler(store, notification)
SFH->>NSS: playSelectedSound()
NSS->>NSS: playSound(value, defaults)
Note over NSS: retainActivePlaybackSound(sound)<br/>sound.delegate = activePlaybackSoundDelegate<br/>sound.play()
Note right of SFH: ⚠️ runCustomCommand NOT called here
else shouldSuppressExternalDelivery == false
NS->>NDH: notificationDeliveryHandler(store, notification)
NDH->>NS: scheduleUserNotification(notification)
NS->>UN: center.add(request)
UN-->>NS: success callback
NS->>NSS: runCustomCommand(title, subtitle, body)
end
Last reviewed commit: "fix: play notificati..." |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
cmuxTests/NotificationAndMenuBarTests.swift (1)
448-450: Optional: tighten assertion to verify exact notification identity.You currently assert count-only for local feedback. Consider asserting the callback carries the same notification ID produced by
addNotificationto make the test more precise.Possible assertion strengthening
XCTAssertTrue(store.hasUnreadNotification(forTabId: workspace.id, surfaceId: terminalPanel.id)) XCTAssertTrue(deliveredNotificationIDs.isEmpty) XCTAssertEqual(localFeedbackNotificationIDs.count, 1) + if let createdId = store.notifications.first?.id { + XCTAssertEqual(localFeedbackNotificationIDs, [createdId]) + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cmuxTests/NotificationAndMenuBarTests.swift` around lines 448 - 450, The test should assert the exact notification identity instead of only count: capture the notification ID returned by addNotification (or the variable that holds it) and assert that localFeedbackNotificationIDs contains exactly that ID (or equals an array with that single ID), while keeping the existing assertions for unread state and deliveredNotificationIDs; refer to addNotification, localFeedbackNotificationIDs, deliveredNotificationIDs, and store.hasUnreadNotification (with workspace.id and terminalPanel.id) to locate and update the assertions.Sources/TerminalNotificationStore.swift (1)
1090-1093: Small readability tweak: drop the placeholder assignment.You can make the unused parameter explicit in the signature and remove
_ = notification.Suggested cleanup
- private func playSuppressedNotificationFeedback(for notification: TerminalNotification) { - _ = notification + private func playSuppressedNotificationFeedback(for _: TerminalNotification) { NotificationSoundSettings.playSelectedSound() }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Sources/TerminalNotificationStore.swift` around lines 1090 - 1093, The assignment `_ = notification` is a placeholder; remove it and mark the parameter as intentionally unused in the function signature of playSuppressedNotificationFeedback(for:) by replacing the named parameter with an unnamed/ignored parameter (e.g., use `_` for the parameter) so the body simply calls NotificationSoundSettings.playSelectedSound() without the redundant assignment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cmuxTests/NotificationAndMenuBarTests.swift`:
- Around line 448-450: The test should assert the exact notification identity
instead of only count: capture the notification ID returned by addNotification
(or the variable that holds it) and assert that localFeedbackNotificationIDs
contains exactly that ID (or equals an array with that single ID), while keeping
the existing assertions for unread state and deliveredNotificationIDs; refer to
addNotification, localFeedbackNotificationIDs, deliveredNotificationIDs, and
store.hasUnreadNotification (with workspace.id and terminalPanel.id) to locate
and update the assertions.
In `@Sources/TerminalNotificationStore.swift`:
- Around line 1090-1093: The assignment `_ = notification` is a placeholder;
remove it and mark the parameter as intentionally unused in the function
signature of playSuppressedNotificationFeedback(for:) by replacing the named
parameter with an unnamed/ignored parameter (e.g., use `_` for the parameter) so
the body simply calls NotificationSoundSettings.playSelectedSound() without the
redundant assignment.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 804668e9-9875-4170-bfcf-ad4879338b2d
📒 Files selected for processing (2)
Sources/TerminalNotificationStore.swiftcmuxTests/NotificationAndMenuBarTests.swift
Summary
NSSoundinstances during playback so focused custom sounds stay reliableTesting
xcodebuild -project GhosttyTabs.xcodeproj -scheme cmux-unit -destination 'platform=macOS' -derivedDataPath /tmp/cmux-task-custom-sound-notification-reliability-tests test -only-testing:cmuxTests/NotificationDockBadgeTests/testFocusedTerminalNotificationStillRunsLocalSoundFeedbackWhenExternalDeliveryIsSuppressed(red on commit3f1e9bfb, green on commitdc00cf3c)xcodebuild -project GhosttyTabs.xcodeproj -scheme cmux-unit -destination 'platform=macOS' -derivedDataPath /tmp/cmux-task-custom-sound-notification-reliability-tests test -only-testing:cmuxTests/NotificationDockBadgeTestsIssues
/Users/lawrence/Documents/dune-scream.mp3Summary by cubic
Fixes focused notification feedback by playing the selected sound locally and running the custom command when external delivery is suppressed. Also improves custom sound reliability by retaining
NSSoundduring playback.NSSoundinstances and release via delegate after playback to prevent early deallocation and missed sounds.Written for commit 56c031f. Summary will update on new commits.
Summary by CodeRabbit