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): transcribe on the round's own time signature; never persist temp layer ids in segments

Adam Eivy9419de3170b3
diff --git a/client/src/components/songs/ReferenceAnalysis.jsx b/client/src/components/songs/ReferenceAnalysis.jsx
index f803b9d01d..d63fcd25cc 100644
--- a/client/src/components/songs/ReferenceAnalysis.jsx
+++ b/client/src/components/songs/ReferenceAnalysis.jsx
@@ -31,7 +31,7 @@ import ScoreSheet from './ScoreSheet.jsx';
import { uploadFile, getUploadUrl } from '../../services/api';
import { startMemoRecording, arrayBufferToBase64 } from '../../lib/audioRecorder';
import { proposeSegmentScore, diffScoreBars, PITCH_CLASS_NAMES } from '../../lib/referenceAnalysis';
-import { scoreHasMusic } from '../../lib/scoreNotation';
+import { scoreHasMusic, parseScore } from '../../lib/scoreNotation';
import { harmonyPartLabel } from '../../lib/songCraft';
// Client-side guard for the base64-JSON upload path: the server body limit is
@@ -359,11 +359,18 @@ export default function ReferenceAnalysis({
setExtracting(true);
// Yield a frame so the button's busy state paints before the O(n·lag) DSP.
setTimeout(() => {
+ // Transcribe on the round's own meter — a 3/4 or 6/8 round quantized and
+ // bar-grouped as 4/4 would diff the wrong measures and, when applied,
+ // silently change the part's time signature. parseScore defaults to 4/4
+ // when the base score declares none.
+ const { beats: beatsPerBar, beatValue } = parseScore(baseScore).time;
const { text } = proposeSegmentScore(decoded.samples, decoded.sampleRate, {
startMs: seg.startMs,
endMs: seg.endMs,
bpm: Number.isFinite(tempo) && tempo > 0 ? tempo : undefined,
key: songKey || 'C',
+ beatsPerBar,
+ beatValue,
});
setExtracting(false);
if (!text) {
@@ -385,7 +392,7 @@ export default function ReferenceAnalysis({
setCompareId(match?.id || '');
}
}, 30);
- }, [decoded, tempo, songKey, scoreParts]);
+ }, [decoded, tempo, songKey, scoreParts, baseScore]);
const comparePart = useMemo(() => {
if (compareId === BASE_TARGET) {
diff --git a/client/src/pages/RoundEditor.jsx b/client/src/pages/RoundEditor.jsx
index 89911a522e..6614599a6c 100644
--- a/client/src/pages/RoundEditor.jsx
+++ b/client/src/pages/RoundEditor.jsx
@@ -219,7 +219,19 @@ export default function RoundEditor() {
layers: (song.layers || []).map(stripTempId),
scoreParts: (song.scoreParts || []).map(stripTempId),
recordings: (song.recordings || []).map(stripTempId),
- references: (song.references || []).map(stripTempId),
+ // References also blank any segment layerId that points at a temp layer
+ // id — the server re-mints that layer's id on save, so the link would
+ // dangle after reload; an unassigned segment is the honest state.
+ references: (song.references || []).map((r) => {
+ const ref = stripTempId(r);
+ if (!ref.segments?.length) return ref;
+ return {
+ ...ref,
+ segments: ref.segments.map((s) => (
+ TEMP_ID_RE.test(s.layerId || '') ? { ...s, layerId: '' } : s
+ )),
+ };
+ }),
partnerRoundIds: song.partnerRoundIds || [],
};
const data = await updateRound(id, patch, { silent: true });
@@ -433,7 +445,10 @@ export default function RoundEditor() {
{analyzeId && (
<ReferenceAnalysis
reference={(song.references || []).find((r) => r.id === analyzeId) || null}
- layers={song.layers || []}
+ // Only stable-id layers are offered as segment targets — a blank
+ // layer's temp id gets re-minted server-side on Save, which would
+ // orphan any segment linked to it.
+ layers={(song.layers || []).filter((l) => !TEMP_ID_RE.test(l.id))}
scoreParts={song.scoreParts || []}
baseScore={song.score || ''}
tempo={song.tempo ?? null}