Skip to content

fix(ui): avoid voice session expiry while waiting for microphone access - #133384

Merged
steipete merged 3 commits into
mainfrom
codex/voice-microphone-before-session
Aug 30, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/voice-microphone-before-session

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #133359

What Problem This Solves

Fixes an issue where users starting Browser Talk could lose the connection before it began if granting microphone access took longer than the provider's activation window. OpenAI's pending-offer broker and Google's new-session token both allow 60 seconds; the browser previously allocated that session before requesting microphone access.

Why This Change Was Made

The browser session now acquires one microphone before allocating a provider session and transfers that same input controller to WebRTC, Google Live, or Gateway relay. One pending-startup owner handles cancellation and replacement. Denial allocates nothing, late grants are released, allocation failures release the microphone, and microphone loss during allocation rejects the candidate. Transport factories move into their own existing-responsibility module; per-transport microphone acquisition and cancellation branches are removed.

This repairs startup ordering rather than increasing provider TTLs or adding refresh/retry paths. Authentication, provider selection, configuration, persistence, and protocol contracts are unchanged. The documented browser permission prompt may wait indefinitely; Codex's WebRTC start contract likewise takes an already-prepared SDP offer (codex-rs/app-server-protocol/src/protocol/v2/realtime.rs:279 and codex-rs/codex-api/src/endpoint/realtime_call.rs:129, directly inspected in openai/codex).

Provenance: the ordering is present in the inspected baseline and its preceding startup-guidance fix; the introducing commit is unknown. #117490 corrected Google's exposed expiry units but did not change microphone acquisition order.

User Impact

A first-time microphone prompt can remain open without spending the voice connection token's lifetime. Cancelling or denying it does not create a provider session. This applies to all three supported browser transports, with no new setting or operator action.

