Repository navigation
fix(locallibrary): player capitals and the mixes-into panel's keys - #511
Open
botandbang wants to merge 2 commits into
Open
botandbang wants to merge 2 commits into
botandbang wants to merge 2 commits into
Conversation
…eir lowercase keys `Q` quit the player in terminals that report keys by their codes (CSI u, xterm's modifyOtherKeys, tmux extended-keys): they send it as `q` with shift, and the keymap took that for `q`. The player quit cleanly, which is why no panic text ever showed. #306 fixed it (ca71e89), and on a release build `Q` sent each way now toggles quantize. This adds the regression test that would have caught it: a property over the deck's and the library's capitals, typed while a track plays, that any run of them leaves the same screen whether each comes as the capital or as its code, and that none of them quits. Fixes LOC-11
…anel The player's "mixes into" panel took the first matches `harmony::suggestions` ranks, and it ranks every same-key track before any other. The keys shown were each track's own, but in a library of any size same-key tracks filled all four to six rows, so the panel never showed a ±1 or relative match: playing an F minor track showed nothing but 4A. `Matches::find` now takes each way of mixing in (same key, one step round the wheel, relative, energy boost) in turn, closest tempo first within each, so the first rows show one of each there is. `track matches` and the sidecar keep listing best first; docs/player.md says how the two differ. Fixes LOC-13
SizeCompared with main. KiB are 1,024 bytes.
|
bnb
approved these changes
Nov 7, 2026
Rust coverageFrom run 499. Both are held to the thresholds in .cargo/config.toml.
|
This branch has not been deployed
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.
What and why
Two fixes to the player, one commit each.
Qquit the playerFixes LOC-11
#306 fixed this, in ca71e8981. In terminals that report keys by their codes (CSI u, xterm's modifyOtherKeys, tmux extended-keys),
Qarrives asqwith shift, and the keymap read it as quit. The player exited normally, so there was never a panic to capture. That commit addedcapitalinapps/locallibrary/src/tui/app/input.rsand a test forQ,SandA.This PR adds the regression test that would have caught it: a Hegel property,
prop_a_shifted_letter_sent_as_its_code_is_its_capital, over the deck's and the library's capitals. Any run of them typed while a track plays leaves the same screen sent either way, and none quits.On a release build of this branch in a pty at 120x40, with
RUST_BACKTRACE=1, playing a track on the demo drive and sendingQ,ESC [113;2u(CSI u) andESC [27;2;113~(modifyOtherKeys) between beat jumps, loops and hot cues, the player kept running, toggled quantize each time and quit with status 0 onq. stderr held only the test-volumes notice.The "mixes into" panel showed one key
Fixes LOC-13
The keys shown were right: each row showed its own track's key. The ranking was the problem. The panel showed the first matches
harmony::suggestionsranks, and it ranks every same-key track before any other, so with more same-key tracks than the panel's four to six rows, which is any real library, same-key tracks filled every row and the panel never showed a ±1 or relative match. An F minor track showed only 4A. On the 3,886-trackrekordcrate/largefixture, a C major track listed8Bfive times at 120x40, whiletrack matcheslists 7B and 9B right after.Matches::findinapps/locallibrary/src/tui/app/loaded.rsnow lets same key, ±1, relative and energy boost take turns, closest tempo first within each. The panel's first rows show the closest track of each kind there is, then the second of each, and so on. The library's details panel and the deck share it.track matchesand the sidecar'sharmonic_matcheskeep listing best first, every same-key track before the rest. That difference is on purpose: a full list reads well best first, and a panel of a few rows needs every kind in it.docs/player.mdsays so.Added
the_mixes_into_panel_shows_more_than_the_playing_key: a library with seven same-key matches, a neighbour and a relative; the deck at 120x40 shows all three kinds.prop_the_ways_of_mixing_in_take_turns: for any made-up library, the matches found are as many as the suggestions allow up to the limit, start with one of each kind in the suggestions' order, and keep the suggestions' tempo order within each kind.prop_a_shifted_letter_sent_as_its_code_is_its_capital, above.playing_inin the TUI's test helpers:playingwith a library of the test's own.apps/locallibrary/changes/loc-11-13-player-fixes.md.Changed
Matches::findorders the matches by turns, as above.docs/player.mdsays how the matches are ordered.Removed
Nothing.
How it was tested
Each new test was seen to fail with its fix broken, one at a time: with
capitalskipped inon_key, the property failed on['Q']with "Q quit" (as did the existinga_shifted_q_sent_as_its_code_quantizes_rather_than_quits); with the old order (kind first, then tempo) the panel test failed missing7B 128.0 Neighbourand the take-turns property failed on its first-rows check.cargo nextest run -p locallibrary-clipassed 1,376 of 1,376, andcargo nextest run --workspace5,114 of 5,114 (1 skipped).cargo fmt --all --checkand the three clippy forms (workspace,--no-default-features --features tui,account,--no-default-features, all with--all-targets -D warnings) pass. Coverage is left to CI.The panel was checked on a release build in a real terminal engine, truecolor and dark, playing "Upstart" (C major, 128.88 BPM) on the
rekordcrate/largefixture. Before, the deck at 120x40 listed8Bin all five rows. Now it lists 8B, 7B, 8A, 8B. At 80x24 the deck has no room for the panel, and the library's details pane shows 8B, 7B, 8A.Matches::findnow asks the suggestions for every match, then sorts and takes 40 (when a track starts) or 60 (the details pane), where it asked for 40 or 60.harmony::suggestionsalready built and cloned every match before cutting the list, so the time barely moves. Measured with a temporary test in an optimised build of theunitbinary (release without LTO), with its counting allocator, per call over 79 playing tracks of the 3,886-track fixture and 150 of a 10,000-track library made ascrates/locallibrary/benches/syntheticmakes its tracks:Allocations a call went from 2,547 to 2,549 on the fixture and from 32,109 to 32,111 on 10,000 tracks. The extra bytes are one more list of every match, each with its turn, built for the sort. It runs on a background thread, not in a frame, so frame work doesn't change; no frame budget was touched.
Checklist
apps/locallibrary/changes/loc-11-13-player-fixes.mdhas a changelog linedocs/and--helpstill say what the code does (apps/locallibrary/docs/rpc/too)