Files
opencode-manager/frontend/src/contexts/tts-context.ts
T
Chris Scott 9319579150 fix(frontend): queue TTS auto-play per step instead of cutting each off
The auto-play hook returned early whenever the last assistant message was
still streaming, before it could record that a reply had started, so the
first reply in a fresh session was never spoken. Remove that input and rely
on the message's own completion state.

Auto-play now speaks every completed assistant step and queues steps that
arrive during playback, resuming after a short pause, rather than
interrupting the audio in progress. Manual playback and stop still interrupt
and clear the queue.
2026-10-22 00:08:11 -04:00

33 lines
860 B
TypeScript

import { createContext } from 'react'
export type TTSState = 'idle' | 'loading' | 'playing' | 'error'
export interface TTSConfig {
enabled: boolean
provider: 'external' | 'builtin'
endpoint: string
apiKey: string
voice: string
model: string
speed: number
}
export interface TTSContextValue {
speak: (text: string) => Promise<boolean>
speakWithConfig: (text: string, config: TTSConfig) => Promise<boolean>
speakMessage: (messageId: string, text: string) => Promise<boolean>
queueMessage: (messageId: string, text: string) => void
stop: () => void
state: TTSState
error: string | null
currentText: string | null
originalText: string | null
activeMessageId: string | null
isEnabled: boolean
isPlaying: boolean
isLoading: boolean
isIdle: boolean
}
export const TTSContext = createContext<TTSContextValue | null>(null)