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
fix: read every non-count beatsPerBar as 4/4 in normalizeBeatsPerBar (#4130)
Adam Eivy097b527323e5
diff --git a/client/src/components/ui/BeatPulse.test.jsx b/client/src/components/ui/BeatPulse.test.jsxindex dc62eccf88..7b7a81cefd 100644--- a/client/src/components/ui/BeatPulse.test.jsx+++ b/client/src/components/ui/BeatPulse.test.jsx@@ -66,7 +66,7 @@ describe('BeatPulse', () => {// The scheduler reads a garbled numerator as 4/4 (`normalizeBeatsPerBar`), so// the dots have to land on the same count or they stop matching the clicks.- it.each([['absent', undefined], ['NaN', NaN], ['zero', 0]])(+ it.each([['absent', undefined], ['NaN', NaN], ['zero', 0], ['negative', -3], ['infinite', Infinity]])('falls back to 4 beats for a %s time signature, like the scheduler does',(_label, beatsPerBar) => {const { container } = render(<BeatPulse beatsPerBar={beatsPerBar} beat={null} />);diff --git a/client/src/lib/metronome.js b/client/src/lib/metronome.jsindex 43e086bedf..aba6d0703d 100644--- a/client/src/lib/metronome.js+++ b/client/src/lib/metronome.js@@ -43,11 +43,15 @@ export const clampBpm = (bpm) => {return Math.max(METRONOME_BPM_MIN, Math.min(METRONOME_BPM_MAX, Math.round(n)));};-// One canonical reading of a time-signature numerator: a garbled, zero or-// negative `beatsPerBar` falls back to 4/4 rather than producing a bar with no-// beats in it. The scheduler and the visual pulse must agree on this or the-// dots stop matching the clicks.-export const normalizeBeatsPerBar = (beatsPerBar) => Math.max(1, Math.floor(beatsPerBar) || DEFAULT_BEATS_PER_BAR);+// One canonical reading of a time-signature numerator: anything not a positive+// finite count — absent, garbled, zero, negative, Infinity — falls back to 4/4+// rather than producing a bar with no beats in it (or, for Infinity, a row of+// dots `Array.from` refuses to build). The scheduler and the visual pulse must+// agree on this or the dots stop matching the clicks.+export const normalizeBeatsPerBar = (beatsPerBar) => {+ const n = Math.floor(Number(beatsPerBar));+ return Number.isFinite(n) && n > 0 ? n : DEFAULT_BEATS_PER_BAR;+};// Seconds between beats at a given BPM (the beat unit is the time-signature// denominator, i.e. one click per notated beat).diff --git a/client/src/lib/metronome.test.js b/client/src/lib/metronome.test.jsindex 3d8738ecb2..46698381fe 100644--- a/client/src/lib/metronome.test.js+++ b/client/src/lib/metronome.test.js@@ -4,6 +4,7 @@ import {clampBpm,secondsPerBeat,timeSignatureFromScore,+ normalizeBeatsPerBar,createMetronome,METRONOME_BPM_MIN,METRONOME_BPM_MAX,@@ -108,6 +109,20 @@ describe('timeSignatureFromScore', () => {});});+describe('normalizeBeatsPerBar', () => {+ it('keeps a positive count, flooring a fractional one', () => {+ expect(normalizeBeatsPerBar(3)).toBe(3);+ expect(normalizeBeatsPerBar('7')).toBe(7);+ expect(normalizeBeatsPerBar(5.9)).toBe(5);+ });++ // Every non-count reads as 4/4 — a one-beat bar or an infinite one would put+ // the visual pulse out of step with the clicks (or fail to render at all).+ it.each([undefined, null, NaN, 0, -3, Infinity, 'x'])('reads %s as 4/4', (input) => {+ expect(normalizeBeatsPerBar(input)).toBe(4);+ });+});+describe('beatDescriptor', () => {it('accents beat 1 of every bar', () => {const opts = { beatsPerBar: 4, countInBars: 0 };