fix(sloppak/ws_highway): drums stay in picker and show correct hit count#1017
fix(sloppak/ws_highway): drums stay in picker and show correct hit count#10170-Scr4tch-0 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughChangesDrum-only song metadata
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/routers/ws_highway.py`:
- Around line 479-494: Update the notes-count override in the arr_list
construction to apply only when the current arrangement is the drum arrangement,
while retaining the existing empty-arrangement and _dt_hit_count checks. Leave
note counting unchanged for non-drum arrangements such as Vocals or Keys.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: bed572ff-4eb5-4a31-91a5-9ca1d21c9176
📒 Files selected for processing (2)
lib/routers/ws_highway.pylib/sloppak.py
Problem:
The editor strips drum arrangements from the sloppak manifest, converting
them to a drum_tab sidecar. This left two visible bugs:
1. "Drums (0)" — drum-only packs showed zero notes in the arrangement
picker even though the drum highway displayed thousands of hits. The
sloppak loader synthesized a placeholder Arrangement(name="Drums")
with no notes whenever the arrangements list was empty, and the
WebSocket highway always reported that placeholder's note count (0).
2. Drums disappear alongside other arrangements — when a drum+bass or
drum+guitar pack was loaded, the placeholder was never created because
the arrangements list was not empty (the other instrument was present).
The drum arrangement had been removed by the editor during drum_tab
conversion, so drums vanished entirely from the arrangement picker.
Fix (sloppak.py):
Replaced the "arrangements list is empty" trigger with "no drum
arrangement exists". The loader now checks whether any arrangement name
contains 'drum' or 'percussion' (case-insensitive substring match using
_DRUM_KEYWORDS) and synthesizes the placeholder when a drum_tab is
present but no matching arrangement is found. This ensures drums appear
in the picker even alongside bass, guitar, or other pitched instruments.
Fix (ws_highway.py):
When building the arrangement list for the song_info WebSocket message,
the highway now reads the drum_tab hit count from the loaded sloppak and
substitutes it for any empty arrangement whose name matches the drum
keywords. The placeholder has no notes of its own (it exists only to
carry the drum_tab through to the drum highway), so the real hit count
from drum_tab is surfaced instead — e.g. "Drums (1922)" instead of
"Drums (0)".
Guard against false positives:
The hit-count override is scoped to drum/percussion arrangements only.
Without this guard, an empty "Vocals" or "Keys" track in the same
pack would incorrectly inherit the drum hit count. The same keyword set
_DRUM_KEYWORDS = ('drum', 'percussion') is used in both sloppak.py and
ws_highway.py to keep the detection consistent.
Signed-off-by: =Scr4tch= <305609711+0-Scr4tch-0@users.noreply.github.com>
db04c4b to
196008a
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/sloppak.py (1)
1256-1276: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAlign arrangement naming logic with
extract_metaand improve condition readability.This function has a couple of minor issues that affect accurate metadata extraction:
- Inconsistent naming fallback:
extract_meta(lines 1287) usesentry.get("id")as a fallback whennameis missing, but this function only checksname. An arrangement with"id": "bass"and nonamewill be recognized as Bass by the library index but skipped here, causing its tuning to be ignored.- Null handling: If the arrangement JSON contains
{"name": null},entry.get("name", "")returnsNone, resulting instr(None)which evaluates to the literal string"none".- Readability: The inline conditional
name == role if match_exact else role in nameis valid Python but difficult to read.Consider aligning the fallback logic, properly handling
nullvalues, and using parentheses to clarify the conditional evaluation.♻️ Proposed fix
for match_exact in (True, False): for entry in arrangements_manifest: - name = str(entry.get("name", "")).lower() + name_val = entry.get("name", entry.get("id", "")) + name = str(name_val or "").lower() tun = entry.get("tuning") if not (tun and isinstance(tun, list)): continue - if name == role if match_exact else role in name: + if (name == role) if match_exact else (role in name): return list(tun) return None🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/sloppak.py` around lines 1256 - 1276, Update _role_tuning_for_meta to derive the arrangement label from name, falling back to id when name is absent or null, and normalize it without converting None to "none". Rewrite the match condition with explicit parentheses so exact matching and containment matching are unambiguous, while preserving the existing exact-first then loose-search behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@lib/sloppak.py`:
- Around line 1256-1276: Update _role_tuning_for_meta to derive the arrangement
label from name, falling back to id when name is absent or null, and normalize
it without converting None to "none". Rewrite the match condition with explicit
parentheses so exact matching and containment matching are unambiguous, while
preserving the existing exact-first then loose-search behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5e48d334-18e9-4062-98d6-92b80637f85b
📒 Files selected for processing (2)
lib/routers/ws_highway.pylib/sloppak.py
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/routers/ws_highway.py
|
Evaluated the PR together with the roadmap report. Verdict: correct fix, right layer — reader-side compensation in Future-proofing (checked against #61, the parts-model note, and the editor work)
Blockers
One reframing request on the reportThe report calls the editor's manifest-stripping the "root cause". It isn't a defect — Follow-up filed#1027 — With the tests, the CHANGELOG entry, and the placeholder-index + shared-helper change, this is a merge. |
Review — please rebase & rework before this can merge (do not merge as-is)Thanks for this — the two problems it targets are real, but the branch forked before #1020 (multi-drum loader) landed on 1. Stale base → semantic revert of #1020 (blocker). This branch's merge-base is 2. The single-drum + melodic gap is genuine, but the fix is too broad. For one drum part + a melodic arrangement, #1020 puts a single entry in 3. Missing before merge: no To land this
Happy to re-review once rebased. 🙏 |
What
Fixes drums disappearing from the arrangement picker when imported alongside other instruments (e.g. bass), and shows the correct note count instead of "Drums (0)".
The editor strips drum arrangements from the manifest and converts them to drum_tab.json, so a saved drum+bass sloppak has no drum arrangement — only bass plus a drum_tab. The sloppak loader's placeholder-creation trigger was "arrangements list is empty", which only fired for drum-only packs. Broadened to "no drum arrangement exists" so drums get a placeholder even when other instruments are present. The placeholder arrangement also now displays the actual drum_tab hit count instead of 0.
feedpak surface
Checklist
Summary by CodeRabbit