Skip to content

Keep failed voice recordings in the composer and retry with the original send choice - #5590

Merged
ymichael merged 3 commits into
mainfrom
bb/voice-retry-behavior-and-ux-thr_aimm2bc7ty
Oct 15, 2026
Merged

ymichael merged 3 commits into
mainfrom
bb/voice-retry-behavior-and-ux-thr_aimm2bc7ty

Conversation

@ymichael

@ymichael ymichael commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

When voice transcription failed, the only way back to the audio was a sticky "Voice input failed" toast. Its Retry ignored how the recording was ended: usePromptVoice reset its pending-send flag when the hook reached the error state (createPromptVoiceIntent().settle), so a retried recording that had been ended with Send was always inserted into the draft instead. The audio also lived only in the toast's closure. Dismissing the toast, or reloading the page or the iOS webview, lost the recording, and on iOS the toast's "Download recording" couldn't save it (#5302).

What changed

  • Send choice travels with the recording. useVoiceInput.stop(delivery) takes "insert" | "send". The choice is stored with the recording and passed to onTranscript(text, delivery), so Retry respects it. The old send-flag state machine in prompt-voice-intent.ts is gone, and the double-stop guard now relies on MediaRecorder.state.
  • Failed recordings stay in the composer. The new lib/voice-recording-store.ts keeps recordings per composer, keyed by composerScopeIdentity. It saves a recording to IndexedDB (via idb-keyval) when transcription starts and removes it on success or discard. Recordings therefore survive navigation, composer unmount, and page or webview reloads. A recording interrupted by a reload comes back as failed, with "Transcription did not finish".
  • Banner replaces the sticky toast. FailedVoiceRecordings.tsx shows "Voice input failed · " with Retry, Download, and an X to discard. It is one row on desktop and two rows on narrow screens. Question-form dictation (VoiceInputTextarea) shows the same banner, but those recordings are not saved across reloads because that input has no draft key.
  • Retry runs inside the banner. The button reads "Retrying…" while the composer stays idle, so you can keep typing or start a new recording. Success removes the banner and delivers with the original choice; failure brings the banner back with the new error; the X aborts the retry and discards the recording. The store owns each recording’s retry state and abort controller, so discarding also cancels a retry after navigating away and returning to the composer. Results are accepted only while the recording still owns that retry; late responses cannot deliver discarded audio. Navigation alone keeps the retry running.
  • Completion transition. The recording bar's exit animation now runs only for live recordings, through a playCompletionTransition option on useVoiceInput. This replaces transcribeAfterCompletionTransition.
  • Cancel semantics. Cancelling a first transcription still discards the recording, as before.
  • Failure after leaving the composer. If transcription fails after its composer unmounts, a short non-sticky toast says the recording is saved in its composer.
  • Recording bar. It shows progress on the button matching the recording's choice, taken from the hook rather than local pressed state, so live transcription shows the right spinner.
  • Dependencies: idb-keyval (runtime) and fake-indexeddb (dev, for the store test).

There are no server, daemon, CLI, or configuration changes.

Behavior notes:

  • The new-thread composer keys recordings by project, while its draft text is shared across projects, so a failed recording is only visible on the project it was recorded on.
  • Recordings for threads that are later deleted stay in IndexedDB until discarded.
  • Other open tabs see a failed recording only after a reload.

How you verified

  • Cancellation regression: start a retry, unmount and remount the composer, discard, then resolve the original request. The test failed before the fix and passes afterward; it verifies cancellation and no transcript delivery. A companion case verifies that navigation without discard still delivers with the original send choice.
  • After the cancellation fix: pnpm exec turbo run test --filter=@bb/app -- src/hooks/useVoiceInput.test.tsx src/lib/voice-recording-store.test.tsx passes all 24 tests; pnpm exec turbo run lint typecheck --filter=@bb/app passes with existing lint warnings; git diff --check passes.
  • New tests:
    • voice-recording-store.test.tsx: an unfinished recording is restored after a simulated reload against fake IndexedDB, and deleting a recording before its save finishes leaves nothing stored.
    • useVoiceInput.test.tsx: retry keeps the original send or insert choice, prompt context, and audio file; a stop/send double click keeps the first choice; a retry leaves the composer idle, allows a new recording, and is aborted by discarding; a live transcript waits for the completion transition while a retry skips it; a failure after unmount shows the toast and the recording on remount.
  • Existing voice, composer, and question-form tests were updated for the new API.
  • pnpm exec turbo run typecheck lint --filter='...[origin/main]' passes; lint shows existing warnings only.
  • Before the cancellation fix, pnpm exec turbo run test --filter=@bb/app: 5852 passed. An earlier run across all affected packages had one failure, PluginSettings.test.tsx > autosaves the latest text value on blur; that test is untouched by this change and passed 3 of 3 runs on its own.
  • Not verified by the agent: the end-to-end retry flow in a running app. A pnpm start:worktree build is up for manual checking; setting Voice input to Off in Settings → AI services makes transcription fail on demand.
  • Not verified: Download on an iOS device.
  • Visual checks in Ladle at 1280 px and at 390 px (2x, touch): two failures, a failure with draft text, the compact composer, a retry in progress, and question-form dictation.

Fixes #5302

AGENT GENERATED

ymichael and others added 3 commits October 15, 2026 15:21
…nal send choice

A failed transcription now leaves a "Voice input failed" banner in the
composer with Retry, Download, and discard. Recordings are saved per
composer in IndexedDB until they transcribe or are discarded, so they
survive navigation, unmount, and reloads. Retry keeps whether the
recording was sent or added to the draft.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Retry no longer moves the composer into the transcribing state. The
banner shows "Retrying…" while the composer stays free for typing or a
new recording; success delivers with the original send or insert
choice, failure returns the banner with the new error, and discarding
aborts the retry. The completion transition now runs only for live
recordings, through a playCompletionTransition option on useVoiceInput.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 2cc5a11 into main Oct 15, 2026
48 checks passed
@ymichael
ymichael deleted the bb/voice-retry-behavior-and-ux-thr_aimm2bc7ty branch October 15, 2026 23:09
ariofrio added a commit to ariofrio/bb that referenced this pull request Oct 16, 2026
Takes upstream's post-get-bb#5590 voice files, since get-bb#5590 applies on top of 0.46.1, and keeps 0.46.1's plugin SDK version and API audit doc, which already include get-bb#5508.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

iOS app: "Download recording" on a failed voice input does nothing, so the audio is lost

1 participant