Previously, tapping the mic button would reset the textarea each time, clobbering anything the user had already typed or previously dictated. Fix: - Capture _prefix = ta.value when recording starts (btn.onclick) - onresult writes _prefix + (final || interim) so live interim text appears after the existing content, not replacing it - onend commits _prefix + _finalText with smart space insertion: if the prefix doesn't end with a space or newline, a space is added before the new transcript so words don't run together - _prefix is reset to '' in _setRecording(false) so each new recording session starts with a fresh snapshot Behaviour now: tap mic, speak, tap again (or wait for auto-stop) -> transcript is appended to whatever was in the textarea. Tap mic again -> continues appending further. Text stays fully editable before send. tests/test_sprint20.py: 6 new tests covering prefix capture, onresult prepend, onend commit, reset, and smart spacing (52 total, 382 overall).
15 KiB
15 KiB