Skip to content

fix(macos): cancelled Talk sessions can spin at full CPU - #129682

Merged
steipete merged 2 commits into
mainfrom
codex/macos-talk-cancelled-silence-monitor
Aug 26, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/macos-talk-cancelled-silence-monitor

Conversation

@steipete

@steipete steipete commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

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 existing SimpleTaskSupport.waitForNextOperation cancellation 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}
  • The exact changed production file passes xcrun swiftc -parse apps/macos/Sources/OpenClaw/TalkModeRuntime.swift.
  • Existing SimpleTaskSupportTests already 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.
  • The exact macOS CI formatter succeeds across all 338 application files and 26 additional native sources: ./scripts/format-swift.sh macos. SwiftLint on the changed owner reports zero violations.
  • Fresh independent structured Codex autoreview: clean, with no accepted/actionable findings.
  • A new in-process regression test is intentionally not added: the unfixed actor enters an unbounded busy loop and can permanently wedge the shared serialized macOS test runner; exposing its private task solely for a test would add an unnecessary production seam. The bounded executable before/after cancellation proof directly covers the violated Swift concurrency contract, and hosted macOS CI validates the real application build and existing native tests.

@clawsweeper

clawsweeper Bot commented Aug 25, 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 app: macos App: macos size: XS maintainer Maintainer-authored PR labels Aug 25, 2026
@steipete
steipete marked this pull request as ready for review August 25, 2026 23:49
@steipete

Copy link
Copy Markdown
Contributor Author

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 xcrun swiftc -parse apps/macos/Sources/OpenClaw/TalkModeRuntime.swift. Fresh independent structured Codex autoreview reports no accepted or actionable findings. The fix removes one production line and adds no configuration, public API, dependency, or test-only seam.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

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 SimpleTaskSupportTests already prove cancellation during sleep, cancellation after sleep, and replacing a superseded task. Fresh independent structured Codex autoreview reports no accepted or actionable findings. The fix removes one production line and adds no configuration, public API, dependency, or test-only seam.

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.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 8:54 PM ET / August 26, 2026, 00:54 UTC.

ClawSweeper review

What this changes

The PR makes a cancelled macOS Talk silence monitor exit its periodic loop instead of immediately continuing stale silence checks.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep 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
Reviewed head: e457cdc3e1ca33f386a768e0b6329e680011a4ab

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary change with coherent source and sibling support; native validation is nearly complete.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: Maintainer-authored PRs are exempt from the contributor proof gate; the body nevertheless includes terminal before/after Swift cancellation output.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Maintainer-authored PRs are exempt from the contributor proof gate; the body nevertheless includes terminal before/after Swift cancellation output.
Evidence reviewed 7 items Current-main behavior: Current main still ignores cancellation from the 200 ms sleep and then runs the next silence check, so the reported busy-loop path remains unfixed outside this PR.
Lifecycle owner repair: The monitor is replaced by cancelling silenceTask, and the proposed loop gates checkSilence on the shared cancellation-aware wait while retaining the 0.2-second cadence.
Shared helper contract: The reused helper returns false if already cancelled, if sleep throws due to cancellation, or if cancellation occurs after sleep; this is the needed owner-boundary behavior.
Findings None None.
Security None None.

Live Verification

Command: swift build --package-path apps/macos --product OpenClaw --configuration release

Result: FAIL (failed) — execution before step 1 run: terminal command did not produce output or exit within 30 seconds: "swift build --package-path apps/macos --product OpenClaw --configuration release"

terminal command did not produce output or exit within 30 seconds: "swift build --package-path apps/macos --product OpenClaw --configuration release"

Captured output:



















































Assertions:

  • FAIL expect_output: Build of product 'OpenClaw' complete!

How this fits together

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

Before merge

  • Resolve merge risk (P1) - The exact-head macos-node check is still queued, so the native validation set is not yet complete.
Agent review details

Security

None.

PR surface

Other -1. Total -1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 2 -1
Total 1 1 2 -1

Review metrics

Metric Value Why it matters
Production vs test delta production +1/-2 (net -1); tests 0 The bug fix removes the cancellation-swallowing loop behavior without expanding API, configuration, or test-support surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the contained lifecycle-owner fix once the queued native check succeeds, retaining the shared cancellation helper as the sole periodic-wait policy.
  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 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.

Labels

Label changes:

  • add P1: A cancelled Talk session can peg CPU and leave an active voice workflow unresponsive for macOS users.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Maintainer-authored PRs are exempt from the contributor proof gate; the body nevertheless includes terminal before/after Swift cancellation output.

Label justifications:

  • P1: A cancelled Talk session can peg CPU and leave an active voice workflow unresponsive for macOS users.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Maintainer-authored PRs are exempt from the contributor proof gate; the body nevertheless includes terminal before/after Swift cancellation output.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Recent Talk and macOS changes in this runtime include the proposed repair and earlier merged voice work. (role: recent Talk contributor; confidence: high; commits: e457cdc3e1ca, e8524a5839a2, 311f5bfbaa5c; files: apps/macos/Sources/OpenClaw/TalkModeRuntime.swift)
  • RoboClaw: Current-main blame attributes the affected monitor lifecycle lines to this commit. (role: current-line introducer; confidence: medium; commits: 3cc64f90edfc; files: apps/macos/Sources/OpenClaw/TalkModeRuntime.swift, apps/macos/Sources/OpenClaw/SimpleTaskSupport.swift)
  • Vincent Koc: Recent merged realtime Talk work touched the same runtime, making this a relevant routing contact for lifecycle interactions. (role: adjacent realtime Talk contributor; confidence: medium; commits: 000db97c8252; files: apps/macos/Sources/OpenClaw/TalkModeRuntime.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Allow the queued exact-head macos-node check to complete before merge.

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-26T00:11:50.075Z sha e457cdc :: needs maintainer review before merge. :: none

@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 26, 2026
@steipete
steipete merged commit 8f22534 into main Aug 26, 2026
228 of 232 checks passed
@steipete
steipete deleted the codex/macos-talk-cancelled-silence-monitor branch August 26, 2026 01:26
@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 26, 2026
…9682)

* fix(macos): stop cancelled Talk silence monitors

* fix(macos): reuse cancellable periodic task owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos 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: XS 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.

1 participant