mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-26 05:15:48 +08:00
fix(voice): validate config and request boundaries
Malformed stored settings could break voice requests instead of using safe defaults. Health results could outlive auth changes. URL checks also did not guard the fetch sink. Remove constant recorder branches so lifecycle cancellation stays clear.
This commit is contained in:
@@ -7,13 +7,11 @@ import { VOICE_CONFIG_SYNC_EVENT, voiceConfigHeaders } from '../../../hooks/useV
|
||||
// the Settings modal) and a configured voice backend.
|
||||
const STORAGE_KEY = 'uiPreferences';
|
||||
const SYNC_EVENT = 'ui-preferences:sync';
|
||||
const healthCache = new Map<string, boolean>();
|
||||
const healthRequests = new Map<string, Promise<boolean>>();
|
||||
|
||||
function checkVoiceHealth(): Promise<boolean> {
|
||||
const baseUrl = voiceConfigHeaders()['x-voice-base-url'];
|
||||
const signature = baseUrl || '';
|
||||
if (healthCache.has(signature)) return Promise.resolve(healthCache.get(signature) ?? false);
|
||||
const pending = healthRequests.get(signature);
|
||||
if (pending) return pending;
|
||||
const request = authenticatedFetch('/api/voice/health', {
|
||||
@@ -24,10 +22,6 @@ function checkVoiceHealth(): Promise<boolean> {
|
||||
const data = await response.json();
|
||||
return data?.configured === true;
|
||||
})
|
||||
.then((available) => {
|
||||
healthCache.set(signature, available);
|
||||
return available;
|
||||
})
|
||||
.finally(() => {
|
||||
healthRequests.delete(signature);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user