Repository navigation
fix(tui): stop audio output after playback - #54434
VitorNathanG wants to merge 2 commits into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
The approach looks sound. Once no sounds are playing, the output is stopped, and the next play() starts it again. I checked against @opentui/core 0.5.17: stop() resets the started state, start() and play() can't be interleaved with the timer because they all run on the same JavaScript thread, and the library has no event for when a sound finishes, so polling makes sense. The audio instance is only used by attention sounds, so stopping it doesn't affect anything else.
I couldn't check the fix itself: the review environment has no audio device (Audio.start() fails with status -5). The new tests and the packages/tui type check pass.
The public API is unchanged.
One request: please cut the test file down (see the inline comment).
Related: #53492
There was a problem hiding this comment.
The fix works. I reproduced #54432 under PulseAudio with the bot's reproduction script, run against each checkout:
- Base: the opencode audio stream stays open 10 seconds or more after the attention sound ends.
- This PR: the stream is gone within about 5 seconds. A second sound opens it again, and it's released again afterwards.
My earlier test comment is resolved: the tests now run the check by hand instead of using real timers and sleeps. They pass, and so does the packages/tui type check.
The public API is unchanged. I have no further concerns.
Related: #53492
|
Also fixes my issue. |
31b95f2 to
7a98baa
Compare
|
I suspect this also helps the case for those using multi-server Bluetooth headsets where having OpenCode open prevents automatic switching to the other device when it starts audio because it appears as thought there's a stream active on the first. |
7a98baa to
5b13af4
Compare
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
The mentioned issue still exists and it fixes the issue at hand. Without this, OpenCode holds the audio device open causing:
|
Issue for this PR
Closes #54432
Type of change
What does this PR do?
Stop OpenCode V2 TUI audio output when no voices remain active, and restart it for the next sound. Cancel idle polling after stopping or disposal.
This fixes Bluetooth headphones being unable to switch playback to another device after a notification.
How did you verify your code works?
Manually confirmed Bluetooth switching works with the patch on macOS. Other platforms are untested.
Screenshots / recordings
Not applicable.
Checklist
Added by the opencode bot (AI-generated).
Related: #53492