[PR #29] Fix mic cleanup when transcription fails; make mic icon state idempotent #29

Open
opened 2026-10-15 13:27:32 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/SillyTavern/Extension-Speech-Recognition/pull/29
Author: @northcraftfoundries
Created: 9/24/2026
Status: 🔄 Open

Base: main ← Head: fix/recorder-cleanup


📝 Commits (2)

  • 82edb71 fix: make mic icon activate/deactivate idempotent
  • edaf939 fix: release mic and restore click handler when transcription fails

📊 Changes

1 file changed (+37 additions, -25 deletions)

View changed files

📝 index.js (+37 -25)

📄 Description

Two small fixes to the shared recording path in index.js. They affect every MediaRecorder-based provider.

Release the mic and restore the click handler when transcription fails

mediaRecorder.onstop awaited processAudio without a try/catch. If the provider threw (for example, the server was unreachable or returned an HTTP error), the rejection went unhandled and the cleanup never ran:

  • the mic tracks stayed live, so the browser's recording indicator stayed on
  • the lazy click handler on the mic button was never restored

The transcription is now wrapped in try/catch/finally. The cleanup uses a local reference to the recorder and is skipped if the user switched providers mid-transcription, so it can't rebind the mic button away from the new provider.

Make mic icon activate/deactivate idempotent

toggleClass flipped whatever state the button was in. Calling activateMicIcon twice, or deactivateMicIcon on an idle button, left the icon inverted. The classes are now set explicitly.

How to test

  • Point a MediaRecorder-based provider at an unreachable server and record. The error should be logged, the mic indicator should turn off, and the button should still work for the next recording.
  • Check that a normal record and transcribe round trip still works.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/SillyTavern/Extension-Speech-Recognition/pull/29 **Author:** [@northcraftfoundries](https://github.com/northcraftfoundries) **Created:** 9/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/recorder-cleanup` --- ### 📝 Commits (2) - [`82edb71`](https://github.com/SillyTavern/Extension-Speech-Recognition/commit/82edb7176a32a824e07af648b478481648643911) fix: make mic icon activate/deactivate idempotent - [`edaf939`](https://github.com/SillyTavern/Extension-Speech-Recognition/commit/edaf9392b239af36e341604082f8df65bdd275a2) fix: release mic and restore click handler when transcription fails ### 📊 Changes **1 file changed** (+37 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `index.js` (+37 -25) </details> ### 📄 Description Two small fixes to the shared recording path in `index.js`. They affect every MediaRecorder-based provider. ## Release the mic and restore the click handler when transcription fails `mediaRecorder.onstop` awaited `processAudio` without a try/catch. If the provider threw (for example, the server was unreachable or returned an HTTP error), the rejection went unhandled and the cleanup never ran: - the mic tracks stayed live, so the browser's recording indicator stayed on - the lazy click handler on the mic button was never restored The transcription is now wrapped in try/catch/finally. The cleanup uses a local reference to the recorder and is skipped if the user switched providers mid-transcription, so it can't rebind the mic button away from the new provider. ## Make mic icon activate/deactivate idempotent `toggleClass` flipped whatever state the button was in. Calling `activateMicIcon` twice, or `deactivateMicIcon` on an idle button, left the icon inverted. The classes are now set explicitly. ## How to test - Point a MediaRecorder-based provider at an unreachable server and record. The error should be logged, the mic indicator should turn off, and the button should still work for the next recording. - Check that a normal record and transcribe round trip still works. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SillyTavern/Extension-Speech-Recognition#29
No description provided.