Repository navigation
fix(audio): keep the chime's context running during a run (#1157) - #1185
Merged
Merged
Conversation
Device feedback on #1178 (Firefox 153, Android 14): with the context suspended between chimes, a run that finished while the phone was locked never chimed, since Firefox leaves the resume() of a suspended context pending there. ChatWindow now holds the context running while its session's run is under way (holdAudio(), released when the run ends or the window unmounts), so the output stream stays open during a run but not between runs. A chime whose resume() took longer than 3 s is dropped instead of playing late when the user comes back. Co-Authored-By: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
agegr#1185) Device feedback on agegr#1178 (Firefox 153, Android 14): with the context suspended between chimes, a run that finished while the phone was locked never chimed, since Firefox leaves the resume() of a suspended context pending there. ChatWindow now holds the context running while its session's run is under way (holdAudio(), released when the run ends or the window unmounts), so the output stream stays open during a run but not between runs. A chime whose resume() took longer than 3 s is dropped instead of playing late when the user comes back. Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
agegr#1185) Device feedback on agegr#1178 (Firefox 153, Android 14): with the context suspended between chimes, a run that finished while the phone was locked never chimed, since Firefox leaves the resume() of a suspended context pending there. ChatWindow now holds the context running while its session's run is under way (holdAudio(), released when the run ends or the window unmounts), so the output stream stays open during a run but not between runs. A chime whose resume() took longer than 3 s is dropped instead of playing late when the user comes back. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Follow-up to #1178 (#1157), based on @1tazura's device check on Firefox 153 for Android 14.
Problem
#1178 suspends the chime's
AudioContextbetween chimes. That released the AudioMix wake lock and the AAudio stream while idle, as intended. However, a run that finished while the phone was locked no longer chimed: Firefox left theresume()of the suspended context pending, and no oscillators were scheduled. v0.10.0's always-running context did chime there.Change
useAudiogetsholdAudio(), which returns a release function. While any hold is outstanding, the idle suspend is skipped and a suspended context is resumed. Releasing the last hold suspends itAUDIO_IDLE_SUSPEND_MSlater.ChatWindowholds the context while its session'sagentRunningis true. The hold is released when the run ends or the window unmounts. The output stream is therefore open during a run, when a chime can come, and closed between runs, which was the original complaint.resume()took longer thanAUDIO_STALE_CHIME_MS(3 s) is dropped. Otherwise, a resume that was held back would play the chime when the user comes back. This also covers a chime requested before the page's first gesture, which used to play at the next click.demo/copy of the hook is mirrored, anddocs/agents/client-platform.mdhas one added line.Verification
hooks/useAudio.test.mjs(12 in total), all of which fail against main:tsc --noEmit, eslint andnpm testpass (2606 passed, 1 skipped).node e2e/run.mjs: 27/27 on the second run. The first run failed at the known flaky "Hide sidebar" step (run.mjs:493).🤖 Generated with Claude Code