Repository navigation
fix(talk): preserve replacement speech when an old utterance is canceled - #130687
Conversation
Revalidate the speech operation token before delayed cancellation cleanup stops the shared Apple synthesizer. Preserve active cancellation and explicit stop, and retain an opt-in real-audio regression for the replacement race. Fixes #130674.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 12:33 AM ET / 04:33 UTC. ClawSweeper reviewWhat this changesThe PR revalidates the shared Apple speech request token before delayed cancellation stops the synthesizer and adds an opt-in real-engine regression test. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open. Current main retains the unguarded delayed cancellation cleanup, while this focused shared-owner repair addresses the reproduced replacement-speech race; the member-authored, Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetheriOS and macOS Talk flows, plus iOS spoken chat pushes, send system-speech requests to one shared Apple synthesizer. Cancellation, watchdogs, and speech delegate callbacks converge there, where completion or cancellation returns control to the calling flow. flowchart LR
A[Talk and spoken chat requests] --> B[Shared Apple speech owner]
B --> C[Cancellation cleanup]
C --> D{Original request still owns speech?}
D -->|Yes| E[Stop active utterance]
D -->|No| F[Replacement utterance continues]
E --> G[Caller receives cancellation]
Decision needed
Why: The PR is authored by a repository member and carries the protected Before merge
Agent review detailsSecurityNone. PR surfaceOther +41. Total +41 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the shared token check after exact-head native CI is green; it keeps cancellation ownership at the synthesizer rather than adding caller-specific workarounds. Do we have a high-confidence way to reproduce the issue? Yes. The linked report documents a real-engine current-main reproduction: cancel a started utterance and immediately await a replacement on the main actor; base source retains the matching unconditional stop. Is this the best way to solve the issue? Yes. The token guard belongs in the shared synthesizer that owns cancellation, watchdog, delegate, and replacement state, avoiding divergent caller-level fixes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 71d4a8c3e305. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Ready to land the shared-owner repair at The exact-head CI run 33039448772 passed on attempt 1, including macOS Swift, iOS build/lifecycle tests, and the iPhone/Watch and iPad screenshot pipeline. Local changed-surface validation passed Swift lint, repository guards, and 502 tests across seven shards: env -u OPENCLAW_TESTBOX PATH="$PWD/.build/swift-tools:$PATH" node scripts/check-changed.mjs -- apps/shared/OpenClawKit/Sources/OpenClawKit/TalkSystemSpeechSynthesizer.swift apps/shared/OpenClawKit/Tests/OpenClawKitTests/TalkSystemSpeechSynthesizerTests.swift
swift test --parallel --package-path apps/shared/OpenClawKit --filter TalkSystemSpeechSynthesizerTests
OPENCLAW_LIVE_TEST=1 swift test --package-path apps/shared/OpenClawKit --filter testLiveOldCancellationDoesNotStopReplacementDefault Swift result: five passing watchdog tests and one intentional live-audio skip. Separately enabled final live regression: one pass, zero failures, replacement started once and completed; the first task was cancelled. The pre-fix retained regression failed on replacement, and earlier real-engine coverage also verified current cancellation and explicit stop. Reviewed the latest ClawSweeper feedback: no actionable findings or additional Rank-up moves. Its displayed live-verification failure is a 30-second harness cutoff while dependencies/build were still running, not a test failure; the completed local invocation above is the actual test result. The +3 production lines are the minimal existing-token ownership check plus its invariant comment; public stop remains unconditional, and no state or fallback is added. Tests are +39/-1. Independent review and isolated Codex autoreview found no accepted/actionable issue. Known limits remain explicit: physical-iPhone test provisioning was unavailable; the isolated local simulator audio proof failed with unavailable audio I/O. The final real-engine regression passed on macOS, and normal CI intentionally does not require live speech output. This fixes #130674 only; broader silent-audio/CarPlay reports remain open. |
|
Merged via squash.
|
…-retirement-v13 * origin/main: (243 commits) fix: preserve Gateway error reasons in text logs (#130645) refactor(video): deduplicate generation contracts (#130635) fix(agents): preserve direct-message sender identity (#124548) fix(agents): preserve silent reply after settled tools (#130675) fix(talk): preserve replacement speech when an old utterance is canceled (#130687) fix(browser): preserve literal names and formatter-owned snapshot refs (#130599) fix(auth): reset only the profile replaced by a successful login (#124014) fix: bind session creation to admitted Gateway (#130686) refactor(qa-lab): reuse model reference splitter (#130317) docs(gateway): clarify independent HTTP endpoint switches (#130690) fix(ui): Control UI smooth scrolling ignores the reduced-motion preference (#130428) refactor(lmstudio): remove unreachable catalog merge (#130689) fix(crabbox): restore cloud machine CPU and RAM (#130684) fix(secrets): compare proxy bearer tokens directly (#127054) fix(matrix): show recovery key availability in text status (#128051) fix(ios): restore approval settings navigation and remove duplicate shell state (#130651) refactor(agents): use fixed tool-loop defaults directly (#130681) refactor(qa-lab): share process tree metric reader (#130419) refactor(models): simplify prepared owner access (#130683) fix(parallels): main install and update smoke cannot complete (#130658) ...
…led (openclaw#130687) Revalidate the speech operation token before delayed cancellation cleanup stops the shared Apple synthesizer. Preserve active cancellation and explicit stop, and retain an opt-in real-audio regression for the replacement race. Fixes openclaw#130674.
Closes #130674
What Problem This Solves
Fixes an issue where users could lose replacement system speech in iOS or macOS Talk when the previous speech task was cancelled just before the replacement started. The same shared owner is used by iOS spoken chat pushes.
Why This Change Was Made
Cancellation schedules cleanup on the main actor. A newer utterance can take ownership before that cleanup runs, so an unconditional stop cancels the wrong operation. Revalidate the existing captured token immediately before stopping, matching the watchdog's ownership check. Explicit public stop remains unconditional; delegate callbacks retain their existing utterance-identity checks.
This is the shared-owner repair, not a caller-specific workaround. No extra state, API, dependency, config, persistence, or fallback is introduced. Production delta is +3/-0: the necessary ownership check and its two-line invariant comment. Tests are separate (+39/-1, including formatter normalization). Moving the check to individual callers would leave other users of the shared synthesizer exposed; introducing another cancellation abstraction would add unnecessary surface.
User Impact
A cancelled utterance can no longer stop speech that replaced it. Active speech cancellation and explicit stop retain their behavior. This fixes the separately reproduced race in #130674, not every silent-audio, provider, or CarPlay report.
Evidence
73b98c4b50160a1f57f6a0f9197ae6c6b53c22b4, ordinary control speech completed, but cancelling A and immediately awaiting B on the main actor cancelled B before its start callback, despite its caller not being cancelled. Reproduced twice. The retained regression also failed on the original source.OPENCLAW_LIVE_TEST=1 swift test --package-path apps/shared/OpenClawKit --filter testLiveOldCancellationDoesNotStopReplacement. It still requires successful replacement completion, exactly one start callback, and cancellation of A. After opt-in, speech errors are failures, not skips.AudioQueue -66680/ unavailable default audio I/O. Do not make headless CI depend on working speech output, extend timeouts, or replace the assertions with a mock. Default CI compiles the regression but intentionally skips its live execution.v2026.7.1-2. The later delegate repair fix(ios): guard talk TTS callbacks to active utterance #33304 did not introduce it.Changed-surface gate passed:
env -u OPENCLAW_TESTBOX PATH="$PWD/.build/swift-tools:$PATH" node scripts/check-changed.mjs -- apps/shared/OpenClawKit/Sources/OpenClawKit/TalkSystemSpeechSynthesizer.swift apps/shared/OpenClawKit/Tests/OpenClawKitTests/TalkSystemSpeechSynthesizerTests.swift. This included Swift lint, repository guards, and 502 passing tests across seven macOS CI shards. Default focused Swift tests also passed with exactly one intentional live-only skip.Exact-head hosted CI run 33039448772 passed on attempt 1 for
d97573868434e98da265e5414c142220450067ca, including macOS Swift, iOS build/lifecycle tests, and the iPhone/Watch and iPad screenshot pipeline. Broader native silent-audio reports remain open; this change does not prove their cause.