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

Publish page: mark a platform done without a link, fold finished cards, and name DistroKid by what it does

[._.]/ Adam Eivye291900aaa60
diff --git a/client/src/components/musicVideo/CoverArtPanel.jsx b/client/src/components/musicVideo/CoverArtPanel.jsx
index 16494f34e0..710f91acbb 100644
--- a/client/src/components/musicVideo/CoverArtPanel.jsx
+++ b/client/src/components/musicVideo/CoverArtPanel.jsx
@@ -3,6 +3,7 @@ import { Download, Image as ImageIcon, Images, Sparkles } from 'lucide-react';
import GalleryImagePicker from '../imageGen/GalleryImagePicker';
import useMusicVideoCoverLettering from '../../hooks/useMusicVideoCoverLettering.js';
import CoverLetteringPanel from './CoverLetteringPanel.jsx';
+import PublishCard from './PublishCard.jsx';
const MAX_SOURCES = 24;
@@ -27,7 +28,7 @@ export function coverArtSources(project) {
}
/**
- * Release cover art: the square image Spotify (via DistroKid) and Suno show.
+ * Release cover art: the square image DistroKid sends to the stores and Suno shows.
* Each song has its own design: the lettering and the photo, drafted from the
* song and steered by what the director types. "Restyle" redrafts the
* lettering from that direction (or adjusts it); "Make a new image" asks an
@@ -68,9 +69,9 @@ export default function CoverArtPanel({ project, publishKit }) {
const restyle = () => publishKit.designCover(notes.trim() ? { direction: notes.trim() } : {});
return (
- <section aria-label="Cover art" className="rounded-lg border border-port-border bg-port-card p-3 space-y-2 text-xs">
- <h3 className="text-sm font-medium flex items-center gap-1.5"><ImageIcon size={14} /> Cover art</h3>
- <p className="text-port-text-muted">The square cover Spotify (via DistroKid) and Suno show. Pick an image, and the title and artist are set on it, or use a finished cover as it is.</p>
+ <PublishCard projectId={project?.id} cardId="cover" label="Cover art" icon={ImageIcon}
+ summary={art.filename ? 'Set' : 'Not set yet'} defaultOpen={!art.filename}>
+ <p className="text-port-text-muted">The square cover DistroKid sends to Spotify, Apple Music and the other stores, and Suno shows. Pick an image, and the title and artist are set on it, or use a finished cover as it is.</p>
<div className="flex flex-col sm:flex-row gap-3">
<div className="w-full sm:w-48 shrink-0 space-y-1">
{art.filename ? (
@@ -172,6 +173,6 @@ export default function CoverArtPanel({ project, publishKit }) {
)}
</div>
</div>
- </section>
+ </PublishCard>
);
}
diff --git a/client/src/components/musicVideo/CoverLetteringPanel.test.jsx b/client/src/components/musicVideo/CoverLetteringPanel.test.jsx
index dc419fb274..75a377ce4c 100644
--- a/client/src/components/musicVideo/CoverLetteringPanel.test.jsx
+++ b/client/src/components/musicVideo/CoverLetteringPanel.test.jsx
@@ -21,6 +21,9 @@ vi.mock('../../hooks/useMusicVideoCoverLettering.js', () => ({ default: () => le
import CoverArtPanel from './CoverArtPanel.jsx';
+// The cover card folds once a cover is set; open it so the lettering controls show.
+const openCard = () => { const t = screen.queryByRole('button', { name: /Cover art/, expanded: false }); if (t) fireEvent.click(t); };
+
const project = {
id: 'mv-example',
name: 'Example Song',
@@ -46,6 +49,7 @@ describe('CoverLetteringPanel (inside CoverArtPanel)', () => {
it('previews a control change at once, and saves the whole design only when asked', () => {
const k = kit();
render(<CoverArtPanel project={project} publishKit={k} />);
+ openCard();
expect(preview().innerHTML).not.toContain('stroke=');
expect(screen.getByRole('button', { name: /Set the lettering/ })).toBeDisabled();
@@ -67,6 +71,7 @@ describe('CoverLetteringPanel (inside CoverArtPanel)', () => {
it("offers the artist's uploaded font as a typeface and applies a saved artist style in one click", () => {
const k = kit();
render(<CoverArtPanel project={project} publishKit={k} />);
+ openCard();
const typeface = screen.getByLabelText('Typeface');
expect(within(typeface).getByRole('option', { name: 'Example Font' })).toHaveValue('font:example-font');
fireEvent.change(typeface, { target: { value: 'font:example-font' } });
diff --git a/client/src/components/musicVideo/PromotionPlanPanel.jsx b/client/src/components/musicVideo/PromotionPlanPanel.jsx
index 2c1beb2f33..a4e951e2c1 100644
--- a/client/src/components/musicVideo/PromotionPlanPanel.jsx
+++ b/client/src/components/musicVideo/PromotionPlanPanel.jsx
@@ -5,6 +5,7 @@ import useProviderModels from '../../hooks/useProviderModels.js';
import ProviderModelSelector from '../ProviderModelSelector.jsx';
import { getMusicVideoPromotionPlan, planMusicVideoPromotion } from '../../services/apiMusicVideo.js';
import { formatWeekdayTime } from '../../utils/formatters.js';
+import PublishCard from './PublishCard.jsx';
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';
const DAY_CHOICES = [3, 7, 14];
@@ -53,8 +54,8 @@ export default function PromotionPlanPanel({ project }) {
const idFor = (name) => `mv-promo-${name}`;
return (
- <section aria-label="Promotion plan" className="rounded-lg border border-port-border bg-port-card p-3 space-y-2 text-xs">
- <h3 className="text-sm font-medium flex items-center gap-1.5"><CalendarClock size={14} /> Promotion plan</h3>
+ <PublishCard projectId={projectId} cardId="promotion" label="Promotion plan" icon={CalendarClock}
+ summary={steps?.length ? `${steps.length} step${steps.length === 1 ? '' : 's'}` : ''}>
<p className="text-port-text-muted">Schedules the steps only you can take, with the text ready to paste. Each one shows up in <Link to="/review" className="text-port-accent underline">Actions</Link> and notifies you when it&apos;s time. Planning again replaces the open steps.</p>
<div className="grid gap-2 sm:grid-cols-2">
<label htmlFor={idFor('goal')} className="space-y-1">
@@ -96,6 +97,6 @@ export default function PromotionPlanPanel({ project }) {
))}
</ol>
)}
- </section>
+ </PublishCard>
);
}
diff --git a/client/src/components/musicVideo/PublishCard.jsx b/client/src/components/musicVideo/PublishCard.jsx
new file mode 100644
index 0000000000..9924e7736d
--- /dev/null
+++ b/client/src/components/musicVideo/PublishCard.jsx
@@ -0,0 +1,53 @@
+import { useState } from 'react';
+import { ChevronDown, ChevronRight } from 'lucide-react';
+import { safeReadJsonStorage, safeWriteJsonStorage } from '../../lib/safeStorage.js';
+
+const STORAGE_KEY = 'portos.musicVideo.publishCards';
+
+/** Open/closed choices the director made on this device, per project and card. */
+function rememberedOpen(projectId, cardId) {
+ const saved = safeReadJsonStorage(STORAGE_KEY, {}) || {};
+ const value = saved[projectId]?.[cardId];
+ return typeof value === 'boolean' ? value : null;
+}
+
+function rememberOpen(projectId, cardId, open) {
+ const saved = safeReadJsonStorage(STORAGE_KEY, {}) || {};
+ safeWriteJsonStorage(STORAGE_KEY, { ...saved, [projectId]: { ...(saved[projectId] || {}), [cardId]: open } });
+}
+
+/**
+ * One card on the Publish page that folds to its header, so the director can
+ * get past the finished ones to the step they need. `defaultOpen` is the
+ * card's own sense of whether it still needs attention; a toggle is
+ * remembered on this device per project. `summary` shows beside a folded
+ * title (e.g. "7 of 9 done"). `actions` (a button, say) sit beside the title,
+ * outside the fold toggle.
+ */
+export default function PublishCard({ projectId, cardId, label, icon: Icon, summary = '', defaultOpen = true, actions = null, className = '', children }) {
+ const [open, setOpen] = useState(() => rememberedOpen(projectId, cardId) ?? defaultOpen);
+ const bodyId = `mv-publish-card-${cardId}`;
+ const toggle = () => {
+ const next = !open;
+ setOpen(next);
+ if (projectId) rememberOpen(projectId, cardId, next);
+ };
+ const Chevron = open ? ChevronDown : ChevronRight;
+ return (
+ <section aria-label={label} className={`rounded-lg border border-port-border bg-port-card p-3 space-y-2 text-xs ${className}`.trim()}>
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <h3 className="text-sm font-medium min-w-0 flex-1">
+ <button type="button" aria-expanded={open} aria-controls={open ? bodyId : undefined} onClick={toggle}
+ className="flex w-full items-center gap-1.5 min-h-[44px] sm:min-h-0">
+ <Chevron size={14} className="shrink-0" />
+ {Icon && <Icon size={14} className="shrink-0" />}
+ <span className="shrink-0">{label}</span>
+ {summary && <span className="min-w-0 truncate text-xs font-normal text-port-text-muted">{summary}</span>}
+ </button>
+ </h3>
+ {actions}
+ </div>
+ {open && <div id={bodyId} className="space-y-2">{children}</div>}
+ </section>
+ );
+}
diff --git a/client/src/components/musicVideo/PublishCard.test.jsx b/client/src/components/musicVideo/PublishCard.test.jsx
new file mode 100644
index 0000000000..588d3141f6
--- /dev/null
+++ b/client/src/components/musicVideo/PublishCard.test.jsx
@@ -0,0 +1,42 @@
+import { describe, it, expect, beforeEach } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+import PublishCard from './PublishCard.jsx';
+
+const card = (props = {}) => (
+ <PublishCard projectId="mv-1" cardId="assets" label="Release assets" summary="Built" {...props}>
+ <p>Card body</p>
+ </PublishCard>
+);
+
+describe('PublishCard', () => {
+ beforeEach(() => localStorage.clear());
+
+ it('opens by default and folds to its header with the summary beside it', () => {
+ render(card());
+ const toggle = screen.getByRole('button', { name: /Release assets/ });
+ expect(toggle).toHaveAttribute('aria-expanded', 'true');
+ expect(screen.getByText('Card body')).toBeInTheDocument();
+ fireEvent.click(toggle);
+ expect(toggle).toHaveAttribute('aria-expanded', 'false');
+ expect(screen.queryByText('Card body')).not.toBeInTheDocument();
+ expect(screen.getByText('Built')).toBeInTheDocument();
+ });
+
+ it('starts folded when it needs nothing, and remembers a toggle per project', () => {
+ const { unmount } = render(card({ defaultOpen: false }));
+ expect(screen.queryByText('Card body')).not.toBeInTheDocument();
+ fireEvent.click(screen.getByRole('button', { name: /Release assets/ }));
+ unmount();
+ render(card({ defaultOpen: false }));
+ expect(screen.getByText('Card body')).toBeInTheDocument();
+ // another project keeps its own default
+ render(card({ projectId: 'mv-2', defaultOpen: false }));
+ expect(screen.getAllByText('Card body')).toHaveLength(1);
+ });
+
+ it('keeps header actions outside the fold toggle', () => {
+ render(card({ actions: <button type="button">Rebuild kit</button> }));
+ fireEvent.click(screen.getByRole('button', { name: /Release assets/ }));
+ expect(screen.getByRole('button', { name: 'Rebuild kit' })).toBeInTheDocument();
+ });
+});
diff --git a/client/src/components/musicVideo/PublishKitPanel.jsx b/client/src/components/musicVideo/PublishKitPanel.jsx
index aa697ce812..e186787007 100644
--- a/client/src/components/musicVideo/PublishKitPanel.jsx
+++ b/client/src/components/musicVideo/PublishKitPanel.jsx
@@ -4,6 +4,7 @@ import useProviderModels from '../../hooks/useProviderModels.js';
import ProviderModelSelector from '../ProviderModelSelector.jsx';
import { copyToClipboard } from '../../lib/clipboard.js';
import CoverArtPanel from './CoverArtPanel.jsx';
+import PublishCard from './PublishCard.jsx';
import { formatCount, formatUsd } from '../../utils/formatters.js';
const fmtTime = (sec) => {
@@ -74,6 +75,7 @@ function CopyField({ id, field, initial, onSave, disabled }) {
*/
export default function PublishKitPanel({ project, publishKit, enabledTargets }) {
const kit = project?.publishKit || {};
+ const hasCopy = Object.values(kit.copy || {}).some((fields) => fields && Object.values(fields).some((v) => (Array.isArray(v) ? v.length : !!v)));
// Copy only for where the director posts (#9287); Suno's caption reuses the YouTube description.
const copyFields = enabledTargets
? PUBLISH_FIELDS.filter(({ platform }) => enabledTargets.includes(platform) || (platform === 'youtube' && enabledTargets.includes('suno')))
@@ -122,14 +124,14 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })
return (
<div className="space-y-3">
- <section aria-label="Release assets" className="rounded-lg border border-port-border bg-port-card p-3 space-y-2">
- <div className="flex flex-wrap items-center justify-between gap-2">
- <h3 className="text-sm font-medium flex items-center gap-1.5"><Package size={14} /> Release assets</h3>
+ <PublishCard projectId={project?.id} cardId="assets" label="Release assets" icon={Package}
+ summary={kit.builtAt ? `Built ${new Date(kit.builtAt).toLocaleDateString()}` : 'Not built yet'} defaultOpen={!kit.builtAt}
+ actions={(
<button type="button" disabled={!canBuild || publishKit.building} onClick={publishKit.build}
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">
<Package size={13} /> {kit.builtAt ? 'Rebuild kit' : 'Build publishing kit'}
</button>
- </div>
+ )}>
{!canBuild && <p className="text-xs text-port-text-muted">Render the final video first. The kit is made from it.</p>}
{kitStale && (
<p role="status" className="text-xs text-port-warning">Kit built from an earlier render. Fill draft is refused until you rebuild it. Use Rebuild kit.</p>
@@ -191,12 +193,12 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })
)}
</div>
)}
- </section>
+ </PublishCard>
<CoverArtPanel key={project?.id} project={project} publishKit={publishKit} />
- <section aria-label="Release copy" className="rounded-lg border border-port-border bg-port-card p-3 space-y-2 text-xs">
- <h3 className="text-sm font-medium flex items-center gap-1.5"><Sparkles size={14} /> Release copy</h3>
+ <PublishCard projectId={project?.id} cardId="copy" label="Release copy" icon={Sparkles}
+ summary={hasCopy ? 'Drafted' : 'Not drafted yet'} defaultOpen={!hasCopy}>
<p className="text-port-text-muted">Each post below is exactly what goes out. Write it yourself, or have the writer draft it from your notes, the links and only what you tick under Draft from. Nothing runs until you press Draft.</p>
<div className="space-y-0.5">
<label htmlFor={idFor('notes')} className="text-[11px] text-port-text-muted">Making-of notes (your story, in your words)</label>
@@ -271,7 +273,7 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })
))}
</div>
)}
- </section>
+ </PublishCard>
</div>
);
}
diff --git a/client/src/components/musicVideo/PublishKitPanel.test.jsx b/client/src/components/musicVideo/PublishKitPanel.test.jsx
index 21e8f61ec5..88393505ec 100644
--- a/client/src/components/musicVideo/PublishKitPanel.test.jsx
+++ b/client/src/components/musicVideo/PublishKitPanel.test.jsx
@@ -13,6 +13,9 @@ vi.mock('../../lib/clipboard.js', () => ({ copyToClipboard: vi.fn() }));
import PublishKitPanel from './PublishKitPanel.jsx';
+// Publish cards and platform rows fold when done; open everything so a test sees the whole page.
+const expandAll = () => { for (let b = screen.queryAllByRole('button', { expanded: false }); b.length; b = screen.queryAllByRole('button', { expanded: false })) b.forEach((x) => fireEvent.click(x)); };
+
const hook = (over = {}) => ({
building: false, progress: 0, build: vi.fn(), drafting: false, saving: false,
draftCopy: vi.fn(async () => null), saveCopy: vi.fn(async () => null), selectThumbnail: vi.fn(async () => null),
@@ -30,6 +33,7 @@ describe('PublishKitPanel (#9281)', () => {
it('builds only once there is a final render', () => {
const k = hook();
const { rerender } = render(<PublishKitPanel project={{ id: 'mv-1' }} publishKit={k} />);
+ expandAll();
expect(screen.getByRole('button', { name: /Build publishing kit/ })).toBeDisabled();
rerender(<PublishKitPanel project={{ id: 'mv-1', renderHistoryId: 'rh-1' }} publishKit={k} />);
fireEvent.click(screen.getByRole('button', { name: /Build publishing kit/ }));
@@ -40,6 +44,7 @@ describe('PublishKitPanel (#9281)', () => {
const k = hook();
const project = { id: 'mv-1', name: 'Example Song', renderHistoryId: 'rh-1', lyricCues: [{ text: 'a line', startSec: 1 }, { text: 'untimed' }], productionRuns: [{ usage: { spentUsd: 4.5 } }] };
render(<PublishKitPanel project={project} publishKit={k} />);
+ expandAll();
fireEvent.change(screen.getByLabelText(/Making-of notes/), { target: { value: 'hummed it in the car' } });
fireEvent.change(screen.getByLabelText(/Full video URL/), { target: { value: 'https://example.com/v' } });
fireEvent.change(screen.getByLabelText(/Song URL/), { target: { value: 'not a url' } });
@@ -65,6 +70,7 @@ describe('PublishKitPanel (#9281)', () => {
const k = hook();
const publishKit = { copy: { x: { hook: 'Mine.' } }, copyDraftedAt: '2026-01-01T00:00:00.000Z', copyEditedAt: '2026-01-02T00:00:00.000Z' };
render(<PublishKitPanel project={{ id: 'mv-1', name: 'Example Song', publishKit }} publishKit={k} enabledTargets={['x']} />);
+ expandAll();
fireEvent.click(screen.getByRole('button', { name: /Redraft copy/ }));
expect(k.draftCopy).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole('button', { name: 'Keep mine' }));
@@ -77,6 +83,7 @@ describe('PublishKitPanel (#9281)', () => {
it('cannot tick lyrics or spend the project does not have, and lets you write a post without drafting', () => {
const k = hook();
render(<PublishKitPanel project={{ id: 'mv-1', name: 'Example Song', renderHistoryId: 'rh-1', lyricCues: [{ text: 'untimed' }] }} publishKit={k} enabledTargets={['x']} />);
+ expandAll();
expect(screen.getByLabelText(/Lyrics/)).toBeDisabled();
expect(screen.getByLabelText(/Generation spend/)).toBeDisabled();
const hook_ = screen.getByLabelText('Hook post (no links)');
@@ -88,6 +95,7 @@ describe('PublishKitPanel (#9281)', () => {
it('shows the built kit, saves an edited field on blur and picks a thumbnail', () => {
const k = hook();
render(<PublishKitPanel project={{ id: 'mv-1', renderHistoryId: 'rh-1', publishKit: built }} publishKit={k} />);
+ expandAll();
expect(screen.getByText('X / social 1080p (12 Mbps)')).toBeTruthy();
expect(screen.getByText(/0:00 Opening line/)).toBeTruthy();
const tags = screen.getByLabelText('Tags (comma-separated)');
@@ -102,6 +110,7 @@ describe('PublishKitPanel (#9281)', () => {
const k = hook();
const project = { id: 'mv-1', name: 'Example Song', publishKit: built, castAndSets: { images: { character: { imageId: 'sheet.png' } } } };
const { rerender } = render(<PublishKitPanel project={project} publishKit={k} />);
+ expandAll();
expect(screen.getByText('No cover yet')).toBeTruthy();
fireEvent.change(screen.getByLabelText('Title on the cover'), { target: { value: 'Example Retitle' } });
fireEvent.click(screen.getByRole('button', { name: 'Make the cover from Cast & Sets: character' }));
diff --git a/client/src/components/musicVideo/PublishPlatformsPanel.jsx b/client/src/components/musicVideo/PublishPlatformsPanel.jsx
index 3cfd8a8717..f120b9919d 100644
--- a/client/src/components/musicVideo/PublishPlatformsPanel.jsx
+++ b/client/src/components/musicVideo/PublishPlatformsPanel.jsx
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { Globe } from 'lucide-react';
import { PUBLISH_TARGETS } from './PublishPostingPanel.jsx';
+import PublishCard from './PublishCard.jsx';
function historyLine(h) {
if (!h?.posts) return 'No posts yet';
@@ -25,13 +26,13 @@ function AccountInput({ id, label, initial, placeholder, onSave, disabled }) {
* the platform shows who is signed in. Each row shows how your posts there
* were received, across every project, so you can learn what is worth it.
*/
-export default function PublishPlatformsPanel({ publishing }) {
+export default function PublishPlatformsPanel({ projectId, publishing }) {
const { platforms, history, setPlatform } = publishing;
if (!platforms) return null;
const enabledCount = Object.values(platforms).filter((p) => p?.enabled).length;
return (
- <section aria-label="Where you post" className="rounded-lg border border-port-border bg-port-card p-3 space-y-2 text-xs">
- <h3 className="text-sm font-medium flex items-center gap-1.5"><Globe size={14} /> Where you post</h3>
+ <PublishCard projectId={projectId} cardId="platforms" label="Where you post" icon={Globe}
+ summary={enabledCount ? `${enabledCount} on` : 'None on yet'} defaultOpen={!enabledCount}>
<p className="text-port-text-muted">
{enabledCount ? 'Copy is drafted and posts are offered only for the platforms turned on here.' : 'No platforms yet. Turn on the ones you use; copy and posting cover only those.'}
</p>
@@ -56,6 +57,6 @@ export default function PublishPlatformsPanel({ publishing }) {
);
})}
</ul>
- </section>
+ </PublishCard>
);
}
diff --git a/client/src/components/musicVideo/PublishPlatformsPanel.test.jsx b/client/src/components/musicVideo/PublishPlatformsPanel.test.jsx
index b82d52702a..085362f2a5 100644
--- a/client/src/components/musicVideo/PublishPlatformsPanel.test.jsx
+++ b/client/src/components/musicVideo/PublishPlatformsPanel.test.jsx
@@ -7,6 +7,9 @@ import { render, screen, fireEvent } from '@testing-library/react';
import PublishPlatformsPanel from './PublishPlatformsPanel.jsx';
import PublishKitPanel from './PublishKitPanel.jsx';
+// Publish cards and platform rows fold when done; open everything so a test sees the whole page.
+const expandAll = () => { for (let b = screen.queryAllByRole('button', { expanded: false }); b.length; b = screen.queryAllByRole('button', { expanded: false })) b.forEach((x) => fireEvent.click(x)); };
+
vi.mock('../../hooks/useProviderModels.js', () => ({
default: () => ({ providers: [], selectedProviderId: '', selectedModel: '', availableModels: [], setSelectedProviderId: vi.fn(), setSelectedModel: vi.fn() }),
}));
@@ -22,6 +25,7 @@ describe('PublishPlatformsPanel (#9287)', () => {
it('toggles platforms and saves an account on blur', () => {
const p = publishing();
render(<PublishPlatformsPanel publishing={p} />);
+ expandAll();
const reddit = screen.getByRole('checkbox', { name: 'Reddit' });
expect(reddit).not.toBeChecked();
expect(screen.getByRole('checkbox', { name: 'X thread' })).toBeChecked();
@@ -37,6 +41,7 @@ describe('PublishPlatformsPanel (#9287)', () => {
it('shows what earlier posts taught', () => {
render(<PublishPlatformsPanel publishing={publishing()} />);
+ expandAll();
expect(screen.getByText('2 posts · 2 poor')).toBeInTheDocument();
expect(screen.getByText('Last note: poorly received')).toBeInTheDocument();
expect(screen.getAllByText('No posts yet').length).toBeGreaterThan(0);
@@ -54,6 +59,7 @@ describe('PublishKitPanel copy per platform (#9287)', () => {
it('shows copy only for enabled platforms (YouTube too when Suno is on)', () => {
render(<PublishKitPanel project={project} publishKit={kitHook} enabledTargets={['suno', 'x']} />);
+ expandAll();
expect(screen.getByText('YouTube', { selector: 'legend' })).toBeInTheDocument();
expect(screen.getByText('X', { selector: 'legend' })).toBeInTheDocument();
expect(screen.queryByText('Reddit', { selector: 'legend' })).toBeNull();
@@ -61,6 +67,7 @@ describe('PublishKitPanel copy per platform (#9287)', () => {
it('holds the copy draft until a platform is on', () => {
render(<PublishKitPanel project={project} publishKit={kitHook} enabledTargets={[]} />);
+ expandAll();
expect(screen.getByRole('button', { name: /Redraft copy/ })).toBeDisabled();
});
});
diff --git a/client/src/components/musicVideo/PublishPostingPanel.jsx b/client/src/components/musicVideo/PublishPostingPanel.jsx
index 3f212eb8bf..5077f56b3f 100644
--- a/client/src/components/musicVideo/PublishPostingPanel.jsx
+++ b/client/src/components/musicVideo/PublishPostingPanel.jsx
@@ -1,7 +1,8 @@
import { useState } from 'react';
import ConfirmButtonPair from '../ui/ConfirmButtonPair.jsx';
import { safeReadJsonStorage, safeWriteJsonStorage } from '../../lib/safeStorage.js';
-import { ExternalLink, X as XIcon, LogIn, Link as LinkIcon } from 'lucide-react';
+import { ExternalLink, X as XIcon, LogIn, Link as LinkIcon, Check, ChevronDown, ChevronRight, Undo2 } from 'lucide-react';
+import PublishCard from './PublishCard.jsx';
import { DISTROKID_GENRES, suggestDistrokidGenres } from '../../../../server/lib/distrokidGenres.js';
import { publishRowAnchor } from '../../lib/musicVideoStages.js';
@@ -23,9 +24,9 @@ export const PUBLISH_TARGETS = [
},
{
// `accountPlaceholder` marks an account that is a name, not an @handle.
- target: 'distrokid', label: 'Spotify (via DistroKid)', accountPlaceholder: 'Artist name',
- note: 'The song as a single for Spotify and other stores, with a square cover and the AI disclosure. You tick the agreements and press Upload',
- linkPlaceholder: 'Live on Spotify? Paste the Spotify link',
+ target: 'distrokid', label: 'DistroKid', accountPlaceholder: 'Artist name',
+ note: 'The song as a single to Spotify, Apple Music, YouTube Music and the other stores, with a square cover and the AI disclosure. You tick the agreements and press Upload',
+ linkPlaceholder: 'Release or store link (optional): Mark done works without one',
},
];
@@ -220,8 +221,12 @@ function PostFeedback({ idFor, label, post, onSave }) {
);
}
-/** Record a post made outside PortOS, so its reception can be tracked too. */
-function ManualLink({ idFor, label, placeholder, onSave }) {
+/**
+ * Record a post made outside PortOS, so its reception can be tracked too, or
+ * mark the platform done without a link (a DistroKid upload has none until the
+ * stores go live).
+ */
+function ManualLink({ idFor, label, placeholder, onSave, hideMarkDone = false }) {
const [url, setUrl] = useState('');
const valid = /^https?:\/\/\S+$/.test(url.trim());
return (
@@ -232,10 +237,39 @@ function ManualLink({ idFor, label, placeholder, onSave }) {
className="flex items-center gap-1 border border-port-border disabled:opacity-50 rounded px-2 py-1.5 text-xs min-h-[44px] sm:min-h-0">
<LinkIcon size={12} /> Record
</button>
+ {!hideMarkDone && (
+ <button type="button" aria-label={`Mark ${label} done`} onClick={() => onSave({ posted: true })}
+ className="flex items-center gap-1 border border-port-border rounded px-2 py-1.5 text-xs min-h-[44px] sm:min-h-0">
+ <Check size={12} /> Mark done
+ </button>
+ )}
</div>
);
}
+/** Undo a platform's done mark (PortOS's record only), behind a confirm. */
+function UndoDone({ label, onUndo }) {
+ const [confirm, setConfirm] = useState(false);
+ return confirm ? (
+ <ConfirmButtonPair
+ prompt={`Mark ${label} as not done? The post itself stays up.`}
+ confirmText="Not done"
+ ariaLabel={`Confirm marking ${label} not done`}
+ confirmAriaLabel={`Confirm marking ${label} not done`}
+ largeTouchTargets
+ onConfirm={() => { setConfirm(false); onUndo(); }}
+ onCancel={() => setConfirm(false)}
+ />
+ ) : (
+ <button type="button" onClick={() => setConfirm(true)}
+ className="flex items-center gap-1 border border-port-border rounded px-2 py-1.5 text-xs min-h-[44px] sm:min-h-0">
+ <Undo2 size={12} /> Not done…
+ </button>
+ );
+}
+
+const STATUS = { posted: ['Done', 'text-port-success border-port-success/40'], draft: ['Draft open', 'text-port-warning border-port-warning/40'], none: ['To do', 'text-port-text-muted border-port-border'] };
+
function TargetRow({ project, kit, entry, publishing }) {
const { target, label, note, linkPlaceholder } = entry;
const idFor = (key) => `mv-post-${project.id}-${target}-${key}`;
@@ -257,11 +291,15 @@ function TargetRow({ project, kit, entry, publishing }) {
const [confirmDiscard, setConfirmDiscard] = useState(false);
const [confirmAgain, setConfirmAgain] = useState(false);
const draft = publishing.drafts[target];
+ // A done platform folds to its header so the ones still to do are easy to reach.
+ const [open, setOpen] = useState(() => !kit.posts?.[target]);
const busy = publishing.busy[target];
const error = publishing.errors[target];
const posted = kit.posts?.[target];
const flairs = draft?.summary?.flairs;
const account = publishing.platforms?.[target]?.account;
+ const status = posted ? 'posted' : draft ? 'draft' : 'none';
+ const Chevron = open ? ChevronDown : ChevronRight;
const clean = Object.fromEntries(Object.entries(options).filter(([, v]) => v !== '' && v != null));
const fill = (extra) => {
if (target === 'distrokid' && clean.songwriterFirst && clean.songwriterLast) {
@@ -273,17 +311,27 @@ function TargetRow({ project, kit, entry, publishing }) {
return (
<li id={publishRowAnchor(target)} className="rounded border border-port-border p-2 space-y-2 scroll-mt-4">
<div className="flex flex-wrap items-start justify-between gap-2">
- <div className="min-w-0">
- <div className="text-xs font-medium">{label}{account && <span className="font-normal text-port-text-muted"> as {entry.accountPlaceholder ? '' : '@'}{account}</span>}</div>
- <div className="text-[11px] text-port-text-muted">{note}</div>
+ <div className="min-w-0 flex-1">
+ <h4 className="text-xs font-medium">
+ <button type="button" aria-expanded={open} aria-controls={open ? idFor('body') : undefined} onClick={() => setOpen(!open)}
+ className="flex items-center gap-1 min-h-[44px] sm:min-h-0">
+ <Chevron size={13} className="shrink-0" />
+ <span>{label}{account && <span className="font-normal text-port-text-muted"> as {entry.accountPlaceholder ? '' : '@'}{account}</span>}</span>
+ <span className={`ml-1 shrink-0 rounded border px-1 text-[10px] font-normal ${STATUS[status][1]}`}>{STATUS[status][0]}</span>
+ </button>
+ </h4>
+ {open && <div className="text-[11px] text-port-text-muted">{note}</div>}
{posted?.url && (
<a href={posted.url} target="_blank" rel="noreferrer" className="text-[11px] text-port-accent flex items-center gap-1 break-all">
<ExternalLink size={11} /> Posted {posted.postedAt ? new Date(posted.postedAt).toLocaleDateString() : ''}: {posted.url}
</a>
)}
+ {posted && !posted.url && (
+ <div className="text-[11px] text-port-text-muted flex items-center gap-1"><Check size={11} /> Marked done {posted.postedAt ? new Date(posted.postedAt).toLocaleDateString() : ''}</div>
+ )}
</div>
{/* Already posted: a second draft would repeat the post, so it takes a confirm (and the server refuses without `again`). */}
- {posted && !draft ? (
+ {!open ? null : posted && !draft ? (
confirmAgain ? (
<ConfirmButtonPair
prompt={`Already posted to ${label}. Fill another draft?`}
@@ -308,8 +356,15 @@ function TargetRow({ project, kit, entry, publishing }) {
</button>
)}
</div>
+ {open && <div id={idFor('body')} className="space-y-2">
{posted
- ? <PostFeedback key={posted.url || 'post'} idFor={idFor} label={label} post={posted} onSave={(body) => publishing.recordPost(target, body)} />
+ ? (
+ <>
+ <PostFeedback key={posted.url || 'post'} idFor={idFor} label={label} post={posted} onSave={(body) => publishing.recordPost(target, body)} />
+ {!posted.url && <ManualLink idFor={idFor} label={label} placeholder={linkPlaceholder} onSave={(body) => publishing.recordPost(target, body)} hideMarkDone />}
+ <UndoDone label={label} onUndo={() => publishing.removePost?.(target)} />
+ </>
+ )
: <ManualLink idFor={idFor} label={label} placeholder={linkPlaceholder} onSave={(body) => publishing.recordPost(target, body)} />}
<TargetOptions target={target} kit={kit} project={project} options={options} setOption={setOption} flairs={flairs} idFor={idFor} account={account} />
{error && (
@@ -346,6 +401,7 @@ function TargetRow({ project, kit, entry, publishing }) {
)}
</div>
)}
+ </div>}
</li>
);
}
@@ -360,14 +416,15 @@ export default function PublishPostingPanel({ project, publishing }) {
if (!kit.builtAt) return null;
// Only the platforms the director turned on (#9287), in posting order.
const targets = PUBLISH_TARGETS.filter((entry) => publishing.enabledTargets?.includes(entry.target));
+ const done = targets.filter(({ target }) => kit.posts?.[target]).length;
return (
- <section aria-label="Post the release" className="rounded-lg border border-port-border bg-port-card p-3 space-y-2 text-xs">
- <h3 className="text-sm font-medium flex items-center gap-1.5"><ExternalLink size={14} /> Publish manually</h3>
+ <PublishCard projectId={project.id} cardId="posting" label="Publish manually" icon={ExternalLink}
+ summary={targets.length ? `${done} of ${targets.length} done` : ''} defaultOpen={!targets.length || done < targets.length}>
<p className="text-port-text-muted">Sign in to each platform in the PortOS Browser first. Fill draft opens a new tab there and fills the post from the kit and copy above; review and publish yourself on the platform. PortOS cannot submit posts.</p>
{!targets.length && <p className="text-port-text-muted">Turn on the platforms you use under Where you post to prepare drafts. Final publication happens on each platform.</p>}
<ul className="space-y-2">
{targets.map((entry) => <TargetRow key={`${project.id}-${entry.target}`} project={project} kit={kit} entry={entry} publishing={publishing} />)}
</ul>
- </section>
+ </PublishCard>
);
}
diff --git a/client/src/components/musicVideo/PublishPostingPanel.test.jsx b/client/src/components/musicVideo/PublishPostingPanel.test.jsx
index 11ae72502b..541aff2178 100644
--- a/client/src/components/musicVideo/PublishPostingPanel.test.jsx
+++ b/client/src/components/musicVideo/PublishPostingPanel.test.jsx
@@ -7,19 +7,24 @@ import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent, within, act } from '@testing-library/react';
import PublishPostingPanel, { PUBLISH_TARGETS } from './PublishPostingPanel.jsx';
+// Publish cards and platform rows fold when done; open everything so a test sees the whole page.
+const expandAll = () => { for (let b = screen.queryAllByRole('button', { expanded: false }); b.length; b = screen.queryAllByRole('button', { expanded: false })) b.forEach((x) => fireEvent.click(x)); };
+
const ALL = ['youtube', 'suno', 'sunoHook', 'x', 'shorts', 'tiktok', 'instagram', 'reddit', 'stackerNews', 'substack', 'distrokid'];
const hook = (over = {}) => ({ drafts: {}, busy: {}, errors: {}, prepare: vi.fn(), submit: vi.fn(), discard: vi.fn(), enabledTargets: ALL, platforms: {}, recordPost: vi.fn(async () => null), ...over });
const project = (kit = {}) => ({ id: 'mv-1', publishKit: { builtAt: '2026-01-01T00:00:00.000Z', thumbnails: ['t1.jpg'], ...kit } });
-const row = (label) => screen.getByText(label, { selector: 'div' }).closest('li');
+const row = (label) => screen.getAllByRole('listitem').find((li) => li.querySelector('h4 button > span')?.firstChild?.textContent === label);
describe('PublishPostingPanel (#9282)', () => {
it('stays hidden until the publishing kit is built', () => {
const { container } = render(<PublishPostingPanel project={{ id: 'mv-1', publishKit: {} }} publishing={hook()} />);
+ expandAll();
expect(container).toBeEmptyDOMElement();
});
it('lists every platform, full video first, with recorded posts linked', () => {
render(<PublishPostingPanel project={project({ posts: { youtube: { url: 'https://youtu.be/abc', postedAt: '2026-01-02T00:00:00.000Z' } } })} publishing={hook()} />);
+ expandAll();
expect(screen.getAllByRole('listitem')).toHaveLength(PUBLISH_TARGETS.length);
expect(PUBLISH_TARGETS[0].target).toBe('youtube');
expect(within(row('YouTube')).getByRole('link')).toHaveAttribute('href', 'https://youtu.be/abc');
@@ -28,6 +33,7 @@ describe('PublishPostingPanel (#9282)', () => {
it('fills a Reddit draft with the subreddit and post type, dropping blanks', () => {
const publishing = hook();
render(<PublishPostingPanel project={project()} publishing={publishing} />);
+ expandAll();
const reddit = row('Reddit');
fireEvent.change(within(reddit).getByLabelText('Subreddit'), { target: { value: 'SunoAI' } });
fireEvent.change(within(reddit).getByLabelText('Post type'), { target: { value: 'link' } });
@@ -38,6 +44,7 @@ describe('PublishPostingPanel (#9282)', () => {
it('fills a Substack draft on the publication typed, else the one under Where you post', () => {
const publishing = hook({ platforms: { substack: { enabled: true, account: 'example' } } });
render(<PublishPostingPanel project={project()} publishing={publishing} />);
+ expandAll();
const substack = row('Substack');
expect(within(substack).getByLabelText('Publication')).toHaveAttribute('placeholder', 'example');
fireEvent.click(within(substack).getByRole('button', { name: 'Fill draft' }));
@@ -52,6 +59,7 @@ describe('PublishPostingPanel (#9282)', () => {
const p = { ...project({ master: { renderHistoryId: 'r1' }, exports: [{ kind: 'vertical-9x16', filename: 'v.mp4', startSec: 10, endSec: 40 }] }),
renderHistoryId: 'r1', excerpts: [{ id: 'ex-1', status: 'complete', aspect: '9:16', filename: 'e.mp4', startSec: 60, endSec: 90 }, { id: 'ex-2', status: 'complete', aspect: '16:9', filename: 'w.mp4' }] };
render(<PublishPostingPanel project={p} publishing={publishing} />);
+ expandAll();
const shorts = row('YouTube Shorts');
const select = within(shorts).getByLabelText('Vertical cut to post');
expect(within(select).getAllByRole('option').map((o) => o.value)).toEqual(['', 'ex-1', 'kit-vertical']);
@@ -64,7 +72,8 @@ describe('PublishPostingPanel (#9282)', () => {
const publishing = hook({ platforms: { distrokid: { enabled: true, account: 'Example Artist' } } });
const p = { ...project(), autonomousRun: { output: { lyrics: 'la la' } } };
const { unmount } = render(<PublishPostingPanel project={p} publishing={publishing} />);
- const dk = row('Spotify (via DistroKid)');
+ expandAll();
+ const dk = row('DistroKid');
expect(within(dk).getByLabelText('Artist name')).toHaveAttribute('placeholder', 'Example Artist');
expect(dk).toHaveTextContent('as Example Artist');
expect(dk).not.toHaveTextContent('@Example Artist');
@@ -76,14 +85,16 @@ describe('PublishPostingPanel (#9282)', () => {
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');
+ expandAll();
+ expect(within(row('DistroKid')).getByLabelText('Songwriter legal first name')).toHaveValue('Alice');
});
it('suggests a genre from the song and remembers the once-only DistroKid answers', () => {
const publishing = hook({ platforms: { distrokid: { enabled: true, account: 'Example Artist' } } });
const p = { ...project(), autonomousRun: { output: { sunoStyle: 'dark synthwave, pop hooks' } } };
const { unmount } = render(<PublishPostingPanel project={p} publishing={publishing} />);
- const dk = row('Spotify (via DistroKid)');
+ expandAll();
+ const dk = row('DistroKid');
expect(within(dk).getByLabelText('Genre')).toHaveDisplayValue('Electronic (from the song\'s style)');
expect(within(dk).getByLabelText('Secondary genre (optional)')).toHaveDisplayValue('Pop (from the song\'s style)');
fireEvent.change(within(dk).getByLabelText('Songwriter legal first name'), { target: { value: 'Alice' } });
@@ -96,7 +107,8 @@ describe('PublishPostingPanel (#9282)', () => {
unmount();
const later = hook({ platforms: { distrokid: { enabled: true, account: 'Example Artist' } } });
render(<PublishPostingPanel project={project()} publishing={later} />);
- const again = row('Spotify (via DistroKid)');
+ expandAll();
+ const again = row('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();
@@ -108,6 +120,7 @@ describe('PublishPostingPanel (#9282)', () => {
it('asks before filling a second draft for a platform already posted to', () => {
const publishing = hook();
render(<PublishPostingPanel project={project({ posts: { youtube: { url: 'https://www.youtube.com/watch?v=example' } } })} publishing={publishing} />);
+ expandAll();
const yt = row('YouTube');
expect(within(yt).queryByRole('button', { name: 'Fill draft' })).toBeNull();
fireEvent.click(within(yt).getByRole('button', { name: 'Post again…' }));
@@ -121,12 +134,14 @@ describe('PublishPostingPanel (#9282)', () => {
it('shows no cut picker when there is only one 9:16 cut', () => {
render(<PublishPostingPanel project={project()} publishing={hook()} />);
+ expandAll();
expect(within(row('TikTok')).queryByLabelText('Vertical cut to post')).toBeNull();
});
it('shows the filled draft and requires manual platform publication', () => {
const publishing = hook({ drafts: { stackerNews: { draftId: 'd1', summary: { title: 'Song', territory: 'art' }, screenshot: 'data:image/jpeg;base64,AA' } } });
render(<PublishPostingPanel project={project()} publishing={publishing} />);
+ expandAll();
const sn = row('Stacker News');
expect(within(sn).getByAltText('Stacker News draft as filled')).toBeInTheDocument();
expect(within(sn).getByText('Song')).toBeInTheDocument();
@@ -142,6 +157,7 @@ describe('PublishPostingPanel (#9282)', () => {
it('keeps a sign-in refusal beside its platform', () => {
const publishing = hook({ errors: { tiktok: { message: 'Sign in to TikTok in the PortOS Browser', code: 'PUBLISH_LOGIN_REQUIRED', url: 'https://www.tiktok.com/login' } } });
render(<PublishPostingPanel project={project()} publishing={publishing} />);
+ expandAll();
const alert = within(row('TikTok')).getByRole('alert');
expect(alert).toHaveTextContent('Sign in to TikTok');
expect(alert).toHaveTextContent('https://www.tiktok.com/login');
@@ -149,6 +165,7 @@ describe('PublishPostingPanel (#9282)', () => {
it('offers only the platforms turned on, with the account posted as', () => {
render(<PublishPostingPanel project={project()} publishing={hook({ enabledTargets: ['x', 'youtube'], platforms: { x: { enabled: true, account: 'antic' } } })} />);
+ expandAll();
expect(screen.getAllByRole('listitem')).toHaveLength(2);
expect(screen.queryByText('Reddit', { selector: 'div' })).toBeNull();
expect(screen.getByText('as @antic')).toBeInTheDocument();
@@ -156,6 +173,7 @@ describe('PublishPostingPanel (#9282)', () => {
it('asks for platforms when none are on', () => {
render(<PublishPostingPanel project={project()} publishing={hook({ enabledTargets: [] })} />);
+ expandAll();
expect(screen.getByText(/Turn on the platforms you use/)).toBeInTheDocument();
expect(screen.queryAllByRole('listitem')).toHaveLength(0);
});
@@ -163,6 +181,7 @@ describe('PublishPostingPanel (#9282)', () => {
it('rates a posted post and records a post made by hand', async () => {
const publishing = hook({ enabledTargets: ['youtube', 'x'], recordPost: vi.fn(async () => ({ url: 'saved' })) });
render(<PublishPostingPanel project={project({ posts: { youtube: { url: 'https://youtu.be/abc', reception: 'good' } } })} publishing={publishing} />);
+ expandAll();
const yt = row('YouTube');
expect(within(yt).getByRole('button', { name: 'Good' })).toHaveAttribute('aria-pressed', 'true');
fireEvent.click(within(yt).getByRole('button', { name: 'Poor' }));
@@ -180,4 +199,31 @@ describe('PublishPostingPanel (#9282)', () => {
expect(publishing.recordPost).toHaveBeenCalledWith('x', { url: 'https://x.com/antic/status/1' });
expect(within(x).getByLabelText('Link to a X thread post made by hand')).toHaveValue('');
});
+
+ it('folds a done platform with its status, marks one done without a link, and undoes a mark', async () => {
+ localStorage.clear();
+ const publishing = hook({ enabledTargets: ['youtube', 'distrokid'], recordPost: vi.fn(async () => ({ postedAt: '2026-01-03T00:00:00.000Z' })), removePost: vi.fn(async () => true) });
+ const { unmount } = render(<PublishPostingPanel project={project({ posts: { youtube: { url: 'https://youtu.be/abc', postedAt: '2026-01-02T00:00:00.000Z' } } })} publishing={publishing} />);
+ expect(screen.getByText('1 of 2 done')).toBeInTheDocument();
+ const yt = row('YouTube');
+ expect(within(yt).getByRole('button', { name: /YouTube.*Done/ })).toHaveAttribute('aria-expanded', 'false');
+ expect(within(yt).queryByRole('button', { name: 'Post again…' })).not.toBeInTheDocument();
+ expect(within(yt).getByRole('link')).toHaveAttribute('href', 'https://youtu.be/abc');
+ const dk = row('DistroKid');
+ expect(within(dk).getByRole('button', { name: /DistroKid.*To do/ })).toHaveAttribute('aria-expanded', 'true');
+ await act(async () => { fireEvent.click(within(dk).getByRole('button', { name: 'Mark DistroKid done' })); });
+ expect(publishing.recordPost).toHaveBeenCalledWith('distrokid', { posted: true });
+ unmount();
+
+ render(<PublishPostingPanel project={project({ posts: { distrokid: { postedAt: '2026-01-03T00:00:00.000Z' } } })} publishing={publishing} />);
+ const done = row('DistroKid');
+ expect(within(done).getByText(/Marked done/)).toBeInTheDocument();
+ fireEvent.click(within(done).getByRole('button', { name: /DistroKid.*Done/ }));
+ // a link can still be added later, and the mark undone behind a confirm
+ expect(within(done).getByLabelText('Link to a DistroKid post made by hand')).toBeInTheDocument();
+ expect(within(done).queryByRole('button', { name: 'Mark DistroKid done' })).not.toBeInTheDocument();
+ fireEvent.click(within(done).getByRole('button', { name: 'Not done…' }));
+ fireEvent.click(within(done).getByRole('button', { name: 'Confirm marking DistroKid not done' }));
+ expect(publishing.removePost).toHaveBeenCalledWith('distrokid');
+ });
});
diff --git a/client/src/components/musicVideo/stages/PublishStage.jsx b/client/src/components/musicVideo/stages/PublishStage.jsx
index 8760e3e8b3..7530f62cc6 100644
--- a/client/src/components/musicVideo/stages/PublishStage.jsx
+++ b/client/src/components/musicVideo/stages/PublishStage.jsx
@@ -14,7 +14,7 @@ export default function PublishStage({ board }) {
const { project, locked, publishKit, publishing } = board;
return (
<fieldset id="mv-publish-kit" disabled={locked} className="min-w-0 space-y-3">
- {publishing && <PublishPlatformsPanel publishing={publishing} />}
+ {publishing && <PublishPlatformsPanel projectId={project?.id} publishing={publishing} />}
<PublishKitPanel project={project} publishKit={publishKit} enabledTargets={publishing?.enabledTargets} />
{publishing && <PublishPostingPanel project={project} publishing={publishing} />}
<PromotionPlanPanel project={project} />
diff --git a/client/src/hooks/useMusicVideoPublishing.js b/client/src/hooks/useMusicVideoPublishing.js
index a91fd786be..bc2f5588f0 100644
--- a/client/src/hooks/useMusicVideoPublishing.js
+++ b/client/src/hooks/useMusicVideoPublishing.js
@@ -7,6 +7,7 @@ import {
getMusicVideoPublishPlatforms,
updateMusicVideoPublishPlatforms,
recordMusicVideoPublishPost,
+ removeMusicVideoPublishPost,
} from '../services/apiMusicVideo.js';
const EMPTY_POSTING = { drafts: {}, busy: {}, errors: {} };
@@ -20,7 +21,8 @@ const EMPTY_POSTING = { drafts: {}, busy: {}, errors: {} };
* Platforms are opt-in (#9287): `platforms` is the director's saved choice of
* where they post (with an optional account each), `history` their posts and
* ratings per platform across projects. `recordPost` saves a post made by hand
- * or rates one.
+ * (a link, or `{ posted: true }` to mark it done without one) or rates one;
+ * `removePost` undoes the done mark.
*/
export default function useMusicVideoPublishing({ project, replaceProject } = {}) {
const projectId = project?.id || null;
@@ -108,7 +110,11 @@ export default function useMusicVideoPublishing({ project, replaceProject } = {}
.then((res) => { if (res?.project) replaceProject?.(res.project); loadPlatforms(); return res?.post || null; })
.catch(() => null);
+ const removePost = (target) => removeMusicVideoPublishPost(projectId, target)
+ .then((res) => { if (res?.project) replaceProject?.(res.project); loadPlatforms(); return true; })
+ .catch(() => false);
+
const enabledTargets = Object.entries(platforms || {}).filter(([, p]) => p?.enabled).map(([t]) => t);
- return { drafts, busy, errors, prepare, discard, platforms, history, enabledTargets, setPlatform, recordPost };
+ return { drafts, busy, errors, prepare, discard, platforms, history, enabledTargets, setPlatform, recordPost, removePost };
}
diff --git a/client/src/hooks/useMusicVideoPublishing.test.jsx b/client/src/hooks/useMusicVideoPublishing.test.jsx
index 2600eb93d7..65e4fb90be 100644
--- a/client/src/hooks/useMusicVideoPublishing.test.jsx
+++ b/client/src/hooks/useMusicVideoPublishing.test.jsx
@@ -11,13 +11,16 @@ const api = vi.hoisted(() => ({
getMusicVideoPublishPlatforms: vi.fn(async () => ({ platforms: { youtube: { enabled: true }, reddit: { enabled: true } } })),
updateMusicVideoPublishPlatforms: vi.fn(),
recordMusicVideoPublishPost: vi.fn(),
+ removeMusicVideoPublishPost: vi.fn(),
}));
vi.mock('../services/apiMusicVideo.js', () => api);
vi.mock('../services/socket', () => ({ default: { on: vi.fn(), off: vi.fn() } }));
vi.mock('../components/ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));
const project = (id) => ({ id, publishKit: { builtAt: '2026-01-01T00:00:00.000Z' } });
-const row = (label) => screen.getByText(label, { selector: 'div' }).closest('li');
+// a platform row: its fold toggle names it (label first, then its status)
+const rowLabel = (label) => (_, el) => el?.matches?.('h4 button > span') && el.firstChild?.textContent === label;
+const row = (label) => screen.getByText(rowLabel(label)).closest('li');
const deferred = () => {
let resolve;
let reject;
@@ -39,7 +42,7 @@ describe('music-video publishing project boundary', () => {
it('drops the previous project preview and posting options immediately on selection', async () => {
api.prepareMusicVideoPublishDraft.mockResolvedValue({ draftId: 'draft-a', summary: { title: 'Example A' } });
const view = render(<Posting id="project-a" />);
- await screen.findByText('YouTube', { selector: 'div' });
+ await screen.findByText(rowLabel('YouTube'));
fireEvent.change(within(row('Reddit')).getByLabelText('Subreddit'), { target: { value: 'example-community' } });
await act(async () => { fireEvent.click(within(row('YouTube')).getByRole('button', { name: 'Fill draft' })); });
expect(screen.getByText('Example A')).toBeInTheDocument();
@@ -57,7 +60,7 @@ describe('music-video publishing project boundary', () => {
const second = deferred();
api.prepareMusicVideoPublishDraft.mockReturnValueOnce(first.promise).mockReturnValueOnce(second.promise);
const view = render(<Posting id="project-a" />);
- await screen.findByText('YouTube', { selector: 'div' });
+ await screen.findByText(rowLabel('YouTube'));
fireEvent.click(within(row('YouTube')).getByRole('button', { name: 'Fill draft' }));
view.rerender(<Posting id="project-b" />);
fireEvent.click(within(row('YouTube')).getByRole('button', { name: 'Fill draft' }));
@@ -74,7 +77,7 @@ describe('music-video publishing project boundary', () => {
const first = deferred();
api.prepareMusicVideoPublishDraft.mockReturnValueOnce(first.promise);
const view = render(<Posting id="project-a" />);
- await screen.findByText('YouTube', { selector: 'div' });
+ await screen.findByText(rowLabel('YouTube'));
fireEvent.click(within(row('YouTube')).getByRole('button', { name: 'Fill draft' }));
view.rerender(<Posting id="project-b" />);
view.rerender(<Posting id="project-a" />);
diff --git a/client/src/services/apiMusicVideo.js b/client/src/services/apiMusicVideo.js
index 12cceb9993..378dec64f4 100644
--- a/client/src/services/apiMusicVideo.js
+++ b/client/src/services/apiMusicVideo.js
@@ -295,6 +295,9 @@ export const updateMusicVideoPublishPlatforms = (patch, options = {}) =>
request('/music-video/publish/platforms', { method: 'PUT', body: JSON.stringify(patch || {}), ...options });
export const recordMusicVideoPublishPost = (id, target, body, options = {}) =>
request(`/music-video/${encodeURIComponent(id)}/publish/posts/${encodeURIComponent(target)}`, { method: 'PUT', body: JSON.stringify(body || {}), ...options });
+// Undo a platform's "done" (PortOS's record only) → { project }.
+export const removeMusicVideoPublishPost = (id, target, options = {}) =>
+ request(`/music-video/${encodeURIComponent(id)}/publish/posts/${encodeURIComponent(target)}`, { method: 'DELETE', ...options });
export const musicVideoExcerptRenderEventsUrl = (jobId) =>
`/api/music-video/excerpt/${encodeURIComponent(jobId)}/events`;
export const cancelMusicVideoExcerptRender = (jobId, options = {}) =>
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index d42d7779fb..a9e4a2dec4 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -754,9 +754,11 @@ const publishPlatformEntry = z.object({ enabled: z.boolean(), account: z.string(
export const musicVideoPublishPlatformsPatchSchema = z.object(Object.fromEntries(MUSIC_VIDEO_PUBLISH_TARGETS.map((t) => [t, publishPlatformEntry.optional()]))).strict();
export const musicVideoPublishPostSchema = z.object({
url: publishUrl.nullable(),
+ // Marks the platform done without a link (a DistroKid upload has none until the stores go live).
+ posted: z.literal(true),
reception: z.enum(['good', 'mixed', 'poor']).nullable(),
notes: z.string().max(2000).nullable(),
-}).partial().strict().refine((b) => Object.keys(b).length > 0, { message: 'url, reception or notes is required' });
+}).partial().strict().refine((b) => Object.keys(b).length > 0, { message: 'url, posted, reception or notes is required' });
export const musicVideoPublishPrepareSchema = z.object({
subreddit: z.string().max(40),
kind: z.enum(['self', 'link', 'video']),
diff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.js
index a742505f42..6ff1e4e9f7 100644
--- a/server/routes/musicVideo.js
+++ b/server/routes/musicVideo.js
@@ -131,7 +131,7 @@ import { startExcerptRender, attachExcerptRenderSseClient, cancelExcerptRender }
import { deleteExcerpt, addReviewNote, editReviewNote, deleteReviewNote } from '../services/musicVideo/excerptService.js';
import { suggestSocialCuts } from '../services/musicVideo/socialCuts.js';
import { getActivePublishKitBuild, startPublishKitBuild, attachPublishKitSseClient, cancelPublishKitBuild, draftPublishKitCopy, updatePublishKitCopy, selectPublishKitThumbnail } from '../services/musicVideo/publishKit.js';
-import { preparePublishDraft, discardPublishDraft, listPublishDrafts, recordPublishPost } from '../services/musicVideo/publish/index.js';
+import { preparePublishDraft, discardPublishDraft, listPublishDrafts, recordPublishPost, removePublishPost } from '../services/musicVideo/publish/index.js';
import { getPublishPlatforms, updatePublishPlatforms, publishHistory } from '../services/musicVideo/publish/platforms.js';
import { listArtistStyles, saveArtistStyle, removeArtistStyle } from '../services/musicVideo/publish/artistStyles.js';
import { addCoverFont, coverFontPath, listCoverFonts, MAX_COVER_FONT_BYTES, removeCoverFont } from '../services/musicVideo/coverFonts.js';
@@ -1041,6 +1041,12 @@ router.put('/:id/publish/posts/:target', asyncHandler(async (req, res) => {
res.json(await recordPublishPost(req.params.id, target, input));
}));
+// Undo a platform's "done" (the post record only; nothing on the platform changes).
+router.delete('/:id/publish/posts/:target', asyncHandler(async (req, res) => {
+ const target = validateRequest(musicVideoPublishTargetSchema, req.params.target);
+ res.json(await removePublishPost(req.params.id, target));
+}));
+
router.post('/:id/publish/:target/prepare', asyncHandler(async (req, res) => {
const target = validateRequest(musicVideoPublishTargetSchema, req.params.target);
await requireProductionReviewer(req);
diff --git a/server/services/musicVideo/publish/index.js b/server/services/musicVideo/publish/index.js
index f8d4dab7d3..f78cd3a2cf 100644
--- a/server/services/musicVideo/publish/index.js
+++ b/server/services/musicVideo/publish/index.js
@@ -222,3 +222,14 @@ export async function recordPublishPost(projectId, target, input = {}) {
});
return { project, post: project.publishKit.posts[target] };
}
+
+/** Undo a platform's "done": drop its post record (a mistaken mark, or a post taken down). */
+export async function removePublishPost(projectId, target) {
+ const { project } = await mutateProjectRecord(projectId, (current) => {
+ const kit = current.publishKit && typeof current.publishKit === 'object' ? current.publishKit : {};
+ if (!kit.posts?.[target]) return { project: current };
+ const { [target]: _removed, ...posts } = kit.posts;
+ return { project: { ...current, publishKit: { ...kit, posts } } };
+ });
+ return { project };
+}
diff --git a/server/services/musicVideo/publish/index.test.js b/server/services/musicVideo/publish/index.test.js
index e8b133685d..6fc5bb4d0a 100644
--- a/server/services/musicVideo/publish/index.test.js
+++ b/server/services/musicVideo/publish/index.test.js
@@ -14,7 +14,7 @@ vi.mock('../../../lib/paths.js', async (importOriginal) => makePathsProxy(await
const { PATHS } = await import('../../../lib/paths.js');
const projects = await import('../projects.js');
-const { preparePublishDraft, discardPublishDraft, listPublishDrafts, recordPublishPost } = await import('./index.js');
+const { preparePublishDraft, discardPublishDraft, listPublishDrafts, recordPublishPost, removePublishPost } = await import('./index.js');
const { musicVideoEvents } = await import('../events.js');
const platforms = { stackerNews: { enabled: true, account: null }, youtube: { enabled: true, account: null }, x: { enabled: true, account: 'antic' } };
@@ -185,6 +185,19 @@ describe('publish drafts (#9282)', () => {
expect(rated.project.publishKit.posts.reddit.reception).toBe('poor');
});
+ it('marks a platform done without a link, keeps a link added later, and undoes the mark', async () => {
+ const id = await readyProject();
+ const marked = await recordPublishPost(id, 'distrokid', { posted: true });
+ expect(marked.post.url).toBeUndefined();
+ expect(marked.post.postedAt).toBeTruthy();
+ const linked = await recordPublishPost(id, 'distrokid', { url: 'https://open.spotify.com/track/example' });
+ expect(linked.post).toMatchObject({ url: 'https://open.spotify.com/track/example', postedAt: marked.post.postedAt });
+ const { project } = await removePublishPost(id, 'distrokid');
+ expect(project.publishKit.posts.distrokid).toBeUndefined();
+ // undoing a platform with no record is a no-op
+ await expect(removePublishPost(id, 'distrokid')).resolves.toMatchObject({ project: { id } });
+ });
+
it('resolves release files to paths, and 422s before opening a tab when one is missing', async () => {
const id = await readyProject();
await projects.mutateProjectRecord(id, (current) => ({ project: { ...current, publishKit: { ...current.publishKit, master: { filename: 'master.mp4' }, copy: { youtube: { title: 'Song' } } } } }));
diff --git a/server/services/musicVideo/publish/payloads.js b/server/services/musicVideo/publish/payloads.js
index 44c4004b61..f913e3449a 100644
--- a/server/services/musicVideo/publish/payloads.js
+++ b/server/services/musicVideo/publish/payloads.js
@@ -223,7 +223,7 @@ const BUILDERS = {
// project's source audio; the cover is the kit's cover art, else its thumbnail cut square.
distrokid: (project, kit, options = {}) => {
const title = text(project?.name);
- if (!title) throw missing('Name the project first: it is the song title on Spotify');
+ if (!title) throw missing('Name the project first: it is the song title in the stores');
const artist = text(options.artistName);
if (!artist) throw missing('Give the artist name the song is released under (or set it as the DistroKid account under Where you post)');
const songwriter = { first: text(options.songwriterFirst), last: text(options.songwriterLast) };
diff --git a/server/services/musicVideo/publish/platforms.js b/server/services/musicVideo/publish/platforms.js
index cd9b03d2a2..96aa13ddcc 100644
--- a/server/services/musicVideo/publish/platforms.js
+++ b/server/services/musicVideo/publish/platforms.js
@@ -76,7 +76,7 @@ export function normalizePost(existing = {}, input = {}) {
if ('url' in input) post.url = typeof input.url === 'string' && input.url.trim() ? input.url.trim() : null;
if ('reception' in input) post.reception = RECEPTIONS.includes(input.reception) ? input.reception : null;
if ('notes' in input) post.notes = typeof input.notes === 'string' && input.notes.trim() ? input.notes.trim().slice(0, 2000) : null;
- if (!post.postedAt && post.url) post.postedAt = new Date().toISOString();
+ if (!post.postedAt && (post.url || input.posted === true)) post.postedAt = new Date().toISOString();
if ('reception' in input || 'notes' in input) post.ratedAt = new Date().toISOString();
return post;
}