Skip to content

feat(web): on-device voice input in the composer behind T3CODE_FEATURE_VOICE_INPUT - #1

Draft
stevefarthing-amc wants to merge 2 commits into
mainfrom
feat/web-voice-input
Draft

stevefarthing-amc wants to merge 2 commits into
mainfrom
feat/web-voice-input

Conversation

@stevefarthing-amc

@stevefarthing-amc stevefarthing-amc commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Adds a mic to the web and desktop composer, behind the T3CODE_FEATURE_VOICE_INPUT build flag. Click it (or press Enter) to stop, and the transcript is inserted at the cursor for review; nothing is sent automatically. Transcription runs on the device with Whisper, so no audio leaves the machine. This is an internal draft on our fork to review before deciding whether to propose it upstream in Ideas discussion #25797.

At a glance

Goal Dictation on web and desktop, matching what iPhone already has
This PR A web recorder and a Whisper transcriber plugged into the existing shared VoiceInputController
Before -> after No mic on web/desktop -> mic beside Attach when the flag is on; off by default
Install model onnx-community/whisper-base (about 100 MB) downloads on first use and the browser caches it. The composer shows "Downloading speech model, one time only · N%"

Review first

  • Upstream eligibility. CONTRIBUTING requires maintainer approval of a feature's direction before a PR. Several voice PRs were closed for skipping that (#18302, #11278). This should not go upstream until a maintainer agrees in the discussion.
  • Bundle and dependency cost. Adds @huggingface/transformers. The worker chunk is 548 KB, and ONNX Runtime's wasm is a 27 MB lazy asset in the web dist, fetched only on first mic use. Node-only deps (onnxruntime-node, sharp) are removed with pnpm overrides plus a manifest patch so they are neither installed nor listed in license notices.
  • Engine boundary. Swapping engines or adding a cloud service means implementing VoiceTranscriber (see whisperTranscriber.ts). Typing while recording discards the transcript with a message, the same rule iPhone uses. Live partial text and post-transcription cleanup are left out.

Before proposing upstream

What closed or reworked earlier voice PRs, and how this branch stands:

  • Approval. Most outside feature PRs close for lacking it, including voice PR #12275. Get an explicit yes in #25797 and link that comment. A build flag doesn't substitute (#25144); ask whether they want a flag or a Labs toggle.
  • Scope precedent. #11278 was declined on scope and for calling a private Codex endpoint through the wrong environment. This branch calls no provider or server, and follows Theo's on-device iPhone approach (#8614) by reusing VoiceInputController instead of duplicating it.
  • Competing work. #14882 (environment-server transcription, about 18.6k lines) is open again and was cited by maintainers as the web/desktop path. The proposal should say why client-side is smaller and works over remote connections.
  • Rework magnets. No className restyles on components/ui, effects carry a reason, no new test files for wiring, heavy code loads only on first use, model and harness named, rebased right before review, "allow maintainer edits" on.
  • Left for the discussion, not this diff. A keybinding or push-to-talk (#7417), the command palette, Settings → Microphone device choice, a language setting (#21742), and a web/desktop section in docs/user/composer.md.

Validation

  • vp run check:changed at 930be7a: format, lint, knip, typecheck (36 packages), tests, react compiler all pass, rebased on upstream main
  • T3CODE_FEATURE_VOICE_INPUT=1 vp build (before rebase): passes; transformers.js is absent from the main chunk; license manifest lists onnxruntime and transformers, not sharp or libvips
  • Dev server, Chromium with WebGPU, a say-generated clip fed in as the mic: model download 6.5 s, 5 s clip transcribed in 1.1 s, text inserted after existing draft text, Enter stopped instead of sending; download, listening and transcribing labels each shown
  • Mic permission denied: toast shown, button returns to idle
  • Not verified: a live microphone, the Electron desktop app, Safari/Firefox, slow-network download, and the flag-off production build. Screenshots not attached yet.

Security & Privacy Impact

PHI risk: Low. Audio is recorded and transcribed entirely in the browser; the recording is a blob URL revoked after transcription or cancel, and only the inserted text joins the draft. The only network traffic is the one-time model download from huggingface.co, which carries no user audio or text.

Written by Claude Opus 5.5 (claude-opus-5-5) in Claude Code.

🤖 Generated with Claude Code

stevefarthing-amc and others added 2 commits October 29, 2026 14:01
…E_VOICE_INPUT

Dictation exists on iPhone but not on web or desktop. This adds a mic beside
Attach that records, transcribes on the device with Whisper (transformers.js
in a worker, WebGPU when available), and inserts the text at the cursor for
review. Enter or a second click stops recording; nothing is sent.

It reuses the shared VoiceInputController from client-runtime, so the web
client only adds a MediaRecorder recorder and a VoiceTranscriber. The model
(onnx-community/whisper-base, about 100 MB) downloads on first use and the
browser caches it; the ONNX runtime wasm is a lazy asset, so nothing loads
until someone presses the mic. The flag is off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The spinner alone made the one-time model download and transcription easy to
miss. A short label now names each state: the one-time download with its
percentage, listening with elapsed time and the Enter hint, and transcribing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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

Development

Successfully merging this pull request may close these issues.

1 participant