Repository navigation
feat(ui): hold-to-record dictation on the composer mic button - #111114
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 19, 2026, 2:30 AM ET / 06:30 UTC. Summary PR surface: Source +1017, Tests +805. Total +1822 across 17 files. Reproducibility: yes. from source with medium confidence: release during provider WebSocket authentication/reconnection, after browser frames are queued but before readiness, then observe that finalization closes the session and drops queued audio. A real configured-provider browser run is still needed to confirm the exact user-visible outcome. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Preserve the existing tap-to-Talk behavior, make dictation finalization wait for provider readiness or retain queued audio through finalization, then land only after a redacted real browser run proves hold, speech, release, final transcript insertion, cancellation, and selected-microphone behavior against a configured provider. Do we have a high-confidence way to reproduce the issue? Yes, from source with medium confidence: release during provider WebSocket authentication/reconnection, after browser frames are queued but before readiness, then observe that finalization closes the session and drops queued audio. A real configured-provider browser run is still needed to confirm the exact user-visible outcome. Is this the best way to solve the issue? No: reusing the transcription relay is the right boundary, but closing the relay without a provider-readiness or queued-audio preservation guarantee is not a durable dictation finalization path across providers. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7055ed578d08. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1017, Tests +805. Total +1822 across 17 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (4 earlier review cycles)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6523a69952
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| this.inputMeter = new RealtimeTalkMediaStreamMeter(this.callbacks.onLevel); | ||
| this.inputMeter.start(media, this.context); | ||
| this.inputPump.start(media, this.context, (samples) => this.appendAudio(samples)); |
There was a problem hiding this comment.
Use sub-512 ms capture frames for 8 kHz dictation
At the configured 8 kHz sample rate, RealtimeTalkPcmInputPump uses the 4096-sample buffer in ui/src/pages/chat/realtime-talk-audio.ts:88, so onSamples runs only about every 512 ms. Releasing the button immediately stops the processor without flushing its partially filled buffer; consequently, utterances shorter than 512 ms can produce no audio at all, and every recording can lose up to the final 512 ms of speech. Use a smaller dictation capture buffer or a capture path that flushes/resamples pending samples before stopping.
Useful? React with 👍 / 👎.
| if (this.phase === "stopping") { | ||
| return; |
There was a problem hiding this comment.
Handle disconnects while finalizing
If the Gateway disconnects after pointer release has entered stopping, this early return skips markGatewayDisconnected(). A finalization with no completed transcript or with only a partial therefore remains locked for the full 10-second drain timeout and can report a finalization timeout instead of the disconnect, whereas disconnects during recording finish promptly.
Useful? React with 👍 / 👎.
| const keepFinal = this.active && !options.connected; | ||
| if (keepFinal) { | ||
| this.session?.markGatewayDisconnected(); | ||
| } | ||
| void this.stop({ commit: keepFinal }); | ||
| if (keepFinal) { | ||
| options.onError(t("chat.composer.dictationDisconnected")); |
There was a problem hiding this comment.
Suppress request errors after a known disconnect
When the Gateway disconnects while talk.catalog or talk.session.create is pending, this path immediately emits the friendly disconnect error and starts finish(), but the pending RPC rejection is subsequently passed through reportFailure() and invokes onError a second time with the low-level socket error. This overwrites the intended chat error and defeats the single-error behavior; mark the session failure as disconnect-owned or suppress later request failures once disconnection is known.
Useful? React with 👍 / 👎.
6523a69 to
f6dc842
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6dc84250d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| this.closePromise ??= this.client | ||
| .request("talk.session.close", { sessionId: this.sessionId }) | ||
| .then(() => undefined) |
There was a problem hiding this comment.
Commit OpenAI audio before closing dictation
When OpenAI transcription is active and the user releases before server VAD has observed its configured silence interval, this closes the relay immediately after stopping microphone input. The relay calls sttSession.close() (src/gateway/talk-transcription-relay.ts:408-429), but the OpenAI session registers no onClose action (extensions/openai/realtime-transcription-provider.ts:218-257), unlike providers that send a finalize/end frame, so the buffered utterance is never explicitly committed and cannot produce the final transcript that finish() awaits. This makes an otherwise fully transmitted utterance time out after 10 seconds and insert nothing; send the provider's input-buffer commit before closing or add a generic transcription-session finalize contract.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f801c4bc0d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await this.appendChain; | ||
| await this.closeRemote(); |
There was a problem hiding this comment.
Preserve queued audio until the provider is ready
When the user releases while the provider WebSocket is still authenticating or reconnecting, this closes the relay immediately. The relay returns the session before sttSession.connect() settles (src/gateway/talk-transcription-relay.ts:333-367), while the WebSocket session queues pre-ready audio but clears that queue in close() (src/realtime-transcription/websocket-session.ts:124-145). Consequently, a quick dictation can lose every frame even after the browser successfully sent it; wait for provider readiness/queue flushing before closing, or preserve the queued audio during finalization.
Useful? React with 👍 / 👎.
| const inputDeviceId = loadSettings().realtimeTalkInputDeviceId?.trim() || undefined; | ||
| const media = await openRealtimeTalkInput(inputDeviceId, { | ||
| signal: this.abortController.signal, | ||
| }); |
There was a problem hiding this comment.
Skip microphone acquisition after cancellation
If the hold is released, blurred, or cancelled while talk.catalog is pending, stopCapture() aborts the signal, but after the catalog response this still invokes getUserMedia. openRealtimeTalkInput() does not inspect an already-aborted signal until after getUserMedia resolves (ui/src/pages/chat/realtime-talk-input.ts:157-184), so a cancelled gesture can unexpectedly display a permission prompt or acquire the microphone later only to discard it. Check the stopped/aborted state before starting microphone acquisition.
Useful? React with 👍 / 👎.
| await this.stopCapture(); | ||
| await this.startPromise?.catch(() => undefined); | ||
| await this.appendChain; | ||
| await this.closeRemote(); |
There was a problem hiding this comment.
Route cancelled holds through the cancellation lifecycle
For Escape, blur, pointer-cancel, or slide-off, cancel() calls closeRemote(), which sends talk.session.close. The relay's close path explicitly emits input.audio.committed (src/gateway/talk-transcription-relay.ts:408-428), whereas talk.session.cancelTurn reaches cancelTalkTranscriptionRelayTurn() and emits the turn.cancelled outcome (src/gateway/talk-transcription-relay.ts:431-450). These user-cancelled dictations are therefore recorded as committed turns in Talk observability/state; use the cancellation contract and clean up the unified session afterward.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c46c4848d3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const dictationOptions = { | ||
| client: props.gatewayClient ?? null, | ||
| connected: props.connected, | ||
| enabled: props.composerHoldToRecord !== false, |
There was a problem hiding this comment.
Disable dictation when the composer cannot accept drafts
When canSend is false for an archived or otherwise read-only session (chat-pane.ts:2857), the textarea is disabled, but this still enables the hold controller and the microphone button remains clickable while connected. A long press therefore acquires the microphone, creates a transcription session, and calls onDraftChange to insert text into a composer the user cannot edit or send; gate hold-to-record on canCompose while preserving the existing tap-to-Talk behavior if needed.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
…aw#111114) * feat(ui): add hold-to-record dictation * chore: drop changelog edit (release generation owns CHANGELOG.md) * fix(ui): preserve composer controls after rebase * fix(ui): preserve dictation pointer capture * fix(ui): finish dictation on cancellation * docs(ui): note transcription-relay event envelope contract at the dictation parser * test(ui): complete realtime-talk-input mock factory for shared-registry workers * test(ui): isolate composer mocks across workers * test(ui): isolate shared chat module mocks * test(ui): type shared chat spies
…aw#111114) * feat(ui): add hold-to-record dictation * chore: drop changelog edit (release generation owns CHANGELOG.md) * fix(ui): preserve composer controls after rebase * fix(ui): preserve dictation pointer capture * fix(ui): finish dictation on cancellation * docs(ui): note transcription-relay event envelope contract at the dictation parser * test(ui): complete realtime-talk-input mock factory for shared-registry workers * test(ui): isolate composer mocks across workers * test(ui): isolate shared chat module mocks * test(ui): type shared chat spies
fix(ui): keep dictated text when the window loses focus Control UI dictation cancelled on window blur and on a hidden page, discarding everything already transcribed, so an Alt+Tab, screensaver or tab switch threw away minutes of speech. Blur now stops dictation through the existing commit path, so the transcribed text stays in the draft; capture still stops, the microphone is released and nothing is sent. A repeated blur or hidden event while the final text drains commits it once. Escape and hold-mode drag-out still discard. "Lose focus to cancel" came from #111114's hold-to-record gesture, which no longer exists now that all dictation is latched; keeping the user's already-transcribed draft is the intended behavior. No new text. Evidence: the built Gateway and Control UI in headed Chromium with a fake microphone and a local speech-to-text stand-in, with real keystrokes for window blur and tab switch, main once and candidate once. On main a window blur, a tab switch, and a stop followed by a tab and window switch all reset the draft to its starting text. With this change the full dictated text stays in the draft, committed once. Escape and drag-out discard and Stop keeps the same text on both; in every run the microphone stopped and nothing was sent. Control UI +156 B gzip. The latched test covers click, blur and visibilitychange each followed by a hidden page, at net 0 test lines. Screenshots: #197852 (comment). Fixes #197843. Thanks @wr-web, and @digitalfrost84 for the report. Co-authored-by: Ayaan Zaidi <[email protected]>
) fix(ui): keep dictated text when the window loses focus Control UI dictation cancelled on window blur and on a hidden page, discarding everything already transcribed, so an Alt+Tab, screensaver or tab switch threw away minutes of speech. Blur now stops dictation through the existing commit path, so the transcribed text stays in the draft; capture still stops, the microphone is released and nothing is sent. A repeated blur or hidden event while the final text drains commits it once. Escape and hold-mode drag-out still discard. "Lose focus to cancel" came from openclaw#111114's hold-to-record gesture, which no longer exists now that all dictation is latched; keeping the user's already-transcribed draft is the intended behavior. No new text. Evidence: the built Gateway and Control UI in headed Chromium with a fake microphone and a local speech-to-text stand-in, with real keystrokes for window blur and tab switch, main once and candidate once. On main a window blur, a tab switch, and a stop followed by a tab and window switch all reset the draft to its starting text. With this change the full dictated text stays in the draft, committed once. Escape and drag-out discard and Stop keeps the same text on both; in every run the microphone stopped and nothing was sent. Control UI +156 B gzip. The latched test covers click, blur and visibilitychange each followed by a hidden page, at net 0 test lines. Screenshots: openclaw#197852 (comment). Fixes openclaw#197843. Thanks @wr-web, and @digitalfrost84 for the report. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
The web composer has no dictation: the mic button only toggles a full realtime Talk session. Users who want to speak a message into the composer — without starting a live conversation — have no path, even though the gateway already ships a transcription relay that Android's dictation uses.
Why This Change Was Made
Press-and-hold is the natural quick-dictation gesture (design reference: Claude desktop's composer). A hold ≥250ms records; release inserts the transcript into the composer at the cursor without sending; a quick tap keeps starting realtime Talk exactly as before. The pipeline rides the existing gateway transcription relay as-is —
talk.session.create { mode: "transcription", transport: "gateway-relay", brain: "none" }, G.711 μ-law @ 8kHz (src/gateway/talk-transcription-relay.ts), the same envelope Android's dictation consumes. No server or protocol changes.User Impact
composerHoldToRecordsetting (default on) with a Settings toggle; turning it off restores the exact previous button behavior.Release-note context: Composer hold-to-record dictation — hold the web composer's mic button to dictate into the message box via the gateway transcription provider; tap still starts realtime Talk.
Evidence
transcriptionSessionIdenvelope this client parses; Android consumes the same shape — documented inline).src/gateway/talk-transcription-relay.ts(encoding, sample rate, event shapes) rather than assumed.git diff --check: clean.