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 one platform at a time, and confirm before posting anywhere twice

Claude4bcd3a18a61d
diff --git a/client/src/components/musicVideo/PublishPostingPanel.jsx b/client/src/components/musicVideo/PublishPostingPanel.jsx
index d29cf32fe3..35322df0d4 100644
--- a/client/src/components/musicVideo/PublishPostingPanel.jsx
+++ b/client/src/components/musicVideo/PublishPostingPanel.jsx
@@ -3,6 +3,7 @@ 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 { DISTROKID_GENRES, suggestDistrokidGenres } from '../../../../server/lib/distrokidGenres.js';
+import { publishRowAnchor } from '../../lib/musicVideoStages.js';
// Where the release goes, in posting order: the full video first so every
// other post can link to it.
@@ -234,6 +235,7 @@ function TargetRow({ project, kit, entry, publishing }) {
});
const setOption = (key, value) => setOptions((prev) => ({ ...prev, [key]: value }));
const [confirmDiscard, setConfirmDiscard] = useState(false);
+ const [confirmAgain, setConfirmAgain] = useState(false);
const draft = publishing.drafts[target];
const busy = publishing.busy[target];
const error = publishing.errors[target];
@@ -241,9 +243,15 @@ function TargetRow({ project, kit, entry, publishing }) {
const flairs = draft?.summary?.flairs;
const account = publishing.platforms?.[target]?.account;
const clean = Object.fromEntries(Object.entries(options).filter(([, v]) => v !== '' && v != null));
+ const fill = (extra) => {
+ 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, { ...clean, ...extra });
+ };
return (
- <li className="rounded border border-port-border p-2 space-y-2">
+ <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>
@@ -254,15 +262,31 @@ function TargetRow({ project, kit, entry, publishing }) {
</a>
)}
</div>
- <button type="button" onClick={() => {
- 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, 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')}
- </button>
+ {/* Already posted: a second draft would repeat the post, so it takes a confirm (and the server refuses without `again`). */}
+ {posted && !draft ? (
+ confirmAgain ? (
+ <ConfirmButtonPair
+ prompt={`Already posted to ${label}. Fill another draft?`}
+ confirmText="Post again"
+ ariaLabel={`Confirm posting to ${label} again`}
+ confirmAriaLabel={`Confirm posting to ${label} again`}
+ largeTouchTargets
+ busy={!!busy}
+ onConfirm={() => { setConfirmAgain(false); fill({ again: true }); }}
+ onCancel={() => setConfirmAgain(false)}
+ />
+ ) : (
+ <button type="button" onClick={() => setConfirmAgain(true)} disabled={!!busy}
+ 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">
+ {busy === 'prepare' ? 'Filling…' : 'Post again…'}
+ </button>
+ )
+ ) : (
+ <button type="button" onClick={() => fill(posted ? { again: true } : {})} 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')}
+ </button>
+ )}
</div>
{posted
? <PostFeedback key={posted.url || 'post'} idFor={idFor} label={label} post={posted} onSave={(body) => publishing.recordPost(target, body)} />
diff --git a/client/src/components/musicVideo/PublishPostingPanel.test.jsx b/client/src/components/musicVideo/PublishPostingPanel.test.jsx
index 5a84d54ba1..b3696ba770 100644
--- a/client/src/components/musicVideo/PublishPostingPanel.test.jsx
+++ b/client/src/components/musicVideo/PublishPostingPanel.test.jsx
@@ -93,6 +93,20 @@ describe('PublishPostingPanel (#9282)', () => {
expect(within(again).getByLabelText('Genre')).toHaveValue('');
});
+ 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} />);
+ const yt = row('YouTube');
+ expect(within(yt).queryByRole('button', { name: 'Fill draft' })).toBeNull();
+ fireEvent.click(within(yt).getByRole('button', { name: 'Post again…' }));
+ expect(publishing.prepare).not.toHaveBeenCalled();
+ fireEvent.click(within(yt).getByRole('button', { name: 'Confirm posting to YouTube again' }));
+ expect(publishing.prepare).toHaveBeenCalledWith('youtube', { again: true });
+ // A platform not yet posted fills straight away, on its own.
+ fireEvent.click(within(row('TikTok')).getByRole('button', { name: 'Fill draft' }));
+ expect(publishing.prepare).toHaveBeenLastCalledWith('tiktok', {});
+ });
+
it('shows no cut picker when there is only one 9:16 cut', () => {
render(<PublishPostingPanel project={project()} publishing={hook()} />);
expect(within(row('TikTok')).queryByLabelText('Vertical cut to post')).toBeNull();
diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.js
index 64c0104790..c942bca911 100644
--- a/client/src/lib/musicVideoStages.js
+++ b/client/src/lib/musicVideoStages.js
@@ -473,10 +473,15 @@ export function deriveNextAction(project, {
const shortLabel = { document: 'Attach', eidoverse: 'Save', code: 'Generate' }[project.composition?.mode] || 'Type';
return { id: 'goto-compose', kind: 'goto', stage: 'produce', anchor: 'mv-composition', label, shortLabel };
}
- case 'publish':
- return project.publishKit?.builtAt
- ? { id: 'goto-publish', kind: 'goto', stage: 'publish', label: 'Publish the release', shortLabel: 'Publish' }
- : { id: 'goto-publish', kind: 'goto', stage: 'publish', label: 'Build the publishing kit', shortLabel: 'Kit' };
+ case 'publish': {
+ if (!project.publishKit?.builtAt) return { id: 'goto-publish', kind: 'goto', stage: 'publish', label: 'Build the publishing kit', shortLabel: 'Kit' };
+ // One platform at a time, never "publish everything": the next platform
+ // not yet posted, so a click can't repeat a post that already went out.
+ const next = publishPlatformProgress(project, publish).rows.find((row) => row.state !== 'posted');
+ return next
+ ? { id: 'goto-publish', kind: 'goto', stage: 'publish', anchor: publishRowAnchor(next.target), label: `Next: post to ${next.label}`, shortLabel: next.label }
+ : { id: 'goto-publish', kind: 'goto', stage: 'publish', anchor: PUBLISH_ANCHOR, label: 'Open publishing', shortLabel: 'Publish' };
+ }
default:
if (isFinalRenderStale(project)) {
return {
@@ -507,6 +512,8 @@ export function changedFieldsText(changedFields, limit = 4) {
const APPROVAL_ANCHORS = { art: 'mv-review-art', storyboard: 'mv-review-storyboard', proof: 'mv-review-proof' };
const APPROVAL_STAGES = { art: 'cast-sets', storyboard: 'board', proof: 'produce' };
const PUBLISH_ANCHOR = 'mv-publish-kit';
+/** The anchor of one platform's row in the posting panel. */
+export const publishRowAnchor = (target) => `mv-post-${target}`;
// Storyboard readiness problems, grouped by what the user has to go fix. The
// server returns plain sentences; the first matching rule picks the group.
@@ -655,7 +662,12 @@ export function stageChecklist(stageId, project, readiness = project?.production
if (!progress.rows.length) return [...items, { id: 'posted', label: 'Posted to a platform', done: progress.done, action: progress.done ? null : { label: 'Open publishing', anchor: PUBLISH_ANCHOR } }];
items.push({ id: 'posted', label: `Posted to every enabled platform (${formatCount(progress.posted)} of ${formatCount(progress.total)})`, done: progress.done, action: progress.done ? null : { label: 'Open publishing', anchor: PUBLISH_ANCHOR } });
const STATE_LABELS = { posted: 'posted', draft: 'draft filled', none: 'not started' };
- for (const row of progress.rows) items.push({ id: `post-${row.target}`, label: `${row.label}: ${STATE_LABELS[row.state]}`, done: row.state === 'posted', action: row.state === 'posted' ? null : { label: 'Open publishing', anchor: PUBLISH_ANCHOR } });
+ for (const row of progress.rows) {
+ items.push({
+ id: `post-${row.target}`, label: `${row.label}: ${STATE_LABELS[row.state]}`, done: row.state === 'posted',
+ action: row.state === 'posted' ? null : { label: row.state === 'draft' ? 'Finish this post' : 'Post here', anchor: publishRowAnchor(row.target) },
+ });
+ }
return items;
}
default:
diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.js
index c63b8039d4..52c5fc7e25 100644
--- a/client/src/lib/musicVideoStages.test.js
+++ b/client/src/lib/musicVideoStages.test.js
@@ -108,7 +108,12 @@ describe('deriveStages / deriveNextAction', () => {
expect(stateOf(finished)).toEqual({ setup: 'done', 'cast-sets': 'done', board: 'done', produce: 'done', review: 'done', publish: 'active' });
// #9281: a rendered project moves on to the release.
expect(deriveNextAction(finished)).toMatchObject({ id: 'goto-publish', kind: 'goto', stage: 'publish', label: 'Build the publishing kit' });
- expect(deriveNextAction({ ...finished, publishKit: { builtAt: '2026-01-01T00:00:00.000Z' } })).toMatchObject({ label: 'Publish the release' });
+ // With the kit built, the header names one platform at a time: the next one not yet posted.
+ const kitBuilt = { ...finished, publishKit: { builtAt: '2026-01-01T00:00:00.000Z', posts: { youtube: { url: 'https://example.com/v' } } } };
+ const publish = { targets: [{ target: 'youtube', label: 'YouTube' }, { target: 'distrokid', label: 'Spotify (via DistroKid)' }] };
+ expect(deriveNextAction({ ...finished, publishKit: { builtAt: '2026-01-01T00:00:00.000Z' } })).toMatchObject({ label: 'Open publishing', anchor: 'mv-publish-kit' });
+ expect(deriveNextAction(kitBuilt, { publish })).toMatchObject({ label: 'Next: post to Spotify (via DistroKid)', anchor: 'mv-post-distrokid' });
+ expect(stageChecklist('publish', kitBuilt, undefined, publish).find((i) => i.id === 'post-distrokid').action).toEqual({ label: 'Post here', anchor: 'mv-post-distrokid' });
expect(stateOf({ ...finished, publishKit: { posts: { youtube: { url: 'https://example.com/v' } } } }).publish).toBe('done');
});
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index 2f2b355e19..cd0941a2b9 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -732,6 +732,8 @@ export const musicVideoPublishPrepareSchema = z.object({
prompt: kitText(25000),
storyImage: z.string().min(1).max(300),
cutId: z.string().min(1).max(100),
+ // Fill a draft for a platform the release was already posted to.
+ again: z.boolean(),
// DistroKid (the song as a Spotify single): who it is by and the store flags.
artistName: z.string().trim().min(1).max(100),
songwriterFirst: z.string().trim().min(1).max(100),
diff --git a/server/services/musicVideo/publish/index.js b/server/services/musicVideo/publish/index.js
index b9a1e88f09..0bbe31cef8 100644
--- a/server/services/musicVideo/publish/index.js
+++ b/server/services/musicVideo/publish/index.js
@@ -155,6 +155,11 @@ export async function preparePublishDraft(projectId, target, options = {}, deps
assertPlatformEnabled(platforms, target);
const project = await getProject(projectId);
if (!project) throw new ServerError('Project not found', { status: 404, code: 'NOT_FOUND' });
+ // A platform already posted to gets a second draft only when the director says so:
+ // otherwise one stray click is one duplicate post.
+ if (project.publishKit?.posts?.[target] && options.again !== true) {
+ throw new ServerError(`Already posted to ${adapter.label}. Confirm "Post again" to fill another draft`, { status: 409, code: 'PUBLISH_ALREADY_POSTED' });
+ }
let payload = resolveFiles(buildPublishPayload(target, project, withPlatformDefaults(target, options, platforms)));
payload = await withAudio(target, payload, project, deps);
payload = await withCovers(target, payload, deps);
diff --git a/server/services/musicVideo/publish/index.test.js b/server/services/musicVideo/publish/index.test.js
index 4d67d35bed..0e64161d5f 100644
--- a/server/services/musicVideo/publish/index.test.js
+++ b/server/services/musicVideo/publish/index.test.js
@@ -184,6 +184,14 @@ describe('publish drafts (#9282)', () => {
await writeFile(join(PATHS.videos, 'master.mp4'), 'x');
await preparePublishDraft(id, 'youtube', {}, { connect, adapters, platforms });
expect(adapters.youtube.prepare.mock.calls[0][1].video.path).toBe(join(PATHS.videos, 'master.mp4'));
+
+ // Once posted, a second draft (a duplicate post) needs the director's explicit "again".
+ await recordPublishPost(id, 'youtube', { url: 'https://www.youtube.com/watch?v=example' });
+ connect.mockClear();
+ await expect(preparePublishDraft(id, 'youtube', {}, { connect, adapters, platforms })).rejects.toMatchObject({ status: 409, code: 'PUBLISH_ALREADY_POSTED' });
+ expect(connect).not.toHaveBeenCalled();
+ await preparePublishDraft(id, 'youtube', { again: true }, { connect, adapters, platforms });
+ expect(adapters.youtube.prepare).toHaveBeenCalledTimes(2);
});
it('sends the song to DistroKid with its audio, a square store cover, and the account as the artist', async () => {