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 (codex): preserve unsaved track edits + lyrics absent-vs-empty
[._.]/ Adam Eivy6993da630b98
diff --git a/client/src/components/music/TracksManager.jsx b/client/src/components/music/TracksManager.jsxindex 187275b863..daff1794df 100644--- a/client/src/components/music/TracksManager.jsx+++ b/client/src/components/music/TracksManager.jsx@@ -333,8 +333,14 @@ export default function TracksManager() {prompt={form.prompt}lyrics={form.lyrics}onGenerated={(updated) => {- upsertLocal(updated);- if (selectedIdRef.current === updated.id) setForm(formFromTrack(updated));+ upsertLocal(updated); // list update is id-keyed → always safe+ // Merge ONLY the server-set generation fields into the open+ // form (audio + gen metadata mirror onto the form's read-only+ // badges/player) so any UNSAVED edits the user made to title/+ // artist/album/prompt/lyrics before clicking Generate survive.+ if (selectedIdRef.current === updated.id) {+ setForm((f) => ({ ...f, audioFilename: updated.audioFilename || '' }));+ }}}/>) : null}diff --git a/server/routes/music.js b/server/routes/music.jsindex e259efd2ef..a350c4db0e 100644--- a/server/routes/music.js+++ b/server/routes/music.js@@ -99,7 +99,9 @@ router.delete('/models/:engine/*id', asyncHandler(async (req, res) => {const generateSchema = z.object({prompt: z.string().trim().min(1, 'prompt is required').max(8000),- lyrics: z.string().trim().max(20000).optional().default(''),+ // No default: distinguish ABSENT (don't touch the track's lyrics) from a+ // present '' (the user cleared them and generated without — persist the clear).+ lyrics: z.string().trim().max(20000).optional(),engine: z.string().trim().max(60).optional(),modelId: z.string().trim().max(120).optional(),durationSec: z.number().positive().max(600).optional(),@@ -135,19 +137,23 @@ router.post('/generate', asyncHandler(async (req, res) => {}// generateMusic throws a typed ServerError (503 venv-missing / 500 sidecar- // failure) that asyncHandler maps verbatim — no need to re-wrap here.+ // failure) that asyncHandler maps verbatim — no need to re-wrap here. A+ // lyric-aware engine renders with the provided lyrics ('' = no lyrics); a+ // non-lyric engine ignores the flag entirely.const result = await generateMusic({prompt: body.prompt,- lyrics: body.lyrics,+ lyrics: engine.lyrics ? (body.lyrics ?? '') : '',engine: engine.id,modelId: body.modelId,repo,durationSec: body.durationSec,});- // Persist the audio + gen metadata. Lyrics: only write them when the engine is- // lyric-aware AND the caller sent some — otherwise a non-lyric render (or an- // engine that sends lyrics:'') would silently erase a track's existing lyrics.+ // Persist the audio + gen metadata. Lyrics follow the audio that was actually+ // rendered: for a lyric-aware engine we persist what the caller SENT —+ // including an intentional '' clear (the audio was generated without lyrics) —+ // but an ABSENT lyrics field leaves the track's lyrics untouched. A non-lyric+ // engine never writes lyrics (it can't erase a song's words by adding a bed).const meta = {audioFilename: result.filename,engine: result.engine,@@ -155,7 +161,7 @@ router.post('/generate', asyncHandler(async (req, res) => {durationSec: Math.round(result.durationSec),prompt: body.prompt,};- if (engine.lyrics && body.lyrics) meta.lyrics = body.lyrics;+ if (engine.lyrics && body.lyrics !== undefined) meta.lyrics = body.lyrics;let track;if (existing) {@@ -166,7 +172,7 @@ router.post('/generate', asyncHandler(async (req, res) => {artistId: body.artistId,artist: body.artist,albumId: body.albumId,- ...(engine.lyrics && body.lyrics ? { lyrics: body.lyrics } : {}),+ ...(engine.lyrics && body.lyrics !== undefined ? { lyrics: body.lyrics } : {}),...meta,});// Mirror the /api/tracks create path: a new track with an albumId must bediff --git a/server/routes/music.test.js b/server/routes/music.test.jsindex bf6a84b7d2..cc4b3a6f29 100644--- a/server/routes/music.test.js+++ b/server/routes/music.test.js@@ -152,6 +152,24 @@ describe('music routes', () => {expect(patch).not.toHaveProperty('lyrics');});+ it('POST /generate on a lyric engine with ABSENT lyrics leaves the track lyrics untouched', async () => {+ tracks.getTrack.mockResolvedValueOnce({ id: 'track-1', title: 'Song', lyrics: 'old words' });+ gen.generateMusic.mockResolvedValueOnce({ filename: 'm.wav', durationSec: 60, engine: 'acestep', modelId: 'a' });+ await request(app).post('/api/music/generate').send({ prompt: 'folk', engine: 'acestep', trackId: 'track-1' }); // no lyrics field+ const patch = tracks.updateTrack.mock.calls[0][1];+ expect(patch).not.toHaveProperty('lyrics');+ // The sidecar still renders (with empty lyrics) — engine.lyrics coalesces to ''.+ expect(gen.generateMusic).toHaveBeenCalledWith(expect.objectContaining({ lyrics: '' }));+ });++ it('POST /generate on a lyric engine with an EXPLICIT empty lyrics persists the clear', async () => {+ tracks.getTrack.mockResolvedValueOnce({ id: 'track-1', title: 'Song', lyrics: 'old words' });+ gen.generateMusic.mockResolvedValueOnce({ filename: 'm.wav', durationSec: 60, engine: 'acestep', modelId: 'a' });+ await request(app).post('/api/music/generate').send({ prompt: 'instrumental', lyrics: '', engine: 'acestep', trackId: 'track-1' });+ const patch = tracks.updateTrack.mock.calls[0][1];+ expect(patch.lyrics).toBe(''); // audio was rendered WITHOUT lyrics → persist the clear+ });+it('POST /generate validates trackId BEFORE rendering (no wasted render)', async () => {tracks.getTrack.mockResolvedValueOnce(null);const r = await request(app).post('/api/music/generate').send({ prompt: 'x', trackId: 'gone' });