Skip to content

feat: add ambient sound mini-player#15

Open
tskovlund wants to merge 3 commits intomainfrom
feat/ambient-sound
Open

feat: add ambient sound mini-player#15
tskovlund wants to merge 3 commits intomainfrom
feat/ambient-sound

Conversation

@tskovlund
Copy link
Copy Markdown
Owner

Summary

  • Add persistent ambient sound mini-player in the header
  • Four procedurally-generated soundscapes: rain, coffee shop, fireplace, nature (Web Audio API, no files needed)
  • Compact dropdown UI with sound selector, volume slider, play/pause
  • Persists across View Transitions (lives in header with transition:persist)
  • Sound selection and volume saved to localStorage
  • Future PR can replace procedural audio with real MP3 loops

Test plan

  • Click volume icon: dropdown opens with 4 sound options
  • Select a sound: plays procedural audio
  • Volume slider: adjusts volume in real-time
  • Navigate between pages: audio continues uninterrupted
  • Reload page: audio stops (browser policy) but UI shows last selection
  • Click outside dropdown: closes
  • Escape key: closes dropdown
  • Mobile: player accessible in hamburger menu
  • Keyboard navigation works throughout

Closes #8

🤖 Generated with Claude Code

- Create AmbientSound.astro component with Web Audio API synthesis
- Four procedurally-generated soundscapes: rain, coffee shop, fireplace, nature
- Compact dropdown UI with sound selector, volume slider, play/pause
- Persists across View Transitions (lives in header with transition:persist)
- Sound selection and volume saved to localStorage
- Accessible keyboard navigation and ARIA attributes
- Integrated into both desktop and mobile header sections

Closes #8

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 15, 2026 16:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an ambient sound mini-player to the site header that generates looping soundscapes via the Web Audio API and persists UI state (sound + volume) using localStorage, intended to remain present across View Transition navigations (header persists via transition:persist).

Changes:

  • Add new AmbientSound header control with dropdown UI (sound selection, volume, play/pause).
  • Implement procedural audio generation (noise + filters + simple oscillators) and persist selected sound/volume to localStorage.
  • Add English i18n strings for the ambient sound player UI.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/i18n/en.ts Adds ambientSound strings for trigger, sound labels, volume, and play/pause.
src/components/Header.astro Renders the ambient sound control in both desktop and mobile header areas.
src/components/AmbientSound.astro New component providing UI + Web Audio playback logic + persistence.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/AmbientSound.astro
Comment thread src/components/AmbientSound.astro
Comment thread src/components/AmbientSound.astro Outdated
Comment thread src/components/AmbientSound.astro
Comment on lines 71 to 74
/>
</button>
<AmbientSound />
</div>
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

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

<AmbientSound /> is rendered twice (desktop + mobile). With the current implementation using global [data-ambient-*] selectors and a per-instance player, this leads to broken behavior on mobile and/or duplicate event listeners. Consider rendering a single instance and repositioning it responsively, or refactor the component so multiple UIs can safely share one underlying player.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 2368538. Added data-ambient-root wrapper and scoped all DOM queries to the component instance. Created a singleton player shared across both desktop and mobile UIs via window.__ambientSoundPlayer. Both instances now work correctly.

Comment thread src/components/AmbientSound.astro Outdated
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 15, 2026

🔍 Preview deployment ready: https://d7295693.skovlund-dev.pages.dev

- Scope DOM queries to component instance with data-ambient-root to fix
  double-rendering issue (desktop + mobile)
- Create singleton player shared across UI instances using window global
- Resume AudioContext after suspend to fix silent playback bug
- Use i18n strings for Play/Pause button text and aria-label
- Track and cancel fireplace pop scheduler timeout to prevent memory leak
- Auto-play when selecting a sound (typical UX pattern)
- Remove AudioContext suspend on pause (just stop/disconnect nodes)

Fixes all 6 Copilot review comments.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ambient sound mini-player

2 participants