Evidence

  • Before: a real-clock request to the actual OpenAI localhost offer broker at 60,141 ms returned HTTP 401, Invalid or expired realtime session token; it released all reservations and made zero upstream calls. This used synthetic credentials and SDP, not a live authenticated provider call.
  • Eight new owner regressions fail on the previous implementation. They cover a 65-second permission wait for all three transports, denial, cancellation with late grant, allocation failure, and microphone loss during initial/replacement allocation.
  • After: all 284 voice tests across 19 files pass, including the original WebRTC execution order, transcript/lifecycle, Google, relay, camera, and microphone siblings. Scoped type-aware lint, formatting, and the assertion-safety ratchet pass. The initial hosted run caught undocumented assertions moved into the new factory; redundant casts were removed, the remaining transport assumptions documented, and the former owner baseline reduced. The patch is unchanged after rebasing onto both landed prerequisites (fix(ui): explain pending voice microphone access #133353 and fix(google): avoid duplicate turn completion after voice interruption #133365).
  • Native Chromium Control UI E2E: both microphone-lifetime scenarios plus all 11 start/stop, camera, backpressure, and WebKit-error sibling scenarios pass. The pending-permission scenario explicitly observes zero talk.client.create requests while waiting, then exactly one after permission is granted and the UI reaches Listening. This is a synthetic browser/Gateway fixture, not a live provider call. Hosted CI exposed three stale sibling assertions that still expected allocation before microphone permission; they now assert zero allocation/close on denial and two captures with old-input release on stop/restart. No runtime change was needed for that correction.
  • Independent Codex review of the final implementation reports no actionable P0–P2 findings. Full clean-install coverage is delegated to hosted CI: the shared local dependency checkout has an unrelated pako type-version mismatch that blocks the broad UI check.

The following inspected synthetic captures show the fixed flow. The RPC assertions above prove allocation order; screenshots alone do not. Visible startup guidance was introduced in #133353, so these are pending/ready flow evidence rather than a new rendering change.

Microphone permission pending; no provider session allocated

Permission granted and voice listening

Production: +127/-106, net +21, including the factory relocation. Tests/test support: +466/-384, net +82. Docs: +4. Assertion baseline: +1/-1, reducing the old owner allowance from seven to two. The production increase establishes the canonical prepared-input handoff and single startup-resource owner; it replaces three separate acquisition paths. No generated files, dependencies, or runtime configuration surfaces change.

Remaining limits: live provider recognition accuracy and physical microphone/OS permission behavior are not established by these deterministic tests. Replacement tests preserve the previous browser transport; server-side provider replacement activation is tracked separately in #133387 and is not claimed repaired here. No changes to Google manual-VAD behavior are included.

@steipete steipete self-assigned this Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: XL maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 16:30
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 12:57 PM ET / 16:57 UTC.

ClawSweeper review

What this changes

The PR acquires Browser Talk microphone input before allocating a provider session, then hands that input to WebRTC, Google Live, or gateway-relay transport.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This maintainer-authored, maintainer-labeled PR stays open for exact-head checks and normal merge handling; source and test review found no introduced blocking defect.

Priority: P1
Reviewed head: c09107dc7349c5724533e3aeec88823b8fd569f0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has a coherent shared lifecycle boundary, focused regression coverage, and no actionable source-review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This is maintainer-authored, so the external-contributor proof gate does not apply; the supplied Chromium fixture evidence is supplemental and directly aligns with the changed allocation order.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is maintainer-authored, so the external-contributor proof gate does not apply; the supplied Chromium fixture evidence is supplemental and directly aligns with the changed allocation order.
Evidence reviewed 7 items Startup owner ordering: The session owner opens the selected microphone before calling the provider-session RPC, and passes that same controller into the selected transport.
Control UI caller: The chat toggle creates the Browser Talk session with the persisted microphone choice and retains it as the active UI session before awaiting startup.
Transport handoff: Each supported transport adopts the prepared input and retains its existing transport-specific teardown behavior instead of opening another microphone stream.
Findings None None.
Security None None.

How this fits together

Browser Talk turns a Control UI start action into microphone permission, provider-session allocation, and one browser voice transport. The change prevents permission waits from consuming short-lived provider activation windows.

flowchart LR
A[Start Browser Talk] --> B[Request microphone]
B --> C[Prepared microphone input]
C --> D[Create provider session]
D --> E[Select voice transport]
E --> F[Voice call connected]
Loading

Decision needed

Question Recommendation
After exact-head required checks complete, should this maintainer-authored Browser Talk lifecycle fix be merged? Merge after exact-head CI: Merge the reviewed microphone-first lifecycle once the required checks for the current head are green.

Why: The item is maintainer-authored and carries the protected maintainer label, so automated cleanup must not decide its final disposition.

Before merge

  • Resolve merge risk (P1) - Production code is net +21 lines; the shared prepared-input handoff and deleted per-transport acquisition paths justify that growth, but exact-head CI should still verify the widened startup lifecycle.
Agent review details

Security

None.

PR surface

Source +47, Tests +56, Docs +4, Other 0. Total +107 across 27 files.

View PR surface stats
Area Files Added Removed Net
Source 9 155 108 +47
Tests 16 438 382 +56
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 27 598 491 +107

Review metrics

Metric Value Why it matters
Production vs test delta production +127/-106 (net +21); tests/support +466/-384 (net +82); docs +4 The production growth centralizes one prepared-input owner and removes three per-transport acquisition paths.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #133359
Summary: This PR is the candidate fix for the microphone-before-session ordering bug tracked by the canonical issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the single prepared-input lifecycle after exact-head CI: no net-neutral alternative preserves the shared cancellation, late-grant release, and three-transport handoff contract.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the single prepared-input lifecycle after exact-head CI: no net-neutral alternative preserves the shared cancellation, late-grant release, and three-transport handoff contract.

Do we have a high-confidence way to reproduce the issue?

Yes, by holding getUserMedia() pending beyond the activation lifetime, then granting it and observing session allocation; the new owner-boundary regression specifies this for all three transports. This read-only review did not execute the test.

Is this the best way to solve the issue?

Yes. The session lifecycle owner now acquires and owns the microphone once, while transports only adopt it, eliminating the previous three acquisition paths without changing provider TTLs or configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against eed74eefd336.

Labels

Label justifications:

  • P1: A normal Browser Talk start can fail after a prolonged microphone-permission wait on the default user flow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is maintainer-authored, so the external-contributor proof gate does not apply; the supplied Chromium fixture evidence is supplemental and directly aligns with the changed allocation order.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-30T16:43:50.948Z sha c941703 :: needs maintainer review before merge. :: none

@steipete

steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Maintainer review complete for c09107d. The latest ClawSweeper review has no patch findings or additional rank-up repairs; its remaining requirement is exact-head CI and normal maintainer landing. The subsequent commit changes only the three stale E2E expectations revealed by hosted CI. A fresh independent review of the complete final change has no actionable P0–P2 findings.

Root cause and owner: the browser session allocated a short-lived provider credential before waiting for microphone permission. The canonical session owner now prepares one input and transfers it to WebRTC, Google Live, or Gateway relay, removing three separate acquisition paths. Eight regressions fail before the repair; 284 voice tests, both microphone-lifetime browser scenarios, and all 11 start/stop/WebKit/camera/backpressure sibling scenarios pass afterward. The real-clock local broker also proves the 60-second expiry failure. Synthetic fixtures are not physical-microphone or authenticated-provider proof.

I accept the net +21 production lines (+127/-106, including factory relocation) for the single prepared-input ownership boundary. Tests/support are +466/-384; docs +4; the assertion baseline shrinks from seven to two at the former owner. No auth, configuration, TTL, schema or protocol surface changes. The restart follow-up is #133387; its selected repair simplifies private client lifecycle rather than adding a transactional Gateway protocol.

The hosted assertion-safety failure was fixed by removing redundant casts, documenting existing transport assumptions and reducing the old baseline. The later browser shard failure was corrected by asserting zero allocations on denied input and checking release of the first microphone during stop/restart; that shard now passes. Landing remains gated on completion of the current exact-head CI run: https://github.com/openclaw/openclaw/actions/runs/33323580069.

Update: exact-head CI is now fully green. I also read the refreshed ClawSweeper review for c09107d; its +21-line ownership-growth decision is accepted for the reasons above, and its CI condition is satisfied. Proceeding through native prepare/merge.

@steipete
steipete merged commit 6f3b26f into main Aug 30, 2026
158 of 160 checks passed
@steipete
steipete deleted the codex/voice-microphone-before-session branch August 30, 2026 17:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…ss (openclaw#133384)

* fix(ui): acquire voice microphone before session allocation

* chore(ui): document moved voice transport assertions

* test(ui): assert microphone-first browser voice lifecycle
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 docs Improvements or additions to documentation maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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]: Long microphone permission waits expire Browser Talk sessions

1 participant