Skip to content

fix(voice): guard piecewise dictation against stale callbacks and hung pieces - #816

Merged
LeanBitLab merged 1 commit into
mainfrom
fix/voice-piecewise-hardening
Nov 15, 2026
Merged

LeanBitLab merged 1 commit into
mainfrom
fix/voice-piecewise-hardening

Conversation

@LeanBitLab

Copy link
Copy Markdown
Owner

Summary of Changes

Hardening for the "transcribe while speaking" voice mode added in v4.3.3-beta2.

Motivation & Context

Found while reviewing the beta2 voice changes:

  1. The audio thread posts piece and end-of-recording callbacks to the main thread, guarded only by piecewiseActive. A late post from a finished session could end or feed a newer one if a new dictation started before it ran.
  2. A piece is only finished when the plugin calls onSessionEnded. If it never does, pieceInFlight stays set and every later piece waits forever; the 60 s processing timeout only starts after the user stops recording.

Changes Made

  • VoiceInputManager.kt: per-session piecewiseGeneration. The audio thread tags its posts with it, the handlers ignore a mismatch, and starting or cleaning up a session bumps it.
  • Per-piece timeout using the existing processingTimeoutFor formula (at least 60 s). It is cancelled when the piece's session ends and in cleanupSession. On expiry the dictation stops with the usual "Voice processing timed out" error; text already inserted stays.
  • Only API 1 constructs are used (Android 6 is the minimum).

Verification & Testing

  • helium314.keyboard.latin.voice.* unit tests pass
  • Builds via ./gradlew :app:assembleStandardDebug, installed on a device, starts without a crash in logcat
  • Not exercised on a device: needs a Whisper model, live audio, and a plugin that hangs

Guidelines Checklist

  • This PR addresses a single focused concern.
  • Does not add unnecessary dependencies or binary blobs.
  • No em dashes used in comments, descriptions, or documentation.

…g pieces

Tag the audio thread's posts with a per-session generation so a late post
from a finished session cannot end or feed a newer one. Add a per-piece
timeout (same length-based formula as the final processing timeout) so a
plugin that never ends a piece's session no longer blocks later pieces.
@LeanBitLab
LeanBitLab merged commit 77d8944 into main Nov 15, 2026
1 check passed
@LeanBitLab
LeanBitLab deleted the fix/voice-piecewise-hardening branch November 15, 2026 06:44
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.

1 participant

⌂ Proxy