Repository navigation
fix(ui): keep dictated text when the window loses focus - #197852
Conversation
Window blur and visibilitychange to hidden used the Escape path and stopped live dictation without committing, so a screensaver, Alt+Tab or a tab switch silently discarded everything already transcribed. They now finish an active capture and commit its transcript into the draft. A hold that has not started capture is still cancelled, and Escape and draft replacement still discard. Fixes openclaw#197843
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesWindow blur and page hiding now stop dictation while preserving its transcript in the composer draft. Example: Switch browser tabs after dictating “Five minutes of careful dictation” into a draft containing “Notes: ”.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a focused fix for dictated text loss that remains on current main, with no actionable code findings; CI is still running, and the failed PR-context check concerns section headings. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Control UI dictation owner coordinates microphone capture and Gateway transcription, then inserts completed speech into the owning composer draft. flowchart LR
A[Microphone audio] --> B[Dictation session]
B <--> C[Gateway transcription]
D[Blur or hidden page] --> E[Composer dictation owner]
E --> B
B --> F[Composer draft]
Technical reviewBest possible solution: Use the existing committing Stop path for focus interruptions while retaining explicit cancellation and draft-ownership safeguards. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the discard path, and the supplied browser before/after evidence reproduces its visible result; this review executed no target code. Is this the best way to solve the issue? This is the smallest complete repair: it reuses finalization and transcript ownership already implemented for Stop, without another state machine or persistence layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 96c685be0e01. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests 0. Total +4 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)Reviewed November 13, 2026, 3:43 AM ET / 08:43 UTC (Revision 3). |
A tab switch or minimize fires blur and then visibilitychange. The first event starts the commit and leaves the phase idle, so the second took the cancel path and retired the pending commit, losing the text again. An interruption now leaves a pending commit to finish; a hold without a session still cancels.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Proof on head 78f6040 (main 8ebe740 merged in). Built Gateway and built Control UI in headed Chromium (secretless node:24.22.1 container, Xvfb + openbox), latched dictation from a local realtime STT fixture. Interruptions are real keystrokes via xdotool: Ctrl+N (window blur) and Ctrl+T then Ctrl+W (tab switch: blur, then hidden, then visible). Main once, candidate once.
In every run the microphone track ended (0 live tracks) and nothing was sent (chat shows "No messages yet"). Unit file: 34/34 pass. Control UI JS gzip: +156 B. Before (main) and after (this PR), tab switch: |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 5da97e5. Thanks @wr-web, and @digitalfrost84 for the report. |
) 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]>
) (cherry picked from commit 5da97e5) Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit bcf4b79a28f2cd273baa94cfda1cf6c85edc8905)





Fixes #197843. Thanks @wr-web for the fix and @digitalfrost84 for the clear report and root cause.
What Problem This Solves
Control UI dictation listens for window
blurand for the page becoming hidden while it records or finalizes. Both routed tocancel(), which stops withcommit: false: capture stopped, but every word already dictated was thrown away. Alt+Tab, a tab switch or a screensaver lost the whole dictation. A blur followed by a hidden page (a tab switch), or a blur during finalization after Stop, also discarded the pending final.Fix
Blur and hidden page now stop through the same committing path as Stop (
finishActive()): the microphone and recognition still stop, and the text goes into the draft (nothing is sent). Escape and hold-mode drag-out still discard. A repeat blur or hidden event while the final drains is a no-op, so the text is committed once.Maintainer decision: keep text on blur. #111114 chose "lose focus to cancel" for the old hold-to-record gesture; that gesture is gone (
start()clears the pointer gesture and all dictation is latched), so keeping already-transcribed draft text is data preservation. Capture still stops and nothing is sent.Tests
The latched-Stop test now runs for click, blur and visibilitychange, follows each with a hidden-page event, and checks one commit and a stopped microphone track. The hidden case leaves the discard test (Escape and draft replacement stay there). Net test lines: 0.
Evidence
Built Gateway and built Control UI in headed Chromium, real window blur and real tab switch; see the proof comment.