Repository navigation
fix(workspace): dictate on the path we control, and say why voice failed (#2212) - #2239
Merged
Merged
Conversation
…led (#2212) The Workspace mic "kind of turns on and dies instantly" with nothing shown. Two causes, both fixed here. THE BRANCH. `micMode` preferred the browser Web Speech API whenever the object merely EXISTED, so Chrome never reached the MediaRecorder path. Measured in Playwright's Chromium (secure context, microphone permission granted, fake audio device): `webkitSpeechRecognition` exists, `start()` does not throw, and the engine then emits NO event at all for 15s — no start, no audiostart, no result, no error, no end. `continuous` also defaults to false, so even where the service does answer, recognition ends at the first pause. That API is a browser-hosted, Google-backed service: not ours to fix and not ours to see into. THE SILENCE. Every failure path discarded its own signal — `onerror` dropped the error code, `getUserMedia` was wrapped in `catch { return }` (a denied mic looked exactly like success-then-stop), a short blob was dropped with no feedback, and the transcription call ended in `catch { /* keep text mode */ }`. - prefer MediaRecorder + `POST /stt` whenever the platform can transcribe, since that path is ours end to end (real status, real message, real transcript); Web Speech stays the no-key fallback rather than the default (`resolveMicMode`) - new roster-card bit `stt_available` = exactly the `/stt` gate (platform ElevenLabs key), separate from `voice_available`, which additionally needs an effective voice to speak WITH. On a key-but-no-voice agent the old single bit had no correct answer; with neither path available the mic is now not rendered at all instead of being a dead control - every failure says what happened, in one inline aria-live notice beside a composer that still works: SpeechRecognition error codes (blocked permission vs unreachable service — the distinction the discarded code held), the getUserMedia rejection name, a too-short recording, the `/stt` `detail` verbatim, and a narration (TTS) failure - a watchdog for the engine that reports nothing — the measured case — so the button cannot stay lit forever with no recourse - `continuous = true` plus final-result accumulation, so a pause is not the end - Firefox reports `mediaRec.mimeType === ""` and puts `audio/ogg; codecs=opus` on the chunks, so every clip from the one engine that ALWAYS records was uploaded as `voice.webm` labelled audio/webm while containing Ogg (`resolveRecordingMimeType`) The decisions live in pure helpers (`portalUtils.js`) because this project has no component-mount harness; the wiring is covered by source-structure guards in the shape of `portalVoiceModePersistence.spec.js`. Verified: cross-engine capability probe feeding each engine's REAL capabilities into the shipped resolver (Chromium → `record` with a key, `speech` without; Firefox → `record` with a key, no mic without); and a real end-to-end — ElevenLabs TTS → Chromium fake-mic capture → MediaRecorder (audio/webm;codecs= opus, 97 KB) → ElevenLabs Scribe returned the spoken sentence. 841 frontend unit tests pass (34 new), 6 new backend tests, full client_portal backend suite 444 passed, production build and design-token check clean. Related to #2212 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Closed
7 tasks
vybe
approved these changes
Aug 17, 2026
vybe
left a comment
Contributor
There was a problem hiding this comment.
Validated via /validate-pr. Root cause captured from the running browser rather than inferred; the stt_available split is argued from a case the single-bit design cannot express, and the card bit is literally tts_service.is_available() on both sides — pinned by a parametrized test, which is the drift that is the dead-control bug. All 22 checks green.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
The Workspace mic "kind of turns on and dies instantly", with nothing shown, and dictation never reaches the composer. Two independent causes.
1. The branch — we preferred the path we do not control
micModechose the browser Web Speech API whenever the object merely existed, so Chrome never reached the MediaRecorder +/sttpath.Real signal captured (Playwright Chromium,
http://127.0.0.1secure context, microphone permission granted,--use-fake-device-for-media-stream):start()does not throw and the engine then emits no event at all — nostart, noaudiostart, noresult, noerror, noend— solisteningsticks on with no recourse.continuousalso defaults tofalse, so even where the service does answer (official Chrome), recognition ends at the first pause. It is a browser-hosted, Google-backed service: not ours to fix, not ours to see into.2. The silence — every failure path discarded its own signal
onerrordropped the error code;getUserMediawas wrapped incatch { return }(a denied mic is then indistinguishable from success-then-stop); a short blob was dropped with no feedback; the transcription call ended incatch { /* keep text mode */ }.Changes
resolveMicModepicksrecord(MediaRecorder →POST /stt) whenever the platform can transcribe — that path is ours end to end: a real status, a real message, a real transcript. Web Speech stays the no-key fallback instead of the default.stt_available= exactly the/sttgate (platform ElevenLabs key resolves). It cannot be folded intovoice_available, which additionally needs an effective voice to speak with: on a key-but-no-voice agent, dictation works and narration does not, and one bit has no correct answer for that. With neither path available the mic is not rendered — no dead control.aria-livenotice beside a composer that still works: SpeechRecognition error codes (blocked permission vs unreachable service — the distinction the discarded code held), thegetUserMediarejection name, a too-short recording, the/sttdetailverbatim, and a narration (TTS) failure.continuous = trueplus final-result accumulation, so a pause is not the end of dictation.mediaRec.mimeType === ""and putsaudio/ogg; codecs=opuson the chunks, so every clip from the one engine that always records was uploaded asvoice.webmlabelledaudio/webmwhile containing Ogg.resolveRecordingMimeTypereads the chunk when the recorder is silent.Decisions live in pure helpers (
portalUtils.js) because this project has no component-mount harness; the wiring is pinned by source-structure guards in the shape ofportalVoiceModePersistence.spec.js.Acceptance criteria
Root cause confirmed with the real signal captured — the probe above; not inferred.
Dictation produces a transcript — real end-to-end: ElevenLabs TTS → Chromium fake-mic capture → MediaRecorder (
audio/webm;codecs=opus, 97 KB) → ElevenLabs Scribe returned"Book the meeting for Thursday afternoon and send Rachel the agenda.", the sentence spoken in.Failures surfaced with an actionable message — permission denied / no speech / network-service / not configured / too short / provider
detail, each its own line (asserted distinct in tests).No dead control — mic hidden when neither path can work; the card bit and the endpoint's own 404 gate are asserted to be the same condition, since drift between them is the dead-control bug.
Verified in both engines, feeding each engine's real capabilities into the shipped resolver:
speechApicanRecordrecordspeechrecordHeader speaker toggle (TTS) reviewed separately — it stays on its own
voice_availablegate, untouched apart from now reporting a failure instead of silently doing nothing; the bug(voice): agents tell Workspace clients the surface is text-only — portal TTS is never advertised, and the channel/portal voice gates disagree #2157 gate test still passes, and the TTS provider call returned 200 with this instance's key during the end-to-end above.Room composer —
components/rooms/RoomComposer.vuehas no mic/voice control (the only STT call site in the frontend isPortalConversation.vue), so there is nothing to apply there.Verification
vitest run— 841 passed / 37 files (34 new inportalVoiceDictation.spec.js)pytest tests/unit/test_2212_portal_stt_gate.py— 6 passedclient_portalbackend unit test — 444 passedvite buildclean;check-design-tokenscleanFixes #2212
🤖 Generated with Claude Code