feat(mobile): transcribe voice input through the Kilo gateway - #6032
Conversation
54d7121 to
d82ce82
Compare
d82ce82 to
34a38ad
Compare
34a38ad to
8ddd98a
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryIncremental review of Files Reviewed (18 files)
Previous Review Summaries (3 snapshots, latest commit 3074f80)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 3074f80)Status: No Issues Found | Recommendation: Merge Incremental review of the changes since Files Reviewed (18 files)
Previous review (commit 4a9ff31)Status: No Issues Found | Recommendation: Merge Files Reviewed (38 files)
Previous review (commit 8ddd98a)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (24 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
f202d33 to
4a9ff31
Compare
Replace the primary/fallback dispatcher with a selector. The gateway switch now chooses the only engine that runs: off is the OS recogniser, on is the Kilo gateway. No engine ever hands a session to the other. - Default the gateway model to the first catalogue entry when the user has not stored a choice. - Drop the "Use as primary" preference, the engine-fell-back event, the both-engines copy, and the transcribing hand-off tone. - Remove the dispatch machine and its fallback suites; cover the selector instead.
…ing-voice-i-6a1b # Conflicts: # apps/mobile/src/components/agents/chat-composer.tsx
request.formData() rejects on a malformed body or missing boundary. The rejection escaped the route as an unhandled 500. Catch it and return null so POST answers the controlled 400 invalid-request response.
The default model and the picker read the catalogue unscoped, then the upload carried the organization header. The first global model can be unavailable to the organization, so the default could pick a model the scoped upload rejects. Read the stored organization id and pass it to fetchTranscriptionModels, and pass it from the picker into useTranscriptionModels.
Recorder.release() frees the native object, not the recording file, so every gateway dictation left an m4a behind. Inject a best-effort deleteRecording dependency and run it once the URI is known on every terminal path: upload success, classified failure, model/auth short-circuit, stale session, and abort during recording or upload. Tests cover success, failure, and both aborts.
The modern API covers deletion, size and existence checks, cache copies, and uploads through File.createUploadTask, so migrate the voice transcription client, the gateway recording cleanup, share-payload cache copies, and agent attachment uploads off expo-file-system/legacy. The upload task cancel handle is now synchronous (cancel), so the attachment hook drops its async seam. Add expo-file-system/legacy to no-restricted-imports so new code cannot regress.
…ing-voice-i-6a1b # Conflicts: # pnpm-lock.yaml
Changelog for users
Changelog for maintainers
apps/mobile/src/lib/voice-input/voice-input-engine-select.ts— the selector composes the OS recogniser and the gateway engine behind the singleVoiceInputNativethe controller consumes. It reads the chosen engine atstart(), routes start/stop/abort and every capability probe to that one engine, and drops events from the idle engine. No engine ever hands a session to the other. Review this file first.apps/mobile/src/lib/voice-input/voice-input-engine-mode.ts—resolveVoiceInputEngineName(enabled)maps the switch toosorgateway. The formergateway-primary/device-primarymodes and theVoiceInputEngineModeunion are gone.apps/mobile/src/lib/voice-input/native-voice-input.ts—createSelectingVoiceInputNativereplaces the two-engine dispatcher; the gateway-enabled subscription still refreshes availability so enabling the switch surfaces the mic without a restart.apps/mobile/src/lib/voice-input/gateway/gateway-transcription-preference.ts— two SecureStore keys remain (enabled default off, chosen model). Thegateway-transcription-primarykey and its hooks are removed.apps/mobile/src/lib/voice-input/gateway/native-gateway-voice-input.ts:22—resolveGatewayTranscriptionModelId()returns the stored model, else the first catalogue entry, else null. An unreachable or empty catalogue reads as no model, which surfaces the actionable picker message instead of an upload that must fail. The engine'sreadModelIddependency is now async.apps/mobile/src/lib/voice-input/use-voice-input-actions.ts— the start path branches once: switch on starts the gateway engine with no OS consent disclosure (the switch is the consent); switch off runs the existing OS consent flow. The model precondition and the picker alert on start are gone because the engine now resolves the default.VOICE_INPUT_TOAST_IDis a module-private constant shared by every voice-input toast, so sonner replaces messages in place; check:unused reports no unused exports, no checker ignore.engine-fell-backcontroller event and its listener,classifyVoiceInputEngineFallback, thevoice-engines-failederror case and its copy, thetone: 'info'feedback field, the Preferences "Use as primary" row, and thevoice-input-engine-dispatch*module plus its five suites. New coverage isvoice-input-engine-select.test.ts.apps/mobile/src/lib/voice-input/gateway/gateway-transcription-client.ts:133— a cancelled upload that resolves with no response is classified by checking the timeout signal first: a fired timeout returns the retryable timeout, while a caller abort stays an invalid response.apps/web/src/app/api/openrouter/audio/transcriptions/route.ts:278— the resolved organization provider policy is computed once and appended to the multipart form as a JSONproviderfield (the JSON branch merges it as before); multipart requests also carrysafety_identifieranduser, both the provider-specific hash.{ text: string }; failures classify into distinct codes that map to one copy each. The gateway route accepts multipart uploads and exempts free models from the zero-balance gate; the catalogue fetch is uncached; the feature value ismobile-voice-input. The fake gateway keeps exactly its two committed transcription models and a request counter; no fixture, test hook, or test-only flag is committed. The feature-flags mounted test mocks the gateway transcription preference module, whose import-time Sentry chain cannot resolve under vitest.Owner manual verification
E2E proof
The device captures for the Preferences rows, persistence across launch, the fake-gateway round trip, and the switch-off no-call check remain valid. The prior "use as primary" and fallback hand-off captures are superseded by this change and are not part of the current proof.
Owner request
E2E proof — log excerpts
.../e2e-mobile-app/p1-timeout.log.../e2e-mobile-app/p2-upstream-fields.log