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

refactor: absorb the pulse coercion into BeatPulse and drop the unused className prop (#4130)

Adam Eivye812c65772a2
diff --git a/client/src/components/songbook/ChordTransportBar.jsx b/client/src/components/songbook/ChordTransportBar.jsx
index b3f5d7be2f..997492b2ed 100644
--- a/client/src/components/songbook/ChordTransportBar.jsx
+++ b/client/src/components/songbook/ChordTransportBar.jsx
@@ -79,7 +79,7 @@ export default function ChordTransportBar({
{/* Where you are: the visual pulse plus the chord counter */}
<div className="flex items-center gap-2">
- <BeatPulse beatsPerBar={beatsPerBar} beat={pulse?.beat ?? null} countingIn={!!pulse?.countingIn} />
+ <BeatPulse beatsPerBar={beatsPerBar} beat={pulse?.beat} countingIn={pulse?.countingIn} />
<span className="text-xs text-gray-400 tabular-nums whitespace-nowrap">
{pulse?.countingIn
? 'count-in'
diff --git a/client/src/components/songbook/DrumTransportBar.jsx b/client/src/components/songbook/DrumTransportBar.jsx
index e933fd569f..0bfeb5a0a8 100644
--- a/client/src/components/songbook/DrumTransportBar.jsx
+++ b/client/src/components/songbook/DrumTransportBar.jsx
@@ -109,7 +109,7 @@ export default function DrumTransportBar({
{/* Where you are: the visual pulse plus the bar counter */}
<div className="flex items-center gap-2">
- <BeatPulse beatsPerBar={beatsPerBar} beat={pulse?.beat ?? null} countingIn={!!pulse?.countingIn} />
+ <BeatPulse beatsPerBar={beatsPerBar} beat={pulse?.beat} countingIn={pulse?.countingIn} />
<span className="text-xs text-gray-400 tabular-nums whitespace-nowrap">
{pulse?.countingIn ? 'count-in' : `${currentBar || 1}/${Math.max(1, barCount)}`}
</span>
diff --git a/client/src/components/songs/Metronome.jsx b/client/src/components/songs/Metronome.jsx
index c7f584fcd9..1e3eed36e3 100644
--- a/client/src/components/songs/Metronome.jsx
+++ b/client/src/components/songs/Metronome.jsx
@@ -109,7 +109,7 @@ export default function Metronome({ tempo = null, score = '', countInBars = 1 })
{/* Visual beat pulse — shared with the SongBook play-along transports. */}
<div className="flex items-center gap-2 mt-3">
- <BeatPulse beatsPerBar={beatsPerBar} beat={activeBeat} countingIn={!!pulse?.countIn} />
+ <BeatPulse beatsPerBar={beatsPerBar} beat={activeBeat} countingIn={pulse?.countIn} />
{running && (
<span className="text-xs text-gray-500 ml-1">
{pulse?.countIn ? 'Count-in…' : pulse?.bar ? `Bar ${pulse.bar}` : ''}
diff --git a/client/src/components/ui/BeatPulse.jsx b/client/src/components/ui/BeatPulse.jsx
index e9a555c354..f35aa027d4 100644
--- a/client/src/components/ui/BeatPulse.jsx
+++ b/client/src/components/ui/BeatPulse.jsx
@@ -14,8 +14,10 @@
* - a count-in beat lights amber (`port-warning`) so "not yet" is unmistakable;
* - unlit dots are `port-border`, i.e. the same weight as any inert chrome.
*
- * `beat` is 1-based and `null`/`0` when stopped — the audible click is easy to
- * lose under a backing track, so "nothing lit" has to read as stopped.
+ * `beat` is 1-based and nullish/`0` when stopped — the audible click is easy to
+ * lose under a backing track, so "nothing lit" has to read as stopped. Hosts
+ * therefore pass `pulse?.beat` straight through: the nullish/boolean coercion
+ * lives here once rather than being re-typed at every call site.
*/
// Lit dots are `port-success`, not `port-accent`: in the transport bars the
@@ -24,7 +26,7 @@
// "sounding now" and stays clearly distinct from the amber count-in.
const litTone = (countingIn) => (countingIn ? 'bg-port-warning' : 'bg-port-success');
-export default function BeatPulse({ beatsPerBar = 4, beat = null, countingIn = false, className = '' }) {
+export default function BeatPulse({ beatsPerBar = 4, beat = null, countingIn = false }) {
// A malformed time signature must not blank the row out.
const beats = Number.isFinite(beatsPerBar) ? Math.max(1, Math.floor(beatsPerBar)) : 4;
const label = countingIn
@@ -33,7 +35,7 @@ export default function BeatPulse({ beatsPerBar = 4, beat = null, countingIn = f
return (
<div
- className={`flex items-center gap-1.5 ${className}`.trim()}
+ className="flex items-center gap-1.5"
role="status"
aria-live="off"
aria-label={label}
diff --git a/client/src/components/ui/BeatPulse.test.jsx b/client/src/components/ui/BeatPulse.test.jsx
index 19d4d901d9..70ca249d96 100644
--- a/client/src/components/ui/BeatPulse.test.jsx
+++ b/client/src/components/ui/BeatPulse.test.jsx
@@ -55,6 +55,15 @@ describe('BeatPulse', () => {
expect(screen.getByRole('status')).toHaveAttribute('aria-label', expected);
});
+ it('reads an absent pulse as stopped, so hosts can pass `pulse?.beat` raw', () => {
+ const pulse = null;
+ const { container } = render(
+ <BeatPulse beatsPerBar={4} beat={pulse?.beat} countingIn={pulse?.countingIn} />,
+ );
+ dotsOf(container).forEach((dot) => expect(dot.className).toContain('bg-port-border'));
+ expect(screen.getByRole('status')).toHaveAttribute('aria-label', 'Stopped');
+ });
+
it('falls back to 4 beats when the time signature is unusable', () => {
const { container } = render(<BeatPulse beatsPerBar={NaN} beat={null} />);
expect(dotsOf(container)).toHaveLength(4);