Skip to content

fix(mobile): keep dictated words through calls, busy taps and failed inserts, and say why dictation failed - #35216

Merged
AmoabaKelvin merged 4 commits into
mainfrom
mobile-dictation-keeps-transcript
Oct 28, 2026
Merged

AmoabaKelvin merged 4 commits into
mainfrom
mobile-dictation-keeps-transcript

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​294 $\color{#cf222e}{\Huge{\mathbf{−}}}$​187 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​107
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​118 $\color{#cf222e}{\Huge{\mathbf{−}}}$​79 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39

ELI5

Dictating on the phone could lose what you said with no message: a phone call or Siri cut it off, a second tap on the mic while it was transcribing threw the result away, and a terminal that couldn't take the text just dropped it. Errors sometimes showed internal codes like dictation_already_active. Now an interruption keeps what you said, a tap while transcribing waits, text a target refuses goes to the clipboard with a toast saying so, and the codes read as sentences.

What Changed

  • Interruptions finish instead of cancelling (Phone dictation drops what you said when a call or Siri interrupts it #35207). Native began/blocked interruptions, plus the page capture's own losses (recording:false or a refused read), used to call cancel(). That is abandonDictation(null), the silent path reserved for the user's own cancel, so the audio already sent to the computer was never finished. In use-mobile-dictation.ts the interruption handler now finishes a recording dictation the same way stop does, and keeps the transcript. If nothing was transcribed, or the interruption lands while starting, the user sees "Voice dictation stopped because the microphone was interrupted. Try again." stop and the interruption share one finishDictation; only the empty-transcript message differs. An interruption while processing or idle is ignored.
  • A tap while processing waits (Tapping the mic while phone dictation is processing throws the transcript away #35208). handleDictationToggle used to cancel while processing. Cancelling bumps the generation, so the finish reply that came back was ignored. Now the tap does nothing until the finish settles, the same as a tap while starting. Long-press on the terminal mic still cancels on purpose. The terminal mic's accessibility label while processing changes from "Cancel voice dictation" to "Transcribing voice dictation".
  • Refused transcripts are kept (Phone dictation into a live terminal is lost when the insert fails #35209). When a terminal live insert fails (no handle, a failed flush, a switched tab, not connected, or a refused send), or the chat/queued-edit destination refuses the text, the transcript is copied to the clipboard and a toast says "Couldn't insert dictation, so it was copied to the clipboard". It used to just return.
  • Plain error messages (Phone dictation errors show raw codes like dictation_already_active #35210). dictationFailureMessage in mobile-dictation-setup.ts maps the host's dictation codes next to the existing speechless-server mapping. dictation_already_active becomes "Dictation is already in use on the computer or another phone." The three session-gone codes (dictation_owner_mismatch, dictation_stream_not_started, dictation_stream_closing) become "Dictation lost its connection to the computer. Try again." dictation_requires_mobile_client asks the user to re-pair the phone. Unknown messages pass through unchanged.

Why

Each fix is in the place that makes the decision. The interruption rule goes in useMobileDictation, because it owns the status, the dictation id and the finish/cancel calls. The capture seam only reports that the mic dropped. The clipboard fallback goes in the session hook where every dictation route ends. sendLiveTerminalInput also carries typed keystrokes, which must not land on the clipboard. The codes are wire identity that older phones match exactly (the setup-sheet codes, for one), so the host keeps sending codes and the phone translates them for display. Neither desktop nor mobile had a mapper to reuse. Desktop shows the same raw dictation_already_active when a phone holds the model; that's left for a follow-up, and the map should move to src/shared then rather than being copied.

One dictation at a time across the computer and phones is intended, since there's one speech model, so only the message changes.

Linked Issue

Fixes #35207
Fixes #35208
Fixes #35209
Fixes #35210

Visual Proof

No capture. The only visible changes are toast text and a transcript landing where it used to vanish. A real phone call or Siri interruption can't be triggered in the simulator, and the processing tap needs a paired computer with a speech model. Each case is proven in mobile-dictation-session-outcomes.test.tsx, which mounts the real session and dictation hooks over the native capture binding with a fake host. Every new case failed on main and passes here.

Testing

  • New mobile/src/session/mobile-dictation-session-outcomes.test.tsx covers: an interruption while recording sends finish (not cancel) and inserts the transcript; an empty interrupted transcript shows the interrupted message; a tap while processing keeps the transcript; a refused live insert copies to the clipboard with the toast; dictation_already_active toasts the sentence. It also absorbs the old mobile-dictation-refused-start-routing.test.tsx cases, so the two files share one harness. Every new case was run against main's production files and failed.

  • Ran every test file that imports or mocks a changed module (27 files), the dictation setup tests, and the mobile RPC recording goldens (mobile/src/test-support/rpc-recording, 1695 tests): all pass.

  • check:code-quality:changed and check:react-doctor:changed pass. CI runs typecheck and the full suite.

  • Not run on a device.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Codex and a Claude reviewer each reviewed one round. Codex found nothing. Claude raised one P2: in chat, the mic doesn't show a busy state while the transcript is processing, so a tap during a slow finish looks dead. That is left as a follow-up because it needs new composer UI in files #32656 also edits. Its two P3s (a delivery-ambiguous send reported as failed, and a double toast for an over-256 KiB transcript) were left as is.

CodeRabbit's Major (a rejecting flush or send skipped the fallback) is fixed in 8fc28d2, with a throwing-send test case. Its Minor (an unknown message named like an object prototype key) and Trivial (no second fallback when the clipboard refuses) were left as is.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Phone-only change, with no wire or host change, so mixed phone and computer versions behave as before apart from the new copy. Native capture (iOS/Android) and the OTA page capture share the same interruption handler. Terminal live and buffered input and the native chat/queued-edit destinations all go through the same fallback. Nothing here depends on the platform or on SSH vs local, and folder workspaces are unaffected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

… failed inserts

A call, Siri or mic dropout now finishes the dictation instead of
discarding it, a tap while transcribing no longer cancels, a transcript
its target refuses is copied to the clipboard with a toast, and host
dictation error codes show as plain sentences.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bdef1319-7a35-4fe4-a569-f4ed91a0f082
Commits

Reviewing files that changed from the base of the PR and between 5489a1f and 8fc28d2.

Files selected for processing: 2
  • mobile/src/session/mobile-dictation-session-outcomes.test.tsx
  • mobile/src/session/use-mobile-session-native-chat-dictation.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Walkthrough

Mobile dictation now finishes recording when the microphone is interrupted and reports an interruption message if no transcript is available. Dictation failures use mapped user-facing messages. If transcript delivery fails, the session attempts to copy the transcript and reports the result. Taps during processing no longer cancel dictation. Tests cover these behaviors and related start-refusal outcomes.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Low · up to 8fc28

Unusual error messages may not display correctly. Clipboard refusal can still lose undelivered dictation, although recovery is improved overall.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main mobile dictation changes: retaining dictated text through interruptions and failed inserts, handling busy taps, and improving failure messages.
Linked Issues check Passed The PR meets the coding requirements for [#35207], [#35208], [#35209], and [#35210]. The interruption path now finishes recording and keeps the transcript, including microphone-drop cases. An empty in…
Out of Scope Changes check Passed The production changes remain within phone dictation handling. The shared finish path, processing accessibility label, failure-message mapping, clipboard fallback, route handling, and related test-har…
Description check Passed The description is complete and aligned with the required template. It explains the user impact, implementation, rationale, linked issues, visual-proof decision, testing, review notes, scope, and chec…
Full details: Linked Issues check

Explanation

The PR meets the coding requirements for [#35207], [#35208], [#35209], and [#35210]. The interruption path now finishes recording and keeps the transcript, including microphone-drop cases. An empty interrupted transcript uses the interruption message. A processing tap no longer cancels the active dictation. Failed live-terminal delivery and refused destination insertion copy the transcript and show a toast. dictationFailureMessage maps all five listed host codes to plain-language messages. The added session outcome tests cover these behaviors.

Full details: Out of Scope Changes check

Explanation

The production changes remain within phone dictation handling. The shared finish path, processing accessibility label, failure-message mapping, clipboard fallback, route handling, and related test-harness changes support [#35207] through [#35210]. The chat and queued-edit fallback extends the same failed-insert recovery behavior. No unrelated product area is shown in the supplied change summary.

Full details: Description check

Explanation

The description is complete and aligned with the required template. It explains the user impact, implementation, rationale, linked issues, visual-proof decision, testing, review notes, scope, and checklist. The linked issue references and visual-proof explanation satisfy the required information, despite not using full URLs or the exact N/A wording.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 11 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Nitpick comments: 1
mobile/src/session/use-mobile-session-native-chat-dictation.ts: 1

125-125: Trivial · Functional Correctness · Poor tradeoff

Consider a fallback for clipboard-write failure.

When Clipboard.setStringAsync returns false or rejects, keepUndeliveredDictation only shows "Couldn't insert dictation". The transcript then has no recoverable destination. The toast correctly avoids claiming that the text was copied and signals that insertion failed.

No supplied contract requires a second destination when the clipboard itself refuses the write. Treat this as optional hardening, not a major issue.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2ebe6859-94d3-4eba-b407-28681b1578ee
Commits

Reviewing files that changed from the base of the PR and between 3416bda and 5489a1f.

Files selected for processing: 12
  • mobile/src/dictation/mobile-dictation-setup.test.ts
  • mobile/src/dictation/mobile-dictation-setup.ts
  • mobile/src/hooks/mobile-dictation-session-state.ts
  • mobile/src/hooks/use-mobile-dictation.ts
  • mobile/src/platform/dictation-capture-contract.ts
  • mobile/src/platform/dictation-capture.test.ts
  • mobile/src/session/MobileTerminalInputActions.tsx
  • mobile/src/session/mobile-dictation-agent-chat-start.test.tsx
  • mobile/src/session/mobile-dictation-mode-refresh.test.tsx
  • mobile/src/session/mobile-dictation-refused-start-routing.test.tsx
  • mobile/src/session/mobile-dictation-session-outcomes.test.tsx
  • mobile/src/session/use-mobile-session-native-chat-dictation.ts
Files with no reviewable changes: 1
  • mobile/src/session/mobile-dictation-refused-start-routing.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

if (isSpeechlessServerError(message)) {
return SPEECHLESS_SERVER_MESSAGE
}
return HOST_DICTATION_ERROR_MESSAGES[message] ?? message

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Preserve unknown messages that match object prototype keys.

If the host sends an unknown message such as constructor or toString, this lookup returns an inherited function instead of the message. showToast then receives a non-string value. Use an own-property check or a Map so unknown messages pass through unchanged. (raw.githubusercontent.com)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant