Fix TTS sanitization and message handling bugs

- Add duplicate config validation to backend
- Fix TTS button comparison using original text
- Track original vs sanitized text in TTS context
- Update toast import in message hooks
- Add type safety for error handling
This commit is contained in:
Chris Scott committed 2025-12-18 22:44:07 -05:00
1 parent 698ad7b020
commit 44240f0aab
9 files changed
+23 -10

No files matched your search

+4 -1
View File
@@ -31,6 +31,7 @@ export function TTSProvider({ children }: TTSProviderProps) {
const [state, setState] = useState<TTSState>('idle')
const [error, setError] = useState<string | null>(null)
const [currentText, setCurrentText] = useState<string | null>(null)
const [originalText, setOriginalText] = useState<string | null>(null)
const abortControllerRef = useRef<AbortController | null>(null)
const audioRef = useRef<HTMLAudioElement | null>(null)
@@ -67,6 +68,7 @@ export function TTSProvider({ children }: TTSProviderProps) {
cleanup()
setState('idle')
setCurrentText(null)
setOriginalText(null)
setError(null)
}, [cleanup])
@@ -240,7 +242,7 @@ export function TTSProvider({ children }: TTSProviderProps) {
stoppedRef.current = false
setError(null)
// Store the sanitized text for playback
setOriginalText(text)
setCurrentText(sanitizedText)
abortControllerRef.current = new AbortController()
@@ -257,6 +259,7 @@ export function TTSProvider({ children }: TTSProviderProps) {
state,
error,
currentText,
originalText,
isEnabled,
isPlaying: state === 'playing',
isLoading: state === 'loading',
+1
View File
@@ -8,6 +8,7 @@ export interface TTSContextValue {
state: TTSState
error: string | null
currentText: string | null
originalText: string | null
isEnabled: boolean
isPlaying: boolean
isLoading: boolean