fix(web): play completion sounds without delay #29146
MergedYash-Singh1(GitHub profile, opens in a new tab)merged 3 commits into
main fromrefs/pull/29146/headmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/web/src/threadNotifications.ts lines 109 to 112Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -88,4 +90,21 @@90+ if (!buffer) {91+ buffer = fetch(url)92+ .then((response) => response.arrayBuffer())93+ .then((data) => context.decodeAudioData(data))94+ .catch((error: unknown) => {95+ buffers.delete(url);96+ throw error;97+ });98+ buffers.set(url, buffer);99+ }100+ return buffer;101+}102+88103 /** Called from a gesture so browsers allow later background playback. */89104 export function unlockNotificationAudio() {90105 audioContext ??= new AudioContext();91106 void audioContext.resume().catch(() => undefined);107+ // Fetch and decode during interaction so the first alert is ready when the thread finishes.108+ for (const url of [completionUrl, inputUrl]) {109+ void loadNotificationBuffer(audioContext, url).catch(() => undefined);110+ }
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Yash-Singh1(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed