Skip to content

fix(ui): keep dictated text when the window loses focus - #197852

Merged
obviyus merged 5 commits into
openclaw:mainfrom
wr-web:fix/dictation-blur-keeps-text
Nov 13, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
wr-web:fix/dictation-blur-keeps-text

Conversation

@wr-web

@wr-web wr-web commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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 blur and for the page becoming hidden while it records or finalizes. Both routed to cancel(), which stops with commit: 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.

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
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Window 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: ”.

  • Before: Recording stops and the draft returns to “Notes: ”.
  • After: Recording stops and the dictated sentence remains in the draft without sending a message.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, minimal repair with applicable browser proof and focused regression coverage; broad exact-head validation has not finished.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): obviyus exercised built Gateway and Control UI dictation in headed Chromium using a local STT fixture and real window/tab keystrokes; inspected screenshots show text retained after tab switching and Stop followed by interruptions, with no chat message sent, and the changed files match the reviewed head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A window switch, tab switch, or screensaver can erase all speech already dictated into the composer.
Reason: Preserving draft text while still stopping capture has clear value; the historical cancellation choice is acknowledged, and an established dictation contributor supplied the revised implementation and browser verification.

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
Reviewed head: 24c020788041114ab7d0bb3720eb95751518d9c2

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit aae5b0f adds ui/src/pages/chat/composer-dictation.ts:576 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: aae5b0f041db; files: ui/src/pages/chat/composer-dictation.ts)
  • Ayaan Zaidi: Raw commit 925056c adds ui/src/pages/chat/composer-dictation.ts:694 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 925056cc25c2; files: ui/src/pages/chat/composer-dictation.ts)
  • mushuiyu886: Raw commit 71eb77b adds ui/src/pages/chat/composer-dictation.ts:375 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 71eb77b765ca; files: ui/src/pages/chat/composer-dictation.ts)

PR surface

Source +4, Tests 0. Total +4 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 5 1 +4
Tests 1 31 31 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 36 32 +4

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Ordinary window or tab switching can silently discard several minutes of dictated text on the affected released Control UI.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-12T18:14:37.574Z sha 562e140 :: needs real behavior proof before merge. :: [P1] Preserve the pending transcript across consecutive interruption events
  • reviewed 2026-11-12T18:42:45.081Z sha 3b31dda :: needs real behavior proof before merge. :: none

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.
@wr-web

wr-web commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

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.

Case main this PR
Window blur draft back to Notes: (text lost) full sentence kept
Tab switch (blur + hidden) text lost full sentence kept
Stop, then tab switch and window switch while the final drains text lost full sentence kept, committed once
Escape (control) discarded discarded
Stop (control) full sentence kept same text kept
Hold-mode drag-out (control) discarded discarded

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:

main: dictating before the tab switch

main: after the tab switch, dictated text is gone

this PR: after the tab switch, dictated text is kept

this PR: Stop then tab and window switch, text committed once

this PR: Escape still discards

@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Nov 13, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 13, 2026
@obviyus
obviyus merged commit 5da97e5 into openclaw:main Nov 13, 2026
107 of 110 checks passed
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Landed in 5da97e5. Thanks @wr-web, and @digitalfrost84 for the report.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 14, 2026
)

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]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
)

(cherry picked from commit 5da97e5)

Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit bcf4b79a28f2cd273baa94cfda1cf6c85edc8905)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Control UI dictation silently discards the whole transcript on window blur / page hidden (e.g. screensaver after 5 min)

2 participants