fix(tts): let voice mode read replies aloud on iOS

iOS rejects play() outside a user gesture unless the same media element was
already played inside one. Each chunk used a new Audio element, so replies in
voice mode failed with "Reading the reply failed".

- reuse one audio element for all external TTS playback
- add tts.unlock(), which plays a short silent clip on that element, and call
  it from the voice mode start and orb taps
- route every playback failure through failPlayback(message) and pass the
  message to onEnd so voice mode shows the underlying reason
- report a blocked play() as "Audio playback was blocked by the browser"
This commit is contained in:
Chris Scott committed 2026-10-23 14:08:33 -04:00
1 parent 10190940bd
commit 67cfd862b1
8 files changed
+354 -190

No files matched your search

@@ -48,6 +48,7 @@ vi.mock('@/hooks/useTTS', () => ({
useTTS: () => ({
speakMessage: vi.fn(),
stop: vi.fn(),
unlock: vi.fn(),
isEnabled: false,
isPlaying: false,
isLoading: false,
@@ -15,6 +15,7 @@ const mocks = vi.hoisted(() => ({
const tts = {
speakMessage: vi.fn(),
stop: vi.fn(),
unlock: vi.fn(),
isEnabled: true,
isPlaying: false,
isLoading: false,
@@ -76,6 +76,7 @@ function mockHooks(preferences: UserPreferences = buildPreferences()) {
stop: vi.fn(),
pause: vi.fn(),
resume: vi.fn(),
unlock: vi.fn(),
state: 'idle',
error: null,
currentText: null,