Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: refuse publish drafts built from a stale kit after a re-render (#10146)
Adam Eivyfcf47fa70767
diff --git a/client/src/components/musicVideo/PublishKitPanel.jsx b/client/src/components/musicVideo/PublishKitPanel.jsxindex 8a247a4009..b6a77c2c1a 100644--- a/client/src/components/musicVideo/PublishKitPanel.jsx+++ b/client/src/components/musicVideo/PublishKitPanel.jsx@@ -77,6 +77,7 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })providers, selectedProviderId, selectedModel, availableModels, setSelectedProviderId, setSelectedModel,} = useProviderModels({ allowDefault: true, silent: true });const canBuild = !!project?.renderHistoryId;+ const kitStale = !!kit.builtAt && (kit.master?.renderHistoryId ?? null) !== (project?.renderHistoryId ?? null);const links = {...(/^https?:\/\//.test(youtubeUrl.trim()) ? { youtube: youtubeUrl.trim() } : {}),...(/^https?:\/\//.test(songUrl.trim()) ? { song: songUrl.trim() } : {}),@@ -98,6 +99,9 @@ export default function PublishKitPanel({ project, publishKit, enabledTargets })</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>+ )}{publishKit.building && (<div><div className="h-1.5 bg-port-bg rounded overflow-hidden"><div className="h-full bg-port-accent transition-all" style={{ width: `${publishKit.progress}%` }} /></div>diff --git a/server/services/musicVideo/publish/payloads.js b/server/services/musicVideo/publish/payloads.jsindex c8e714dd29..0d7a318421 100644--- a/server/services/musicVideo/publish/payloads.js+++ b/server/services/musicVideo/publish/payloads.js@@ -11,9 +11,15 @@ const TITLE_LIMITS = { youtube: 100, shorts: 100, reddit: 300, stackerNews: 80 }const DEFAULT_SUBREDDIT = 'aivideo';const missing = (message) => new ServerError(message, { status: 422, code: 'PUBLISH_ASSET_MISSING' });+const stale = () => new ServerError('The publishing kit was built from an earlier render — rebuild the kit before filling this draft', { status: 409, code: 'PUBLISH_KIT_STALE' });const text = (v) => (typeof v === 'string' ? v.trim() : '');const kitOf = (project) => (project?.publishKit && typeof project.publishKit === 'object' ? project.publishKit : {});+/** Refuse a kit whose master came from a different render than the project's current one. */+function requireFreshKit(project, kit) {+ if ((kit.master?.renderHistoryId ?? null) !== (project?.renderHistoryId ?? null)) throw stale();+}+/** The newest finished 9:16 social cut (#9280): what Shorts, TikTok and Reels upload. */function latestVerticalCut(project) {const cuts = (project?.excerpts || []).filter((e) => e?.status === 'complete' && e.aspect === '9:16' && e.filename);@@ -44,6 +50,7 @@ const instagramSafe = (caption) => caption.replace(/@(\w)/g, '$1');const BUILDERS = {youtube: (project, kit) => {if (!kit.master?.filename) throw missing('Build the publishing kit first — it names the final render to upload');+ requireFreshKit(project, kit);return {video: { dir: 'videos', name: kit.master.filename },title: requireTitle('youtube', text(kit.copy?.youtube?.title)),@@ -75,6 +82,7 @@ const BUILDERS = {if (!hook) throw missing('Write the X hook post in the release copy first');const clip = (kit.exports || []).find((e) => e.kind === 'x-1080p')?.filename;if (!clip) throw missing('Build the publishing kit first — the X post carries its 1080p encode');+ requireFreshKit(project, kit);const links = [songUrl(kit, options) ? `The song: ${songUrl(kit, options)}` : '',// X builds a post's link card from its LAST link, so the full video goes last.@@ -104,6 +112,7 @@ const BUILDERS = {let video = null;if (kind === 'video') {if (!kit.master?.filename) throw missing('Build the publishing kit first — a Reddit video post uploads the final render');+ requireFreshKit(project, kit);video = { dir: 'videos', name: kit.master.filename };}const url = kind === 'link' ? (text(options.url) || fullVideoUrl(kit)) : '';diff --git a/server/services/musicVideo/publish/payloads.test.js b/server/services/musicVideo/publish/payloads.test.jsindex 89f0476652..acf55b096f 100644--- a/server/services/musicVideo/publish/payloads.test.js+++ b/server/services/musicVideo/publish/payloads.test.js@@ -35,6 +35,15 @@ describe('buildPublishPayload (#9282)', () => {expect(p.captions).toEqual({ dir: 'videos', name: 'captions.srt' });});+ it('refuses YouTube, X and Reddit video drafts when the kit master is from an earlier render (#10146)', () => {+ const staleProject = () => ({ ...project({ master: { filename: 'master.mp4', renderHistoryId: 'old' } }), renderHistoryId: 'new' });+ for (const platform of ['youtube', 'x', 'reddit']) {+ expect(() => buildPublishPayload(platform, staleProject())).toThrow(expect.objectContaining({ status: 409, code: 'PUBLISH_KIT_STALE' }));+ }+ const fresh = { ...project({ master: { filename: 'master.mp4', renderHistoryId: 'new' } }), renderHistoryId: 'new' };+ expect(buildPublishPayload('youtube', fresh).video.name).toBe('master.mp4');+ });+it('does not repeat chapters the description already has', () => {const p = buildPublishPayload('youtube', project({ copy: { youtube: { title: 't', description: 'x\n0:00 Start\n0:30 Next' } } }));expect(p.description).not.toContain('Chapters');