Fix Activity 3 multitrack DAW not rendering with bassline track#154
Merged
hcientist merged 2 commits intoLab-Lab-Lab:mainfrom Mar 27, 2026
Merged
Conversation
…ent data - Add DAWInitializer component to set showDAW=true and dawMode='multi' for steps 3-4 (showDAW defaulted to false and was never set in the activity flow, causing the entire DAW to render null; dawMode defaulted to 'single') - Replace hardcoded nonexistent /media/sample_audio/Air_for_Band_Bass_Line.mp3 with preferredSample from the assignment's part data (backend-served URL) - Gate DAWProvider mount on preferredSample being ready for step 3 to avoid useState(initialTracks) ignoring late-arriving track data - Remove redundant initialTracks prop from <DAW> (already in context via provider)
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.
Problem
When navigating from Activity 2 to Activity 3 in the guided DAW study, the multitrack editor was not appearing and no bassline track was loaded. Three independent bugs prevented this:
What was happening (old approach)
showDAWwas never set totrue—UIContextdefaultsshowDAWtofalse, and the only call sites that set it totruewere inrecorder.js(when a user clicks "Edit" on a take) and standalone pages like/studioand/audio-utils/daw. Nothing in the Activity 3/4 flow ever enabled it. The DAW component's first line isif (!showDAW) return null;, so the entire editor was invisible.dawModedefaulted to'single'— Even if the DAW had rendered,AudioContextinitializesdawModeas'single', and nothing in the activity flow switched it to'multi'. The single-track waveform editor would have rendered instead of the multitrack editor.Bassline audio file did not exist — The
initialTracksconfig hardcoded a path to/media/sample_audio/Air_for_Band_Bass_Line.mp3. This file doesn't exist in the frontend'spublic/directory. The/media/URL pattern is served by the Django backend, but the specific file path was incorrect and not sourced from any actual backend data.What the new approach delivers
DAWInitializercomponent — A small render-null component placed insideDAWProviderfor Activities 3-4 that callssetShowDAW(true)andsetDawMode('multi')on mount. It must live inside the provider tree becauseuseUI()anduseAudio()require their respective contexts.Bassline sourced from assignment data — Instead of a hardcoded path, the bassline track URL now comes from
preferredSample, which is already resolved from the assignment'spart.sample_audioor instrument-specificpart.instrument_samplesdata (the same URL used for the<audio>player in Activities 1-2). The track name is derived from the actual piece name (e.g. "Freedom 2040 - Bassline").Loading gate for
useStatetiming —MultitrackProviderinitializes tracks viauseState(initialTracks), which only reads the value on first mount. SincepreferredSampleis set asynchronously in an effect, the provider could mount before the URL was available, resulting in empty tracks that never update. The fix adds a loading gate that keeps the spinner visible for Activity 3 untilpreferredSampleis resolved, ensuringinitialTracksis populated before the provider mounts.Removed unused
initialTracksprop from<DAW>— The prop was accepted but never forwarded to child components. The tracks reachMultitrackContextcorrectly throughDAWProvider→MultitrackProvider, not through the DAW component itself.Expected prod behavior
On navigating to Activity 3, students should see: spinner while assignment loads → multitrack editor appears with the piece's bassline pre-loaded as an audio track → student can add tracks, record, apply effects, etc.
These changes fix the rendering pipeline and data sourcing, but need to be verified in a production environment where:
sample_audiofiles via/media/part.sample_audioorpart.instrument_samplesfield is usedFiles changed
pages/courses/[slug]/[piece]/[actCategory]/[partType]/activity/[step].js— DAWInitializer, dynamic bassline URL, loading gatecomponents/audio/DAW/index.js— removed unusedinitialTracksprop