[GH-ISSUE #2758] [Issue]: STT mic input — no stop path when disabled flips mid-recognition (+ lifecycle nits) #1397

Closed
opened 2026-10-21 05:33:01 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2758

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Minor STT/settings lifecycle issues. The notable one is that toggling the button's disabled prop while recognition is live removes the only stop path and still funnels dictated text into a disabled input until the current utterance ends.

Sub-bug 1: No stop path on mid-recognition disable (#50) [primary]

  • How it breaks: startListening's guard if (disabled) return; (86) precedes the if (listening) { stopListening(); } toggle (87); there is no effect keyed on disabled. When the parent flips disabled true mid-listen (GameInput: generation starts; ChatInput: chat cleared), the button is DOM-disabled and the early-return blocks the toggle, so the user can't stop; the recording ring stays lit and onend still fires onTranscript, writing dictated text into the now-disabled input. (Self-heals at utterance end since continuous=false — bounded, not an indefinite leak.)
  • Repro: Start dictation in GameInput, let a generation begin (disabled->true) mid-utterance.

Sub-bug 2: Stale voice selection (#17)

  • How it breaks: voice is hydrated from saved config but voiceOptions comes only from the freshly-fetched list; a deleted/renamed/other-account ElevenLabs voice id has no matching <option>, so the select shows blank while state/payload still hold the stale id and preview/synthesis use it.

Sub-bug 3: Untracked status timer (#51) [nit]

  • How it breaks: The 2s saved->idle setTimeout (417) isn't stored or cleared; harmless on React 19 (no state-after-unmount warning) and only one narrow unmount path exists. Code-hygiene only.

Sub-bug 4: Double-start SpeechRecognition (#16) [disputed/latent]

  • How it breaks: Guarding on stale listening closure could orphan a second recognition IF startListening were invoked twice synchronously — but no real path does this (single onClick, React commits between discrete clicks). Latent; guard on the ref for robustness.

Suggested Fix

  • Add useEffect(() => { if (disabled && listening) recognitionRef.current?.abort(); }, [disabled, listening]) (or reorder the guards), and skip writing transcript when disabled.
  • When voice is non-empty and absent from voiceOptions, inject a synthetic '(saved)' option or surface a re-select warning (same for narratorVoice/per-character voices).
  • Store the status-reset timeout in a ref and clear it in cleanup.
  • Guard startListening on recognitionRef.current before creating a new instance.

Verification checklist (all manual)

  • Manually verify starting dictation then triggering a generation stops the mic and does not dump text into the disabled input
  • Verify a stale/deleted ElevenLabs voice id is visibly flagged rather than silently used
  • Run pnpm check

Affected files

  • packages/client/src/components/ui/SpeechToTextButton.tsx
  • packages/client/src/components/panels/settings/TTSConfigCard.tsx

Audit provenance

Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged staging tree. Severity: LOW.

AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2758 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Minor STT/settings lifecycle issues. The notable one is that toggling the button's `disabled` prop while recognition is live removes the only stop path and still funnels dictated text into a disabled input until the current utterance ends. ## Sub-bug 1: No stop path on mid-recognition disable (#50) [primary] - **How it breaks:** `startListening`'s guard `if (disabled) return;` (86) precedes the `if (listening) { stopListening(); }` toggle (87); there is no effect keyed on `disabled`. When the parent flips `disabled` true mid-listen (GameInput: generation starts; ChatInput: chat cleared), the button is DOM-disabled and the early-return blocks the toggle, so the user can't stop; the recording ring stays lit and `onend` still fires `onTranscript`, writing dictated text into the now-disabled input. (Self-heals at utterance end since `continuous=false` — bounded, not an indefinite leak.) - **Repro:** Start dictation in GameInput, let a generation begin (disabled->true) mid-utterance. ## Sub-bug 2: Stale voice selection (#17) - **How it breaks:** `voice` is hydrated from saved config but `voiceOptions` comes only from the freshly-fetched list; a deleted/renamed/other-account ElevenLabs voice id has no matching `<option>`, so the select shows blank while state/payload still hold the stale id and preview/synthesis use it. ## Sub-bug 3: Untracked status timer (#51) [nit] - **How it breaks:** The 2s saved->idle `setTimeout` (417) isn't stored or cleared; harmless on React 19 (no state-after-unmount warning) and only one narrow unmount path exists. Code-hygiene only. ## Sub-bug 4: Double-start SpeechRecognition (#16) [disputed/latent] - **How it breaks:** Guarding on stale `listening` closure could orphan a second recognition IF `startListening` were invoked twice synchronously — but no real path does this (single onClick, React commits between discrete clicks). Latent; guard on the ref for robustness. ## Suggested Fix - Add `useEffect(() => { if (disabled && listening) recognitionRef.current?.abort(); }, [disabled, listening])` (or reorder the guards), and skip writing transcript when disabled. - When `voice` is non-empty and absent from `voiceOptions`, inject a synthetic '(saved)' option or surface a re-select warning (same for narratorVoice/per-character voices). - Store the status-reset timeout in a ref and clear it in cleanup. - Guard `startListening` on `recognitionRef.current` before creating a new instance. ## Verification checklist (all manual) - [ ] Manually verify starting dictation then triggering a generation stops the mic and does not dump text into the disabled input - [ ] Verify a stale/deleted ElevenLabs voice id is visibly flagged rather than silently used - [ ] Run `pnpm check` --- ### Affected files - `packages/client/src/components/ui/SpeechToTextButton.tsx` - `packages/client/src/components/panels/settings/TTSConfigCard.tsx` ### Audit provenance Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged `staging` tree. Severity: **LOW**. > AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Addressed on PR #2747. Fixed the STT disabled-mid-recognition path by aborting active recognition when disabled flips, preserving a stop path before the disabled guard, guarding double-starts with the recognition ref, and suppressing transcript writes while disabled. Also made saved/stale TTS voice IDs visible in voice selects/pools and tracked the saved-status timeout for cleanup. Validation so far: git diff --check. Full pnpm checks are intentionally deferred until the issue sweep is complete.

<!-- gh-comment-id:4763332502 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Addressed on PR #2747. Fixed the STT disabled-mid-recognition path by aborting active recognition when disabled flips, preserving a stop path before the disabled guard, guarding double-starts with the recognition ref, and suppressing transcript writes while disabled. Also made saved/stale TTS voice IDs visible in voice selects/pools and tracked the saved-status timeout for cleanup. Validation so far: git diff --check. Full pnpm checks are intentionally deferred until the issue sweep is complete.
Sign in to join this conversation.
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
Pasta-Devs/Marinara-Engine#1397
No description provided.