Skip to content

fix(gui): Stop also stops audio that is still playing - #24

Merged
DavidTbilisi merged 1 commit into
masterfrom
fix/gui-stop-playback
Oct 23, 2026
Merged

DavidTbilisi merged 1 commit into
masterfrom
fix/gui-stop-playback

Conversation

@DavidTbilisi

Copy link
Copy Markdown
Owner

Problem

The GUI's Stop button only cancelled synthesis.

  • Background player: once every chunk was ready, Stop left playback running to the end.
  • Player window: Stop greyed out as soon as the run finished, while the mpv window kept playing.

Changes

  • StreamingAudioPlayer.wait_until_released(cancel_event=) returns as soon as the event is set. smart_generate_long_text then raises GenerationCancelled, which stops the player, so cancelling cuts playback short, not only synthesis.
  • A GUI player window stays registered after its worker ends, until it is closed or stopped (running(), any_streaming_player_running()). The GUI keeps Stop enabled while the window is open ("Playing in the player window. Stop closes it."), and Stop closes it. Stopping runs off the Tk thread.
  • start() registers the player before starting its worker. A worker that ended at once used to unregister first and leave a stale entry; a new test caught it.
  • The status shows "Playing…" once every chunk is ready, and "Stopped." after a stop (it used to say "Generation cancelled.").
  • CLAUDE.md streaming notes updated.

Testing

  • 8 new tests: cancel while the worker or the player process is still playing, a player window staying registered, Stop closing it, a headless player unregistering, Stop during playback raising GenerationCancelled and removing the run dir, and the GUI Stop / window-watch flow.
  • Full suite: 801 passed. No new mypy errors.
  • Driven in the real GUI with flatpak mpv:
    • Background mode, Stop 2 s into playback: audio stopped in 0.3 s and no mpv was left.
    • Window mode, Stop 2 s after the run ended: the window closed and no mpv was left.

🤖 Generated with Claude Code

Stop only cancelled synthesis. Once every chunk was ready, pressing it in
background mode let playback run to the end, and in window mode the button
greyed out while the mpv window kept playing.

- wait_until_released(cancel_event=) returns as soon as Stop is pressed;
  smart_generate_long_text then raises GenerationCancelled, which stops
  the player.
- A GUI player window stays registered after its worker ends, until it is
  closed or stopped (running(), any_streaming_player_running()). The GUI
  keeps Stop enabled while it is open, and Stop closes it.
- start() registers the player before starting its worker, so a worker
  that ends at once can no longer leave a stale registration.
- Status shows "Playing…" once every chunk is ready, and "Stopped." after
  a stop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DavidTbilisi
DavidTbilisi merged commit ec6f8a4 into master Oct 23, 2026
6 checks passed
@DavidTbilisi
DavidTbilisi deleted the fix/gui-stop-playback branch October 23, 2026 17:35
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