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 (claude): drop a stale MIDI result when the reference audio was swapped mid-transcription

[._.]/ Adam Eivy4ae3564443bd
diff --git a/client/src/components/songs/ReferenceAnalysis.jsx b/client/src/components/songs/ReferenceAnalysis.jsx
index b1b13ee5da..70507b3450 100644
--- a/client/src/components/songs/ReferenceAnalysis.jsx
+++ b/client/src/components/songs/ReferenceAnalysis.jsx
@@ -115,7 +115,11 @@ export function ReferenceAudioAttach({ reference, onUpdate }) {
startRequest: (filename) => transcribeReferenceMidi(filename, undefined, { silent: true }),
eventsUrl: referenceMidiTranscriptionEventsUrl,
cancelRequest: cancelReferenceMidiTranscription,
- onComplete: ({ filename }) => {
+ onComplete: ({ filename }, sourceAudio) => {
+ // The .mid is a transcription OF the audio captured at kickoff — if the
+ // reference's audio was swapped while it ran, drop the stale result
+ // rather than attaching the old recording's MIDI to the new audio.
+ if (sourceAudio !== reference.audioFilename) return;
onUpdate('midiFilename', filename);
toast.success('MIDI transcribed — Save the song to keep it');
},
@@ -220,7 +224,9 @@ export function ReferenceAudioAttach({ reference, onUpdate }) {
onClick={() => {
// Segments are offsets into THIS audio — and the MIDI was
// transcribed from it — clear them with it so stale artifacts
- // can't resurrect against a different recording.
+ // can't resurrect against a different recording. An in-flight
+ // transcription is of this audio too; cancel it (no-op when idle).
+ midiJob.cancel();
onUpdate('segments', []);
onUpdate('midiFilename', '');
onUpdate('audioFilename', '');