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: Music Video Review reopens when the final render goes stale, and Publish needs every enabled platform posted (#10143)
Adam Eivy2d9482ec29fa
diff --git a/client/src/components/musicVideo/RenderStatusPanel.jsx b/client/src/components/musicVideo/RenderStatusPanel.jsxindex 4c4ba6df53..36b2df0221 100644--- a/client/src/components/musicVideo/RenderStatusPanel.jsx+++ b/client/src/components/musicVideo/RenderStatusPanel.jsx@@ -1,6 +1,7 @@import Banner from '../ui/Banner.jsx';import { useRef } from 'react';-import { Film, Download, Maximize2 } from 'lucide-react';+import { Film, Download, Maximize2, AlertTriangle } from 'lucide-react';+import { STALE_RENDER_MESSAGE } from '../../lib/musicVideoStages.js';// The final-render surface: a progress bar while the assemble job runs, and the// finished MP4 (inline player + download + Media History deep link) once the@@ -16,7 +17,7 @@ import { Film, Download, Maximize2 } from 'lucide-react';// Media History →" stays — it goes to the full history grid, not the same-page// lightbox.export default function RenderStatusPanel({- rendering, progress, renderHistoryId, finalVideo, onOpenPreview,+ rendering, progress, renderHistoryId, finalVideo, onOpenPreview, stale = false,}) {const playerRef = useRef(null);if (rendering) {@@ -31,10 +32,10 @@ export default function RenderStatusPanel({}if (!renderHistoryId) return null;return (- <div className="mt-3 border border-port-success/40 bg-port-success/5 rounded-lg p-3 space-y-2">+ <div className={`mt-3 border rounded-lg p-3 space-y-2 ${stale ? 'border-port-warning/40 bg-port-warning/5' : 'border-port-success/40 bg-port-success/5'}`}><div className="flex flex-wrap items-center justify-between gap-2"><span className="text-sm font-medium flex items-center gap-1.5">- <Film size={15} className="text-port-success" /> Final music video+ <Film size={15} className={stale ? 'text-port-warning' : 'text-port-success'} /> Final music video</span><div className="flex items-center gap-2 text-xs">{finalVideo?.src && (@@ -50,6 +51,11 @@ export default function RenderStatusPanel({className="text-port-accent">Open in Media History →</a></div></div>+ {stale && (+ <p role="status" className="text-xs text-port-warning flex items-center gap-1.5">+ <AlertTriangle size={13} /> {STALE_RENDER_MESSAGE}+ </p>+ )}{finalVideo?.resolving && <p className="text-xs text-port-text-muted">Loading final video…</p>}{finalVideo?.src && (// aspect-video reserves the box before the video's intrinsic dimensionsdiff --git a/client/src/components/musicVideo/RenderStatusPanel.test.jsx b/client/src/components/musicVideo/RenderStatusPanel.test.jsxindex 895a334e9d..ab26bc03b7 100644--- a/client/src/components/musicVideo/RenderStatusPanel.test.jsx+++ b/client/src/components/musicVideo/RenderStatusPanel.test.jsx@@ -1,6 +1,6 @@import { afterEach, expect, it } from 'vitest';import { cleanup, render, screen } from '@testing-library/react';-import { RenderFailure } from './RenderStatusPanel.jsx';+import RenderStatusPanel, { RenderFailure } from './RenderStatusPanel.jsx';afterEach(cleanup);it('keeps a persisted render failure visible after reload and isolates another project’s SSE failure', () => {@@ -13,3 +13,10 @@ it('keeps a persisted render failure visible after reload and isolates another prerender(<RenderFailure project={{ ...project, status: 'complete', renderError: null }} renderJob={{}} />);expect(screen.queryByRole('alert')).not.toBeInTheDocument();});++it('shows an amber out-of-date notice only when the final render is stale (#10143)', () => {+ const { rerender } = render(<RenderStatusPanel renderHistoryId="rh-1" stale />);+ expect(screen.getByRole('status')).toHaveTextContent('Final render is out of date — re-render');+ rerender(<RenderStatusPanel renderHistoryId="rh-1" />);+ expect(screen.queryByRole('status')).not.toBeInTheDocument();+});diff --git a/client/src/components/musicVideo/stages/ReviewStage.jsx b/client/src/components/musicVideo/stages/ReviewStage.jsxindex a48e3bb38a..63b4f7b538 100644--- a/client/src/components/musicVideo/stages/ReviewStage.jsx+++ b/client/src/components/musicVideo/stages/ReviewStage.jsx@@ -4,6 +4,7 @@ import ExcerptPanel from '../ExcerptPanel.jsx';import DevArtifactsPanel from '../DevArtifactsPanel.jsx';import HandoffControls from '../HandoffControls.jsx';import StageSection from '../StageSection.jsx';+import { isFinalRenderStale } from '../../../lib/musicVideoStages.js';import { RenderFinalButton } from '../ProjectActionGroups.jsx';/**@@ -28,6 +29,7 @@ export default function ReviewStage({ board }) {rendering={renderBound}progress={renderJob.progress}renderHistoryId={project.renderHistoryId}+ stale={isFinalRenderStale(project)}finalVideo={finalVideo}onOpenPreview={board.openPreview}/>diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.jsindex 45989b497b..6a3f35c857 100644--- a/client/src/lib/musicVideoStages.js+++ b/client/src/lib/musicVideoStages.js@@ -174,12 +174,34 @@ export function describeProjectStatus(project, { progress, nextAction = null, reconst showApprovals = progress.current !== 'setup' || (project.scenes || []).length > 0;if (approvals && showApprovals) facts.push({ id: 'approvals', label: `Approvals: ${approvals}`, tone: readiness.readyForProduction ? 'ok' : 'warn' });const drafts = (project.excerpts || []).filter((e) => e.status === 'complete' && e.filename).length;- if (project.renderHistoryId) facts.push({ id: 'render', label: 'Final render ready', tone: 'ok' });+ if (isFinalRenderStale(project)) facts.push({ id: 'render', label: STALE_RENDER_MESSAGE, tone: 'warn' });+ else if (project.renderHistoryId) facts.push({ id: 'render', label: 'Final render ready', tone: 'ok' });else if (drafts) facts.push({ id: 'render', label: `${drafts} draft ${drafts === 1 ? 'excerpt' : 'excerpts'}, no final render`, tone: 'muted' });else facts.push({ id: 'render', label: 'Nothing rendered yet', tone: 'muted' });return { headline, tone: activeEvidence ? 'muted' : allDone ? 'ok' : needsYou ? 'warn' : 'muted', facts };}+export const STALE_RENDER_MESSAGE = 'Final render is out of date — re-render';++/** The server's dependency projection says scenes changed after the final render was made. */+export const isFinalRenderStale = (project) => !!project?.renderHistoryId && project.renderDependencyState?.status === 'stale';++/**+ * Publish progress per enabled platform. `publish.targets` is the director's+ * enabled `[{ target, label }]` list (machine-level settings, so the caller+ * supplies it) and `publish.drafts` the drafts filled this session. With no+ * platform enabled there is nothing to count per platform, so any one recorded+ * post still counts as published.+ */+export function publishPlatformProgress(project, publish = {}) {+ const posts = project?.publishKit?.posts || {};+ const rows = (publish.targets || []).map(({ target, label }) => ({+ target, label, state: posts[target] ? 'posted' : publish.drafts?.[target] ? 'draft' : 'none',+ }));+ const posted = rows.length ? rows.filter((row) => row.state === 'posted').length : Object.keys(posts).length;+ return { rows, posted, total: rows.length, done: rows.length ? posted === rows.length : posted > 0 };+}+/** Resolve the `:stage` route param; an unknown or missing value is null. */export const resolveStageParam = (value) => (isStageId(value) ? value : null);@@ -207,7 +229,7 @@ const composeDone = (project, mode) => {* `todo` — plus `current`, the first stage that is not done. A live production* run owns the project, so it pins `current` to Produce.*/-export function deriveStages(project, readiness = project?.productionReadiness) {+export function deriveStages(project, readiness = project?.productionReadiness, publish = {}) {const scenes = project?.scenes || [];const mode = project?.composition?.mode || 'concat';const cast = project?.castAndSets || null;@@ -227,9 +249,10 @@ export function deriveStages(project, readiness = project?.productionReadiness)board: planned,produce: produceDone && !!readiness?.proof.approved,compose: !!readiness?.proof.approved && composeDone(project || {}, mode),- review: !!project?.renderHistoryId,- // #9281/#9282: a release is published once any platform post is recorded.- publish: Object.keys(project?.publishKit?.posts || {}).length > 0,+ // A render made before later scene edits no longer counts as the final video.+ review: !!project?.renderHistoryId && !isFinalRenderStale(project),+ // #9281/#9282: published once every enabled platform has a recorded post.+ publish: publishPlatformProgress(project, publish).done,};const blocked = {'cast-sets': castStopped,@@ -258,10 +281,10 @@ export function deriveStages(project, readiness = project?.productionReadiness)export function deriveNextAction(project, {draftActive = false, proofActive = false, renderActive = false, renderProgress = 0, renderPending = false, renderBlockedByOther = false,kickoffRunning = false, kickoffStep = '', kickoffBlockedReason = null,- planning = false, analyzing = false, readiness = project?.productionReadiness,+ planning = false, analyzing = false, readiness = project?.productionReadiness, publish = {},} = {}) {if (!project) return null;- const { current } = deriveStages(project, readiness);+ const { current } = deriveStages(project, readiness, publish);const run = currentProductionRun(project);const cast = project.castAndSets || null;const scenes = project.scenes || [];@@ -342,6 +365,12 @@ export function deriveNextAction(project, {? { 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' };default:+ if (isFinalRenderStale(project)) {+ return {+ id: 'render-final', kind: 'run', label: 'Re-render final video', shortLabel: 'Re-render',+ disabled: renderBlockedByOther, reason: renderBlockedByOther ? 'Wait for the other project render to finish' : undefined,+ };+ }if (project.renderHistoryId) return { id: 'goto-final', kind: 'goto', stage: 'review', anchor: 'mv-final-video', label: 'Watch final video', shortLabel: 'Watch' };return {id: 'render-final', kind: 'run', label: 'Render final video', shortLabel: 'Render',@@ -365,7 +394,7 @@ const APPROVAL_ANCHORS = { art: 'mv-review-art', storyboard: 'mv-review-storyboa* Cast & Sets sheet file does not approve the art direction, so the art item* says so while it is open.*/-export function stageChecklist(stageId, project, readiness = project?.productionReadiness) {+export function stageChecklist(stageId, project, readiness = project?.productionReadiness, publish = {}) {if (!project) return [];const draft = project.productionReview?.draft || {};const scenes = project.scenes || [];@@ -433,12 +462,26 @@ export function stageChecklist(stageId, project, readiness = project?.productionreturn [proof, { id: 'composition', label: 'Nothing to compose for this render style', done: true }];}case 'review':- return [{ id: 'final', label: 'Final video rendered', done: !!project.renderHistoryId }];- case 'publish':- return [- { id: 'kit', label: 'Publishing kit built', done: !!project.publishKit?.builtAt },- { id: 'posted', label: 'Posted to a platform', done: Object.keys(project.publishKit?.posts || {}).length > 0 },+ return [{+ id: 'final', label: 'Final video rendered', done: !!project.renderHistoryId && !isFinalRenderStale(project),+ detail: isFinalRenderStale(project) ? `${STALE_RENDER_MESSAGE}.` : null,+ action: isFinalRenderStale(project) ? { label: 'Re-render', anchor: 'mv-final-video' } : null,+ }];+ case 'publish': {+ const kit = project.publishKit || {};+ const kitCurrent = !!kit.builtAt && (!kit.master?.renderHistoryId || kit.master.renderHistoryId === project.renderHistoryId);+ const progress = publishPlatformProgress(project, publish);+ const items = [+ { id: 'kit', label: 'Kit built from the current render', done: kitCurrent,+ detail: kit.builtAt && !kitCurrent ? 'The final render changed since the kit was built; rebuild it.' : null },+ { id: 'copy', label: 'Copy drafted', done: !!(kit.copyDraftedAt || kit.copy) },];+ if (!progress.rows.length) return [...items, { id: 'posted', label: 'Posted to a platform', done: progress.done }];+ items.push({ id: 'posted', label: `Posted to every enabled platform (${formatCount(progress.posted)} of ${formatCount(progress.total)})`, done: progress.done });+ 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' });+ return items;+ }default:return [];}diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.jsindex 1f42208729..d051f9613d 100644--- a/client/src/lib/musicVideoStages.test.js+++ b/client/src/lib/musicVideoStages.test.js@@ -92,6 +92,35 @@ describe('deriveStages / deriveNextAction', () => {expect(stateOf({ ...finished, publishKit: { posts: { youtube: { url: 'https://example.com/v' } } } }).publish).toBe('done');});+ it('sends a stale final render back to Review with a re-render prompt (#10143)', () => {+ const ready = { audioAnalysis: ANALYSIS, uploadedAudioFilename: 'a.mp3', scenes: [scene()], productionReadiness: APPROVED, renderHistoryId: 'rh-1' };+ const stale = { ...ready, renderDependencyState: { status: 'stale', reasons: ['Selected clip changed'] } };+ expect(deriveStages({ ...ready, renderDependencyState: { status: 'current', reasons: [] } }).current).toBe('publish');+ expect(deriveStages(stale)).toMatchObject({ current: 'review' });+ expect(stateOf(stale).review).toBe('active');+ expect(deriveNextAction(stale)).toMatchObject({ id: 'render-final', label: 'Re-render final video' });+ expect(stageChecklist('review', stale)[0]).toMatchObject({ done: false, detail: 'Final render is out of date — re-render.' });+ expect(describeProjectStatus(stale, { progress: deriveStages(stale) }).facts.find((f) => f.id === 'render'))+ .toMatchObject({ label: 'Final render is out of date — re-render', tone: 'warn' });+ });++ it('counts Publish per enabled platform, done only when each has a post (#10143)', () => {+ const ready = { audioAnalysis: ANALYSIS, uploadedAudioFilename: 'a.mp3', scenes: [scene()], productionReadiness: APPROVED, renderHistoryId: 'rh-1',+ publishKit: { builtAt: '2026-01-01T00:00:00.000Z', master: { renderHistoryId: 'rh-1' }, copyDraftedAt: '2026-01-02T00:00:00.000Z', posts: { youtube: { url: 'https://example.com/v' } } } };+ const targets = [{ target: 'youtube', label: 'YouTube' }, { target: 'x', label: 'X thread' }, { target: 'reddit', label: 'Reddit' }];+ const publish = { targets, drafts: { x: { summary: {} } } };+ expect(deriveStages(ready, undefined, publish).current).toBe('publish');+ expect(stageChecklist('publish', ready, undefined, publish).map((i) => [i.label, i.done])).toEqual([+ ['Kit built from the current render', true], ['Copy drafted', true],+ ['Posted to every enabled platform (1 of 3)', false],+ ['YouTube: posted', true], ['X thread: draft filled', false], ['Reddit: not started', false],+ ]);+ const all = { ...ready, publishKit: { ...ready.publishKit, posts: { youtube: {}, x: {}, reddit: {} } } };+ expect(deriveStages(all, undefined, publish).stages.find((s) => s.id === 'publish').state).toBe('done');+ // A kit built from an older render is not "from the current render".+ expect(stageChecklist('publish', { ...ready, renderHistoryId: 'rh-2' }, undefined, publish)[0].done).toBe(false);+ });+it('derives Produce and Compose for all five render styles (#10139)', () => {const bare = { productionReadiness: APPROVED, id: 'p', trackId: 't1', audioAnalysis: ANALYSIS, scenes: [scene({ referenceImageId: null, videoHistoryId: null })] };const withMode = (composition) => ({ ...bare, composition });diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 3c382a1bba..7f036b3be7 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -72,6 +72,7 @@ import BoardStage from '../components/musicVideo/stages/BoardStage.jsx';import ProduceStage from '../components/musicVideo/stages/ProduceStage.jsx';import ComposeStage from '../components/musicVideo/stages/ComposeStage.jsx';import ReviewStage from '../components/musicVideo/stages/ReviewStage.jsx';+import { PUBLISH_TARGETS } from '../components/musicVideo/PublishPostingPanel.jsx';import PublishStage from '../components/musicVideo/stages/PublishStage.jsx';import { compositionDraft } from '../components/musicVideo/compositionDraft.js';import ContactSheetDrawer from '../components/musicVideo/ContactSheetDrawer.jsx';@@ -190,7 +191,14 @@ export default function MusicVideo() {[projects],);const productionReview = useMusicVideoProductionReview({ project: selected, replaceProject });- const progress = useMemo(() => deriveStages(selected, productionReview.readiness), [selected, productionReview.readiness]);+ // Posting (#9282): fill each platform's post in the PortOS Browser, post on a second press.+ const publishing = useMusicVideoPublishing({ project: selected, replaceProject });+ // Publish counts every platform the director turned on (#9287), not just any one post.+ const publish = {+ targets: PUBLISH_TARGETS.filter((entry) => publishing.enabledTargets?.includes(entry.target)),+ drafts: publishing.drafts,+ };+ const progress = deriveStages(selected, productionReview.readiness, publish);const [openedStage, setOpenedStage] = useState({ id: null, stage: null });if (selected && openedStage.id !== selected.id) setOpenedStage({ id: selected.id, stage: progress.current });const pinnedStage = openedStage.id === selected?.id ? openedStage.stage : null;@@ -259,8 +267,6 @@ export default function MusicVideo() {const excerpts = useMusicVideoExcerpts({ project: selected, replaceProject });// Publishing kit (#9281): release encodes, thumbnails, captions, chapters and copy.const publishKit = useMusicVideoPublishKit({ project: selected, replaceProject });- // Posting (#9282): fill each platform's post in the PortOS Browser, post on a second press.- const publishing = useMusicVideoPublishing({ project: selected, replaceProject });const videoSettings = useMusicVideoModelSettings({ project: selected, onProjectPatch: patchProject });const tempo = useMusicVideoManualTempo({ project: selected, onUpdated: replaceProject });const sceneMedia = useMusicVideoSceneMedia({@@ -886,6 +892,7 @@ export default function MusicVideo() {const autopilotRun = selected?.autonomousRun || null;const nextAction = selected ? deriveNextAction(selected, {readiness: productionReview.readiness,+ publish,renderActive: renderTargetsSelected,draftActive: excerpts.rendering,proofActive: productionReview.proof.active,@@ -1357,7 +1364,7 @@ export default function MusicVideo() {</div>}><StageChecklist- items={stageChecklist(activeStage, selected, productionReview.readiness)}+ items={stageChecklist(activeStage, selected, productionReview.readiness, publish)}onAction={(action) => goToStage(activeStage, action.anchor)}headerAnchor={nextAction?.kind === 'goto' ? nextAction.anchor : null}/>diff --git a/server/lib/musicVideoDependencies.js b/server/lib/musicVideoDependencies.jsindex 2fa3c95bc6..dc98a1367d 100644--- a/server/lib/musicVideoDependencies.js+++ b/server/lib/musicVideoDependencies.js@@ -159,6 +159,7 @@ export function presentMusicVideoDependencies(project) {reasons: [...new Set(changes.map((change) => change.reason))] };};return { ...project,+ // Legacy renders recorded no evidence; leave them unflagged rather than calling them stale....(project.renderHistoryId && project.renderDependencies ? { renderDependencyState: state(project.renderDependencies) } : {}),scenes: (project.scenes || []).map((scene) => ({ ...scene, takes: (scene.takes || []).map((take) => ({ ...take,...(take.dependencies ? { dependencyState: state(take.dependencies) } : {}),diff --git a/server/routes/musicVideoDependencies.test.js b/server/routes/musicVideoDependencies.test.jsindex e282d90d9e..38e5e8f945 100644--- a/server/routes/musicVideoDependencies.test.js+++ b/server/routes/musicVideoDependencies.test.js@@ -114,6 +114,15 @@ describe('public dependency save / repair / review workflow', () => {expect(changed.scenes.map((scene) => scene.videoHistoryId)).toEqual(['clip-a', 'clip-b']);});+ it('marks the final render stale once a scene changes after it was rendered', async () => {+ await projects.mutateProjectRecord(project.id, (current) => ({ project: { ...current, renderHistoryId: 'final-render', renderDependencies: captureMusicVideoEvidence(current) } }));+ expect((await fresh()).renderDependencyState.status).toBe('current');+ await request(app).patch(`${base()}/scenes/a`).send({ shotMode: 'performance', performanceSpeaker: 'Example Singer' });+ const changed = await fresh();+ expect(changed.renderDependencyState.status).toBe('stale');+ expect(changed.renderDependencyState.reasons.length).toBeGreaterThan(0);+ });+it('keeps reused take provenance current when cloning a project', async () => {const clone = await projects.cloneProject(project.id);expect(clone.scenes[0].sceneId).not.toBe('a');