Skip to content

fix(player): record actual server-loaded arrangement instead of defaulting to 0#1036

Open
ColeChiodo wants to merge 2 commits into
got-feedBack:mainfrom
ColeChiodo:fix/stats-record-correct-arrangement
Open

fix(player): record actual server-loaded arrangement instead of defaulting to 0#1036
ColeChiodo wants to merge 2 commits into
got-feedBack:mainfrom
ColeChiodo:fix/stats-record-correct-arrangement

Conversation

@ColeChiodo

@ColeChiodo ColeChiodo commented Jul 23, 2026

Copy link
Copy Markdown

What

Fixes "Jump back in!" (home) and "Keep practicing" (song library) loading the wrong arrangement when the user has an instrument preference set (e.g. bass), which resulted in poor UX. The stats recorder defaulted to arrangement 0 because it never learned what arrangement the server actually loaded via instrument routing. Downstream shelves read back the stale 0 and passed it as an explicit index, bypassing server-side routing.

Fix: listen for song:loaded in stats-recorder.js and correct the recorded arrangement from the arrangement_index the server echoes in song_info.

feedpak surface

  • This PR does not change how the app reads/writes feedpaks (manifest keys, pack files, folder layout)

Checklist

  • CHANGELOG.md [Unreleased] updated (user-visible changes)
  • Tests added/updated for new behavior. Tests pass (1194/1194)
  • Commits are DCO signed off (git commit -s)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed “Jump back in!” and “Keep practicing” shelves displaying the wrong song arrangement when an instrument preference was set.
    • Ensured shelves and related activity reflect the arrangement actually loaded by the server.

…ting to 0

Signed-off-by: ColeChiodo <colechiodo@gmail.com>
Signed-off-by: ColeChiodo <colechiodo@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The stats recorder now updates active sessions from the server-provided arrangement index on song:loaded events. Tests cover corrected, zero-valued, and explicitly provided arrangements, and the changelog documents the fix.

Changes

Arrangement attribution correction

Layer / File(s) Summary
Server-selected arrangement tracking
static/v3/stats-recorder.js, tests/js/stats_recorder_arrangement.test.js, CHANGELOG.md
The recorder adopts finite server-provided arrangement indices after song loading. Tests verify correction and preservation behavior, and the changelog records the Home/library shelf fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: byrongamatos

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main fix: recording the server-loaded arrangement instead of defaulting to 0.
Description check ✅ Passed The description includes the required What, feedpak surface, and Checklist sections with the key details filled in.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/js/stats_recorder_arrangement.test.js (1)

60-68: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Make scenario 3 cover a distinct preservation path.

It currently uses arrangement 0 both before and after loading, duplicating scenario 2’s observable result. Test a nonzero explicit arrangement with a missing/invalid arrangementIndex, or remove the scenario because it currently adds no regression coverage.

🤖 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 `@tests/js/stats_recorder_arrangement.test.js` around lines 60 - 68, Update
scenario 3 in the stats recorder test to exercise a distinct
explicit-arrangement preservation path: use a nonzero arrangement and a missing
or invalid arrangementIndex in the loading event, then assert that the posted
stats preserve that explicit arrangement. Alternatively, remove scenario 3 if
this coverage is not needed.
🤖 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 `@static/v3/stats-recorder.js`:
- Around line 198-202: Update the song:loaded handler to correlate the event
with the active session before assigning cur.arrangement: require d.filename to
match cur.filename or use the existing load-session identity. Ignore stale
events from prior playSong or closeCurrentSong operations, while preserving
arrangement updates for the current song.

---

Nitpick comments:
In `@tests/js/stats_recorder_arrangement.test.js`:
- Around line 60-68: Update scenario 3 in the stats recorder test to exercise a
distinct explicit-arrangement preservation path: use a nonzero arrangement and a
missing or invalid arrangementIndex in the loading event, then assert that the
posted stats preserve that explicit arrangement. Alternatively, remove scenario
3 if this coverage is not needed.
🪄 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: 2aaee26a-29a3-488c-9c64-be60a1b5e1bc

📥 Commits

Reviewing files that changed from the base of the PR and between 8297afc and 93e1a7c.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • static/v3/stats-recorder.js
  • tests/js/stats_recorder_arrangement.test.js

Comment on lines +198 to +202
sm.on('song:loaded', (e) => {
const d = (e && e.detail) || {};
if (cur && Number.isFinite(d.arrangementIndex)) {
cur.arrangement = Number(d.arrangementIndex);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files matching stats-recorder.js:"
fd -a 'stats-recorder.js$' . || true

echo
echo "Line count:"
wc -l static/v3/stats-docs.js static/v3/stats-recorder.js 2>/dev/null || true

echo
echo "Relevant section:"
sed -n '150,230p' static/v3/stats-recorder.js 2>/dev/null || true

echo
echo "Search for song:loaded handler/tests/usages:"
rg -n "song:loaded|arrangementIndex|arrangement" -S . --glob '*.{js,html,css}' || true

Repository: got-feedBack/feedBack

Length of output: 50377


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "stats recorder test file:"
sed -n '1,120p' tests/js/stats_recorder_arrangement.test.js 2>/dev/null || true

echo
echo "stats recorder remaining relevant section:"
sed -n '70,210p' static/v3/stats-recorder.js 2>/dev/null || true

echo
echo "Find exact highway song_info -> song:loaded evidence:"
rg -n "songInfo|arrangement_index|song:loaded|emits?|dispatch" plugins/highway_3d/screen.js plugins/keys_highway_3d/screen.js plugins/highway/screen.js plugins/drum_highway_3d/screen.js 2>/dev/null --max-count 80 || true

echo
echo "Focus highway.js related files:"
git ls-files | rg 'highway|playback|session' | head -60

Repository: got-feedBack/feedBack

Length of output: 23517


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "static/highway.js line counts:"
wc -l static/js/highway-colors.js static/js/highway-constants.js static/highway.js static/js/transport.js static/js/session.js 2>/dev/null || true

echo
echo "static/highway.js song:loaded/song_info/reconnect sections:"
rg -n -C 8 "song:loaded|song_info|songInfo|arrangement_index|song:loading|song:ready" static/highway.js static/js/highway-colors.js 2>/dev/null || true

echo
echo "static/js/session.js playSong/reconnect/transport sections:"
sed -n '620,760p' static/js/session.js 2>/dev/null || true
rg -n -C 6 "reconnect|song:loading|song:loaded|song:ready|playSong|socket" static/js/transport.js static/js/session.js 2>/dev/null || true

echo
echo "highway 3d explicit song_info -> song:loaded path sections around main init:"
sed -n '6060,6170p' plugins/highway_3d/screen.js 2>/dev/null || true
sed -n '11640,11670p' plugins/highway_3d/screen.js 2>/dev/null || true

Repository: got-feedBack/feedBack

Length of output: 50377


Correlate song:loaded with the current session.

song:loaded is emitted from the WebSocket song_info path and includes filename, while song:loading resets cur.filename. If an in-flight connection’s song_info arrives after a new playSong or closeCurrentSong, this handler can overwrite the active session’s arrangement and cause the next stats post to be attributed to the wrong song/arrangement pair. Require d.filename === cur.filename or gate updates against the same load/load-session identity before updating cur.arrangement.

🤖 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 `@static/v3/stats-recorder.js` around lines 198 - 202, Update the song:loaded
handler to correlate the event with the active session before assigning
cur.arrangement: require d.filename to match cur.filename or use the existing
load-session identity. Ignore stale events from prior playSong or
closeCurrentSong operations, while preserving arrangement updates for the
current song.

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