Repository navigation
feat(workspace): voice as a conversation, not two controls (ent#440) - #2379
Conversation
obasilakis
left a comment
There was a problem hiding this comment.
Reviewed against /validate-pr + a read of the state machine and the dispatcher. The pure module is genuinely good — the transition table, the off-inertness rule, the voiceStarting/voiceStartToken pair covering both re-entrancy shapes, and dispatch-before-stopUtterance() in monitorTick are all correct and correctly reasoned. Docs, requirements, feature flow and the OSS-core ruling are all in place.
One blocking item.
Narration can start after the loop has already left SPEAKING
narrateReply() awaits speak(spoken), and speak() sets speaking.value = true, awaits store.synthesizeTts(...) (a real 1–3 s round trip), then unconditionally does audioEl.value.src = url; await audioEl.value.play().
During that await voiceState is already SPEAKING, so monitorTick is evaluating barge-in at a 350 ms hold. Two reachable outcomes:
- Barge-in during synthesis — the machine goes
SPEAKING → LISTENING,ACT_STOP_NARRATIONpauses an element that has no new src yet, the mic reopens, and then the pendingspeak()assigns src and plays. The agent narrates over the user's fresh utterance. - Explicit Stop during synthesis — state
OFF, hardware released, and then the audio plays anyway. That contradicts the PR's own AC row: "explicit Stop ends the loop".
narrateReply's trailing if (!speaking.value && voiceState.value === VOICE_SPEAKING) guard only suppresses the dispatch, not the playback — the audio element is already committed by then.
Suggested fix, mirroring the shape you already use for startup: a generation token checked inside speak() after the await, before src = url. voiceStartToken is the precedent and releaseVoiceHardware() already bumps it, so this may be as small as reading it in narrateReply and re-checking after await speak(...) — though it needs to be inside speak, since that is where the commit happens.
Worth noting where this sits: the module is well covered, and this defect lives in the dispatcher — the layer the "rules live in a pure module because vitest has no mount harness" split deliberately leaves untested. Not an argument against the split, just where the remaining risk concentrates.
Non-blocking
releaseVoiceHardware()does not callstopSpeaking(). Safe today only because the machine emitsACT_STOP_NARRATIONon theSPEAKINGexit; combined with the above it is the second half of the same hole. Cheap belt.- No stall guard in
THINKING—utteranceVerdict's idle timeout is only consulted inLISTENING, so a turn that never resolves leaves the mic stream live with no status change. Bounded in practice bydeliver's wait budget; worth a line under Known limits if you'd rather not fix it. stopVoiceConversation({ reason: VOICE_IDLE_STOP_REASON })writes the graceful idle end intovoiceError, so a normal end renders in the error line with a Dismiss button.voiceNoticeis the natural channel butreleaseVoiceHardwareclears it — noting it rather than asking for a change.spokenReply's/(\*\*|__|\*|_|~~)/gstrips underscores anywhere, sosnake_caseidentifiers are spoken concatenated. Cosmetic.
Process
The body says "Related to Abilityai/trinity-enterprise#440" rather than Fixes. Cross-tracker never auto-promotes either way, so this is only about making the intent explicit — but ent#440 will need a manual status-in-dev bump at merge regardless.
|
Resolve by running |
|
Resolve by merging |
6c95991 to
a62a083
Compare
Code review — re-review at
|
obasilakis
left a comment
There was a problem hiding this comment.
Re-reviewed at a62a0837. The branch was rebased since the last review, so I diffed the reviewed tip (6c95991e, now unreferenced but still fetchable) against its rebased equivalent (73a3c0ed) to confirm the rebase carried no content changes to this PR's own files, and then read 73a3c0ed..a62a0837 as the only new code. I also re-read voiceConversation.js and the voice half of PortalConversation.vue in full rather than reading the fix in isolation, and checked the capability wiring, the mic lifecycle, the portal STT/TTS rate limits, and the raw-color scan against dev.
Earlier findings
Narration can start after the loop has already left SPEAKING — fixed. a62a0837 puts a narrationToken generation check inside speak(), immediately after the synthesizeTts await and before src is assigned, which is where the commit actually happens. I traced the four cases: barge-in mid-synthesis now discards and revokes the URL and leaves narrateReply's trailing guard correctly inert because the state is LISTENING, not SPEAKING; explicit Stop mid-synthesis reaches the same discard with the state at OFF; a normal success is unaffected; and a rejected play() still advances the loop through the catch. The ordering detail matters and is right — the token check sits above the !url arm, so a superseded failed synthesis cannot write TTS_FAILED_MESSAGE into voiceError for a conversation that already ended. speaking.value is also never left stale-true, because every path that bumps the token either clears it (stopSpeaking) or is a fresh speak() that sets it.
releaseVoiceHardware() does not call stopSpeaking() — fixed. It now tears narration down itself rather than depending on the machine happening to emit ACT_STOP_NARRATION on the SPEAKING exit.
No stall guard in THINKING — not addressed and not documented. Restating it with a sharper edge than I gave it last time. utteranceVerdict's idle timeout is consulted only in the LISTENING branch of monitorTick, and the shared convStream is held for the whole conversation by design, so during THINKING the microphone stream stays open with the browser's recording indicator lit and no path that can end it. The bound is deliver's wait budget, which #2214 made the agent's own execution_timeout_seconds (clamped at 7200s). A hot microphone on a client's own device is the exact failure mode NO_SPEECH_TIMEOUT_MS exists to prevent, and the 15s rule does not reach this state. I am not asking for a fix, but it belongs under Known limits in workspace-voice-conversation.md alongside the four that are already there.
Idle stop writes into the error line; spokenReply strips underscores anywhere. Both unchanged. Both were raised as observations rather than requests and I am not re-raising them.
New finding
Blocking — a voice turn can enter deliver() while another turn is already in flight
send() guards on sending.value and retry() and reattach() both guard on it too, but deliver() itself does not, and runVoiceTurn → submitUserText → deliver is a new caller that inherits no guard. The loop has no notion of "a turn is already running": ACT_SEND fires purely on transcript arriving in TRANSCRIBING.
Two reachable orderings, both without contrived user behaviour:
- Open a thread whose turn is still running.
loadThreadcallsreattach(line 452), which holdssendingfor the duration of that turn. Start a voice conversation and speak. The transcript dispatchesACT_SENDand entersdeliveralongside the reattached turn. - Type and send while the loop is
LISTENING.send()succeeds because the loop is not itself sending; the mic is still open, and the next utterance dispatches concurrently.
The consequences are all from shared single-slot state in deliver:
elapsedTimeris one module-level handle — the second call clears and reassigns it, resetting the first turn's counter.sendingis one flag — whichever call reaches itsfinallyfirst clears it, so the pending-turn indicator disappears while a turn is still running.currentSessionIdis read at dispatch. On a brand-new chat both calls carrynull, the server mints two portal sessions, andsession-adoptedis emitted twice with different ids. What the client experienced as one conversation lands in two threads — which is the "second conversation wearing the same thread" the design memo at the top ofvoiceConversation.jssays this feature exists not to be.lastAssistantReplyis last-writer-wins, sovoiceDispatch('reply', lastAssistantReply.value)can narrate the other turn's reply.streamingandliveActivityare shared, so the ent#286 activity trail interleaves two turns.
This is a narrower window than the last blocker and nothing is double-billed for the same message — the two turns are genuinely different messages. I am still holding on it because the thread fork is user-visible breakage on a client-facing surface, and because runVoiceTurn is the single unguarded entry point, so the fix is small.
On shape: putting a bare if (sending.value) return in runVoiceTurn would drop the utterance silently, which is the one outcome to avoid — the user spoke and nothing happened. The loop needs to do something it can say: re-listen, or stop with words the way failVoice does. Alternatively the guard lives in submitUserText so both callers inherit it and runVoiceTurn reads the refusal off the returned outcome. Author's call, but it has to live in the dispatcher — the machine has no in-flight state to hang it on, and this is the same untested layer the previous blocker was in.
Non-blocking — a thread switch on the same agent does not stop the loop
The watcher at line 1204 stops a live conversation when props.agent.name changes, with the right reasoning: a conversation belongs to the agent it was started with. The separate watcher at line 538 fires on [props.agent.name, props.sessionId] and calls loadThread, which replaces messages.value — but it does not touch the loop. So switching threads on the same agent while the loop is in THINKING or SPEAKING leaves the agent narrating thread A's reply over thread B, with that reply no longer rendered anywhere on screen. Sending the next utterance into thread B is arguably what the user meant, so I am not claiming the loop should stop outright; the in-flight turn straddling the switch is the part that reads wrong. Worth either handling or naming under Known limits, since the analogous case one level up is handled explicitly.
What I checked and found correct
- The two capability bits are not collapsed.
voiceConversationModerequiresstt_availableforavailableand readsvoice_availableonly intonarrates. A key-but-no-effective-voice agent therefore gets a running loop withVOICE_TEXT_REPLIES_NOTICErather than a dead speaker, and the standalone speaker toggle stays gated onttsEnabledso it does not render for that agent at all. Dictation is not hidden either: the mic button keeps its ownresolveMicModeladder, so an instance with nostt_availablebut a browserSpeechRecognitionstill renders it inspeechmode while the conversation control correctly does not render. - No second capability channel. Both bits come off
props.agent, i.e. the roster payload. There is no feature-flags or entitlement read anywhere in the new code, which is the constraint #2128 established for this surface. - Fail direction is closed. The control renders only on
conversationMode.available, andstartVoiceConversationre-readsconversationModeat click with a named reason, because the roster can refresh between render and press. - Rate limiting.
portal_sttandportal_ttsboth callrate_limiter.enforce(..., 20, 60)keyed on(email, agent_name), andtranscriptionErrorMessagehas a dedicated 429 string, so a throttled loop stops with words rather than spinning. - Mic lifecycle.
onBeforeUnmount → cleanupVoice → releaseVoiceHardwarestops the tracks, clears the 100ms timer, stops the recorder and closes the AudioContext. The startup token/flag pair from003c8bf8covers both the overlapping-press and the released-while-awaiting shapes, and a superseded start stops the tracks it just acquired rather than trusting a teardown that already ran.recorderErrorMessagedistinguishesNotAllowedError/SecurityErrorfromNotFoundError/OverconstrainedErrorfromNotReadableError, so permission-denied, no-device and device-busy are three different sentences. - Design system. Running
scan-raw-colors.mjsagainst the head version ofPortalConversation.vuegives 0 raw non-gray and 0 hardcoded, matchingdev; the added gray classes sit on the ink ladder the contract prescribes (gray-600/gray-300for secondary,gray-500/gray-400for tertiary, nevergray-500as dark meta text). The pulse ismotion-safe:-scoped. - Accessibility. Loop state is carried by text inside a
role="status" aria-live="polite"region, not by the dot colour alone; both the toggle and Stop are real buttons and the toggle carriesaria-pressedplus a state-dependentaria-label. - Scope. Every AC in ent#440 is met by the "a voice turn is an ordinary turn" decision rather than by parallel machinery, and the rejection of the Gemini Live path is argued on the authentication and session-identity grounds that actually apply here. Rooms are excluded explicitly.
Once the concurrent-deliver path is closed I expect to approve without another round.
The Workspace already had both halves of a voice conversation and neither of them was one: hold-to-dictate (#2212) and a speaker toggle (#2157), two manual controls the client drove turn by turn. One control now closes the loop — the mic listens, the utterance becomes an ORDINARY Workspace turn, the reply is spoken, the mic reopens. The load-bearing decision is what a voice turn is. It is submitted through the same path a typed one takes (submitUserText -> deliver -> POST .../chat/stream), so every acceptance criterion follows from that line rather than from machinery built to satisfy it: the same portal session and the same resumed Claude session (shared context), the same enterprise_portal_messages row with nothing marking it as spoken (history parity), no new route and therefore no new gate (permission parity), and an inline-not-modal loop so files, reports and the agent page stay reachable mid-conversation. Bridging the platform's Gemini Live session (VOICE-001) was rejected, and the reason is the premise: it answers with a different model holding a summarised copy of the thread and writes its transcript back afterwards — a parallel conversation wearing the same page — it cannot reach the agent's own tools or canvas, and its JWT-only WebSocket cannot authenticate a portal client, which holds no users row. Every decidable rule is pure in components/portal/voiceConversation.js, because this project has no component-mount harness and a rule kept in a .vue file is a rule no test can execute: - Transition table. `start` is idempotent (no second recorder on one device); every event is inert in `off`, so a /stt answer arriving after teardown cannot restart a loop the user ended; `transcript` sends from exactly one state, so a slow transcription cannot dispatch the same words twice; every exit releases the microphone. `silence` is accepted from TRANSCRIBING as well as LISTENING — it is raised after the recorder has already stopped, and a LISTENING-only edge wedged the loop with the mic open and nothing to advance it. - Utterance boundaries from an RMS level meter: 1.2s silence hold, 30s cap, and 15s with no speech at all ends the conversation WITH A SENTENCE rather than leaving a hot mic open on a client's own device. Room tone re-listens instead of spending a transcription. - Interruption at a HIGHER threshold than listening, held for 350ms, with echoCancellation requested on capture. Without both, the mic hears the agent's narration through the speakers and the agent interrupts itself on every reply. - spokenReply() cleans a reply for the ear (code fences become one spoken sentence, links read as their text, long replies cut at a sentence boundary with "the rest is in the chat") while the rendered message is untouched. Degradation is named at every step and the composer keeps working throughout: the control renders only where the loop can run, an agent with no configured voice still converses in text and says so, and each runtime failure stops the loop with the provider's own user-facing sentence. OSS-core by decision: deliberately ungated, recorded explicitly because the default for an enterprise-tracker feature is gated-unless-ruled-otherwise. No backend change, no new endpoint, no migration. Related to Abilityai/trinity-enterprise#440 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ophones (ent#440) Two things, both surfaced after the first commit. **CI — the #2157 source guards.** `portalVoiceModePersistence.spec.js` pins the narration gate and the agent-switch watcher as literal source, and ent#440 legitimately changed both: the gate gained `&& !voiceConvLive.value` (a live conversation narrates through its own state machine, so this branch must not also speak — it would say every reply twice, once raw and once cleaned for the ear) and the watcher gained a line ending any live conversation on an agent switch. The guards are updated to match, deliberately WITHOUT loosening what they guard: the gate is now asserted term by term rather than as one string, so it still fails if `voiceMode`/`ttsEnabled`/`data.response` stops gating it, and the watcher window is widened while still requiring `loadVoiceMode()`. **Review finding — startup re-entrancy.** The loop is not live until `getUserMedia` resolves, and a permission prompt can sit open for seconds. In that window a second press, a press after Stop, or a nav-away would install a SECOND stream and a second 100 ms timer while the first pair was still owned by nobody — a microphone left hot with no control pointing at it, which is exactly the failure mode this feature must not ship. `voiceStarting` rejects the re-entry; a token invalidates a start whose hardware was released while it was awaiting (`releaseVoiceHardware` bumps it), and a superseded start stops the tracks it just acquired rather than trusting a teardown that already ran. Related to Abilityai/trinity-enterprise#440 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…term source guards (ent#440) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ed on (ent#440) `speak()` awaits a real 1-3 s `synthesizeTts` round trip and then unconditionally assigns `src` and plays. The machine is already in SPEAKING during that await, so `monitorTick` is evaluating barge-in at a 350 ms hold and Stop is one click away. Two reachable outcomes, both wrong: - barge-in mid-synthesis: SPEAKING → LISTENING, `ACT_STOP_NARRATION` pauses an element that has no new src yet, the mic reopens, and the pending `speak()` then plays — the agent narrates over the user's fresh utterance; - explicit Stop mid-synthesis: state OFF, hardware released, audio plays anyway — contradicting "explicit Stop ends the loop". `narrateReply`'s trailing `!speaking.value && voiceState === SPEAKING` guard suppresses only the DISPATCH; by the time it runs the element is committed. So the check belongs where the commit happens. `narrationToken` is the same shape as `voiceStartToken`: `speak` takes a generation at entry and re-checks it after the await, before `src` is assigned, discarding (and revoking) audio it is no longer entitled to play. `stopSpeaking` bumps it — a pause cannot reach audio that has not been assigned yet — so barge-in and agent-switch abandon an in-flight synthesis for free. The `catch` arm is gated on the same token so a superseded synthesis cannot overwrite `voiceError` for a conversation that already ended. `releaseVoiceHardware` now tears narration down itself instead of relying on the machine happening to emit `ACT_STOP_NARRATION` on the SPEAKING exit — the second half of the same hole: a safety property held by a fact somewhere else. The defect lives in the dispatcher, the layer the pure-module split deliberately leaves untested, so it is pinned by source assertion like the rest of that file. Related to Abilityai/trinity-enterprise#440
…three races the dispatcher lost (ent#440) Four findings, all in the dispatcher — the layer the pure-module split leaves untested, which is exactly where the residual risk keeps landing. **`transcribing` had no ceiling, so the loop could wedge with the mic hot.** `stopUtterance()` is a no-op on an already-`inactive` recorder, so `onstop` never fires and `finishUtterance` never runs. Reachable two ways: the mic is unplugged or permission revoked mid-conversation (the recorder auto-stops while the machine is still `listening`, then the next tick dispatches `utterance` into a recorder that cannot stop), and a hung `/stt`, since `transcribeStt` carries no transport timeout. Either way the tracks stay live — browser mic indicator on — with Stop as the only way back, which is the one failure this feature says it must not ship. The 15s no-speech guard covers `listening` only. A watchdog now bounds it (45s — generous, because firing early costs a real utterance), re-checks that we are still waiting before acting so it stays a backstop rather than a competing terminal, and is cleared on every legitimate exit. **The voice path dispatched a turn without `send()`'s in-flight guard.** The textarea stays enabled while the loop is `listening`, so a user who typed and sent, then spoke, put the utterance into a SECOND concurrent `deliver()`. They share `elapsedTimer`, `sending`, `attachments` and — worst — `awaitPersistedReply`'s baseline assistant count, so the second turn's poll sees the first turn's reply cross the baseline and returns the wrong answer. The spoken turn now yields. **`failVoice` had no generation guard.** `nextVoiceState` handles `stop`/`error` BEFORE its `state === VOICE_OFF` short-circuit, so it always returned OFF + ACT_RELEASE. A user who pressed Stop on a slow turn and then restarted the loop had the NEW conversation released when the abandoned turn finally rejected — with an error about a turn they had already abandoned. It takes the same `voiceStartToken` the success paths already re-check. **Stop mid-turn could still get the raw reply spoken.** The #2157 branch is evaluated after the turn's await, so `voiceConvLive` was already false by the time it ran and the un-cleaned reply (code fences, URLs, markdown) was synthesized and played — contradicting "explicit Stop ends the loop", and unmutable, since the speaker button is hidden for the whole duration of a conversation. A flag set when the hardware is released mid-turn, and cleared at the next dispatch so it describes exactly one turn. The fifth finding — the machine permitting `ACT_CAPTURE` from `listening` — is left as recorded: unreachable today, and the honest fix is to drop that arm from the transition table, which is a change to the pure module's contract rather than a dispatcher bug. Related to Abilityai/trinity-enterprise#440
a62a083 to
535144b
Compare
…he literal (ent#440) `portalVoiceModePersistence.spec.js` asserted the exact source text of the #2157 branch, so adding the `!voiceLoopEndedDuringTurn` term to close the speak-after-Stop hole broke it. The assertion now matches the rule — narration requires client narration on, an agent that can be narrated, and no live voice loop — plus the new term as its own line, so a future edit to the wording does not fail the build while a change to the RULE still does.
obasilakis
left a comment
There was a problem hiding this comment.
Re-review at 6ae6d29e
I separated the rebase from the real change first: a62a0837..a401f2dd is pure rebase noise — the PR's own delta is byte-identical across the base move (36877bd5..a62a0837 and 88efbe7d..a401f2dd produce identical added/removed line sets), and ac5124f4/8aa74a61/49ac8983/a401f2dd are renamed-only replays of the round-2 commits. Only 535144b2 and 6ae6d29e are genuinely new. I then re-read voiceConversation.js and the voice half of PortalConversation.vue in full rather than reading the fix in isolation. CI is green except a pending pytest; frontend-build passed, so the new specs run.
Prior findings — verdicts
A. Concurrent deliver() — FIXED, and fixed in the shape I asked for. PortalConversation.vue:1639-1643: runVoiceTurn captures voiceStartToken, then if (sending.value) { failVoice("I couldn't send that — a message was already on its way…", token); return }. The refusal is perceivable rather than a silent drop — failVoice writes voiceError (:1515), which renders in the always-visible danger line (:185-198), and dispatches error, taking the loop to OFF and releasing the mic. deliver() itself is still unguarded, but all four callers now guard (send :1139, retry :1190, reattach :502, runVoiceTurn :1640), and only microtasks separate each check from deliver's sending.value = true (:840), so a setInterval-driven monitorTick cannot interleave. Worth stating the trade you chose: the loop stops rather than re-listening, and restarting it while the abandoned turn is still in flight refuses again immediately.
Round-2 fixes intact. speak()'s generation check sits at :1271, above the !url arm at :1274 — the ordering that keeps a superseded failed synthesis from writing TTS_FAILED_MESSAGE into an ended conversation. releaseVoiceHardware calls stopSpeaking() itself at :1532.
B. No stall guard in THINKING — still open, and now contradicted by the PR's own requirement. The new watchdog bounds TRANSCRIBING, not THINKING: monitorTick's THINKING path is still the bare else { bargeSince = 0 } at :1710. The only bound remains awaitPersistedReply's resolveWaitBudgetMs (:1064), i.e. the agent's execution_timeout_seconds, up to 7200s, with convStream tracks live throughout. It is also not documented: Known limits in workspace-voice-conversation.md:162-173 is unchanged, and public-access.md:857-860 FR-9 enumerates the release triggers as "a stop, an error, an agent switch and unmount" while asserting that "a hot mic left open on a client's own device is the failure mode this feature must not ship". Right now the requirement and the code disagree.
C. Thread switch on the same agent — still open, and worse than I described last round. The [props.agent.name, props.sessionId] watcher (:550-555) calls loadThread and never touches the loop; only the props.agent?.name watcher (:1231-1237) stops it. Beyond the narration problem I raised: deliver's tail pushes into the current messages.value (:940), which loadThread has already replaced (:439), so thread A's reply is rendered into thread B and then narrated, and :954-956 resets currentSessionId back to thread A and re-emits session-adopted. This is pre-existing for typed sends — :958-962 acknowledges the outliving closure — but hands-free dispatch makes it routinely reachable. Not in Known limits either.
D. Observations, unchanged, not re-raised as asks. Idle stop still writes VOICE_IDLE_STOP_REASON into voiceError (:1502), so a graceful end renders in the red danger line with a Dismiss button. spokenReply's /(\*\*|__|\*|_|~~)/g (voiceConversation.js:241) still strips single underscores anywhere, so snake_case is spoken as one word.
Blocking
NEW-1 — the transcribe watchdog is disarmed immediately before the call it claims to bound
armTranscribeWatchdog() has exactly one call site, :1695 in monitorTick, fired just before stopUtterance(). finishUtterance then opens with clearTranscribeWatchdog() at :1606 — and only after that awaits store.transcribeStt(...) at :1620. transcribeStt (stores/clientPortal.js:957-967) rides portalHttp = axios.create() (:61) with no timeout, i.e. axios's timeout: 0.
So the watchdog covers only the recorder-cannot-stop window. The hung-/stt cause — which 535144b2's message names explicitly as one of the two it fixes — is completely unbounded: voiceState stays TRANSCRIBING showing "Got it…", convStream tracks stay live and the browser mic indicator stays on, until the user presses Stop. That is the same hot-mic outcome as B, reached by a different path.
The spec pins the defect rather than the fix — portalVoiceConversation.spec.js asserts /async function finishUtterance\(\) \{\s*clearTranscribeWatchdog\(\)/. Fix shape: move the clear past the await (or re-arm around it), or give transcribeStt a transport timeout.
B and C, restated as one ask
I am not asking for both to be fixed. But FR-9 (public-access.md:857-860) is now a shipped requirement that enumerates the mic-release triggers and declares a hot mic the failure mode this feature must not ship, while THINKING (up to 7200s) and a same-agent thread switch both sit outside that enumeration. Either handle them, or add them to Known limits and amend FR-9's enumeration so the requirement and the code agree. Requirements is the document future readers will trust.
Non-blocking
NEW-2 — one async failure path missed the generation token. convRec.onerror = (e) => failVoice(recorderErrorMessage(e?.error || e)) at :1573 passes no token, so failVoice's new guard (:1514) is skipped. releaseVoiceHardware nulls convRec (:1535) but never clears its handlers, so a late error event from a torn-down recorder tears down a restarted loop with a message about the abandoned one — exactly the class 535144b2 fixed for finishUtterance (:1627) and runVoiceTurn (:1641, :1647). Capture voiceStartToken in startUtterance and pass it.
NEW-3 — voiceLoopEndedDuringTurn is set for turns the loop did not dispatch. releaseVoiceHardware:1523 sets it on any sending.value, so ending the loop while a typed turn is in flight silently suppresses that turn's #2157 narration at :952-953. The user cannot recover it, because the speaker button is v-if="ttsEnabled && !voiceConvLive" (:75) and the loop was live when the turn started. Bounded to exactly one turn (cleared at :839).
NEW-4 — the voice spec greps un-stripped source. portalVoiceConversation.spec.js:51 reads the raw .vue, while its sibling portalVoiceModePersistence.spec.js:25 strips comments with a header stating exactly why: a comment explaining the rule necessarily contains the strings a text scan looks for. Several new guards would pass on a declaration or a comment alone — toContain('armTranscribeWatchdog()') matches the function armTranscribeWatchdog() { declaration even if nothing calls it, which is close to NEW-1's failure mode.
On 6ae6d29e ("pins the rule, not the literal") — partial. It is not a tautology; it does assert a conjunction of four named terms guarding speak(data.response). But it added to the literal rather than replacing it: :58 still contains 'if (voiceMode.value && ttsEnabled.value && data.response', :63's regex still pins the exact order and && spelling of the first three terms, and :64's /!voiceLoopEndedDuringTurn\) speak\(data\.response\)/ is the most literal of the three — it pins !voiceLoopEndedDuringTurn as the last term with an exact closing paren, so adding a fifth term breaks it. "A future edit to the wording does not fail the build" holds only for whitespace between terms.
Design-system ratchet. At head, scan-raw-colors.mjs reports raw_nongray 0 and hardcoded_colors 0, but raw_gray grows 63 → 72 against base 88efbe7d, which is strictly against the "per-file counts may only shrink" rule in CLAUDE.md. It is unchanged from round 2 — the new commits touched <script> only — and the ratchet is measurement-only (scan-raw-colors.mjs:37), so noting rather than asking.
Confirmed still correct
The two capability bits are not collapsed (voiceConversation.js:53-63 — available needs canRecord && secureContext && serverStt, narrates reads voiceAvailable only). No second capability channel: :1415-1422 reads only props.agent.stt_available and voice_available, and the file's only store.* capability read is multiAgentChatAvailable, the unrelated rooms gate. Fail direction closed (v-if="conversationMode.available" at template :60, re-read at click :1456-1460). Portal STT/TTS rate limits intact at client_portal/router.py:721,742. Unmount teardown :584 → cleanupVoice → :1387-1394. Accessibility: role="status" aria-live="polite" on both regions (:188-189, :207-208), real buttons, aria-pressed (:65).
Verdict
Requesting changes, on NEW-1 and on the FR-9 disagreement. Both are small. The blocking finding from round 2 is genuinely closed, in the shape that avoids the silent-drop outcome I flagged, and the round-2 fixes survived the rebase intact.
Process: the body still ends "Related to Abilityai/trinity-enterprise#440" rather than a closing keyword, and ent#440 is open with status-in-progress, so it needs a manual status-in-dev bump at merge either way.
…uth (ent#440) NEW-1 (blocking) — the watchdog was disarmed on finishUtterance's FIRST line, so it bounded only the recorder-cannot-stop window, and `transcribeStt` rides an axios instance created with no `timeout` (i.e. timeout: 0). A hung /stt left voiceState in TRANSCRIBING showing "Got it…", the mic tracks live and the browser's recording indicator on, until the user pressed Stop — the same hot mic FR-9 forbids, reached by the exact cause the watchdog was added for. Two layers now. The clear moved past the await (and onto both early exits, which are no longer waiting for a transcript), and /stt got a 60s transport timeout — comfortably above a real transcription of a 30s-capped utterance. A promise that can never settle is the wrong primitive to hand a UI regardless of who is watching it. The spec assertion that pinned this defect — finishUtterance must OPEN with the clear — is replaced by a structural one: there must be a clear AFTER the await, and any clear before it must belong to an early exit. B and C — taking the 'or' branch, deliberately. Neither is fixed here, so both are now written where a future reader will look: FR-9's enumeration names them (THINKING is bounded only by execution_timeout_seconds, up to 7200s, with the mic live; a thread switch on the SAME agent does not stop the loop, so a dispatch in flight lands in the thread the user left), and Known limits carries each with its reasoning. The requirement and the code agree again. NEW-2 — convRec.onerror now captures and passes the generation token, like the other two async failure paths. releaseVoiceHardware nulls convRec but never clears its handlers, so a late error from a torn-down recorder was tearing down a RESTARTED loop with a message about the abandoned one. 1294 frontend tests passed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Re-review — ent#440 (fresh pass over
|
…ed (ent#440) Two review findings, both in the async paths. 1. A TRANSCRIPT FROM AN ABANDONED LOOP COULD BE SENT AS A REAL TURN. `finishUtterance` captured `transcribeToken` but consulted it only in the catch; the success path guarded on `voiceState !== VOICE_TRANSCRIBING`, which is generation-BLIND. Stop the loop, start it again, and the abandoned `/stt` — up to its 60s timeout — resolves into a NEW loop that is legitimately back in TRANSCRIBING. It would then dispatch the previous conversation's words as a real turn, clobber the live `convChunks`, and disarm the live watchdog. The generation check now runs FIRST, before anything that touches shared loop state. 2. SPEAKING HAD NO BOUND AT ALL. It is the one live state with no timer of its own — barge-in and Stop are its only exits — and it awaits `synthesizeTts` on the same `portalHttp` instance created with `timeout: 0`. A hung `/tts` therefore held the microphone open with nothing counting: the same hot-mic outcome FR-9 forbids that the `/stt` timeout was added to close, one state over. Same 60s bound, same reason. The Known-limits entry claiming "every other live state has a timer" was false once SPEAKING was examined — it has none, and now relies on a transport deadline instead. Rewritten to enumerate what actually bounds each state, since a requirement that disagrees with the code is precisely what the reviewer objected to in the first place. 1296 frontend tests pass. Related to Abilityai/trinity-enterprise#440 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
obasilakis
left a comment
There was a problem hiding this comment.
Approving — this clears my earlier CHANGES_REQUESTED.
Both round-3 blockers are fixed and verified in head:
- Transcribe watchdog —
clearTranscribeWatchdog()no longer fires at the top offinishUtterance; it now runs only on the two early exits and after the await, so it actually bounds the/sttcall it claims to.stores/clientPortal.jsaddstimeout: 60000on/stt(wastimeout: 0), which was the other half. The generation-token check above the clear is a path I hadn't raised — good catch. - FR-9's enumeration disagreeing with the code — I offered fix-or-document and the document arm is satisfied:
public-access.mdgains a named "Two windows this enumeration does NOT cover" block for the unbounded THINKING window and the same-agent thread switch, andworkspace-voice-conversation.mdcarries both in Known limits with the reasoning.
Round-1/2 fixes re-verified intact: narrationToken sits above the !url arm, releaseVoiceHardware calls stopSpeaking() itself, and runVoiceTurn's if (sending.value) failVoice(...) guard is present.
Merge note: this conflicts with dev on docs/memory/learnings.md (EOF append only, no code). #2382 and #2386 conflict on the same file — first one in forces the other two to rebase.
Non-blocking, still open: NEW-3 (voiceLoopEndedDuringTurn set unconditionally in releaseVoiceHardware, so a typed turn's #2157 narration is suppressed when the loop didn't dispatch it); NEW-4 (the voice spec greps un-stripped source, so a comment can satisfy a toContain — partly mitigated by the structural index assertions); and PortalConversation.vue raw_gray 72 vs baseline 57.
…ce-voice-conversation # Conflicts: # docs/memory/learnings.md
…ce-voice-conversation # Conflicts: # docs/memory/learnings.md
What
The Workspace already had both halves of a voice conversation and neither of them was one: hold-to-dictate (#2212) and a speaker toggle (#2157) — two manual controls the client drove turn by turn. One control now closes the loop: the mic listens, the utterance becomes an ordinary Workspace turn, the reply is spoken, the mic reopens. No mode switch, no second surface.
The one decision: what a voice turn IS
A spoken utterance is submitted through the same path a typed one takes —
submitUserText→deliver→POST .../chat/stream:Every acceptance criterion follows from that line rather than from machinery built to satisfy it:
cached_claude_session_id/stt,/tts,/chat/streamare already roster-scoped and rate-limited per (client, agent)Why not the platform's Gemini Live session
routers/voice.py(VOICE-001) already runs a real-time voice session, and porting it in was the obvious-looking move. Rejected, because the reason is the premise:usersrow; a Workspace client holds a portal session token and has nousersrow at all.The issue asks to consolidate rather than replace the existing voice work: this uses the platform's own STT/TTS layers (shared with channels since ent#117) and lets the agent answer as itself.
Where the rules live
src/frontend/src/components/portal/voiceConversation.js— pure, no Vue, no DOM.vitest.config.jsisenvironment: 'node'with no component-mount harness, so a rule expressed inside a.vuefile is a rule no test can execute. The component is a dispatcher over the machine.Properties pinned by tests, each because the obvious implementation gets it wrong:
startis idempotent — a second press while live must not open a second recorder on one device.off— a/sttanswer or anonstopcallback arriving after teardown must not restart a loop the user ended.transcriptsends from exactly one state — a slow transcription answering after the state moved on cannot dispatch the same words twice.stop/errorfrom any state emitrelease, plusstop-capture/stop-narrationfor the state they left.silenceis accepted fromtranscribing, not justlistening— it is raised after the recorder has stopped, so the narrower edge (which is what I wrote first) wedged the loop with the mic open and nothing to advance it. There is now a test asserting every live state has at least one advancing edge.Utterance boundaries and the interrupt
No recognition — a level meter. An
AnalyserNodeon the shared mic stream sampled every 100 ms, reduced to RMS, turned intocontinue/end/idle:end— speech heard, then 1.2 s of pause (or the 30 s cap). Transcribe and send.idle— 15 s open having heard nothing: the conversation ends with a sentence. A hot mic left open on a client's own device is the failure mode this must not ship.Interruption reads the same meter while the agent speaks. Two details are load-bearing rather than tuning: the interrupt threshold is higher than the listening threshold and capture requests
echoCancellation— without both, the mic hears the agent's own narration through the speakers and the agent interrupts itself on every reply; and the 350 ms hold means a cough does not cut it off.What gets spoken
spokenReply()cleans a reply for the ear before synthesis: code fences become one spoken sentence, links read as their text and never their URL, markdown furniture is dropped, long replies are cut at a sentence boundary with "The rest is in the chat." Reading a fenced diff aloud is unlistenable and burns the TTS character cap. The rendered message is untouched.Degradation (never a dead control)
/stt's own user-facing message in the existing voice-error lineScope
No backend change, no new endpoint, no migration. Frontend only.
OSS-core by decision (ent#440): deliberately ungated — no
requires_entitlement, logic stays in the OSS tree. Recorded explicitly in the docs because CLAUDE.md's default for an enterprise-tracker feature is gated unless ruled otherwise, so the ruling must never be inferred later from the mere fact that it merged (the ent#326 / ent#384 / ent#392 discipline). The Workspace is already OSS-core (ent#356) and this consumes only surfaces that shipped there.Testing
src/frontend/tests/unit/portalVoiceConversation.spec.js— availability ladder, the full transition table (incl. the wedge regression and the "no live state without an advancing edge" property), utterance/barge-in thresholds, the spoken-text rewrite, plus source assertions scoped to what only source can answer: dispatch goes through the machine (one state writer), a spoken turn uses the same submit path, no double narration, echo cancellation requested, mic released on unmount.npm run check:tokenspasses; raw-color scan shows 0 non-gray / 0 hardcoded for the touched file; the SFC compiles.vitestandvite build— this clone'snode_modulesis root-owned and incomplete (mermaidmissing,npm installfailsEACCES), which is pre-existing and unrelated. Every pure assertion in the spec was executed locally against the module through a plain-node harness and passes; CI runs the real suite.Known limits (stated, not hidden)
PortalRoom.vue) are out of scope — turn-taking with several agents is a different problem.Docs
docs/memory/requirements/public-access.md§48.3 (FR-1…FR-9 + limits)docs/memory/feature-flows/workspace-voice-conversation.md(+ index row and changelog entry)docs/memory/architecture.md— Workspace sectionRelated to Abilityai/trinity-enterprise#440
🤖 Generated with Claude Code