fix: prevent double notification sound playback#11283
Open
hannesrudolph wants to merge 1 commit intomainfrom
Open
fix: prevent double notification sound playback#11283hannesrudolph wants to merge 1 commit intomainfrom
hannesrudolph wants to merge 1 commit intomainfrom
Conversation
Contributor
Review complete -- no issues found. The Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
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
Notification sounds sometimes play twice, with the second starting milliseconds after the first. This is caused by React
<StrictMode>inwebview-ui/src/index.tsxwhich intentionally double-fires effects in development builds. The sound-triggeringuseDeepCompareEffectinChatView.tsxhas no cleanup function, so StrictMode's mount → cleanup → mount cycle plays the sound twice. Sinceuse-sound(Howler.js) defaults tointerrupt: false, both audio instances play concurrently.Root Cause Analysis
Fix
Two layers of protection:
interrupt: trueon alluseSoundhooks — Tells Howler.js to stop any playing instance before starting a new one, preventing overlapping audio regardless of causeplaySound()— Tracks last-played timestamp per audio type, skips calls within 100ms window. Directly neutralizes StrictMode's double-fireTesting
ChatView.notification-sound.spec.tsx:Files Changed
webview-ui/src/components/chat/ChatView.tsxwebview-ui/src/components/chat/__tests__/ChatView.notification-sound.spec.tsxImportant
Fix double notification sound playback by setting
interrupt: trueforuseSoundhooks and adding a debounce mechanism inChatView.tsx.interrupt: trueforuseSoundhooks inChatView.tsxto prevent overlapping audio.playSound()to skip sound playback within 100ms window.ChatView.notification-sound.spec.tsxto verify sound is not played twice within 100ms and is played after 100ms.ChatView.tsxChatView.notification-sound.spec.tsxThis description was created by
for 7b2b6ca. You can customize this summary. It will automatically update as commits are pushed.