This file gives future Codex runs project-specific context for piano-trainer.
- Prioritize behavior correctness over UI polish when touching MIDI paths.
- Keep fixes scoped. Do not make speculative refactors in unrelated files.
- If user reports a regression, first revert unstable logic, then add tests, then reapply minimal fix.
For any MIDI/input/progression fix:
- Reproduce from current code and identify exact code path.
- Add or update a focused test that fails before the fix.
- Implement the smallest fix that makes the test pass.
- Run targeted tests and a build before handoff.
- Report exactly what changed and what was validated.
Minimum validation commands:
CI=true npm test -- --runTestsByPath <path-to-test>npm run build
- On iOS Web MIDI Browser,
inputscan be Map-like but not fully iterable with typical helpers. - Use key iteration (
map.keys().next()loop) for stable device enumeration and lookup. - Keep this behavior in
src/core/services/midiService.ts.
- In scales mode, progression is octave-agnostic by design.
- Matching should accept the target pitch class across octaves.
- Prefer exact MIDI match first if present, then fallback to same note name.
- Current helper:
findExactScaleMatchinsrc/core/hooks/usePianoKeyboard.ts. - Tests for this behavior live in
src/core/hooks/usePianoKeyboard.test.ts.
- Avoid remapping active MIDI notes in ways that alter perceived octave correctness.
- If a display mapping is needed, it must be deterministic and covered by tests.
- Prefer showing raw MIDI notes by expanding visible range over implicit octave folding.
- Converting MIDI numbers to note names (
midiNumberToNote) removes octave. - That is useful for pitch-class matching but dangerous where exact octave matters.
- Be explicit about when octave should and should not be preserved.
- Working tree may be dirty. Never revert unrelated user changes.
- There are existing non-blocking build warnings from
midimessagesourcemap resolution. - The project currently runs with
npmin this environment (notyarn).
- Web MIDI service:
src/core/services/midiService.ts - MIDI-driven progression logic:
src/core/hooks/usePianoKeyboard.ts - Bottom keyboard UI/input rendering:
src/components/Keyboard/Keyboard.tsx - Scale generation and MIDI roots:
src/core/services/scaleService.ts