From c9208cfff2c55a2b5ef888844ac965305a702d83 Mon Sep 17 00:00:00 2001 From: Gigi Date: Wed, 22 Oct 2025 01:26:42 +0200 Subject: [PATCH] chore: remove all debug console logs - Remove console.log from bookmark hydration - Remove console.log from relay initialization - Remove all console.debug calls from TTS hook and controls - Remove debug logging from RouteDebug component - Fix useCallback dependency warning in speak function --- src/App.tsx | 2 -- src/components/RouteDebug.tsx | 2 +- src/components/TTSControls.tsx | 3 +-- src/hooks/useTextToSpeech.ts | 34 +++++++----------------------- src/services/bookmarkController.ts | 2 -- 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 992708f9..c6c0050f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -578,8 +578,6 @@ function App() { // Handle user relay list and blocked relays when account changes const userRelaysSub = accounts.active$.subscribe((account) => { - console.log('[relay-init] userRelaysSub fired, account:', account ? 'logged in' : 'logged out') - console.log('[relay-init] Pool has', Array.from(pool.relays.keys()).length, 'relays before applying changes') if (account) { // User logged in - start with hardcoded relays immediately, then stream user relay list updates const pubkey = account.pubkey diff --git a/src/components/RouteDebug.tsx b/src/components/RouteDebug.tsx index 4a6eb522..dd0b3a40 100644 --- a/src/components/RouteDebug.tsx +++ b/src/components/RouteDebug.tsx @@ -20,7 +20,7 @@ export default function RouteDebug() { // Unexpected during deep-link refresh tests console.warn('[RouteDebug] unexpected root redirect', info) } else { - console.debug('[RouteDebug]', info) + // silent } }, [location, matchArticle]) diff --git a/src/components/TTSControls.tsx b/src/components/TTSControls.tsx index c0921b62..83895f42 100644 --- a/src/components/TTSControls.tsx +++ b/src/components/TTSControls.tsx @@ -60,7 +60,7 @@ const TTSControls: React.FC = ({ text, defaultLang, className, settings } const lang = detect(text) if (typeof lang === 'string' && lang.length >= 2) langOverride = lang.slice(0, 2) } catch (err) { - console.debug('[tts][detect] failed', err) + // ignore detection errors } } if (!langOverride && resolvedSystemLang) { @@ -78,7 +78,6 @@ const TTSControls: React.FC = ({ text, defaultLang, className, settings } const currentIndex = SPEED_OPTIONS.indexOf(rate) const nextIndex = (currentIndex + 1) % SPEED_OPTIONS.length const next = SPEED_OPTIONS[nextIndex] - console.debug('[tts][ui] cycle speed', { from: rate, to: next, speaking, paused }) setRate(next) } diff --git a/src/hooks/useTextToSpeech.ts b/src/hooks/useTextToSpeech.ts index 2c87ae6f..595c852c 100644 --- a/src/hooks/useTextToSpeech.ts +++ b/src/hooks/useTextToSpeech.ts @@ -59,7 +59,6 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { // Update rate when defaultRate option changes useEffect(() => { if (options.defaultRate !== undefined) { - console.debug('[tts] defaultRate changed ->', options.defaultRate) setRate(options.defaultRate) } }, [options.defaultRate]) @@ -73,7 +72,6 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { if (!voice && v.length) { const byLang = v.find(x => x.lang?.toLowerCase().startsWith(defaultLang.toLowerCase())) setVoice(byLang || v[0] || null) - console.debug('[tts] voices loaded', { total: v.length, picked: (byLang || v[0] || null)?.lang }) } } load() @@ -107,44 +105,37 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { u.onstart = () => { if (utteranceRef.current !== self) return - console.debug('[tts] onstart') setSpeaking(true) setPaused(false) } u.onpause = () => { if (utteranceRef.current !== self) return - console.debug('[tts] onpause') setPaused(true) } u.onresume = () => { if (utteranceRef.current !== self) return - console.debug('[tts] onresume') setPaused(false) } u.onend = () => { if (utteranceRef.current !== self) return - console.debug('[tts] onend') // Continue with next chunk if available const hasMore = chunkIndexRef.current < (chunksRef.current.length - 1) if (hasMore) { - chunkIndexRef.current += 1 - globalOffsetRef.current += self.text.length - const next = chunksRef.current[chunkIndexRef.current] || '' - const nextUtterance = createUtterance(next, langRef.current) + chunkIndexRef.current++ + charIndexRef.current += self.text.length + const nextChunk = chunksRef.current[chunkIndexRef.current] + const nextUtterance = createUtterance(nextChunk, langRef.current) utteranceRef.current = nextUtterance synth!.speak(nextUtterance) - return + } else { + setSpeaking(false) + setPaused(false) } - setSpeaking(false) - setPaused(false) - utteranceRef.current = null } u.onerror = () => { if (utteranceRef.current !== self) return - console.debug('[tts] onerror') setSpeaking(false) setPaused(false) - utteranceRef.current = null } u.onboundary = (ev: SpeechSynthesisEvent) => { if (utteranceRef.current !== self) return @@ -197,7 +188,6 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { const stop = useCallback(() => { if (!supported) return - console.debug('[tts] stop') synth!.cancel() setSpeaking(false) setPaused(false) @@ -211,18 +201,16 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { const speak = useCallback((text: string, langOverride?: string) => { if (!supported || !text?.trim()) return - console.debug('[tts] speak', { len: text.length, rate }) synth!.cancel() spokenTextRef.current = text charIndexRef.current = 0 langRef.current = langOverride startSpeakingChunks(text) - }, [supported, synth, startSpeakingChunks, rate]) + }, [supported, synth, startSpeakingChunks]) const pause = useCallback(() => { if (!supported) return if (synth!.speaking && !synth!.paused) { - console.debug('[tts] pause') synth!.pause() setPaused(true) } @@ -231,7 +219,6 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { const resume = useCallback(() => { if (!supported) return if (synth!.speaking && synth!.paused) { - console.debug('[tts] resume') synth!.resume() setPaused(false) } @@ -242,14 +229,11 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { if (!supported) return if (!utteranceRef.current) return - console.debug('[tts] rate change', { rate, speaking: synth!.speaking, paused: synth!.paused, charIndex: charIndexRef.current }) - if (synth!.speaking && !synth!.paused) { const fullText = spokenTextRef.current const startIndex = Math.max(0, Math.min(charIndexRef.current, fullText.length)) const remainingText = fullText.slice(startIndex) - console.debug('[tts] restart at new rate', { startIndex, remainingLen: remainingText.length }) synth!.cancel() // restart chunked from current global index spokenTextRef.current = remainingText @@ -273,7 +257,6 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { const fullText = spokenTextRef.current const startIndex = Math.max(0, Math.min(charIndexRef.current, fullText.length - 1)) const remainingText = fullText.slice(startIndex) - console.debug('[tts] updateRate -> restart', { newRate, startIndex, remainingLen: remainingText.length }) synth!.cancel() const u = createUtterance(remainingText) // ensure the new rate is applied immediately on the new utterance @@ -281,7 +264,6 @@ export function useTextToSpeech(options: UseTTSOptions = {}): UseTTS { utteranceRef.current = u synth!.speak(u) } else if (utteranceRef.current) { - console.debug('[tts] updateRate -> set on utterance', { newRate }) utteranceRef.current.rate = newRate } }, [supported, synth, createUtterance]) diff --git a/src/services/bookmarkController.ts b/src/services/bookmarkController.ts index aa6e6d08..2126856e 100644 --- a/src/services/bookmarkController.ts +++ b/src/services/bookmarkController.ts @@ -279,8 +279,6 @@ class BookmarkController { } }) - console.log(`📋 Requesting hydration for: ${noteIds.length} note IDs, ${coordinates.length} coordinates`) - // Helper to build and emit bookmarks const emitBookmarks = (idToEvent: Map) => { // Now hydrate the ORIGINAL items (which may have duplicates), using the deduplicated results