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

feat: autopilot Suno tracks use the second render by default

[._.]/ Adam Eivy09992c71704d
diff --git a/server/services/musicVideo/autonomousSuno.js b/server/services/musicVideo/autonomousSuno.js
index 3afec2ab07..bea9dd6b6a 100644
--- a/server/services/musicVideo/autonomousSuno.js
+++ b/server/services/musicVideo/autonomousSuno.js
@@ -289,6 +289,10 @@ async function closeSunoBrowser(page, browser) {
}
}
+// Suno returns two renders per request; the second is usually the better one.
+// A single-id resume (or a one-render result) falls back to the only id.
+const pickRender = (ids) => ids[1] ?? ids[0];
+
/** Generate (or resume) a song and import its completed, validated M4A. */
export async function generateSunoSong(fields, deps = {}) {
const connect = deps.connect || connectPortosBrowser;
@@ -307,7 +311,7 @@ export async function generateSunoSong(fields, deps = {}) {
page = await context.newPage();
const ids = deps.songIds?.length ? deps.songIds : await submitSunoSong(page, fields, deps);
if (!deps.songIds?.length) await deps.onSubmitted?.(ids);
- await downloadSunoAudio(page, ids[0], path, deps);
+ await downloadSunoAudio(page, pickRender(ids), path, deps);
return ids;
} finally {
await closeSunoBrowser(page, browser); // disconnect; keep the shared browser running
@@ -315,7 +319,7 @@ export async function generateSunoSong(fields, deps = {}) {
});
deps.signal?.throwIfAborted();
const { filename, sizeBytes } = await importAudio(path, 'song.m4a');
- return { songId: songIds[0], songIds, filename, sizeBytes };
+ return { songId: pickRender(songIds), songIds, filename, sizeBytes };
} finally {
await rm(dir, { recursive: true, force: true });
}
diff --git a/server/services/musicVideo/autonomousSuno.test.js b/server/services/musicVideo/autonomousSuno.test.js
index d61e58416d..4ff9b6786f 100644
--- a/server/services/musicVideo/autonomousSuno.test.js
+++ b/server/services/musicVideo/autonomousSuno.test.js
@@ -185,7 +185,7 @@ describe('generateSunoSong M4A export', () => {
const w = workflow();
const onSubmitted = vi.fn();
const out = await generateSunoSong(fields, { ...w, onSubmitted, sleep: noSleep });
- expect(out).toEqual({ songId: NEW_A, songIds: [NEW_A, NEW_B], filename: 'music-example.m4a', sizeBytes: m4a.length });
+ expect(out).toEqual({ songId: NEW_B, songIds: [NEW_A, NEW_B], filename: 'music-example.m4a', sizeBytes: m4a.length });
expect(onSubmitted).toHaveBeenCalledWith([NEW_A, NEW_B]);
expect(w.selected).toEqual(new Set(['M4A']));
expect(w.actions.filter(x => x === 'export')).toHaveLength(1);