Skip to content

ui-react: Gemini dictation Done always waits its full 3 s drain because Google never sends finished/turnComplete #3768

Closed

Description

@schlessera

Part of #3705. Found by the #3710 Phase A check of the protocol against real Google (results).

Context

Done (drainAndStop) sends audioStreamEnd. It then waits until a final arrives with finished: true or turnComplete: true, or until GEMINI_DRAIN_MS (3 s) passes (receive, packages/ui-react/src/voice/asr-gemini.ts:244; the timer is at packages/ui-react/src/voice/asr-gemini.ts:153). The plan describes the same wait (docs/plans/selectable-dictation.md §6, "Done (drainAndStop)").

Measured against models/gemini-3.5-transcribe-live on 2026-11-09 (kit main fb999b8ba):

  • Google never sent finished or turnComplete, in any of 14 sessions that opened, during an 8 s watch after audioStreamEnd. It never closed the socket either.
  • Each final arrives as a burst: inputTranscription, then serverContent.generationComplete: true, then speechState: NON_SPEECH. It comes on a pause, or +253 ms after audioStreamEnd when speech was still pending.
  • With no speech pending (silence, or a final already delivered before Done), nothing at all follows audioStreamEnd.

So every Done waits the full 3 s, about 2.7 s longer than it needs to. No words are lost.

Scope

  • After audioStreamEnd has been sent, end the drain on generationComplete as well as the existing finished/turnComplete.
  • When no speech is pending at audioStreamEnd, end the drain after a short quiet grace period instead of the full cap. No speech pending means no speechState: SPEECH since the last NON_SPEECH, and no interim since the last final.
  • Any SPEECH or interim during that grace period switches to waiting for generationComplete.
  • Keep GEMINI_DRAIN_MS as the upper bound.
  • Update the plan's Done description and its "still unproven" list with the measured behavior.

Out of scope

Language hints (separate issue). Changing the 3 s cap. Session resumption. Deepgram or browser drains. Any vendor-key test.

Acceptance criteria

  • A drain with an interim pending resolves on the first generationComplete received after audioStreamEnd, with the final committed. A unit test proves it and fails on the tree before the change.
  • A generationComplete received before audioStreamEnd is sent does not end the drain: the tail can still be flushing. A test proves it.
  • A drain with nothing pending resolves within the grace period, and speech or an interim arriving inside the grace period extends it to generationComplete. Tests prove both.
  • The cap still resolves at GEMINI_DRAIN_MS when Google stays silent, and the teardown assertions are unchanged.
  • A mutation receipt for each new guard is recorded in the PR.
  • Plan §2 and §6 state the measured end-of-stream behavior.

Verification

bun run test packages/ui-react/tests/asr-gemini.test.ts, plus the existing browser dictation suites. A real-device timing check is part of #3710 Phase B.

Contract impact

None. Internal client behavior; no API, schema or --json shape.

Activity

  1. added this to the 0.45.0 milestone on Nov 9, 2026
  2. added
    type: fix
    area: ui-react
    priority: p2
    agent-ready
    on Nov 9, 2026
  3. self-assigned this
    on Nov 9, 2026
  4. schlessera commented on Nov 9, 2026

    @schlessera
    OwnerAuthor

    Claimed (token claim-1794216672-25469). Branch fix/3768-gemini-drain-language, which fixes #3768 and #3769 in one PR. Collisions: none on these paths, only closure-level overlap with older draft PRs.

  5. removed their assignment
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-reactpriority: p2type: fix

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions