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: reject unrelated Suno workspace rows as submitted songs (#9474)
[._.]/ Adam Eivydee2bc5cc6bb
diff --git a/server/services/musicVideo/autonomousSuno.js b/server/services/musicVideo/autonomousSuno.jsindex 43b0484513..f8c675ac21 100644--- a/server/services/musicVideo/autonomousSuno.js+++ b/server/services/musicVideo/autonomousSuno.js@@ -38,7 +38,11 @@ const SUNO_POLL_INTERVAL_MS = 10 * 1000;// A real song is megabytes; anything under this is a stub or error body.const MIN_AUDIO_BYTES = 100 * 1024;-const songLinks = (page) => page.evaluate(() => [...document.querySelectorAll('a[href*="/song/"]')].map((a) => a.getAttribute('href')));+const songLinks = (page, title = null) => page.evaluate((wantedTitle) => [...document.querySelectorAll('a[href*="/song/"]')]+ // Workspace rows may finish loading after Create. A newly seen href alone+ // is not evidence that this request produced the song.+ .filter((a) => wantedTitle === null || a.textContent.trim() === wantedTitle)+ .map((a) => a.getAttribute('href')), title);/*** Fill Suno's custom-song form and press Create. Returns the ids of the songs@@ -46,7 +50,7 @@ const songLinks = (page) => page.evaluate(() => [...document.querySelectorAll('a* the click are excluded, so an older song in the workspace is never mistaken* for ours.*/-async function submitSunoSong(page, fields, { sleep = defaultSleep } = {}) {+async function submitSunoSong(page, fields, { sleep = defaultSleep, now = Date.now } = {}) {await step(LABEL, 'open the create page', () => page.goto(SUNO_CREATE_URL, { waitUntil: 'domcontentloaded', timeout: T }));await page.locator('textarea').first().waitFor({ state: 'visible', timeout: T }).catch(() => {});// A signed-out visitor is bounced to a sign-in page or sees no create form.@@ -93,13 +97,13 @@ async function submitSunoSong(page, fields, { sleep = defaultSleep } = {}) {});// New rows land at the top of the workspace list once Suno accepts the request.- const deadline = Date.now() + 90_000;- while (Date.now() < deadline) {+ const deadline = now() + 90_000;+ while (now() < deadline) {await sleep(3000);- const fresh = sunoSongIdsFromHrefs(await songLinks(page)).filter((id) => !before.has(id));+ const fresh = sunoSongIdsFromHrefs(await songLinks(page, fields.title)).filter((id) => !before.has(id));if (fresh.length) return fresh;}- throw new ServerError('Suno: no new song appeared after pressing Create — check the PortOS Browser for a credits, captcha or content-policy prompt', {+ throw new ServerError('Suno: no matching song appeared after pressing Create — check the PortOS Browser for a credits, captcha or content-policy prompt', {status: 502, code: 'SUNO_NO_SONG', context: { platform: LABEL },});}diff --git a/server/services/musicVideo/autonomousSuno.test.js b/server/services/musicVideo/autonomousSuno.test.jsindex f8f55e9766..b9c7c469e8 100644--- a/server/services/musicVideo/autonomousSuno.test.js+++ b/server/services/musicVideo/autonomousSuno.test.js@@ -16,7 +16,7 @@ const NEW_B = '33333333-3333-3333-3333-333333333333';const noSleep = async () => {};/** A just-enough Playwright page: tracks fills/clicks and exposes song links that appear after Create. */-function fakePage({ url = 'https://suno.com/create', hasForm = true, modern = true, afterCreate = [NEW_A, NEW_B] } = {}) {+function fakePage({ url = 'https://suno.com/create', hasForm = true, modern = true, newTitleMatches = true, afterCreate = [NEW_A, NEW_B] } = {}) {const fills = {};let created = false;const locator = (selector) => {@@ -39,7 +39,10 @@ function fakePage({ url = 'https://suno.com/create', hasForm = true, modern = trurl: () => url,locator,getByRole: button,- evaluate: async () => [`/song/${OLD}`, ...(created ? afterCreate.map((id) => `/song/${id}`) : [])],+ evaluate: async (_fn, title) => [+ ...(title === null ? [`/song/${OLD}`] : []),+ ...(created && (title === null || newTitleMatches) ? afterCreate.map((id) => `/song/${id}`) : []),+ ],close: async () => {},};}@@ -62,6 +65,13 @@ describe('submitSunoSong', () => {expect(page.fills['[role="textbox"][aria-label="Lyrics editor"],textarea[placeholder*="lyrics" i]']).toBe('');});+ it('does not accept unrelated workspace rows that load after Create', async () => {+ let time = 0;+ await expect(submitSunoSong(fakePage({ newTitleMatches: false }), fields, {+ sleep: noSleep, now: () => (time += 30_000),+ })).rejects.toMatchObject({ code: 'SUNO_NO_SONG' });+ });+it('keeps the older Custom form compatible', async () => {const page = fakePage({ modern: false });await submitSunoSong(page, fields, { sleep: noSleep });