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

DistroKid AI disclosure fails on an unsaveable modal and re-reads the gate after Save

[._.]/ Adam Eivya1fd7e6966c5
diff --git a/client/src/lib/distrokidForm.test.js b/client/src/lib/distrokidForm.test.js
index a27a4eea7a..cbfb958f67 100644
--- a/client/src/lib/distrokidForm.test.js
+++ b/client/src/lib/distrokidForm.test.js
@@ -112,6 +112,48 @@ describe('DistroKid form recipe', () => {
expect(saved).toBe(1);
});
+ it('discloses AI music under a human voice in the modal as part of the audio, with instruments', () => {
+ document.body.innerHTML = `
+ <div class="swal2-popup ai-credits-swal-modal">
+ <input type="checkbox" class="distroAiLyrics" name="ai_lyrics_ef56" value="1">
+ <input type="checkbox" class="distroAiMusic" name="ai_music_ef56" value="1">
+ <input type="checkbox" class="distroAiRecordingScope" value="full">
+ <input type="checkbox" class="distroAiRecordingScope" value="partial">
+ ${radios('ai_partial_audio_type_ef56', ['vocals', 'instruments'])}
+ <button class="swal2-confirm">Save</button>
+ </div>`;
+ let saved = 0;
+ document.querySelector('.swal2-confirm').addEventListener('click', () => { saved += 1; });
+ expect(discloseDistrokidAi({ step: 'parts', ai: { lyrics: false, music: true, vocals: false } })).toBe(true);
+ const box = (sel) => document.querySelector(sel).checked;
+ expect([box('[value=full]'), box('[value=partial]'), box('.distroAiMusic')]).toEqual([false, true, true]);
+ expect(checked('ai_partial_audio_type_')).toBe('instruments');
+ expect(saved).toBe(1);
+ });
+
+ it('fails when a modal is showing but has no Save to press', () => {
+ document.body.innerHTML = `
+ <div class="swal2-popup">
+ <input type="checkbox" name="ai_lyrics_ef56"><input type="checkbox" name="ai_music_ef56">
+ <input type="checkbox" class="distroAiRecordingScope" value="full"><input type="checkbox" class="distroAiRecordingScope" value="partial">
+ </div>`;
+ expect(discloseDistrokidAi({ step: 'parts', ai: { lyrics: false, music: true, vocals: true } })).toBe(false);
+ });
+
+ it('confirms the answer stuck: the gate still says yes and the modal closed', () => {
+ const ai = { lyrics: false, music: true, vocals: true };
+ document.body.innerHTML = `${radios('ai_gate_ef56', ['0', '1'])}`;
+ document.querySelector('[value="1"]').checked = true;
+ expect(discloseDistrokidAi({ step: 'check', ai })).toBe(true);
+ // A Save that didn't take: the gate fell back to No.
+ document.querySelector('[value="0"]').checked = true;
+ expect(discloseDistrokidAi({ step: 'check', ai })).toBe(false);
+ // Or the modal is still open.
+ document.querySelector('[value="1"]').checked = true;
+ document.body.insertAdjacentHTML('beforeend', '<div class="ai-credits-swal-modal"></div>');
+ expect(discloseDistrokidAi({ step: 'check', ai })).toBe(false);
+ });
+
it('does not save the modal when a part it needed is missing', () => {
document.body.innerHTML = `<div class="ai-credits-swal-modal"><input type="checkbox" name="ai_music_ef56"><button class="swal2-confirm">Save</button></div>`;
let saved = 0;
diff --git a/server/lib/distrokidForm.js b/server/lib/distrokidForm.js
index a934b1715a..e1cd96ec1c 100644
--- a/server/lib/distrokidForm.js
+++ b/server/lib/distrokidForm.js
@@ -128,7 +128,8 @@ export function fillDistrokidFields(plan) {
* yes. `{ step: 'gate', ai }` answers the gate; `{ step: 'parts', ai }` ticks
* lyrics, music, and all of the audio (AI vocals) or part of it (AI
* instruments under a human voice), then presses the parts modal's Save when
- * DistroKid shows them in one. `ai`: { lyrics, music, vocals }.
+ * DistroKid shows them in one; `{ step: 'check', ai }` confirms afterwards that
+ * the gate still holds the answer and the modal closed. `ai`: { lyrics, music, vocals }.
* Resolves true when every field it needed was there.
*/
export function discloseDistrokidAi({ step, ai }) {
@@ -138,6 +139,12 @@ export function discloseDistrokidAi({ step, ai }) {
if (el.checked !== on) el.click();
return true;
};
+ if (step === 'check') {
+ // After Save: the gate still holds the answer and no AI modal is left open.
+ const gate = document.querySelector('input[type=radio][name^="ai_gate_"]:checked');
+ const open = [...document.querySelectorAll('.ai-credits-swal-modal')].some((m) => m.isConnected && !m.closest('[hidden]') && m.style.display !== 'none');
+ return gate?.value === (any ? '1' : '0') && !open;
+ }
if (step === 'gate') {
const gate = document.querySelector(`input[type=radio][name^="ai_gate_"][value="${any ? 1 : 0}"]`);
if (!gate) return false;
@@ -166,8 +173,11 @@ export function discloseDistrokidAi({ step, ai }) {
const parts = set(document.querySelector('input[name^="ai_lyrics_"]'), !!ai.lyrics)
&& set(document.querySelector('input[name^="ai_music_"]'), !!ai.music)
&& audio;
- // The modal keeps nothing until Save, and closing it any other way resets the gate to No.
- const save = document.querySelector('.ai-credits-swal-modal .swal2-confirm');
+ // The modal keeps nothing until Save, and closing it any other way resets the gate to No,
+ // so a modal with no Save to press is a failure, not a pass.
+ const popup = document.querySelector('.ai-credits-swal-modal') || document.querySelector('.swal2-popup');
+ const save = popup?.querySelector('.swal2-confirm');
+ if (popup && !save) return false;
if (parts && save) save.click();
return parts;
}
diff --git a/server/services/musicVideo/publish/distrokid.js b/server/services/musicVideo/publish/distrokid.js
index 6188c44d31..e1e5525cd1 100644
--- a/server/services/musicVideo/publish/distrokid.js
+++ b/server/services/musicVideo/publish/distrokid.js
@@ -98,7 +98,10 @@ export const distrokidAdapter = {
if (!(await page.evaluate(discloseDistrokidAi, { step: 'gate', ai: payload.ai }))) return false;
if (!(payload.ai.lyrics || payload.ai.music || payload.ai.vocals)) return true;
await page.waitForTimeout(1000);
- return page.evaluate(discloseDistrokidAi, { step: 'parts', ai: payload.ai });
+ if (!(await page.evaluate(discloseDistrokidAi, { step: 'parts', ai: payload.ai }))) return false;
+ // A Save that didn't take resets the gate to No once the modal goes, so the answer is re-read.
+ await page.waitForTimeout(800);
+ return page.evaluate(discloseDistrokidAi, { step: 'check', ai: payload.ai });
});
// Paid extras are the director's call, every time: none stays ticked.
const extras = await page.evaluate(untickDistrokidExtras).catch(() => null);