Repository navigation
fix(grok-voice): cancel stale read-aloud playback - #665
Open
rudycelekli wants to merge 2 commits into
Open
rudycelekli wants to merge 2 commits into
rudycelekli wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
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.
Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
rudycelekli
force-pushed
the
fix/voice-read-aloud-request-lifecycle-20261016
branch
from
October 24, 2026 01:58
7b09b09 to
22c194e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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
endedrevokes 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 --checkpasses. 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
fetchandblob()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 supersededplay()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 stubbedfetch/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.