You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Result should be minimal - most should use centralized utilities
570
+
```
571
+
572
+
---
573
+
574
+
## #007: Fix Without Tests Anti-Pattern
575
+
576
+
**Date**: 2024-12-17
577
+
**Severity**: medium
578
+
**Category**: process
579
+
580
+
### Symptoms
581
+
- Bug is fixed but similar bugs reappear later
582
+
- Regression in functionality that was "already fixed"
583
+
- No confidence that fix actually addresses root cause
584
+
585
+
### Root Cause
586
+
Fixing a bug without first writing a test that:
587
+
1. Reproduces the bug (fails before fix)
588
+
2. Passes after the fix is applied
589
+
3. Prevents regression
590
+
591
+
### Detection Strategy
592
+
593
+
**Process check:**
594
+
- Did you write a test that fails BEFORE the fix?
595
+
- Does the test pass AFTER the fix?
596
+
- Would the test catch if the bug was reintroduced?
597
+
598
+
### Fix
599
+
600
+
**Test-first workflow for bug fixes:**
601
+
602
+
```typescript
603
+
// 1. Write test that exposes the bug (should FAIL)
604
+
it('preloads piano from sampled:piano track', () => {
605
+
const tracks = [{ sampleId: 'sampled:piano' }];
606
+
const result =collectSampledInstruments(tracks);
607
+
expect(result.has('piano')).toBe(true); // FAILS with buggy code
608
+
});
609
+
610
+
// 2. Run test, confirm it fails
611
+
// 3. Apply the fix
612
+
// 4. Run test, confirm it passes
613
+
// 5. Commit test AND fix together
614
+
```
615
+
616
+
### Prevention
617
+
1.**Write failing test first** before any code changes
618
+
2.**Include edge cases** in the test (all namespace formats, boundary conditions)
619
+
3.**Commit test with fix** so they're always paired
620
+
4.**Code review check**: "Where's the test for this fix?"
621
+
622
+
### Related Files
623
+
- All test files
624
+
- CI/CD pipeline configuration
625
+
626
+
---
627
+
628
+
## #008: Mid-Playback Sampled Instrument Not Preloaded
629
+
630
+
**Date**: 2024-12-17
631
+
**Severity**: high
632
+
**Category**: race-condition
633
+
634
+
### Symptoms
635
+
- "Sampled instrument piano not ready, skipping at step X" warning repeated many times
636
+
- Piano track added during playback produces no sound
637
+
- Other instruments (synths, drums) work fine
638
+
- Issue resolves after stopping and starting playback again
639
+
640
+
### Root Cause
641
+
When a sampled instrument track (e.g., `synth:piano`, `sampled:piano`) is added **during playback**, the instrument samples are never preloaded because:
642
+
643
+
1.`preloadInstrumentsForTracks()` is only called when play starts (in `handlePlayToggle`)
644
+
2. Scheduler runs `collectSampledInstruments()` at play start - doesn't include tracks added later
645
+
3.`signalMusicIntent('add_track')` initializes audio engine but doesn't preload the specific instrument
646
+
647
+
### Detection Strategy
648
+
649
+
**Log patterns:**
650
+
```
651
+
[Audio] No sampled instruments to preload // At play start (no piano yet)
652
+
[Audio] Sampled instrument piano not ready, skipping at step 1
653
+
[Audio] Sampled instrument piano not ready, skipping at step 4
654
+
[Audio] Sampled instrument piano not ready, skipping at step 9
655
+
// ... repeated until play is restarted
656
+
[Audio] Preloading sampled instruments: piano // Only after restart
657
+
```
658
+
659
+
**Runtime detection:**
660
+
```javascript
661
+
// If seeing "not ready" warnings but no corresponding "Preloading" message
662
+
// The instrument was added mid-playback
663
+
```
664
+
665
+
### Fix
666
+
667
+
**In SamplePicker.tsx, preload sampled instruments immediately on selection:**
0 commit comments