From cdf3c7ca2499a94dd1b1e49e7b2bdd94d8fc2fb5 Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Wed, 3 Jun 2026 17:50:04 -0400 Subject: [PATCH] debug(tts): log attachSentenceGlow path to diagnose missing manual highlights Temporary instrumentation to pinpoint why sentence highlighting fails on manual Play. Logs whether audio/button are present, whether sentences is the expected array, the post-wrap span count, and the wrap-flag state. Will revert once root cause is found. --- templates/chat.html | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/templates/chat.html b/templates/chat.html index e6304c6..b64cc43 100644 --- a/templates/chat.html +++ b/templates/chat.html @@ -1039,17 +1039,29 @@ function wrapSentencesForGlow(container) { // array from the speech service: [{index, text, start_ms, end_ms}, ...]. // Without it (non-F5 models), we no-op rather than guess. function attachSentenceGlow(audio, playButton, sentences) { - if (!audio || !playButton) return; + console.log("[glow] attach called", { + hasAudio: !!audio, + hasButton: !!playButton, + sentencesType: Array.isArray(sentences) ? 'array' : typeof sentences, + sentencesLen: Array.isArray(sentences) ? sentences.length : -1 + }); + if (!audio || !playButton) { console.log("[glow] bail: missing audio/button"); return; } // Allow an initially-empty array: under SSE it grows as sentences arrive, // and the tick reads its length live. Undefined (non-F5) still no-ops. - if (!Array.isArray(sentences)) return; + if (!Array.isArray(sentences)) { console.log("[glow] bail: sentences not array"); return; } const wrapper = playButton.closest('.message-wrapper'); const container = wrapper && wrapper.querySelector('.message-content'); - if (!container) return; + if (!container) { console.log("[glow] bail: no container"); return; } wrapSentencesForGlow(container); const spans = container.querySelectorAll('.tts-sentence'); const domCount = container._glowSentenceCount || 0; - if (!spans.length || domCount <= 0) return; + console.log("[glow] post-wrap", { + spans: spans.length, + domCount, + glowWrappedFlag: container.dataset.glowWrapped, + containerHasContent: container.textContent.substring(0, 50) + }); + if (!spans.length || domCount <= 0) { console.log("[glow] bail: no spans"); return; } let active = -1; function setActive(idx) {