From 3689775efc478d4f65aeb9f5b3ed51a187c2ea98 Mon Sep 17 00:00:00 2001 From: retoor Date: Wed, 31 Dec 2025 10:37:15 +0100 Subject: [PATCH] Don't send empty dots and spaces --- src/snek/static/stt.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/snek/static/stt.js b/src/snek/static/stt.js index c45cf87..6fa727d 100644 --- a/src/snek/static/stt.js +++ b/src/snek/static/stt.js @@ -132,8 +132,13 @@ class STTButton extends HTMLElement { text += '.'; } this._finalTranscript += text + ' '; - this._updateTextarea(this._finalTranscript.trim()); - this._finalize(); + const finalText = this._finalTranscript.trim(); + if (this._hasContent(finalText)) { + this._updateTextarea(finalText); + this._finalize(); + } else { + this._clearTextarea(); + } this._finalTranscript = ''; this._interimTranscript = ''; } else { @@ -182,9 +187,13 @@ class STTButton extends HTMLElement { } } + _hasContent(text) { + return text.replace(/[\s.]+/g, '').length > 0; + } + _finalize() { const chatInput = this._getChatInput(); - if (chatInput) { + if (chatInput && this._hasContent(chatInput.value)) { chatInput.finalizeMessage(); } } @@ -277,8 +286,13 @@ class STTButton extends HTMLElement { } this._finalTranscript += text + ' '; } - this._updateTextarea(this._finalTranscript.trim()); - this._finalize(); + const finalText = this._finalTranscript.trim(); + if (this._hasContent(finalText)) { + this._updateTextarea(finalText); + this._finalize(); + } else { + this._clearTextarea(); + } } this._stop();