feat(audio): add opt-in browser dictation - #3039
Open
berdebotond wants to merge 1 commit into
Open
berdebotond wants to merge 1 commit into
berdebotond wants to merge 1 commit into
Conversation
Co-Authored-By: Codex <noreply@openai.com>
berdebotond
requested review from
asvishnyakov,
hayescode and
sandangel
as code owners
September 5, 2026 16:54
Contributor
There was a problem hiding this comment.
1 issue found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="frontend/src/components/chat/MessageComposer/index.tsx">
<violation number="1" location="frontend/src/components/chat/MessageComposer/index.tsx:101">
P3: The onTranscript handler appends dictated text to the React `value` state: `setValueExtern([value, text].join(' '))`. If two final recognition results arrive before React re-renders, both use the same stale `value`, so the second overwrites the first instead of appending to it and dictated text is lost. Read the live input text rather than the `value` state (e.g., from `inputRef.current` or an accumulating ref) so consecutive results always build on the latest content.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| const dictation = useBrowserSpeechRecognition({ | ||
| enabled: browserDictation && !disabled, | ||
| language: i18n.language, | ||
| onTranscript: (text) => { |
Contributor
There was a problem hiding this comment.
P3: The onTranscript handler appends dictated text to the React value state: setValueExtern([value, text].join(' ')). If two final recognition results arrive before React re-renders, both use the same stale value, so the second overwrites the first instead of appending to it and dictated text is lost. Read the live input text rather than the value state (e.g., from inputRef.current or an accumulating ref) so consecutive results always build on the latest content.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/components/chat/MessageComposer/index.tsx, line 101:
<comment>The onTranscript handler appends dictated text to the React `value` state: `setValueExtern([value, text].join(' '))`. If two final recognition results arrive before React re-renders, both use the same stale `value`, so the second overwrites the first instead of appending to it and dictated text is lost. Read the live input text rather than the `value` state (e.g., from `inputRef.current` or an accumulating ref) so consecutive results always build on the latest content.</comment>
<file context>
@@ -89,6 +92,17 @@ export default function MessageComposer({
+ const dictation = useBrowserSpeechRecognition({
+ enabled: browserDictation && !disabled,
+ language: i18n.language,
+ onTranscript: (text) => {
+ inputRef.current?.setValueExtern([value, text].filter(Boolean).join(' '));
+ },
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds opt-in browser speech-to-text for #3003. With
[features.audio] enabled = trueandmode = "browser", the microphone usesSpeechRecognition/webkitSpeechRecognitionand appends finalized transcripts to the composer. Users can edit the text and submit through the normal message path, retaining selected commands and attachments.The existing Python audio streaming path remains the default (
mode = "realtime"). Browser mode requires no Python audio callbacks. Recognition stops on submit, disables/unmounts safely, handles microphone/start errors, avoids duplicate final results, and shows a disabled microphone when unsupported. The README and generated config explain browser support and possible vendor-hosted recognition.Validation:
Fixes #3003
AI assistance: implemented and tested with Codex at the contributor's request, credited in the commit as required by AGENTS.md.
Summary by cubic
Fixes #3003 by adding opt-in browser dictation. With
features.audio.mode = "browser", the composer microphone uses the Web Speech API and appends finalized transcripts for editing and normal submission;mode = "realtime"with Python audio callbacks remains the default.SpeechRecognitionorwebkitSpeechRecognition.Written for commit 86cec9a. Summary will update on new commits.