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): wire solfège/dirge exports, clamp tempo client-side, dedupe presets by id
Adam Eivycdc0d7dd63f2
diff --git a/client/src/lib/songCraft.js b/client/src/lib/songCraft.jsindex a6c36e8c1d..8f5dac00e7 100644--- a/client/src/lib/songCraft.js+++ b/client/src/lib/songCraft.js@@ -1,10 +1,10 @@// Canonical a cappella song-craft reference data: dirge rhythm shapes, the// layer-building ladder, a learning sequence, musical-notation help, and the-// solfège scale used by the editor's harmony helpers. The Songs Guide page-// renders directly from these arrays; the Song editor reuses RHYTHM_SHAPES,-// VOICE_LAYERS, and SOLFEGE_DEGREES so the picker options and the docs never-// drift. Keep this module pure (no React, no imports) — it is mirrored into-// the client lib barrel and unit-tested for shape.+// movable-do solfège scale. The Songs Guide page renders directly from these+// arrays (rhythm shapes, layer ladder, learning steps, notation, solfège), and+// the Song editor reuses RHYTHM_SHAPES and VOICE_LAYERS for its picker options+// so the editor and the docs never drift. Keep this module pure (no React, no+// imports) — it is mirrored into the client lib barrel and unit-tested.// --- Rhythm shapes ---------------------------------------------------------// A "rhythm shape" is the felt pulse + note-length feel a song leans on. Adiff --git a/client/src/pages/SongEditor.jsx b/client/src/pages/SongEditor.jsxindex 6af312d8b8..608b623284 100644--- a/client/src/pages/SongEditor.jsx+++ b/client/src/pages/SongEditor.jsx@@ -31,6 +31,18 @@ import { RHYTHM_SHAPES, VOICE_LAYERS } from '../lib/songCraft';let localSeq = 0;const localId = (prefix) => `${prefix}-new-${localSeq++}`;+// Mirror the server tempo band (services/songs.js TEMPO_MIN/MAX) so the input+// clamps locally — otherwise an out-of-band value only surfaces as an opaque+// "Failed to save" toast after the server 400s. Empty input clears (null).+const TEMPO_MIN = 20;+const TEMPO_MAX = 320;+const clampTempo = (raw) => {+ if (raw === '' || raw == null) return null;+ const n = Number(raw);+ if (!Number.isFinite(n)) return null;+ return Math.max(TEMPO_MIN, Math.min(TEMPO_MAX, Math.round(n)));+};+export default function SongEditor() {const { id } = useParams();const navigate = useNavigate();@@ -92,10 +104,13 @@ export default function SongEditor() {...prev, layers: prev.layers.filter((l) => l.id !== lid),}));- // Layer presets the user hasn't added yet, in foundation-first order.+ // Layer presets the user hasn't added yet, in foundation-first order. Match+ // on the preset id (seed layers carry the bare id like `lead`; ladder-added+ // layers carry `${id}-new-N`), so renaming a layer's label doesn't make its+ // preset reappear and two presets sharing a label can't collide.const remainingPresets = useMemo(() => {- const have = new Set((song?.layers || []).map((l) => l.label));- return VOICE_LAYERS.filter((p) => !have.has(p.label));+ const have = new Set((song?.layers || []).map((l) => l.id.replace(/-new-\d+$/, '')));+ return VOICE_LAYERS.filter((p) => !have.has(p.id));}, [song?.layers]);if (loading) {@@ -169,10 +184,10 @@ export default function SongEditor() {<inputid="tempo"type="number"- min="20"- max="320"+ min={TEMPO_MIN}+ max={TEMPO_MAX}value={song.tempo ?? ''}- onChange={(e) => setField('tempo', e.target.value === '' ? null : Number(e.target.value))}+ onChange={(e) => setField('tempo', clampTempo(e.target.value))}placeholder="e.g. 68"className={inputCls}/>diff --git a/client/src/pages/SongsGuide.jsx b/client/src/pages/SongsGuide.jsxindex 9f2de8fc8d..ec7730db4e 100644--- a/client/src/pages/SongsGuide.jsx+++ b/client/src/pages/SongsGuide.jsx@@ -14,11 +14,18 @@ import { Music, ArrowLeft, Drum, Layers, GraduationCap, FileMusic } from 'lucideimport Pill from '../components/ui/Pill';import {RHYTHM_SHAPES,+ DIRGE_RHYTHM_SHAPES,VOICE_LAYERS,LEARNING_STEPS,NOTATION_HELP,+ SOLFEGE_DEGREES,+ solfegeForDegree,} from '../lib/songCraft';+// Dirges lead the rhythm list (the workbench's home turf), then the rest.+const NON_DIRGE_SHAPES = RHYTHM_SHAPES.filter((s) => !s.dirge);+const ORDERED_RHYTHM_SHAPES = [...DIRGE_RHYTHM_SHAPES, ...NON_DIRGE_SHAPES];+function RhythmCard({ shape }) {return (<div className="bg-port-card border border-port-border rounded-lg p-4 flex flex-col gap-2">@@ -96,7 +103,7 @@ export default function SongsGuide() {subtitle="The felt pulse a song leans on. Dirges — slow, solemn laments — lead the list, since that's the workbench's home turf."/><div className="grid grid-cols-1 sm:grid-cols-2 gap-3">- {RHYTHM_SHAPES.map((s) => <RhythmCard key={s.id} shape={s} />)}+ {ORDERED_RHYTHM_SHAPES.map((s) => <RhythmCard key={s.id} shape={s} />)}</div></section>@@ -157,6 +164,25 @@ export default function SongsGuide() {</div>))}</div>++ {/* Movable-do solfège ladder — how harmony parts name their home+ degree relative to the tonic (Do). The octave repeats Do. */}+ <div className="bg-port-card border border-port-border rounded-lg p-4 mt-3">+ <h3 className="text-sm font-semibold text-white">Solfège — naming the scale</h3>+ <p className="text-xs text-gray-500 mb-3">+ Movable-do: sing degrees relative to the key's tonic (Do). Find a harmony part by+ its degree above the lead — a third is Mi, a fifth is Sol.+ </p>+ <div className="flex flex-wrap gap-1.5">+ {SOLFEGE_DEGREES.map((d) => (+ <Pill key={d.degree} tone={d.degree === 1 ? 'accent' : 'muted'}>+ {d.degree}. {d.solfege}+ </Pill>+ ))}+ {/* The octave folds back to the tonic — solfegeForDegree wraps. */}+ <Pill tone="note">8. {solfegeForDegree(8)} (octave)</Pill>+ </div>+ </div></section></div></div>diff --git a/server/services/songs.test.js b/server/services/songs.test.jsindex d37dcf44e5..bc8024cc1b 100644--- a/server/services/songs.test.js+++ b/server/services/songs.test.js@@ -52,13 +52,19 @@ describe('songs service', () => {expect(songs[0].id).toBe(song.id); // unshifted to front});- it('clamps tempo into the supported band and nulls unparseable values', async () => {- const fast = await svc.createSong({ title: 'Too fast', tempo: 9000 });- expect(fast.tempo).toBe(svc.TEMPO_MAX);+ it('nulls a missing tempo on create', async () => {const noTempo = await svc.createSong({ title: 'No tempo' });expect(noTempo.tempo).toBeNull();});+ it('clamps an out-of-band tempo on the sanitize/read path', () => {+ // The route 400s an out-of-band tempo before createSong runs, so this+ // clamp only ever fires when reading hand-edited JSON — exercise it there.+ expect(svc.sanitizeSong({ id: 'x', tempo: 9000 }).tempo).toBe(svc.TEMPO_MAX);+ expect(svc.sanitizeSong({ id: 'x', tempo: 1 }).tempo).toBe(svc.TEMPO_MIN);+ expect(svc.sanitizeSong({ id: 'x', tempo: 'fast' }).tempo).toBeNull();+ });+it('drops empty sections/layers and labels the survivors', async () => {const song = await svc.createSong({title: 'Layered',