ADR-026: Client-Side Logging + linting fixes
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Has been cancelled

This commit is contained in:
2026-01-09 17:58:21 -08:00
parent 9ffcc9d65d
commit 25d6b76f6d
24 changed files with 242 additions and 195 deletions

View File

@@ -15,47 +15,43 @@ export const VoiceLabPage: React.FC = () => {
const [audioPlayer, setAudioPlayer] = useState<HTMLAudioElement | null>(null);
// Debug log for rendering
console.log(
'[VoiceLabPage RENDER] audioPlayer state is:',
audioPlayer ? 'Present (Object)' : 'Null',
);
logger.debug({ hasAudioPlayer: !!audioPlayer }, '[VoiceLabPage] Render');
const handleGenerateSpeech = async () => {
console.log('[VoiceLabPage] handleGenerateSpeech triggered');
logger.debug('[VoiceLabPage] handleGenerateSpeech triggered');
if (!textToSpeak.trim()) {
notifyError('Please enter some text to generate speech.');
return;
}
setIsGeneratingSpeech(true);
try {
console.log('[VoiceLabPage] Calling generateSpeechFromText...');
logger.debug('[VoiceLabPage] Calling generateSpeechFromText');
const response = await generateSpeechFromText(textToSpeak);
const base64Audio = await response.json(); // Extract the base64 audio string from the response
console.log('[VoiceLabPage] Response JSON received. Length:', base64Audio?.length);
logger.debug({ audioLength: base64Audio?.length }, '[VoiceLabPage] Response JSON received');
if (base64Audio) {
const audioSrc = `data:audio/mpeg;base64,${base64Audio}`;
console.log('[VoiceLabPage] creating new Audio()');
logger.debug('[VoiceLabPage] Creating new Audio()');
const audio = new Audio(audioSrc);
console.log('[VoiceLabPage] Audio created:', audio);
logger.debug('[VoiceLabPage] Audio created');
console.log('[VoiceLabPage] calling setAudioPlayer...');
logger.debug('[VoiceLabPage] Calling setAudioPlayer');
setAudioPlayer(audio);
console.log('[VoiceLabPage] calling audio.play()...');
logger.debug('[VoiceLabPage] Calling audio.play()');
await audio.play();
console.log('[VoiceLabPage] audio.play() resolved');
logger.debug('[VoiceLabPage] audio.play() resolved');
} else {
console.warn('[VoiceLabPage] base64Audio was falsy');
logger.warn('[VoiceLabPage] base64Audio was falsy');
notifyError('The AI did not return any audio data.');
}
} catch (error) {
console.error('[VoiceLabPage] Error caught:', error);
logger.error({ err: error }, '[VoiceLabPage] Failed to generate speech');
const errorMessage = error instanceof Error ? error.message : 'An unknown error occurred.';
logger.error({ err: error }, 'Failed to generate speech:');
notifyError(`Speech generation failed: ${errorMessage}`);
} finally {
console.log('[VoiceLabPage] finally block - setting isGeneratingSpeech false');
logger.debug('[VoiceLabPage] finally block - setting isGeneratingSpeech false');
setIsGeneratingSpeech(false);
}
};