feat(spotify): configurable bitrate#177
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a configurable Spotify bitrate: parsed from config, clamped to supported values (96, 160, 320; <=0 → 320), stored on the Spotify provider, and passed into stream creation instead of a hardcoded constant. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ConfigLoader
participant App
participant SpotifyProvider
participant Session
User->>ConfigLoader: start (reads config files)
ConfigLoader->>ConfigLoader: parse [spotify].bitrate
ConfigLoader->>ConfigLoader: clampSpotifyBitrate(value) -> supported bitrate
ConfigLoader->>App: return Config (Spotify.Bitrate)
App->>SpotifyProvider: New(session=nil, clientID, bitrate)
SpotifyProvider->>Session: session.NewStream(trackID, bitrate)
Session-->>SpotifyProvider: stream (uses provided bitrate)
SpotifyProvider-->>App: streamer
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@config/config_test.go`:
- Around line 145-157: Add an explicit negative-input case to the
TestClampSpotifyBitrate table to cover the v <= 0 branch in clampSpotifyBitrate:
update the tests slice in TestClampSpotifyBitrate to include a case such as {
-1, 320 } so the behavior that negative inputs map to 320 is asserted (locate
the TestClampSpotifyBitrate function and the tests variable to modify).
In `@docs/spotify.md`:
- Line 27: Update the docs text for the bitrate option to explicitly state that
non-positive values are treated as 320 rather than being rounded: mention that
when bitrate <= 0 the implementation maps it to 320, while unsupported positive
values are rounded to the nearest supported bitrate (96, 160, 320); reference
the config/option name "bitrate" and the implementation behavior that checks for
<= 0 to locate where this wording should be added.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 79dee6ba-a25e-42d2-bd5d-1e42b8839d90
📒 Files selected for processing (7)
config.toml.exampleconfig/config.goconfig/config_test.godocs/spotify.mdexternal/spotify/provider.goexternal/spotify/stub_windows.gomain.go
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@config/config_test.go`:
- Around line 145-165: The tests for clampSpotifyBitrate need explicit midpoint
cases to lock tie-breaking behavior; update TestClampSpotifyBitrate in
config_test.go to include inputs exactly at midpoints between available bitrates
(e.g., 128 and 240) and assert the function returns the lower option
(clampSpotifyBitrate(128) == 96 and clampSpotifyBitrate(240) == 160) so the
current "pick lower on tie" behavior is preserved.
- Around line 356-387: Add a non-positive test case to TestLoadSpotifyBitrate:
include an entry like {"non-positive value", 0, ClampSpotifyBitrate(0)} (or use
the known clamp/default value) so Load() integration asserts that
cfg.Spotify.Bitrate is clamped when the TOML contains a non-positive bitrate;
update the tests slice in TestLoadSpotifyBitrate and keep the same
setup/verification that compares cfg.Spotify.Bitrate to the expected value
derived from ClampSpotifyBitrate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: a614ce81-fff4-48c9-9a17-5aaff654fa73
📒 Files selected for processing (4)
config/config_test.godocs/spotify.mdexternal/spotify/provider.goexternal/spotify/stub_windows.go
Summary by CodeRabbit
New Features
Documentation