Skip to content

Preserve accepted voice transcription across navigation - #4330

Merged
ymichael merged 2 commits into
mainfrom
bb/investigate-and-reproduce-reported-github-issue-thr_eaj79srsgx
Sep 25, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/investigate-and-reproduce-reported-github-issue-thr_eaj79srsgx

Conversation

@ymichael

@ymichael ymichael commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The voice hook aborted accepted transcription when its composer unmounted. Even if the request completed, the result callback only targeted the mounted editor ref, so navigation lost the transcript. See #4236 and its reproduction report.

What changed

Accepted transcription continues after unmount and appends to the originating persisted draft when the editor is gone. A review follow-up keeps accepted recording data alive when MediaRecorder.onstop arrives after unmount. Recording cleanup still discards unaccepted audio, and explicit Cancel still aborts processing. New-thread and thread follow-up composers provide their draft accessor, including embedded thread chat.

How you verified

  • Added regression tests for accepted transcription after unmount, saved-draft delivery, pre-acceptance unmount, and explicit cancellation. A delayed-onstop regression failed before the review fix and passed after it; the focused Vitest run passed (9 tests).
  • pnpm exec turbo run typecheck --filter=@bb/app passed.
  • Served the exact PR head with pnpm start:worktree. In headless Chromium, a labeled speech fixture went through the real composer controls and transcription API. Accepted text reached the root and thread follow-up drafts after navigation; the thread draft survived a full reload. Cancel aborted the signal and left the draft unchanged; leaving before acceptance sent no request. The fixture replaced microphone capture, not the server transcript.
  • All 16 required checks passed at the current PR head, including Linux and macOS package smoke.

Fixes #4236

AGENT GENERATED

@ymichael
ymichael merged commit 97d6b34 into main Sep 25, 2026
18 checks passed
@ymichael
ymichael deleted the bb/investigate-and-reproduce-reported-github-issue-thr_eaj79srsgx branch September 25, 2026 17:34
ymichael added a commit that referenced this pull request Oct 30, 2026
## Human comments

## What was wrong

`useVoiceInput`'s unmount cleanup treated a still-running recording as
cancelled: it set `shouldTranscribeRef` to false before stopping the
recorder, so the stop handler cleared the captured chunks and returned
before anything reached the recording store. Leaving a thread while
dictating lost the audio with no transcript, retry entry, or toast.
Investigation report: https://get-bb.github.io/reports/issues/6660.html

## What changed

- `apps/app/src/hooks/useVoiceInput.ts`: a recording started in a
composer with a persisted draft (`recordingKey` set) is accepted as Stop
with `insert` delivery when the composer unmounts. It then follows the
existing accepted-recording path from #4330/#5590: transcribe into the
originating draft, or keep it in that composer's failed recordings with
the "saved in its composer" toast. It is never sent automatically.
Explicit Cancel still discards.
- The question field (`VoiceInputTextarea`, `recordingKey: null`) still
discards on unmount because it has no durable destination after the
question closes. That needs a separate ownership decision (issue options
1/3 are not implemented here).
- No wire, CLI, or doc changes.

## How you verified

- `useVoiceInput.test.tsx`: new test records 3 minutes, emits a chunk,
unmounts, then finishes the recorder late; asserts all chunks are
transcribed once and delivered with `insert` and no error toast. It
fails on main (1 failed, 22 passed) and passes with the fix. The old
discard-on-unmount test now covers the question field only.
- `pnpm exec turbo run test --filter=@bb/app --
src/hooks/useVoiceInput.test.tsx src/components/promptbox`: 559 passed.
`@bb/app` typecheck and lint pass.
- Ran a `pnpm start:worktree` instance with two threads for a manual
check; `bb voice transcribe` succeeded on that instance.

Fixes #6660

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Voice transcription is lost when its composer unmounts

1 participant