Skip to content

feat(ios): add Listen action speaking assistant messages via gateway TTS - #100771

Merged
steipete merged 8 commits into
mainfrom
claude/listen-ios-chat-speech
Jul 6, 2026
Merged

steipete merged 8 commits into
mainfrom
claude/listen-ios-chat-speech

Conversation

@steipete

@steipete steipete commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

iOS users cannot hear an assistant reply from the chat transcript (tracking issue: #100708). Gateway dependency #100770 is landed and provides the tts.speak method consumed here.

Why This Change Was Made

  • Listen action: long-press an assistant bubble → "Listen" (or "Stop Listening" while active). While active, an inline "Preparing audio…"/"Speaking…" chip renders under the bubble; tapping it stops playback.
  • Shared controller (OpenClawChatSpeechController in OpenClawChatUI): one message speaks at a time; gateway clip first via an injected synthesis closure, AVSpeechSynthesizer on-device fallback whenever the gateway can't render (unconfigured provider, offline, older gateway, undecodable or unsupported headerless clip). Output format, MIME, and extension metadata reach AVAudioPlayer; raw PCM/mulaw/alaw falls back because the RPC does not expose the sample-rate/channel metadata needed to decode it safely. A generation token and player/utterance identity guards keep stale callbacks from clearing newer state.
  • Spoken text mirrors the transcript: the exporter's visible-text filtering moved to a shared ChatMessageVisibleText helper used by both the transcript exporter and Listen (tool calls/results and non-text blocks excluded).
  • Audio etiquette: the audio session activates as .playback + .spokenAudio with .duckOthers only while speaking (explicit user-initiated playback), and deactivates with .notifyOthersOnDeactivation. Playback stops on session switch, scene background, and view disappearance.
  • iOS wiring: ChatMessageSpeechClient calls tts.speak through the generated TtsSpeakParams/TtsSpeakResult protocol types; ChatProTab injects the controller (hosts that don't inject one — e.g. macOS — see no UI change).

User Impact

New "Listen" context-menu action on assistant messages in the iOS chat transcript with inline playing state; speech uses the operator's configured TTS voice and falls back to the on-device voice when the gateway can't render audio.

Evidence

  • swift test --package-path apps/shared/OpenClawKit --filter 'ChatSpeechControllerTests|ChatMessageVisibleTextTests' — 10/10 passed on macOS with Swift 6.2 (controller state machine, metadata/raw-format classification, fallback/supersede/stop paths, visible-text extraction).
  • Focused Xcode 26.5 iPhone 17 simulator test — ChatMessageSpeechClientTests 1/1 passed, including tts.speak request decoding and playback-metadata preservation.
  • Blacksmith Testbox tbx_01kww9ebc3wprwsap4snc52jx8 — native i18n inventory green (entries=2758 changed=false); gateway method-order regression green in both configs (16/16).
  • Strict SwiftFormat on touched Swift files — 0/8 require formatting; swiftc -frontend -parse green.
  • Fresh Codex autoreview — clean after fixing metadata propagation, stale synthesizer callback ownership, exact Listen eligibility, dynamic localization, and optional MIME unwrapping.
  • Exact-head hosted macos-swift and ios-build are merge gates. No physical iOS device is attached to this host, so audible gateway/fallback playback remains a release-evidence gap rather than a claimed automated proof.

@openclaw-barnacle openclaw-barnacle Bot added app: ios App: ios size: L maintainer Maintainer-authored PR docs Improvements or additions to documentation labels Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 2:25 PM ET / 18:25 UTC.

Summary
The branch adds an iOS assistant-message Listen/Stop context-menu action backed by gateway tts.speak, a shared chat speech controller and visible-text helper, focused Swift tests, i18n inventory, and iOS docs/changelog notes.

PR surface: Docs +2, Other +869. Total +871 across 13 files.

Reproducibility: yes. for the review finding from source inspection: ChatMessageSpeechClient sends tts.speak without ifCurrentRoute, while current main exposes GatewayNodeSessionRoute specifically to prevent retargeting after actor hops. I did not run a live iOS gateway-switch repro in this read-only review.

Review metrics: 1 noteworthy metric.

  • Route-bound TTS requests: 1 new tts.speak call, 0 route leases. The new request carries assistant transcript text over the operator gateway, so stale-route protection matters before merge.

Stored data model
Persistent data-model change detected: vector/embedding metadata: apps/ios/Tests/ChatMessageSpeechClientTests.swift. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #100708
Summary: This PR is the iOS implementation candidate for the canonical mobile transcript Listen feature; the gateway dependency has merged and the Android sibling remains open.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Capture and pass a current GatewayNodeSessionRoute for tts.speak, falling back locally when stale.
  • [P1] Add focused coverage for the stale-route or gateway-switch path.
  • Post redacted iOS playback proof showing the Listen action, gateway audio, and fallback behavior.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides tests and CI but explicitly leaves audible iOS gateway/fallback playback as a gap; add redacted device or simulator recording, logs, or copied live output, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] The new Listen path can send assistant transcript text to a replacement operator gateway after reconnect or gateway switch unless it captures and passes a GatewayNodeSessionRoute.
  • [P2] The PR has tests and CI evidence, but no real iOS playback proof for the visible Listen action, gateway clip playback, or on-device fallback.

Maintainer options:

  1. Bind Listen to the captured gateway route (recommended)
    Capture the current GatewayNodeSessionRoute before starting synthesis, pass it through ifCurrentRoute, and fall back locally if the route is stale before dispatch.
  2. Accept route retargeting as intentional
    Maintainers could decide Listen should always use the latest gateway, but that would explicitly allow transcript text to move across gateway switches.
  3. Pause the iOS slice
    If route ownership or proof cannot be settled now, keep the canonical feature issue open and pause this PR until the gateway-switch semantics are decided.

Next step before merge

  • [P1] Protected maintainer-labeled PR needs human review after the route-binding security blocker and real playback proof gap are resolved; this is not a cleanup close.

Security
Needs attention: The diff introduces a concrete gateway-routing security concern because assistant transcript text can be sent without a current-route guard.

Review findings

  • [P1] Bind TTS requests to the current gateway route — apps/ios/Sources/Chat/ChatMessageSpeechClient.swift:17-20
Review details

Best possible solution:

Keep the iOS Listen direction, but bind tts.speak to the current gateway route with regression coverage and add redacted iOS playback proof for both gateway audio and fallback before merge.

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

Yes for the review finding from source inspection: ChatMessageSpeechClient sends tts.speak without ifCurrentRoute, while current main exposes GatewayNodeSessionRoute specifically to prevent retargeting after actor hops. I did not run a live iOS gateway-switch repro in this read-only review.

Is this the best way to solve the issue?

No, not yet. The feature shape is otherwise plausible, but the client should use the existing route-lease contract and include route-switch coverage plus real playback proof before this is the best merge path.

Full review comments:

  • [P1] Bind TTS requests to the current gateway route — apps/ios/Sources/Chat/ChatMessageSpeechClient.swift:17-20
    This sends the full assistant text with gateway.request but never captures or passes a GatewayNodeSessionRoute. Current main added that route lease so suspended work cannot retarget payloads to a replacement gateway, and the chat transport already uses it for message/history requests. If the user reconnects or switches gateways after starting Listen, this can dispatch transcript text to the new gateway instead of falling back locally.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add merge-risk: 🚨 security-boundary: Merging the PR as written could dispatch assistant transcript text to a replacement gateway after a reconnect or switch.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides tests and CI but explicitly leaves audible iOS gateway/fallback playback as a gap; add redacted device or simulator recording, logs, or copied live output, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Label justifications:

  • P2: This is a normal-priority mobile accessibility feature PR with a concrete merge blocker, not an active shipped regression or first-run blocker.
  • merge-risk: 🚨 security-boundary: Merging the PR as written could dispatch assistant transcript text to a replacement gateway after a reconnect or switch.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides tests and CI but explicitly leaves audible iOS gateway/fallback playback as a gap; add redacted device or simulator recording, logs, or copied live output, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Docs +2, Other +869. Total +871 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 2 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 11 930 61 +869
Total 13 932 61 +871

Security concerns:

  • [medium] Assistant text can retarget to a replacement gateway — apps/ios/Sources/Chat/ChatMessageSpeechClient.swift:17
    tts.speak carries user-visible assistant transcript text, but the new client does not pass ifCurrentRoute; a reconnect or gateway switch before dispatch can send that text to a different gateway than the one active when the user tapped Listen.
    Confidence: 0.89

What I checked:

  • PR source: unbound TTS dispatch: The new client calls gateway.request for tts.speak without passing ifCurrentRoute, so the assistant text is dispatched to whichever gateway channel is current when the actor executes the request. (apps/ios/Sources/Chat/ChatMessageSpeechClient.swift:17, ee1196bc274a)
  • Current route contract: Current main documents GatewayNodeSessionRoute as the guard that prevents suspended work from retargeting a payload to a replacement gateway, and GatewayNodeSession.request supports ifCurrentRoute. (apps/shared/OpenClawKit/Sources/OpenClawKit/GatewayNodeSession.swift:45, 962d1096d492)
  • Sibling chat transport uses route leases: The iOS chat transport captures the current route and passes it through ifCurrentRoute for targeted history and send paths, showing the sibling invariant for gateway-bound chat payloads. (apps/ios/Sources/Chat/IOSGatewayChatTransport.swift:147, 962d1096d492)
  • PR tests cover metadata but not routing: The focused iOS speech client test verifies method, params, timeout, and playback metadata, but there is no route-switch or stale-route assertion for the new request path. (apps/ios/Tests/ChatMessageSpeechClientTests.swift:15, ee1196bc274a)
  • Real behavior proof gap: The PR body lists unit/simulator/CI evidence and explicitly says no physical iOS device is attached, leaving audible gateway and fallback playback unproven in a real setup. (ee1196bc274a)
  • Feature provenance: The gateway dependency for this feature merged as tts.speak in commit 553acdf, and the route-lease guard relevant to this review was added in commit 06789ca. (06789ca4c2ed)

Likely related people:

  • steipete: Peter authored the merged tts.speak gateway method and the current-main iOS gateway route-lease work that defines the invariant this PR needs to follow. (role: recent area contributor; confidence: high; commits: 553acdfc1aef, 06789ca4c2ed, 1af9cbe904a4; files: src/gateway/server-methods/tts.ts, apps/shared/OpenClawKit/Sources/OpenClawKit/GatewayNodeSession.swift, apps/ios/Sources/Chat/IOSGatewayChatTransport.swift)
  • mbelinky: GitHub commit metadata links mbelinky to earlier shared iOS chat UI work touching ChatView.swift and ChatMessageViews.swift. (role: adjacent iOS chat UI contributor; confidence: medium; commits: 9476dda9f617; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift, apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMessageViews.swift)
  • obviyus: GitHub commit metadata links obviyus to nearby Talk provider and speaking-state fixes on the existing mobile speech path. (role: adjacent Talk/TTS contributor; confidence: medium; commits: 2afd65741cda, 47e412bd0b2b; files: apps/ios/Sources/Voice/TalkModeManager.swift, apps/ios/Sources/Voice/TalkGatewaySpeechClient.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • 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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-06T09:51:29.886Z sha 4a60d15 :: needs real behavior proof before merge. :: [P2] Move the new doc comment before @MainActor
  • reviewed 2026-07-06T15:14:58.975Z sha 3cfcadd :: needs real behavior proof before merge. :: [P2] Preserve TTS format metadata before playback | [P2] Refresh the native i18n inventory

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jul 6, 2026
@steipete
steipete force-pushed the claude/listen-ios-chat-speech branch from 4a60d15 to fb7db88 Compare July 6, 2026 14:40
@blacksmith-sh

This comment has been minimized.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb7db88fc3

ℹ️ 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".

@steipete
steipete force-pushed the claude/listen-ios-chat-speech branch from fb7db88 to 3cfcadd Compare July 6, 2026 14:59
@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed 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. labels Jul 6, 2026
@steipete
steipete force-pushed the claude/listen-gateway-tts-speak branch 8 times, most recently from 8babb16 to 906f51b Compare July 6, 2026 17:21
Base automatically changed from claude/listen-gateway-tts-speak to main July 6, 2026 17:25
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Jul 6, 2026
@steipete
steipete force-pushed the claude/listen-ios-chat-speech branch from c7a7fa7 to ee1196b Compare July 6, 2026 18:14
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee1196bc27

ℹ️ 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".

Comment on lines +17 to +20
try await gateway.request(
method: method,
paramsJSON: paramsJSON,
timeoutSeconds: timeoutSeconds)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bind Listen TTS requests to the current gateway route

When a user starts Listen during a gateway reconnect or switch, this request is made without an ifCurrentRoute lease, so the actor can dispatch the full assistant text to whichever operator channel is current by the time gateway.request runs. The chat transport already passes ifCurrentRoute for message/history RPCs (apps/ios/Sources/Chat/IOSGatewayChatTransport.swift:170-190), and GatewayNodeSessionRoute exists to prevent retargeting to replacement gateways (apps/shared/OpenClawKit/Sources/OpenClawKit/GatewayNodeSession.swift:45-47). Capture the current route and pass it here, falling back locally if the route is nil or stale.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 6, 2026
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready after rebase and hardening.

  • Preserved tts.speak output format/MIME/extension metadata through playback; known headerless PCM/mulaw/alaw variants now use the on-device fallback instead of being handed to AVAudioPlayer without sample metadata.
  • Guarded AVAudioPlayer/AVSpeechSynthesizer continuations by active object identity, localized the dynamic Listen/status labels, and limited Listen eligibility to assistant messages with actual visible transcript text.
  • Shared Swift Listen/visible-text suites: 10/10 passed locally with Swift 6.2. Focused Xcode 26.5 iPhone 17 simulator client test: 1/1 passed. Strict SwiftFormat and Swift parse checks passed.
  • Blacksmith Testbox tbx_01kww9ebc3wprwsap4snc52jx8: native i18n inventory green and gateway method-order regression green in both configs (16/16).
  • Exact head ee1196bc274ae4510d801b47250ddef9f7a883f4: full CI green on rerun, including macos-swift, ios-build, native i18n, types, lint, and test shards: https://github.com/openclaw/openclaw/actions/runs/28813231123
  • Fresh final Codex autoreview: no actionable findings. The metadata review thread is fixed, replied to, and resolved.

Known proof gap: no physical iOS device is attached to this host, so audible configured-Gateway and on-device fallback playback remains manual release evidence. The code paths, state transitions, metadata boundary, simulator build/test, and hosted platform lanes are proven here.

One unrelated lifecycle-admission shard failed once under the first full run; its exact test passed twice focused on Testbox and the failed CI shard passed on rerun without code changes.

@steipete
steipete merged commit 60ce506 into main Jul 6, 2026
172 of 180 checks passed
@steipete
steipete deleted the claude/listen-ios-chat-speech branch July 6, 2026 18:32
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
…TTS (openclaw#100771)

* test(gateway): shift advertised-method window for tts.speak

* feat(ios): add Listen action speaking assistant messages via gateway TTS

* docs(ios): document the chat Listen action

* style(ios): keep outbox label doc comment attached and give speech chip its own

* fix(ios): harden chat Listen playback

* docs(changelog): note iOS chat Listen

* fix(ios): unwrap speech MIME before classification

* docs(changelog): keep Listen note app-scoped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant