Repository navigation
fix(macos): cancelled Talk sessions can spin at full CPU - #129682
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Verified exact head 3ae1442 against the actual macOS Talk lifecycle, iOS silence-monitor sibling, adjacent RMS cancellation owner, and real Swift 6.4 task behavior. Before the fix, cancelling a replacement silence monitor caused 5,000 erroneous stale checks in 0.789 ms. After the fix, the same real executable Swift cancellation proof exits with zero stale checks in 0.043 ms; an uncancelled monitor still performs its normal tick. The exact production source passes An in-process regression on the old implementation would permanently wedge its shared serialized actor/test runner; the bounded executable before/after proof safely covers the actual Swift cancellation contract, with full macOS application validation delegated to exact-head hosted CI. |
|
Verified exact head e457cdc against the actual macOS Talk lifecycle, canonical SimpleTaskSupport periodic-task owner, presence/channel-polling siblings, iOS silence-monitor contract, and real Swift 6.4 task behavior. Before the fix, cancelling a replacement silence monitor caused 5,000 erroneous stale checks in 0.789 ms. After the fix, the same real executable Swift cancellation proof exits with zero stale checks in 0.043 ms; an uncancelled monitor still performs its normal tick. The exact production source passes Swift compiler parsing, zero-violation SwiftLint, and the actual full macOS SwiftFormat workflow across 338 application files plus 26 native sources. Existing An in-process regression on the old implementation would permanently wedge its shared serialized actor/test runner; the bounded executable before/after proof safely covers the actual Swift cancellation contract, with full macOS application validation delegated to exact-head hosted CI. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 8:54 PM ET / August 26, 2026, 00:54 UTC. ClawSweeper reviewWhat this changesThe PR makes a cancelled macOS Talk silence monitor exit its periodic loop instead of immediately continuing stale silence checks. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the one-line macOS Talk lifecycle repair matches the cancellation invariant and current main still has the busy-loop behavior; this maintainer-labeled PR awaits the queued exact-head native check and maintainer handling. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togethermacOS Talk runs a background silence monitor while listening for speech. Session changes replace or cancel that monitor; its periodic wait decides whether to run the next silence check or exit. flowchart LR
A[Talk session change] --> B[Talk runtime]
B --> C[Cancel old silence monitor]
C --> D[Cancellable periodic wait]
D -->|continues| E[Silence check]
E --> F[Transcript handling]
D -->|cancelled| G[Old monitor exits]
Before merge
Agent review detailsSecurityNone. PR surfaceOther -1. Total -1 across 1 file. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the contained lifecycle-owner fix once the queued native check succeeds, retaining the shared cancellation helper as the sole periodic-wait policy. Do we have a high-confidence way to reproduce the issue? Yes—on current main, replace a running silence monitor while its ignored Task.sleep cancellation is pending; source shows it immediately repeats checkSilence instead of exiting. Is this the best way to solve the issue? Yes. Reusing the existing cancellation-aware periodic-wait owner fixes the lifecycle boundary directly and preserves the established 200 ms cadence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0036788055b5. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…9682) * fix(macos): stop cancelled Talk silence monitors * fix(macos): reuse cancellable periodic task owner
What Problem This Solves
Fixes an issue where macOS Talk users resuming voice input, replacing a silence monitor, or reconfiguring an active session could experience a pegged CPU and an unresponsive Talk runtime.
Why This Change Was Made
The macOS silence-monitor lifecycle cancels its previous task before starting a replacement while Talk remains enabled. Its previous loop discarded the cancellation thrown by Swift
Task.sleep, immediately repeated without waiting, and continued invoking silence checks indefinitely. The monitor now reuses the application's existingSimpleTaskSupport.waitForNextOperationcancellation owner, already used by presence reporting and channel polling, to exit before a stale check while preserving its existing 200 ms cadence. Production delta: +1/-2, net -1; no new API, configuration, dependency, actor seam, or UI surface.User Impact
Replacing, pausing, or reconfiguring an active macOS Talk session no longer leaves an orphaned monitor spinning at full CPU or competing with the active voice session. Normal silence detection behavior remains unchanged.
Evidence
Actual Swift 6.4 executable cancellation proof, using the same task/sleep lifecycle as the production owner:
{"verdict":"FAIL","cancelledSilenceChecks":5000,"elapsedMs":0.789584,"expectedCancelledChecks":0} {"verdict":"PASS","cancelledSilenceChecks":0,"elapsedMs":0.043167,"expectedCancelledChecks":0} {"normalCadenceVerdict":"PASS","normalSilenceChecks":1}xcrun swiftc -parse apps/macos/Sources/OpenClaw/TalkModeRuntime.swift.SimpleTaskSupportTestsalready cover cancellation during sleep, cancellation after sleep, and replacing a superseded task. The same canonical helper is already used by presence reporting and channel polling; the iOS Talk silence owner likewise returns immediately when its sleep is cancelled../scripts/format-swift.sh macos. SwiftLint on the changed owner reports zero violations.