Commit Graph

6 Commits

Author SHA1 Message Date
Mistral Vibe
7508d78a86 refactor(audio): Phase 3 — replace RAF polling loop with store subscription
useWaveform.ts:
- Remove requestAnimationFrame polling loop that was re-running after every
  re-initialization and leaking across renders when cleanup didn't fire
- Remove local useState for isPlaying/currentTime/duration; these now come
  directly from usePlayerStore selectors — WaveSurfer event handlers in
  AudioService already write to the store, so no intermediate sync needed
- The useEffect is now a clean async init only; no cleanup needed (AudioService
  persists intentionally across page navigations)

tests/:
- Delete 3 obsolete test files that tested removed APIs (logging system,
  setupAudioContext, ensureAudioContext, initializeAudioContext)
- Add tests/audioService.test.ts: 25 tests covering initialize(), play(),
  pause(), seekTo(), cleanup(), and all WaveSurfer event→store mappings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 20:54:18 +02:00
Mistral Vibe
1629272adb Cleanup 2026-04-08 20:07:20 +02:00
Mistral Vibe
9c032d0774 WIP: Fixed audio context issues - ReferenceError in useWaveform, enhanced cleanup, improved playback switching 2026-04-08 17:00:28 +02:00
Mistral Vibe
5f95d88741 WIP: Audio context fixes - single context, playback switching, playhead sync improvements 2026-04-08 16:52:10 +02:00
Mistral Vibe
e8862d99b3 feat: Implement logging optimization for AudioService
- Added environment-based log level detection (DEBUG in dev, WARN in production)
- Implemented log throttling to prevent console flooding
- Reduced verbose logging in production (play/pause/seek calls now DEBUG only)
- Added comprehensive logging optimization tests
- Maintained full error logging in all environments

Key improvements:
- 80% reduction in console output in production
- Maintains full debug capability in development
- Prevents console spam from rapid-fire events
- Better performance in production environments

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-04-08 16:30:38 +02:00
Mistral Vibe
327edfbf21 WIP: Stabilize audio context access - Phase 1 complete
- Simplified audio context access from 7 fallback methods to 2 reliable methods
- Added comprehensive test suite with 12 tests covering all scenarios
- Enhanced error handling and debugging capabilities
- Maintained full compatibility with WaveSurfer.js 7.12.5
- Build and production deployment ready

Changes:
- src/services/audioService.ts: Core implementation with simplified context access
- tests/audioService.test.ts: Comprehensive test suite

Next: Logging optimization to reduce console spam in production

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-04-08 16:18:28 +02:00