Skip to content

fix(locallibrary-cli): list the audio outputs without holding up the player - #201

Open
botandbang wants to merge 2 commits into
mainfrom
bnb/tui-outputs-async
Open

botandbang wants to merge 2 commits into
mainfrom
bnb/tui-outputs-async

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

Pressing d in the player listed the audio outputs on the UI thread (deck::list_outputs called outputs.list directly), so the screen didn't redraw until cpal had enumerated every host's devices, which can take a while with ALSA on Linux. Keys pressed meanwhile went to a list that wasn't drawn yet: the scheduled Bombadil run saw d then the next key close the list unseen. Now:

  • src/tui/deck.rs: list_outputs opens the list at once, on the system's default, and lists the devices on a worker through app.spawn_or, as read_sets does. listed_outputs fills the list when they come back, selecting the output playing, and drops a listing for a list closed or opened again since (a listing id, as Msg::Sets drops an older load). Outputs gains listing and failed.
  • src/tui/app.rs: Msg::Outputs carries the result; animating() counts the outputs being listed, so they're drawn as soon as they're in rather than at the next idle poll.
  • src/tui/ui.rs: while the devices are listed, the list shows "listing the outputs…" under the default; when they can't be, it says why in the list ("can't list the outputs: …"), in the style of "No audio output". The devices replace that row, so with one device the popup keeps its size.
  • src/tui/audio.rs: Outputs::list returns a Result, and listing the devices passes on cpal's error, where it used to show only the system's default as if there were no others.
  • CHANGELOG.md: a line under Unreleased.
  • bombadil/tui.sh and CONTRIBUTING.md gave --seed 7 as an example option, which Bombadil 0.7.8 doesn't have; the example is --columns 80.

Opening an output (use_output, and open_preferring when a track starts) still runs on the UI thread and looks the device up by name; moving that means handing a cpal stream across threads, and isn't in this change.

How it was tested

  • New tests in src/tui/deck/tests.rs: the list opens with "listing the outputs…" before its devices are in and fills when they arrive; a late listing after the list was closed, or for an older listing after it was reopened, is dropped; a listing that fails (or panics) says why in the list and Enter still plays through the default. Each fails with the old synchronous list_outputs.
  • background_results_land_where_they_belong (Hegel) sends Msg::Outputs with current and stale ids, Ok and Err, to open and closed lists; the_screen_moves_only_while_something_does counts the outputs being listed. Both fail with the id check or the animating() line removed.
  • CI=true cargo nextest run -p locallibrary-cli: 1,046 passed; cargo clippy --workspace --all-targets --locked -- -D warnings; cargo fmt --all --check.
  • TIME_LIMIT=5m ./tui.sh: every d drew the list with "listing the outputs…". The run stopped on digitsSwitchViews in full screen, where digits play hot cues; fix(locallibrary): get the scheduled suites passing again #200 fixes that in the spec.

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)

…player

d opens the outputs list at once and lists the devices on a worker, which can take a while; the devices fill the list when they come back, a listing for a list closed or opened again since is dropped, and one that fails says why in the list. Listing the devices now passes on cpal's error rather than showing only the system's default.
@botandbang
botandbang requested a review from bnb as a code owner October 23, 2026 16:12
@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 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Rust coverage

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

Tests Lines Functions Regions
All 97.38% (77588/79676) 96.45% (12290/12743) 95.66% (170428/178151)
Hegel property tests alone 95.42% (76026/79676) 93.89% (11964/12743) 93.5% (166575/178151)

This branch has not been deployed

No deployments
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.

1 participant