Skip to content

feat: switch notification playback to Web Audio API to avoid macOS media session#442

Merged
Dimillian merged 4 commits intomainfrom
codex/github-mention-notification-sounds-register-app-in-macos-no
Feb 16, 2026
Merged

feat: switch notification playback to Web Audio API to avoid macOS media session#442
Dimillian merged 4 commits intomainfrom
codex/github-mention-notification-sounds-register-app-in-macos-no

Conversation

@Dimillian
Copy link
Owner

Motivation

  • Playing notification sounds with new Audio(...).play() registered the app with macOS Now Playing / Media Control Center and could cause device focus switching; the change removes that behavior by using the Web Audio API.

Description

  • Replace use of HTMLAudioElement in src/utils/notificationSounds.ts with a Web Audio API implementation that fetches, decodes, and plays an AudioBuffer via a BufferSource and GainNode at low gain.
  • Add lazy AudioContext resolution/reuse with support for AudioContext and legacy webkitAudioContext, and call resume() when the context is suspended before playback.
  • Preserve and consolidate debug logging for initialization/load/play failures and update error labels to audio/<label> load/play error.
  • Add a focused unit test suite src/utils/notificationSounds.test.ts (jsdom environment) covering successful playback, fetch failure debug logging, and suspended-context resume behavior, and replace global usage with globalThis where needed for typecheck compatibility.

Testing

  • Ran the focused tests with npm run test -- src/utils/notificationSounds.test.ts, which passed (3 tests passed).
  • Ran npm run typecheck and the full test suite with npm run test, and the typecheck and full suite completed successfully (typecheck passed and all tests passed).
  • Addressed an initial test failure caused by a missing jsdom environment by adding // @vitest-environment jsdom to the new test file, after which the tests passed.

Codex Task

@Dimillian Dimillian changed the title Switch notification playback to Web Audio API to avoid macOS media session feat: switch notification playback to Web Audio API to avoid macOS media session Feb 15, 2026
@Dimillian
Copy link
Owner Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78bdf33e28

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Dimillian Dimillian merged commit d77ab4b into main Feb 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant