Skip to content

fix(locallibrary): go on past a queued track that played out before the tick - #276

Merged
botandbang merged 2 commits into
mainfrom
bnb/tui-queue-flake
Oct 29, 2026
Merged

botandbang merged 2 commits into
mainfrom
bnb/tui-queue-flake

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

The player's follow_queue caught up with at most one change of the audio player per call. It either noticed that the player had moved on to the track queued behind the playing one, or that the playing track had finished. When both happened since the last call (a queued track short enough to play out between two ticks, or a slow tick), it moved the queue on to the queued track but left that track showing as playing on an empty player until the next call. A key pressed in that window caught up first and then acted, so n skipped the track after it. This made tui::props::playing_keeps_the_queue_whole fail intermittently ("n from 1 of 4", 3 against 2), depending on which tick the background opener's results landed on.

follow_queue now checks for a finished player after handling the move to the queued track, re-reading why the new track ended if it did, so one call goes on past both. With a single change, nothing differs from before.

the_queue_plays_on_through_what_goes_wrong had relied on the old behaviour. To play out the current track it pulled half a second minus the playhead's position, but its 16 kHz tracks last a quarter second, so the pull also played out the track opened ahead. It now pulls up to the playing track's actual duration, and its assertion that the player goes on to the track opened ahead is as strict as before.

How it was tested

  • The new test a_tick_after_the_queued_track_played_out_goes_on_past_it plays out the playing track and the queued one with no tick in between, then checks that one tick goes on to the third. It fails without the fix.
  • Hegel's reproducer for the intermittent failure failed every run before the fix. With the fix it passed 250 runs unloaded and 250 runs (7,250 replays) with every core busy. playing_keeps_the_queue_whole and the_queue_plays_on_through_what_goes_wrong also passed 100 and 40 runs with random seeds.
  • cargo fmt --check, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo nextest run -p locallibrary -p locallibrary-cli and tools/hegel-coverage.sh all pass.

Checklist

  • Tests cover the change
  • For the website: Storybook stories cover any new UI states
  • For locallibrary: apps/locallibrary/CHANGELOG.md has a line under Unreleased, if people using it will notice
  • The READMEs, docs/ and --help still say what the code does (apps/locallibrary/docs/rpc/ too, for a sidecar change)

…he tick

follow_queue caught up with at most one change of the audio player per call. When the queued track had also played out since the last look (a short track, or a slow tick), it moved on to that track but left it showing as playing on an empty player, so a key pressed then, like n, skipped the track after it. It now checks for a finished player after moving on as well. the_queue_plays_on_through_what_goes_wrong relied on the old behaviour by pulling more samples than its tracks hold; it now pulls up to the playing track's duration.
@botandbang
botandbang requested a review from bnb as a code owner October 29, 2026 13:41
@github-actions github-actions Bot added documentation Improvements or additions to documentation locallibrary locallibrary and the loclib-* crates locallibrary: player The terminal player and its waveforms tests Tests, fixtures and test harnesses labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown

Rust coverage

From run 523. Both are held to the thresholds in .cargo/config.toml.

Tests Lines Functions Regions
All 97.53% (81248/83306) 96.68% (12973/13418) 95.84% (178606/186359)
Hegel property tests alone 95.36% (79443/83306) 93.88% (12597/13418) 93.45% (174153/186359)

@botandbang
botandbang merged commit 141d91a into main Oct 29, 2026
66 checks passed
@botandbang
botandbang deleted the bnb/tui-queue-flake branch October 29, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation locallibrary: player The terminal player and its waveforms locallibrary locallibrary and the loclib-* crates tests Tests, fixtures and test harnesses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants