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([issue-863]): single-track music routes flip audioMode to uploaded-track
[._.]/ Adam Eivy7b15a265185e
diff --git a/server/routes/pipeline.js b/server/routes/pipeline.jsindex 175eef5466..a08c934c77 100644--- a/server/routes/pipeline.js+++ b/server/routes/pipeline.js@@ -927,6 +927,20 @@ const musicUpload = uploadSingle('track', {const audioStatusAfterMusicChange = (stage) =>(stage.lines?.length ? 'edited' : 'empty');+// Attaching/generating/uploading a single track means "use this one track as+// the episode bed" — flip audioMode to 'uploaded-track' so the stitcher+// actually muxes it. Without this a new issue stays at the default 'per-clip'+// mode, which (correctly) ignores the music pointer, so the track would land on+// the issue but never play (issue #863). Only override the generated/silent+// modes when the user explicitly attaches a single track — those are deliberate+// strategy choices we shouldn't silently undo for an unrelated music write... but+// since all three routes ARE the "set the single track" action, the override is+// the user's intent. The delete route mirrors this: clearing the only track+// reverts an 'uploaded-track' issue to 'per-clip', leaving generated/silent be.+const audioModeAfterTrackSet = () => 'uploaded-track';+const audioModeAfterTrackClear = (stage) =>+ (stage.audioMode === 'uploaded-track' ? 'per-clip' : stage.audioMode);+router.get('/audio/music-library', asyncHandler(async (_req, res) => {res.json({ tracks: await listMusicLibrary() });}));@@ -999,6 +1013,7 @@ router.post('/issues/:id/stages/audio/music/generate', asyncHandler(async (req,'audio',(current) => ({status: audioStatusAfterMusicChange(current),+ audioMode: audioModeAfterTrackSet(),music: { source: MUSIC_SOURCE.GEN, trackFilename: gen.filename, label: gen.model },errorMessage: '',}),@@ -1024,6 +1039,7 @@ router.post('/issues/:id/stages/audio/music/upload', musicUpload, asyncHandler(a'audio',(current) => ({status: audioStatusAfterMusicChange(current),+ audioMode: audioModeAfterTrackSet(),music: { source: MUSIC_SOURCE.UPLOAD, trackFilename: filename, label },errorMessage: '',}),@@ -1049,6 +1065,7 @@ router.post('/issues/:id/stages/audio/music/attach', asyncHandler(async (req, re'audio',(current) => ({status: audioStatusAfterMusicChange(current),+ audioMode: audioModeAfterTrackSet(),music: {source: MUSIC_SOURCE.LIBRARY,trackFilename: body.trackFilename,@@ -1066,6 +1083,7 @@ router.delete('/issues/:id/stages/audio/music', asyncHandler(async (req, res) =>'audio',(current) => ({status: audioStatusAfterMusicChange(current),+ audioMode: audioModeAfterTrackClear(current),music: null,errorMessage: '',}),diff --git a/server/routes/pipeline.test.js b/server/routes/pipeline.test.jsindex c4b8601f81..ed6b4f931c 100644--- a/server/routes/pipeline.test.js+++ b/server/routes/pipeline.test.js@@ -2525,9 +2525,12 @@ describe('pipeline routes', () => {expect(r.status).toBe(200);expect(r.body.music.source).toBe('upload');expect(r.body.music.trackFilename).toMatch(/^music-uuid-/);+ // Uploading a single track flips the episode to 'uploaded-track'.+ expect(r.body.stage.audioMode).toBe('uploaded-track');// Persisted on the issueconst after = await request(app).get(`/api/pipeline/issues/${iss.id}`);expect(after.body.stages.audio.music.trackFilename).toBe(r.body.music.trackFilename);+ expect(after.body.stages.audio.audioMode).toBe('uploaded-track');expect(lastImportedName).toBe('My Theme.mp3');});@@ -2551,6 +2554,10 @@ describe('pipeline routes', () => {expect(r.body.music.source).toBe('library');expect(r.body.music.trackFilename).toBe('shared.mp3');expect(r.body.music.label).toBe('Library pick');+ // Attaching a single track flips the episode to 'uploaded-track' so the+ // stitcher actually muxes it (a new issue defaults to 'per-clip', which+ // ignores the music pointer — issue #863).+ expect(r.body.stage.audioMode).toBe('uploaded-track');});it('POST /audio/music/attach 404s when the track is not in the library', async () => {@@ -2596,10 +2603,28 @@ describe('pipeline routes', () => {.send();expect(r.status).toBe(200);expect(r.body.stage.music).toBeNull();+ // Clearing the only track reverts an 'uploaded-track' issue to 'per-clip'.+ expect(r.body.stage.audioMode).toBe('per-clip');// Library entry survives the issue detachexpect(musicLibraryStore.has('shared.mp3')).toBe(true);});+ it('DELETE /audio/music leaves a generated-mode issue in generated mode', async () => {+ const app = makeApp();+ const iss = await seedIssue(app);+ // Put the issue in generated mode with a (stale) music pointer, then clear+ // the pointer — the explicit generated strategy must survive.+ await request(app).patch(`/api/pipeline/issues/${iss.id}`).send({+ stages: { audio: { audioMode: 'generated', music: { source: 'gen', trackFilename: 'old.wav', label: 'x' } } },+ });+ const r = await request(app)+ .delete(`/api/pipeline/issues/${iss.id}/stages/audio/music`)+ .send();+ expect(r.status).toBe(200);+ expect(r.body.stage.music).toBeNull();+ expect(r.body.stage.audioMode).toBe('generated');+ });+it('DELETE /audio/music 404s with PIPELINE_ISSUE_NOT_FOUND when the issue does not exist', async () => {const app = makeApp();const r = await request(app)