Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): match the open-note wording to the piece, and stop a playback stop from re-revealing an old selection

[._.]/ Adam Eivyc22fb7c2a5a4
diff --git a/client/src/components/songbook/DrumSheetView.jsx b/client/src/components/songbook/DrumSheetView.jsx
index 7a7625c6d7..58f5a78bbd 100644
--- a/client/src/components/songbook/DrumSheetView.jsx
+++ b/client/src/components/songbook/DrumSheetView.jsx
@@ -275,9 +275,8 @@ function DrumSheetView({
const laneRef = useRef(null);
const lineRef = useRef(null);
const columnRef = useRef(null);
- // Set by the arrow walk so the reveal effect knows a selection came from the
- // keyboard and may be off screen (see that effect).
- const revealRef = useRef(false);
+ // The selection the reveal effect has already scrolled to (see that effect).
+ const revealedRef = useRef(null);
// The note whose explanation is showing — `{ bar, step, piece }` or null.
const [selection, setSelection] = useState(null);
const [legendOpen, setLegendOpen] = useState(false);
@@ -343,11 +342,6 @@ function DrumSheetView({
const within = rel - (bar - 1) * span;
// `uy < GRID_TOP` floors negative → no piece; `within >= barW` is the gap
// between bars. Either way there's nothing under the finger.
- // A tap's note is on screen by definition, and an arrow walk that ended on
- // the last hit leaves its flag set (React bails out of the no-op state write,
- // so the reveal effect never ran to clear it) — clear it here rather than let
- // it fire a pointless layout read on the next tap.
- revealRef.current = false;
if (!piece || bar < 1 || bar > barCount || within < 0 || within >= barW) { setSelection(null); return; }
const cells = cellsFor(bar, piece);
const step = Math.floor(within / CELL);
@@ -364,7 +358,6 @@ function DrumSheetView({
: (e.key === 'ArrowLeft' || e.key === 'ArrowUp') ? -1 : 0;
if (!delta || !hits.length) return;
e.preventDefault(); // arrows would otherwise scroll the lane out from under the walk
- revealRef.current = true;
setSelection((prev) => {
const i = prev
? hits.findIndex((h) => h.bar === prev.bar && h.step === prev.step && h.piece === prev.piece)
@@ -376,15 +369,19 @@ function DrumSheetView({
useEscapeKey(!!selection, () => setSelection(null));
- // Bring an arrow-walked note into view. Gated on the keyboard flag, not just on
- // `selection`: reading `scrollLeft`/`clientWidth` right after React commits the
- // selection box forces a synchronous layout of the whole strip, and for a TAP
- // it can never help — the note the finger landed on is on screen by definition.
- // Skipped while playing too, where the rAF follow loop owns `scrollLeft`.
+ // Bring a newly selected note into view — for the arrow walk, which is the only
+ // path that can select something off screen (a tap's note is under the finger,
+ // so both branches below are no-ops for it).
+ //
+ // Keyed on the SELECTION IDENTITY, not just the effect firing: `playing` is a
+ // dep (the rAF follow loop owns `scrollLeft` while it runs, so this must stand
+ // down), and without the identity check, merely STOPPING playback would re-run
+ // this and yank the strip back to a selection made long before — away from where
+ // the playhead just stopped.
useEffect(() => {
const el = scrollRef.current;
- if (!revealRef.current) return;
- revealRef.current = false;
+ if (selection === revealedRef.current) return;
+ revealedRef.current = selection;
if (!selection || !el || playing) return;
const left = (barX(selection.bar) + selection.step * CELL) * scale;
const right = left + CELL * scale;
diff --git a/client/src/components/songbook/DrumSheetView.test.jsx b/client/src/components/songbook/DrumSheetView.test.jsx
index 6f25085185..7309792c65 100644
--- a/client/src/components/songbook/DrumSheetView.test.jsx
+++ b/client/src/components/songbook/DrumSheetView.test.jsx
@@ -225,6 +225,24 @@ describe('DrumSheetView', () => {
expect(readout()).toHaveTextContent('count “1”');
});
+ it('does not yank the strip back to an old selection when playback stops', () => {
+ // The reveal effect depends on `playing` (the rAF follow loop owns scrollLeft
+ // while it runs), so it re-fires when playback stops. It must no-op there: the
+ // strip belongs to wherever the playhead stopped, not to a note selected
+ // before playback started.
+ const chart = 'subdivision: 1\n\nHH: x-x-\n\nHH: x-x-\n\nHH: x-x-';
+ const { container, rerender } = render(<DrumSheetView text={chart} />);
+ fireEvent.keyDown(lane(container), { key: 'ArrowRight' }); // select bar 1's first hit
+ const scroller = container.querySelector('.overflow-x-auto');
+ rerender(<DrumSheetView text={chart} playing />);
+ scroller.scrollLeft = 400; // where the playhead left it
+ // A boundary press while playing selects the same hit, so React skips the
+ // state write — the effect must not treat the later `playing` flip as new.
+ fireEvent.keyDown(lane(container), { key: 'ArrowLeft' });
+ rerender(<DrumSheetView text={chart} playing={false} />);
+ expect(scroller.scrollLeft).toBe(400);
+ });
+
it('dismisses the readout with Escape or its close button', () => {
const { container } = render(<DrumSheetView text={'subdivision: 1\n\nHH: x---'} />);
tap(container, 0, 0);
diff --git a/client/src/lib/drumNotation.js b/client/src/lib/drumNotation.js
index a00f64e38d..421c0e96f2 100644
--- a/client/src/lib/drumNotation.js
+++ b/client/src/lib/drumNotation.js
@@ -104,20 +104,33 @@ const cellFor = (ch) => {
// read. Kept here, beside the notation it describes (and derived from the same
// two tables), so prose and notation can't drift apart.
-// What each cell character asks for, independent of which piece it lands on.
-// `openHead` is the one entry with no glyph of its own: it covers `open` landing
-// on a DRUM, which has nothing to open, so it sounds (and draws) as a normal hit
-// — calling a kick's `o` "open" would describe a technique that doesn't exist.
+// What each cell character asks for. Every key but the three `open*` ones is a
+// cell-glyph id; `open` is piece-dependent, because "open" means a different
+// technique — or none at all — depending on what it lands on, and only the hi-hat
+// voice actually sustains it in playback (it is the only voice with an
+// `openDecay`, see drumPlayback.js). So the variants say what the player should
+// do AND, where the play-along can't reproduce it, that it sounds the same.
const ARTICULATIONS = {
rest: { name: 'Rest', detail: 'Nothing is played on this step — count it, don\'t fill it.' },
normal: { name: 'Normal hit', detail: 'An unaccented stroke at your regular playing volume.' },
accent: { name: 'Accent', detail: 'Strike noticeably harder than the notes around it. The ">" chevron drawn above the glyph is the accent mark.' },
- open: { name: 'Open', detail: 'Let the cymbals ring instead of choking them: ease off the hi-hat pedal as you strike, and close again on the next unopened note. The circle drawn around the "×" is the open mark.' },
+ open: { name: 'Open', detail: 'Ease off the hi-hat pedal as you strike so the cymbals ring instead of clicking shut, then close again on the next unopened note. The circle drawn around the "×" is the open mark, and the play-along lets the note sustain.' },
+ openRing: { name: 'Open (let it ring)', detail: 'The circle around the "×" says let the cymbal sustain rather than choking it with your hand. A crash or ride rings freely already, so the play-along sounds this the same as a normal hit.' },
+ openFoot: { name: 'Open (foot splash)', detail: 'Let the pedal rebound as you press it so the cymbals splash open instead of clapping shut. The play-along sounds it as a normal foot "chick".' },
openHead: { name: 'Normal hit', detail: 'The "o" open mark only changes hi-hats and cymbals — on a drum there is nothing to open, so this sounds and draws as a normal hit.' },
ghost: { name: 'Ghost note', detail: 'A very light tap that sits under the groove rather than in it, drawn as a small hollow glyph.' },
flam: { name: 'Flam', detail: 'Two strokes so close together they read as one thick hit: the small grace glyph just before the beat lands a hair early, then the main note on the beat.' },
};
+// Which `open` entry a piece takes, keyed off the piece's SYNTH VOICE rather than
+// its glyph shape: the parser accepts `o` on any row, and `CR: o` draws the same
+// open ring a hi-hat does, but only the hi-hat voice sustains it — so keying on
+// `glyph === 'cross'` alone would tell a crash player to work the hi-hat pedal.
+const OPEN_BY_SOUND = { hihat: 'open', hihatFoot: 'openFoot' };
+const openArticulationFor = (piece) => (piece.glyph === 'cross'
+ ? (OPEN_BY_SOUND[piece.sound] || 'openRing')
+ : 'openHead');
+
// The six cell characters for a legend panel. Each shows the articulation as
// written for a cymbal (the `open` wording names the hi-hat pedal), which is the
// form the glyph is defined by; `describeDrumCell` is what re-reads it per piece.
@@ -138,9 +151,8 @@ export const describeDrumCell = (pieceId, cell) => {
const piece = kitPiece(pieceId);
if (!piece) return null;
const glyph = CELL_GLYPHS[cell?.char] || CELL_GLYPHS['-'];
- // `open` is the one piece-dependent glyph (see ARTICULATIONS).
const articulation = ARTICULATIONS[
- glyph.id === 'open' && piece.glyph !== 'cross' ? 'openHead' : glyph.id
+ glyph.id === 'open' ? openArticulationFor(piece) : glyph.id
];
return {
pieceLabel: piece.label,
diff --git a/client/src/lib/drumNotation.test.js b/client/src/lib/drumNotation.test.js
index cc33d55761..1815ef1700 100644
--- a/client/src/lib/drumNotation.test.js
+++ b/client/src/lib/drumNotation.test.js
@@ -321,6 +321,24 @@ describe('describeDrumCell', () => {
expect(kick.char).toBe('o');
});
+ it('does not send a crash or ride player to the hi-hat pedal for an "o"', () => {
+ // The parser accepts `o` on any row and the renderer rings every cross glyph,
+ // but only the hi-hat VOICE sustains it (drumPlayback's `openDecay`) — so the
+ // wording has to follow the piece, not just the glyph shape.
+ for (const id of ['CR', 'RD']) {
+ const info = describeDrumCell(id, CELL_GLYPHS.o);
+ expect(info.articulation).toBe('Open (let it ring)');
+ expect(info.detail).not.toMatch(/pedal/i);
+ expect(info.detail).toMatch(/same as a normal hit/i);
+ }
+ });
+
+ it('reads an "o" on the hi-hat FOOT row as a splash, not a stick-played open hat', () => {
+ const info = describeDrumCell('HF', CELL_GLYPHS.o);
+ expect(info.articulation).toBe('Open (foot splash)');
+ expect(info.detail).toMatch(/splash/i);
+ });
+
it('describes ghosts, flams and rests', () => {
expect(describeDrumCell('S', cellOf('subdivision: 1\n\nS: g---', 'S')).articulation).toBe('Ghost note');
expect(describeDrumCell('S', cellOf('subdivision: 1\n\nS: f---', 'S')).articulation).toBe('Flam');