diff --git a/web/zebra-spaces.html b/web/zebra-spaces.html index cee1daa..131aca5 100644 --- a/web/zebra-spaces.html +++ b/web/zebra-spaces.html @@ -1637,23 +1637,24 @@ try { if (localStorage.getItem(TRANSCRIBE_KEY) === '1') transcribeEnabled = true $('btn-vault').addEventListener('click', () => $('vault-panel').classList.toggle('hidden')); $('btn-transcribe').addEventListener('click', () => toggleTranscribe().catch(e => logLine('err','transcribe toggle: '+e.message))); -/* If transcribe was on at the previous session, restore the state - * now (UI label, transcript-log visibility, worker pre-warm). - * Captures attach lazily as remote speakers arrive and self capture - * fires when micStream is available — both paths already check the - * transcribeEnabled flag. */ +/* If transcribe was on at the previous session, restore the state. + * Deferred via setTimeout so the rest of the script (including + * whisperWorker, listenerAudioNodes, audioCtx, micStream and the + * Whisper helper functions further down) has finished initializing + * — otherwise the restore body trips TDZ on those `let`/`const`s. + * Fox 2026-06-05: "can't access lexical declaration 'whisperWorker' + * before initialization." */ if (transcribeEnabled){ - /* call setTranscribe with the SAME value but force-apply UI + spin - * the worker. The function's "same-state" branch refreshes UI and - * returns without flipping the flag. */ - applyTranscribeUI(); - ensureWhisperWorker(); - /* If captures need to be installed (e.g. listenerAudioNodes - * populated before this code ran), kick them off. */ - for (const [uuid] of listenerAudioNodes){ - startCaptureForUuid(uuid).catch(()=>{}); - } - startSelfCapture().catch(()=>{}); + setTimeout(() => { + try { + applyTranscribeUI(); + ensureWhisperWorker(); + for (const [uuid] of listenerAudioNodes){ + startCaptureForUuid(uuid).catch(()=>{}); + } + startSelfCapture().catch(()=>{}); + } catch(e){ logLine('err', 'transcribe restore: '+e.message); } + }, 0); } /* log out — destructive: wipes Ed25519 + handle from localStorage and @@ -7426,8 +7427,8 @@ logLine('', 'ready — pick a handle, type a rendezvous code, enter the space');