镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(grok-voice): cancel stale read-aloud playback - #665

Open
rudycelekli wants to merge 2 commits into
cursor:mainfrom
rudycelekli:fix/voice-read-aloud-request-lifecycle-20261016
Open

rudycelekli wants to merge 2 commits into
cursor:mainfrom
rudycelekli:fix/voice-read-aloud-request-lifecycle-20261016

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

The batch read-aloud client example promises one utterance at a time, but two clicks before either request finishes can play both responses. A slower response for the older click can replace the newer reply, and Stop during a fetch/body download still permits playback afterward. Stopped/replaced audio also retains its blob URL because only ended revokes it.

Give each request a generation token, invalidate pending work on Stop/new playback, and check ownership after both awaits. Share one disposal path for pause, URL cleanup, completion, and playback errors. The player still belongs in the shared store described by the skill.

Validation: node --test grok-voice/tests/read-aloud.test.cjs (Node 22.13+) passes 6 tests that extract and execute the actual TypeScript client snippet. Controlled fetch completion and audio/URL stand-ins reproduce out-of-order replies, Stop before response, Stop during body download, and URL lifetime. Unchanged base: 5 failures and 1 natural-completion control passes. Fixed: 6 pass. git diff --check passes. These are deterministic client lifecycle checks; no xAI calls or browser playback were performed.

Review follow-up: stop/replacement can reject a pending Audio.play promise. Ignore a superseded request rejection while retaining active playback errors. The extracted client now passes 9 tests, including Stop during play, replacement during play, and a genuine active playback failure. Both cancellation regressions fail before the follow-up change. This is deterministic lifecycle evidence, not a browser playback claim.


Note

Low Risk
Documentation and deterministic Node tests only; no runtime app or data-path changes.

Overview
Hardens the batch read-aloud client pattern in the add-read-aloud skill so only one utterance can win: a generation counter invalidates in-flight TTS work on stop or a new click, with checks after fetch and blob() so slower or out-of-order responses cannot start playback. Stop is centralized to pause audio, revoke the active blob URL, and bump generation; ended and play failures use the same cleanup path, and superseded play() rejections are ignored.

Smoke-test bullets now cover double-click before fetch completes, stop during download, and blob URL release on stop/replace.

Adds grok-voice/tests/read-aloud.test.cjs, which pulls the documented TypeScript client from the skill, runs it in a VM with stubbed fetch/Audio/URL, and asserts nine lifecycle cases (latest wins, stop during pending/body/play, URL cleanup, real playback errors).

Reviewed by Cursor Bugbot for commit 7b09b09. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit f4d4d37. Configure here.

Comment thread grok-voice/skills/add-read-aloud/SKILL.md
Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
@rudycelekli
rudycelekli force-pushed the fix/voice-read-aloud-request-lifecycle-20261016 branch from 7b09b09 to 22c194e Compare October 24, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant