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 draft never assumes new store profiles, and checks its own work

Claude2052bb691d70
diff --git a/client/src/components/musicVideo/PublishPostingPanel.jsx b/client/src/components/musicVideo/PublishPostingPanel.jsx
index abe839b99f..d29cf32fe3 100644
--- a/client/src/components/musicVideo/PublishPostingPanel.jsx
+++ b/client/src/components/musicVideo/PublishPostingPanel.jsx
@@ -24,9 +24,10 @@ export const PUBLISH_TARGETS = [
];
// The DistroKid answers the director gives once (songwriter legal name and
-// role, language, store profiles, Apple performer role), remembered on this device only.
+// role, language, Apple performer role), remembered on this device only. The
+// store-profile answer is never remembered: new profiles are per first release.
const SONGWRITER_KEY = 'portos.musicVideo.distrokidSongwriter';
-const DISTROKID_REMEMBERED = { songwriterFirst: 'first', songwriterLast: 'last', songwriterRole: 'role', language: 'language', newArtistProfile: 'newArtistProfile', performerRole: 'performerRole' };
+const DISTROKID_REMEMBERED = { songwriterFirst: 'first', songwriterLast: 'last', songwriterRole: 'role', language: 'language', performerRole: 'performerRole' };
const inputCls = 'w-full bg-port-bg border border-port-border rounded px-1.5 py-1 text-xs min-h-[44px] sm:min-h-0';
@@ -141,7 +142,7 @@ function TargetOptions({ target, kit, project, options, setOption, flairs, idFor
<div className="flex flex-wrap gap-x-4">
{check('explicit', 'Explicit lyrics', false)}
{check('instrumental', 'Instrumental', !hasLyrics)}
- {check('newArtistProfile', 'First release as this artist (new store profiles)', true)}
+ {check('newArtistProfile', 'First release as this artist (new store profiles)', false)}
</div>
<div role="group" aria-label="Apple Music credits" className="grid sm:grid-cols-3 gap-2">
{text('performerName', 'Apple performer (real name)', fullName)}
@@ -257,7 +258,7 @@ function TargetRow({ project, kit, entry, publishing }) {
if (target === 'distrokid' && clean.songwriterFirst && clean.songwriterLast) {
safeWriteJsonStorage(SONGWRITER_KEY, Object.fromEntries(Object.entries(DISTROKID_REMEMBERED).filter(([opt]) => clean[opt] != null).map(([opt, k]) => [k, clean[opt]])));
}
- publishing.prepare(target, target === 'distrokid' ? { newArtistProfile: true, ...clean } : clean);
+ publishing.prepare(target, clean);
}} disabled={!!busy}
className="flex items-center gap-1 bg-port-accent/20 text-port-accent disabled:opacity-50 rounded px-2 py-1.5 text-xs min-h-[44px] sm:min-h-0">
{busy === 'prepare' ? 'Filling…' : (draft ? 'Fill again' : 'Fill draft')}
diff --git a/client/src/components/musicVideo/PublishPostingPanel.test.jsx b/client/src/components/musicVideo/PublishPostingPanel.test.jsx
index 0673d103fa..5a84d54ba1 100644
--- a/client/src/components/musicVideo/PublishPostingPanel.test.jsx
+++ b/client/src/components/musicVideo/PublishPostingPanel.test.jsx
@@ -61,7 +61,7 @@ describe('PublishPostingPanel (#9282)', () => {
fireEvent.change(within(dk).getByLabelText('Songwriter legal last name'), { target: { value: 'Example' } });
fireEvent.click(within(dk).getByLabelText('Explicit lyrics'));
fireEvent.click(within(dk).getByRole('button', { name: 'Fill draft' }));
- expect(publishing.prepare).toHaveBeenCalledWith('distrokid', { songwriterFirst: 'Alice', songwriterLast: 'Example', aiLyrics: true, explicit: true, newArtistProfile: true });
+ expect(publishing.prepare).toHaveBeenCalledWith('distrokid', { songwriterFirst: 'Alice', songwriterLast: 'Example', aiLyrics: true, explicit: true });
unmount();
render(<PublishPostingPanel project={project()} publishing={hook()} />);
expect(within(row('Spotify (via DistroKid)')).getByLabelText('Songwriter legal first name')).toHaveValue('Alice');
@@ -80,12 +80,16 @@ describe('PublishPostingPanel (#9282)', () => {
fireEvent.change(within(dk).getByLabelText('Language'), { target: { value: 'Spanish' } });
fireEvent.click(within(dk).getByLabelText('First release as this artist (new store profiles)'));
fireEvent.click(within(dk).getByRole('button', { name: 'Fill draft' }));
- expect(publishing.prepare).toHaveBeenCalledWith('distrokid', expect.objectContaining({ genre: 'Rock', language: 'Spanish', newArtistProfile: false }));
+ expect(publishing.prepare).toHaveBeenCalledWith('distrokid', expect.objectContaining({ genre: 'Rock', language: 'Spanish', newArtistProfile: true }));
unmount();
- render(<PublishPostingPanel project={project()} publishing={hook()} />);
+ const later = hook({ platforms: { distrokid: { enabled: true, account: 'Example Artist' } } });
+ render(<PublishPostingPanel project={project()} publishing={later} />);
const again = row('Spotify (via DistroKid)');
expect(within(again).getByLabelText('Language')).toHaveValue('Spanish');
+ // New store profiles are asked per release, never carried to the next one.
expect(within(again).getByLabelText('First release as this artist (new store profiles)')).not.toBeChecked();
+ fireEvent.click(within(again).getByRole('button', { name: 'Fill draft' }));
+ expect(later.prepare.mock.calls[0][1]).not.toHaveProperty('newArtistProfile');
expect(within(again).getByLabelText('Genre')).toHaveValue('');
});
diff --git a/client/src/lib/distrokidForm.test.js b/client/src/lib/distrokidForm.test.js
index 7628cae714..b229312986 100644
--- a/client/src/lib/distrokidForm.test.js
+++ b/client/src/lib/distrokidForm.test.js
@@ -26,7 +26,7 @@ const FORM = `
<select><option>Music</option><option>Lyrics</option><option>Music and lyrics</option></select>
<input name="songwriter_real_name_first1"><input name="songwriter_real_name_last1">
</div>
- <div class="preview">${radios('previewStart_1', ['no', 'yes'])}<select>${options(range(10))}</select><select>${options(range(60))}</select></div>
+ <div class="preview">${radios('previewStart_1', ['no', 'yes'])}<select><option value=""></option>${options(range(10))}</select><select>${options(range(60))}</select></div>
<select id="track-1-performer-1-role">${options(['', 'Vocals', 'Synthesizer'])}</select><input id="track-1-performer-1-name">
<select id="track-1-producer-1-role">${options(['', 'Producer', 'Mixing Engineer'])}</select><input id="track-1-producer-1-name">
${radios('ai_gate_cd34', ['0', '1'])}
@@ -93,7 +93,25 @@ describe('DistroKid form recipe', () => {
});
it('leaves no paid extra ticked, and names the ones it unticked', () => {
- expect(untickDistrokidExtras()).toEqual(['Social Media Pack', 'Leave a Legacy']);
+ expect(untickDistrokidExtras()).toEqual({ unticked: ['Social Media Pack', 'Leave a Legacy'], stillTicked: [] });
expect(document.querySelectorAll('input[name=extras]:checked')).toHaveLength(0);
});
+
+ it('reports a paid extra whose untick did not take', () => {
+ $('input[value=legacy]').addEventListener('click', (e) => e.preventDefault());
+ expect(untickDistrokidExtras()).toEqual({ unticked: ['Social Media Pack'], stillTicked: ['Leave a Legacy'] });
+ });
+
+ it('starts the preview at minute 0 on the real option, not the blank placeholder', () => {
+ fillDistrokidFields({ ...PLAN, previewStart: { min: 0, sec: 42 } });
+ const [min, sec] = document.querySelectorAll('.preview select');
+ expect([min.selectedIndex, min.value, sec.value]).toEqual([1, '0', '42']);
+ });
+
+ it('leaves a store-profile question DistroKid hid for the director', () => {
+ document.querySelectorAll('input[name=spotifyArtistID]').forEach((r) => r.closest('label').setAttribute('hidden', ''));
+ const { missed } = fillDistrokidFields(PLAN);
+ expect(missed).toEqual(['store profiles: new on all five']);
+ expect(document.querySelector('input[name=spotifyArtistID]:checked')).toBeNull();
+ });
});
diff --git a/server/lib/distrokidForm.js b/server/lib/distrokidForm.js
index f45c43b9f5..42a3eacd47 100644
--- a/server/lib/distrokidForm.js
+++ b/server/lib/distrokidForm.js
@@ -29,9 +29,10 @@ export function fillDistrokidFields(plan) {
el.dispatchEvent(new Event('input', { bubbles: true }));
el.dispatchEvent(new Event('change', { bubbles: true }));
};
+ // Only a shown variant is answered: a question DistroKid hid (an artist it
+ // already knows) is not answered behind the director's back.
const radio = (selector, value) => {
- const all = [...document.querySelectorAll(selector)].filter((r) => r.value === value);
- const pick = all.find(shown) || all[0];
+ const pick = [...document.querySelectorAll(selector)].filter((r) => r.value === value).find(shown);
if (!pick) return false;
if (!pick.checked) pick.click();
return true;
@@ -96,7 +97,11 @@ export function fillDistrokidFields(plan) {
if (ok) {
const selects = [...(around(yes, 'select', 2)?.querySelectorAll('select') || [])];
const at = (el, n) => {
- const opt = el && [...el.options].find((o) => Number(o.value || o.textContent) === n);
+ // A blank placeholder is not minute 0.
+ const opt = el && [...el.options].find((o) => {
+ const raw = (o.value || o.textContent).trim();
+ return raw !== '' && Number(raw) === n;
+ });
if (!opt) return false;
el.value = opt.value;
fire(el);
@@ -160,12 +165,17 @@ export function discloseDistrokidAi({ step, ai }) {
&& audio;
}
-/** Untick every paid extra (they share name=extras). Resolves the labels of the ones that were ticked. */
+/**
+ * Untick every paid extra (they share name=extras). Resolves `{ unticked,
+ * stillTicked }`: the labels of the ones it unticked, and of any whose click
+ * did not take (a handler or a confirm blocked it).
+ */
export function untickDistrokidExtras() {
- return [...document.querySelectorAll('input[name=extras]')]
- .filter((b) => b.checked)
- .map((b) => {
- b.click();
- return (b.closest('label')?.textContent || b.value || '').replace(/\s+/g, ' ').trim().slice(0, 60);
- });
+ const labelOf = (b) => (b.closest('label')?.textContent || b.value || '').replace(/\s+/g, ' ').trim().slice(0, 60);
+ const ticked = [...document.querySelectorAll('input[name=extras]')].filter((b) => b.checked);
+ for (const b of ticked) b.click();
+ return {
+ unticked: ticked.filter((b) => !b.checked).map(labelOf),
+ stillTicked: ticked.filter((b) => b.checked).map(labelOf),
+ };
}
diff --git a/server/lib/distrokidGenres.js b/server/lib/distrokidGenres.js
index 7f380e6767..e1a00067cd 100644
--- a/server/lib/distrokidGenres.js
+++ b/server/lib/distrokidGenres.js
@@ -52,7 +52,7 @@ export function suggestDistrokidGenres(project) {
for (const [re, genre] of STYLE_WORDS) {
// A "k-pop" or "j-pop" mention is not also a "pop" one.
for (const m of text.matchAll(re)) {
- if (genre === 'Pop' && /[kj][\s-]?$/i.test(text.slice(Math.max(0, m.index - 2), m.index))) continue;
+ if (genre === 'Pop' && /(?:^|[^a-z])[kj][\s-]?$/i.test(text.slice(Math.max(0, m.index - 3), m.index))) continue;
hits.push({ at: m.index, genre });
break;
}
diff --git a/server/lib/distrokidGenres.test.js b/server/lib/distrokidGenres.test.js
index d9d012dd7e..89151329ad 100644
--- a/server/lib/distrokidGenres.test.js
+++ b/server/lib/distrokidGenres.test.js
@@ -13,6 +13,9 @@ describe('suggestDistrokidGenres', () => {
it('does not read k-pop as pop, and suggests nothing for a song with no style words', () => {
expect(suggestDistrokidGenres(song('k-pop anthem'))).toEqual({ primary: 'K-Pop', secondary: null });
+ // ...but a word that merely ends in k still says pop.
+ expect(suggestDistrokidGenres(song('dark pop, female vocal'))).toEqual({ primary: 'Pop', secondary: null });
+ expect(suggestDistrokidGenres(song('punk pop anthem'))).toEqual({ primary: 'Punk', secondary: 'Pop' });
expect(suggestDistrokidGenres({})).toEqual({ primary: null, secondary: null });
expect(suggestDistrokidGenres(song('slow, sad, whispered'))).toEqual({ primary: null, secondary: null });
});
diff --git a/server/lib/musicVideoValidation.test.js b/server/lib/musicVideoValidation.test.js
new file mode 100644
index 0000000000..c8771ee074
--- /dev/null
+++ b/server/lib/musicVideoValidation.test.js
@@ -0,0 +1,17 @@
+import { describe, it, expect } from 'vitest';
+import { musicVideoPublishPrepareSchema } from './musicVideoValidation.js';
+
+describe('musicVideoPublishPrepareSchema (DistroKid release answers)', () => {
+ const parse = (body) => musicVideoPublishPrepareSchema.safeParse(body);
+
+ it('accepts the release answers the publish panel sends', () => {
+ expect(parse({ genre: 'Electronic', secondaryGenre: 'Pop', language: 'English', songwriterRole: 'both', newArtistProfile: false, preserveCaps: true, performerName: 'Alice Example', performerRole: 'Vocals', producerName: 'Alice Example', previewStartSec: 42 }).success).toBe(true);
+ });
+
+ it('refuses an unknown songwriter role, an out-of-range preview start, and unknown keys', () => {
+ expect(parse({ songwriterRole: 'producer' }).success).toBe(false);
+ expect(parse({ previewStartSec: -1 }).success).toBe(false);
+ expect(parse({ previewStartSec: 3601 }).success).toBe(false);
+ expect(parse({ stores: ['spotify'] }).success).toBe(false);
+ });
+});
diff --git a/server/services/musicVideo/publish/distrokid.js b/server/services/musicVideo/publish/distrokid.js
index f86f9022ac..9396f41506 100644
--- a/server/services/musicVideo/publish/distrokid.js
+++ b/server/services/musicVideo/publish/distrokid.js
@@ -95,8 +95,9 @@ export const distrokidAdapter = {
return page.evaluate(discloseDistrokidAi, { step: 'parts', ai: payload.ai });
});
// Paid extras are the director's call, every time: none stays ticked.
- const unticked = await page.evaluate(untickDistrokidExtras).catch(() => null);
- if (unticked === null) leftForYou.push('check that no paid extras are ticked');
+ const extras = await page.evaluate(untickDistrokidExtras).catch(() => null);
+ if (extras === null) leftForYou.push('check that no paid extras are ticked');
+ else if (extras.stillTicked.length) leftForYou.push(`untick the paid extras: ${extras.stillTicked.join(', ')}`);
await page.evaluate(() => document.querySelector('#js-track-upload-1')?.scrollIntoView({ block: 'center' })).catch(() => {});
const aiParts = [payload.ai.lyrics && 'lyrics', payload.ai.music && 'music', payload.ai.vocals && 'all of the audio'].filter(Boolean);
@@ -111,7 +112,7 @@ export const distrokidAdapter = {
ai: aiParts.length ? aiParts.join(', ') : 'None',
appleCredits: `${payload.credits.performer} (performer), ${payload.credits.producer} (producer)`,
preview: payload.previewStartSec != null ? `from ${clock(payload.previewStartSec)}` : null,
- paidExtras: unticked === null ? null : (unticked.length ? `unticked: ${unticked.join(', ')}` : 'none ticked'),
+ paidExtras: extras === null || extras.stillTicked.length ? null : (extras.unticked.length ? `unticked: ${extras.unticked.join(', ')}` : 'none ticked'),
leftForYou: [...leftForYou, 'which stores (DistroKid picks all by default)', 'the agreement checkboxes', 'Upload'],
};
},
diff --git a/server/services/musicVideo/publish/payloads.js b/server/services/musicVideo/publish/payloads.js
index 1f627ccc61..805722cb6b 100644
--- a/server/services/musicVideo/publish/payloads.js
+++ b/server/services/musicVideo/publish/payloads.js
@@ -194,7 +194,10 @@ const BUILDERS = {
const secondary = text(options.secondaryGenre) || suggested.secondary;
const fullName = `${songwriter.first} ${songwriter.last}`;
// The store preview (and TikTok clip) opens on the song's strongest hook.
- const previewStartSec = Number.isFinite(options.previewStartSec) ? options.previewStartSec : (suggestSocialCuts(project, { count: 1 })[0]?.startSec ?? null);
+ // A pick at 0:00 (no hook signal, or a song too short to choose) says
+ // nothing DistroKid's own default doesn't, so the question stays untouched.
+ const hookSec = suggestSocialCuts(project, { count: 1 })[0]?.startSec;
+ const previewStartSec = Number.isFinite(options.previewStartSec) ? options.previewStartSec : (hookSec > 0 ? hookSec : null);
return {
title, artist, songwriter, releaseDate: releaseDate || null,
songwriterRole: options.songwriterRole || (instrumental ? 'music' : 'both'),
diff --git a/server/services/musicVideo/publish/payloads.test.js b/server/services/musicVideo/publish/payloads.test.js
index 7c12f2c256..907e0a976e 100644
--- a/server/services/musicVideo/publish/payloads.test.js
+++ b/server/services/musicVideo/publish/payloads.test.js
@@ -134,7 +134,7 @@ describe('buildPublishPayload (#9282)', () => {
title: 'Song', artist: 'Example Artist', explicit: false, instrumental: false, releaseDate: null,
ai: { lyrics: false, music: true, vocals: true }, cover: { name: 'thumb-1.jpg' },
songwriterRole: 'both', language: 'English', genre: null, secondaryGenre: null, newArtistProfile: false, preserveCaps: false,
- credits: { performer: 'Alice Example', producer: 'Alice Example', performerRole: null }, previewStartSec: 0,
+ credits: { performer: 'Alice Example', producer: 'Alice Example', performerRole: null }, previewStartSec: null,
});
// Genre comes from the song's own style words; the director's picks win, and the preview opens on the hook.
const styled = song({ autonomousRun: { output: { sunoStyle: 'dark synthwave, pop hooks, female vocal' } } });