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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (claude): touch-tooltip persistence, pinch-tap guard, per-channel note pairing, sub-second ruler labels
[._.]/ Adam Eivya43de975d5e5
diff --git a/client/src/components/songs/MidiPianoRoll.jsx b/client/src/components/songs/MidiPianoRoll.jsxindex bbdc35a414..02af45ccd6 100644--- a/client/src/components/songs/MidiPianoRoll.jsx+++ b/client/src/components/songs/MidiPianoRoll.jsx@@ -142,7 +142,9 @@ export default function MidiPianoRoll({ data, chords, showChords, zoom, onZoomChctx.fillStyle = GRID_LINE;ctx.fillRect(x, gridTop, 1, gridH);ctx.fillStyle = TEXT_DIM;- ctx.fillText(formatTimecode(t).replace(/\.\d+$/, ''), x + 3, RULER_H - 6);+ // Sub-second tick steps need the fractional digits or adjacent labels+ // render identically ("0:03 0:03 0:03") right when fine timing matters.+ ctx.fillText(step < 1 ? formatTimecode(t) : formatTimecode(t).replace(/\.\d+$/, ''), x + 3, RULER_H - 6);}// Chord lane.@@ -356,6 +358,9 @@ export default function MidiPianoRoll({ data, chords, showChords, zoom, onZoomChif (pointersRef.current.size === 2) {const [a, b] = [...pointersRef.current.values()];pinchRef.current = { startDist: Math.abs(a.x - b.x) || 1, startZoom: zoomRef.current };+ // A pinch is never a tap — mark both pointers moved so the anchored+ // finger's release doesn't scrub the playhead as a side effect of zooming.+ pointersRef.current.forEach((p, id) => pointersRef.current.set(id, { ...p, moved: true }));}};@@ -451,7 +456,14 @@ export default function MidiPianoRoll({ data, chords, showChords, zoom, onZoomChonPointerDown={handlePointerDown}onPointerMove={handlePointerMove}onPointerUp={handlePointerUp}- onPointerLeave={() => { pointersRef.current.clear(); pinchRef.current = null; setHoverIdentity(null); }}+ onPointerLeave={(e) => {+ pointersRef.current.clear();+ pinchRef.current = null;+ // Touch pointerup is immediately followed by pointerleave — clearing+ // hover here would erase the tap-tooltip before it ever paints. A tap+ // on empty grid or Escape clears a touch tooltip instead.+ if (e.pointerType !== 'touch') setHoverIdentity(null);+ }}onKeyDown={handleKeyDown}/>{tooltip && (diff --git a/client/src/lib/midiNotes.js b/client/src/lib/midiNotes.jsindex e95ead91a6..03bb6dbdd2 100644--- a/client/src/lib/midiNotes.js+++ b/client/src/lib/midiNotes.js@@ -95,13 +95,14 @@ const parseTrackEvents = (view, start, end) => {runningStatus = status;const kind = status & 0xf0;+ const channel = status & 0x0f;const dataLen = kind === 0xc0 || kind === 0xd0 ? 1 : 2;if (pos + dataLen > end) break;if (kind === 0x90 || kind === 0x80) {const midi = view.getUint8(pos);const velocity = view.getUint8(pos + 1);- if (kind === 0x90 && velocity > 0) events.push({ tick, type: 'on', midi, velocity });- else events.push({ tick, type: 'off', midi });+ if (kind === 0x90 && velocity > 0) events.push({ tick, type: 'on', midi, velocity, channel });+ else events.push({ tick, type: 'off', midi, channel });}pos += dataLen;}@@ -182,19 +183,23 @@ export const parseMidiFile = (buffer) => {const notes = [];const tracks = [];rawTracks.forEach((events, trackIndex) => {- const open = new Map(); // midi → { startTick, velocity } (last-on wins per pitch)+ // Keyed per channel+pitch so a multi-channel format-0 file can't have one+ // channel's note-off truncate a same-pitch note held on another channel.+ const open = new Map(); // (channel<<8)|midi → { startTick, velocity } (last-on wins)let name = null;let noteCount = 0;events.forEach((ev) => {if (ev.type === 'name' && !name) name = ev.name;+ if (ev.type !== 'on' && ev.type !== 'off') return;+ const key = ((ev.channel || 0) << 8) | ev.midi;if (ev.type === 'on') {// Retrigger of an already-open pitch closes the previous note first.- const prev = open.get(ev.midi);+ const prev = open.get(key);if (prev) pushNote(prev, ev.tick);- open.set(ev.midi, { midi: ev.midi, startTick: ev.tick, velocity: ev.velocity });- } else if (ev.type === 'off') {- const prev = open.get(ev.midi);- if (prev) { pushNote(prev, ev.tick); open.delete(ev.midi); }+ open.set(key, { midi: ev.midi, startTick: ev.tick, velocity: ev.velocity });+ } else {+ const prev = open.get(key);+ if (prev) { pushNote(prev, ev.tick); open.delete(key); }}});// Notes left open at end-of-track get a minimal duration instead of vanishing.diff --git a/client/src/lib/midiNotes.test.js b/client/src/lib/midiNotes.test.jsindex f237e73cf6..7d4d65e8f7 100644--- a/client/src/lib/midiNotes.test.js+++ b/client/src/lib/midiNotes.test.js@@ -108,6 +108,22 @@ describe('parseMidiFile', () => {expect(new Set(vm.notes.map((n) => n.track)).size).toBe(2);});+ it('pairs note-off per channel — one channel cannot truncate another channel\'s same pitch', () => {+ // C4 held on ch0 for two beats; C4 on ch1 starts and ends within it.+ const bytes = smf([track([+ noteOn(0, 60, 100, 0),+ noteOn(0, 60, 80, 1),+ noteOff(PPQ, 60, 1), // ch1 off at one beat — must NOT close ch0's note+ noteOff(PPQ, 60, 0), // ch0 off at two beats+ endOfTrack(),+ ])]);+ const vm = parseMidiFile(bytes);+ expect(vm.notes).toHaveLength(2);+ const durations = vm.notes.map((n) => n.durationSec).sort((a, b) => a - b);+ expect(durations[0]).toBeCloseTo(0.5, 5);+ expect(durations[1]).toBeCloseTo(1.0, 5);+ });+it('closes notes left open at end-of-track instead of dropping them', () => {const bytes = smf([track([noteOn(0, 72), endOfTrack(PPQ)])]);const vm = parseMidiFile(bytes);