Skip to content

Add a ceiling to the slskd quality filters - #14

Merged
Gabriel-Lewis merged 1 commit into
devfrom
feat/quality-range
Aug 30, 2026
Merged

Gabriel-Lewis merged 1 commit into
devfrom
feat/quality-range

Conversation

@Gabriel-Lewis

Copy link
Copy Markdown
Owner

First of two. Adds the quality range; the size preference (prefer smaller / larger) follows in a stacked PR.

Why

The slskd filters are floors only — MIN_BITRATE, MIN_BIT_DEPTH — so nothing stops a single recommended track arriving as a 138 MB WAV. In album mode that multiplies across the whole release.

The part that shaped the design

The ceiling couldn't be written the way the floors are. Both existing checks are guarded with if file.BitRate > 0 && because Soulseek peers frequently report nothing — and a ceiling that skips undescribed files would let through exactly what it exists to exclude.

effectiveBitRate prefers the reported value where there is one, so files that describe themselves are judged exactly as before, and otherwise derives from Size × 8 ÷ Length. Neither available means unknown, which is never rejected — dropping everything undescribed would leave very few candidates.

MAX_BITRATE defaults to 0 (disabled), so an upgrade changes nothing until someone sets a limit.

One deliberate asymmetry

Album mode exempts the recommended track from the quality floors ("a mediocre playlist entry beats none"). It is not exempt from the ceiling — that's a question about transfer volume, not quality, and an oversized primary is precisely the case being guarded against. There's a test pinning each half.

UI

The wizard's free-text extensions field becomes format checkboxes plus a dual-handle bitrate slider.

  • Stops are evenly spaced, not linear. Real bitrates reach ~4600, so linear spacing would compress every lossy option into the first few percent of the track.
  • The top stop means no limit and writes 0.
  • With no lossless format ticked the ceiling clamps to 320 and the unreachable top greys out, since the two controls would otherwise silently contradict each other.
  • Extensions the checkboxes can't represent (opus, aiff) are preserved in the saved value and shown as "also accepting …" rather than being dropped.

Testing

Mutation-checked, each fails without its fix:

  • the ceiling applying to the album primary — fails with the primary was kept despite being over the ceiling
  • MIN_BITRATE/MAX_BITRATE in AllConfigKeys — fails with the control would always read back as its default

Plus: effectiveBitRate in all three states, lossless classification, floor/ceiling boundaries, a zero ceiling rejecting nothing, unknown bitrate surviving, derivation catching a big unreported file, the primary keeping its floor exemption, and the wizard round-trip including a zero ceiling written rather than dropped.

go build ./..., go vet ./src/..., go test ./src/... pass; npm run build succeeds.

🤖 Generated with Claude Code

The slskd filters were floors only, so nothing stopped a single
recommended track arriving as a 138 MB WAV or a 100 MB 24/96 FLAC. In
album mode that multiplies across a whole release.

MAX_BITRATE sets the ceiling, defaulting to 0, which disables it -- an
upgrade changes nothing until someone chooses a limit.

The ceiling could not be written the way the floors are. Both existing
checks skip a file when the peer reports no bitrate, which is common on
Soulseek; a ceiling written that way round would let through exactly the
files it exists to exclude. effectiveBitRate prefers the reported value
where there is one, so files that describe themselves are judged exactly
as before, and otherwise works the rate out from size over duration. A
file with neither is treated as unknown and never rejected, since
dropping everything undescribed would leave few candidates.

Album mode exempts the recommended track from the quality floors, on the
grounds that a mediocre playlist entry beats none. It is not exempt from
the ceiling: that is a question about transfer volume rather than
quality, and an oversized primary is the case being guarded against.

In the wizard the free-text extensions field becomes format checkboxes
and a range slider. The slider's stops are evenly spaced rather than
linear, because real bitrates run to about 4600 and linear spacing
would squeeze every lossy option into the first few percent of the
track. Its top stop means no limit and writes 0. With no lossless format
ticked the ceiling clamps to 320, since nothing above that is reachable
and the two controls would otherwise contradict each other in silence.

Extensions the checkboxes do not cover are kept in the saved value and
shown, rather than being dropped by a control that cannot represent
them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Gabriel-Lewis
Gabriel-Lewis merged commit 5fc96cd into dev Aug 30, 2026
4 checks passed
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