Skip to content

Commit 5eb0951

Browse files
committed
Skip default completion sound when playback is disabled
- treat only `src: null` as an explicit no-play signal - add test to ensure disabled playback does not trigger default audio
1 parent 8d35f56 commit 5eb0951

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

apps/web/src/agentCompletionNotifications.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,27 @@ describe("agent completion notifications", () => {
416416
}),
417417
).resolves.toBeNull();
418418
});
419+
420+
it("does not play the default sound when configured playback is disabled", async () => {
421+
const playMock = vi.fn(async () => undefined);
422+
423+
class FakeAudio {
424+
currentTime = 0;
425+
preload = "";
426+
play = playMock;
427+
constructor(public readonly src: string) {}
428+
}
429+
430+
vi.stubGlobal("Audio", FakeAudio);
431+
432+
const { playConfiguredCompletionSound } = await import("./agentCompletionNotifications");
433+
434+
await playConfiguredCompletionSound({
435+
enableCompletionSound: false,
436+
notificationSoundSelection: "default",
437+
notificationCustomSoundId: "",
438+
});
439+
440+
expect(playMock).not.toHaveBeenCalled();
441+
});
419442
});

apps/web/src/agentCompletionNotifications.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ export function collectNewlySettledTurns(
270270

271271
export async function playCompletionSound(options: PlayCompletionSoundOptions = {}): Promise<void> {
272272
try {
273-
const src = options.src ?? "/sounds/agent-finished.mp3";
274-
if (!src) {
273+
if (options.src === null) {
275274
return;
276275
}
276+
const src = options.src ?? "/sounds/agent-finished.mp3";
277277
if (!completionSound || completionSoundSrc !== src) {
278278
completionSound = createCompletionSound(src);
279279
completionSoundSrc = src;

0 commit comments

Comments
 (0)