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
Music Video: let a project finished outside PortOS stop asking for approvals it never had
[._.]/ Adam Eivy8250006e3f47
diff --git a/client/src/components/musicVideo/ProjectOptionsPanel.jsx b/client/src/components/musicVideo/ProjectOptionsPanel.jsxindex 73ff1701ba..4dc592ceff 100644--- a/client/src/components/musicVideo/ProjectOptionsPanel.jsx+++ b/client/src/components/musicVideo/ProjectOptionsPanel.jsx@@ -10,6 +10,8 @@ import { normalizeMusicVideoProductionPolicy } from '../../../../server/lib/musiimport { MUSIC_VIDEO_AUTOMATION_TOOLS, automationDraftFrom, automationFromDraft } from '../../lib/musicVideoAutomation.js';import { musicVideoMediaMode } from '../../../../server/lib/musicVideoMediaPolicy.js';import { formatUsd } from '../../utils/formatters.js';+import { finishedOutside } from '../../../../server/lib/musicVideoFinishedOutside.js';+import { setMusicVideoFinishedOutside } from '../../services/apiMusicVideo.js';const TOOL_GROUPS = [['image', 'Image'], ['video', 'Video'], ['code', 'Code']];const rowCls = 'grid min-w-0 grid-cols-1 gap-1 sm:grid-cols-[9rem_minmax(0,1fr)] sm:items-start sm:gap-3';@@ -22,11 +24,25 @@ const headCls = 'pt-1.5 text-xs font-medium text-port-text-muted';* the media the design may use (code / images / video), the render style, the* image and video services, and, for an autopilot project, the tools the* autopilot may spend on and its Cast & Sets check-in. Every change saves to the- * project through the same paths the Make step's controls use.+ * project through the same paths the Make step's controls use. A project made+ * elsewhere can be marked finished outside PortOS, so Song through Make stop+ * asking for approvals that were never given here (`onProjectUpdated` gets the+ * saved record).*/export default function ProjectOptionsPanel({- project, videoSettings, generatingVideos = false, onMediaMode, onRenderStyle, onSaveAutomation, onSavePolicy,+ project, videoSettings, generatingVideos = false, onMediaMode, onRenderStyle, onSaveAutomation, onSavePolicy, onProjectUpdated,}) {+ const external = finishedOutside(project);+ const [outsideNote, setOutsideNote] = useState('');+ const [outsideSaving, setOutsideSaving] = useState(false);+ const toggleFinishedOutside = () => {+ if (outsideSaving) return;+ setOutsideSaving(true);+ setMusicVideoFinishedOutside(project.id, { finished: !external, note: outsideNote.trim() || undefined })+ .then((next) => { setOutsideNote(''); onProjectUpdated?.(next); })+ .catch(() => {}) // request() already toasted+ .finally(() => setOutsideSaving(false));+ };const [policyError, setPolicyError] = useState('');const [allowanceText, setAllowanceText] = useState(null);const policy = normalizeMusicVideoProductionPolicy(project.productionPolicy);@@ -118,6 +134,34 @@ export default function ProjectOptionsPanel({<VideoRenderSettings videoSettings={videoSettings} generating={generatingVideos} /></div></div>+ <div className={rowCls}>+ <span className={headCls}>Finished outside PortOS</span>+ <div className="flex min-w-0 flex-wrap items-center gap-2">+ <ToggleChip+ id="mv-setup-finished-outside"+ label={external ? 'Marked finished' : 'Mark finished'}+ hint="Song, Look, Storyboard and Make count as done; Final render and Publish still need the real render and posts"+ checked={!!external}+ onToggle={toggleFinishedOutside}+ />+ {!external && (+ <input+ type="text"+ aria-label="Where it was made (optional)"+ placeholder="Where it was made (optional)"+ maxLength={500}+ value={outsideNote}+ onChange={(e) => setOutsideNote(e.target.value)}+ className="min-h-[44px] min-w-0 flex-1 rounded border border-port-border bg-port-bg px-2 py-1.5 text-sm sm:min-h-0"+ />+ )}+ <p className="w-full text-xs text-port-text-muted">+ {external+ ? `Marked ${new Date(external.markedAt).toLocaleDateString()}${external.note ? `: ${external.note}` : ''}. No approval is recorded; unmark to bring the step checks back.`+ : 'For a video made elsewhere: Song through Make count as done without recording approvals. Final render and Publish still need the real render and posts.'}+ </p>+ </div>+ </div>{automation && (<><fieldset className={rowCls} disabled={briefSaving} aria-labelledby="mv-setup-tools-label">diff --git a/client/src/components/musicVideo/ProjectOptionsPanel.test.jsx b/client/src/components/musicVideo/ProjectOptionsPanel.test.jsxindex ac240ca39a..13b4e112e5 100644--- a/client/src/components/musicVideo/ProjectOptionsPanel.test.jsx+++ b/client/src/components/musicVideo/ProjectOptionsPanel.test.jsx@@ -4,10 +4,12 @@ import ProjectOptionsPanel from './ProjectOptionsPanel.jsx';vi.mock('./VideoRenderSettings.jsx', () => ({ default: () => null }));vi.mock('../imageGen/RecordRenderPinRow.jsx', () => ({ default: () => null }));+vi.mock('../../services/apiMusicVideo.js', () => ({ setMusicVideoFinishedOutside: vi.fn() }));+import { setMusicVideoFinishedOutside } from '../../services/apiMusicVideo.js';-const open = (project = {}, onSavePolicy = vi.fn(async () => {})) => {+const open = (project = {}, onSavePolicy = vi.fn(async () => {}), onProjectUpdated = vi.fn()) => {render(<ProjectOptionsPanel project={{ id: 'mv1', ...project }} videoSettings={{ changeFramePin: vi.fn() }}- onMediaMode={vi.fn()} onRenderStyle={vi.fn()} onSaveAutomation={vi.fn()} onSavePolicy={onSavePolicy} />);+ onMediaMode={vi.fn()} onRenderStyle={vi.fn()} onSaveAutomation={vi.fn()} onSavePolicy={onSavePolicy} onProjectUpdated={onProjectUpdated} />);return onSavePolicy;};@@ -35,4 +37,24 @@ describe('ProjectOptionsPanel', () => {expect(await screen.findByRole('alert')).toHaveTextContent('0 to 100%');expect(onSavePolicy).toHaveBeenCalledTimes(1);});++ it('marks a project finished outside PortOS with a note, hands back the saved record, and unmarks it', async () => {+ const saved = { id: 'mv1', finishedOutside: { markedAt: '2026-10-05T00:00:00.000Z', note: 'Studio' } };+ setMusicVideoFinishedOutside.mockResolvedValueOnce(saved);+ const onProjectUpdated = vi.fn();+ open({}, undefined, onProjectUpdated);+ fireEvent.change(screen.getByLabelText('Where it was made (optional)'), { target: { value: ' Studio ' } });+ fireEvent.click(screen.getByLabelText('Mark finished'));+ await waitFor(() => expect(onProjectUpdated).toHaveBeenCalledWith(saved));+ expect(setMusicVideoFinishedOutside).toHaveBeenCalledWith('mv1', { finished: true, note: 'Studio' });+ });++ it('shows an existing marker and clears it', async () => {+ setMusicVideoFinishedOutside.mockResolvedValueOnce({ id: 'mv1', finishedOutside: null });+ open({ finishedOutside: { markedAt: '2026-10-05T12:00:00.000Z', note: 'Studio' } });+ expect(screen.getByText(/: Studio\. No approval is recorded/)).toBeInTheDocument();+ expect(screen.queryByLabelText('Where it was made (optional)')).toBeNull();+ fireEvent.click(screen.getByLabelText('Marked finished'));+ await waitFor(() => expect(setMusicVideoFinishedOutside).toHaveBeenLastCalledWith('mv1', { finished: false, note: undefined }));+ });});diff --git a/client/src/components/musicVideo/ProjectSettingsDrawer.jsx b/client/src/components/musicVideo/ProjectSettingsDrawer.jsxindex 39edbce341..4330eef640 100644--- a/client/src/components/musicVideo/ProjectSettingsDrawer.jsx+++ b/client/src/components/musicVideo/ProjectSettingsDrawer.jsx@@ -51,6 +51,7 @@ export default function ProjectSettingsDrawer({ open, tab, onTabChange, onClose,onRenderStyle={board.onRenderStyle}onSaveAutomation={board.saveAutomation}onSavePolicy={(productionPolicy) => board.saveCreativeSetup({ productionPolicy })}+ onProjectUpdated={board.replaceProject}/>)}{tab === 'audio' && (diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.jsindex 0ca8e0fb6e..a12499bf9c 100644--- a/client/src/lib/musicVideoStages.js+++ b/client/src/lib/musicVideoStages.js@@ -13,6 +13,7 @@ import { isNonBlankStr } from './textUtils';import { modeLabel } from './imageGenModes.js';import { falSceneTake } from './musicVideoShotTiming.js';import { latestMusicVideoReviewDraft } from '../../../server/lib/musicVideoReviewDraft.js';+import { finishedOutside, finishedOutsideCovers } from '../../../server/lib/musicVideoFinishedOutside.js';/*** The six steps of a music video, in the order the director decides them. The@@ -334,13 +335,16 @@ export function deriveStages(project, readiness = project?.productionReadiness,// #9281/#9282: published once every enabled platform has a recorded post.publish: publishPlatformProgress(project, publish).done,};+ // Finished outside PortOS: the steps it made elsewhere count as done, with no approval to go stale.+ const external = !!finishedOutside(project);+ if (external) for (const id of Object.keys(done)) if (finishedOutsideCovers(project, id)) done[id] = true;const blocked = {'cast-sets': castStopped,produce: !!run && RUN_BLOCKED_STATUSES.has(run.status),};// Approved earlier, inputs changed since (#10141): the tab says so rather than// reading as never done. The check-in sheet stays approved while stale.- const stale = {+ const stale = external ? {} : {'cast-sets': !!readiness?.art?.stale || !!readiness?.castAndSets?.stale,board: !!readiness?.storyboard?.stale,produce: !!readiness?.proof?.stale,@@ -395,7 +399,7 @@ export function deriveNextAction(project, {const layered = isLayeredComposition(project);const footageDone = footageOptional || scenes.every((scene) => sceneRenderReady(scene, { layered }));const proofDue = current !== 'produce' || footageDone || (!!run && RESUMABLE_RUN_STATUSES.has(run.status));- if (projectHasAudio(project) && project.audioAnalysis && !CAST_WORKING.has(cast?.status) && !readiness?.readyForProduction && (art || board || proofDue)+ if (!finishedOutside(project) && projectHasAudio(project) && project.audioAnalysis && !CAST_WORKING.has(cast?.status) && !readiness?.readyForProduction && (art || board || proofDue)&& run?.status !== 'running' && !renderActive && !kickoffRunning&& !castNeedsOwnAction && !boardNeedsOwnAction) {return { id: 'review-production', kind: 'goto', stage: art ? 'cast-sets' : board ? 'board' : 'produce',@@ -554,6 +558,11 @@ export function stageChecklist(stageId, project, readiness = project?.productionrevert: !approved && stale && readiness[key].stale.revertible?.length ? { stage: key, fields: readiness[key].stale.revertible } : null,};};+ const external = finishedOutsideCovers(project, stageId) ? finishedOutside(project) : null;+ if (external) {+ return [{ id: 'finished-outside', label: 'Finished outside PortOS', done: true,+ detail: external.note || 'Marked finished in Project settings; no approval is recorded here.' }];+ }switch (stageId) {case 'setup': {// An autonomous run that is still going writes the song itself.diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.jsindex e010aa25be..7df48e91e5 100644--- a/client/src/lib/musicVideoStages.test.js+++ b/client/src/lib/musicVideoStages.test.js@@ -586,6 +586,41 @@ describe('storyboard animatic preview source', () => {});});+describe('finished outside PortOS', () => {+ // A video made elsewhere: rendered and posted, with no approval ever recorded here.+ const external = {+ id: 'p', trackId: 't1', audioAnalysis: ANALYSIS, lyricCues: [{ id: 'l1', text: 'la la' }], automation: { tools: [] },+ scenes: [scene()], composition: { mode: 'document', document: { directory: 'd' } }, renderHistoryId: 'rh-1',+ publishKit: { posts: { youtube: { url: 'https://example.com/v' } } },+ };+ const unapproved = { art: { approved: false, problems: ['x'] }, storyboard: { approved: false, problems: ['x'] }, proof: { approved: false, problems: ['x'] }, alignment: { status: 'provisional' } };+ const marked = { ...external, finishedOutside: { markedAt: '2026-10-05T00:00:00.000Z', note: 'Made elsewhere' } };++ it('without the marker, a published external project reads as stuck on Song', () => {+ expect(deriveStages(external, unapproved).current).toBe('setup');+ expect(deriveNextAction(external, { readiness: unapproved })).toMatchObject({ id: 'review-production' });+ });++ it('counts Song through Make as done, and reads Published once the render and posts are real', () => {+ const progress = deriveStages(marked, unapproved);+ expect(progress.stages.map((s) => [s.id, s.state, s.stale])).toEqual(+ MUSIC_VIDEO_STAGES.map((s) => [s.id, 'done', false]),+ );+ const nextAction = deriveNextAction(marked, { readiness: unapproved });+ expect(nextAction.id).not.toBe('review-production');+ expect(describeProjectStatus(marked, { progress, nextAction })).toMatchObject({ headline: 'Published', needsYouStage: null });+ expect(stageChecklist('board', marked, unapproved)).toEqual([{ id: 'finished-outside', label: 'Finished outside PortOS', done: true, detail: 'Made elsewhere' }]);+ expect(summarizeMusicVideoProject(marked, unapproved).stage).toBe('publish');+ });++ it('still asks for the final render and the posts it never had', () => {+ const unrendered = { ...marked, renderHistoryId: null, publishKit: {} };+ expect(deriveStages(unrendered, unapproved).current).toBe('review');+ expect(summarizeMusicVideoProject(unrendered, unapproved).stage).toBe('review');+ expect(stageChecklist('review', unrendered, unapproved)[0]).toMatchObject({ id: 'final', done: false });+ });+});+describe('server project summary', () => {it('reports the same current step the page derives, for every step', () => {const base = { id: 'p', trackId: 't1', audioAnalysis: ANALYSIS, ...LYRICS };diff --git a/client/src/services/apiMusicVideo.js b/client/src/services/apiMusicVideo.jsindex a67e6d45b3..faf0dd52c8 100644--- a/client/src/services/apiMusicVideo.js+++ b/client/src/services/apiMusicVideo.js@@ -31,6 +31,10 @@ export const cloneMusicVideoProject = (id, data = {}, options = {}) => request(`export const updateMusicVideoProject = (id, patch, options = {}) => request(`/music-video/${encodeURIComponent(id)}`, {method: 'PATCH', body: JSON.stringify(patch), ...options,});+// Mark the project finished outside PortOS (or clear it); returns the presented project.+export const setMusicVideoFinishedOutside = (id, { finished, note } = {}, options = {}) => request(`/music-video/${encodeURIComponent(id)}/finished-outside`, {+ method: 'PUT', body: JSON.stringify({ finished, ...(note ? { note } : {}) }), ...options,+});export const deleteMusicVideoProject = (id, options = {}) => request(`/music-video/${encodeURIComponent(id)}`, {method: 'DELETE', ...options,});diff --git a/server/lib/musicVideoFinishedOutside.js b/server/lib/musicVideoFinishedOutside.jsnew file mode 100644index 0000000000..a8a37a8de6--- /dev/null+++ b/server/lib/musicVideoFinishedOutside.js@@ -0,0 +1,20 @@+/**+ * A project finished outside PortOS: the song, look, storyboard and footage were+ * made elsewhere and only the final video (and its posts) came back in, so the+ * revision-bound approvals those steps gate on were never recorded here.+ *+ * The director says so explicitly (`project.finishedOutside`) instead of PortOS+ * forging review evidence it never saw: the marker counts those four steps as+ * done, while Final render and Publish still read the real render and posts.+ * It records nothing in `productionReview`, so clearing it restores the gates.+ */+export const FINISHED_OUTSIDE_STAGE_IDS = Object.freeze(['setup', 'cast-sets', 'board', 'produce']);++/** The marker (`{ markedAt, note? }`) when the project was finished outside PortOS, else null. */+export const finishedOutside = (project) => {+ const marker = project?.finishedOutside;+ return marker && typeof marker.markedAt === 'string' && marker.markedAt ? marker : null;+};++/** Whether the marker covers `stageId`. */+export const finishedOutsideCovers = (project, stageId) => !!finishedOutside(project) && FINISHED_OUTSIDE_STAGE_IDS.includes(stageId);diff --git a/server/lib/musicVideoSummary.js b/server/lib/musicVideoSummary.jsindex f0db4b868d..5989b109c8 100644--- a/server/lib/musicVideoSummary.js+++ b/server/lib/musicVideoSummary.js@@ -9,6 +9,7 @@*/import { isLayeredComposition, sceneRenderReady } from './musicVideoLayers.js';import { latestMusicVideoReviewDraft } from './musicVideoReviewDraft.js';+import { finishedOutsideCovers } from './musicVideoFinishedOutside.js';// The six steps (Song, Look, Storyboard, Make, Final render, Publish); Make (`produce`) absorbed Compose.const STAGE_IDS = ['setup', 'cast-sets', 'board', 'produce', 'review', 'publish'];@@ -80,7 +81,8 @@ function currentStage(project, readiness, run) {review: Boolean(project.renderHistoryId) && project.renderDependencyState?.status !== 'stale',publish: Object.keys(project.publishKit?.posts || {}).length > 0,};- return STAGE_IDS.find((id) => !done[id]) || 'publish';+ // Finished outside PortOS — mirrors the client's deriveStages.+ return STAGE_IDS.find((id) => !done[id] && !finishedOutsideCovers(project, id)) || 'publish';}function projectPreview(project) {diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.jsindex bbeee290a2..bce9e493fa 100644--- a/server/lib/musicVideoValidation.js+++ b/server/lib/musicVideoValidation.js@@ -1080,6 +1080,13 @@ export const musicVideoProjectUpdateSchema = z.object({soundBed: musicVideoSoundBedSchema.nullable().optional(),}).strict();+// Mark a project finished outside PortOS (or clear the marker). The server+// stamps `markedAt`; the note says where it was made (musicVideoFinishedOutside.js).+export const musicVideoFinishedOutsideSchema = z.object({+ finished: z.boolean(),+ note: z.string().trim().max(500).optional(),+}).strict();+// Fork a project into its next editable version. The server derives lineage and// version numbers from the source; callers may only override the display name// and choose whether generated scene media should remain attached. A videodiff --git a/server/routes/musicVideo.js b/server/routes/musicVideo.jsindex 8d8ab373b1..44961ca6d9 100644--- a/server/routes/musicVideo.js+++ b/server/routes/musicVideo.js@@ -12,7 +12,7 @@ import { existsSync } from 'fs';import { unlink } from 'fs/promises';import { pipeline } from 'stream/promises';import { Router } from 'express';-import { musicVideoProjectListQuerySchema, musicVideoProductionDraftSchema, musicVideoProductionApprovalSchema, musicVideoProductionProofSchema, musicVideoProductionImportSchema, musicVideoProductionFeedbackSchema, musicVideoProductionFeedbackResolutionSchema, musicVideoProductionReviseSchema, musicVideoProductionRevertSchema } from '../lib/musicVideoValidation.js';+import { musicVideoProjectListQuerySchema, musicVideoFinishedOutsideSchema, musicVideoProductionDraftSchema, musicVideoProductionApprovalSchema, musicVideoProductionProofSchema, musicVideoProductionImportSchema, musicVideoProductionFeedbackSchema, musicVideoProductionFeedbackResolutionSchema, musicVideoProductionReviseSchema, musicVideoProductionRevertSchema } from '../lib/musicVideoValidation.js';import { productionReadiness } from '../services/musicVideo/productionReview.js';import { getProductionReview, saveProductionDraft, prepareProductionReview, approveProductionReview, renderProductionProof, requireProductionReviewer, importProductionPlanning, bindProductionShot, addProductionFeedback, closeProductionFeedback, reviseProductionFromFeedback, revertProductionInput } from '../services/musicVideo/productionReviewService.js';import { asyncHandler, ServerError } from '../lib/errorHandler.js';@@ -317,6 +317,14 @@ router.patch('/:id', asyncHandler(async (req, res) => {res.json(updated);}));+// Finished outside PortOS: the earlier steps count as done without forging approvals.+router.put('/:id/finished-outside', asyncHandler(async (req, res) => {+ const { finished, note } = validateRequest(musicVideoFinishedOutsideSchema, req.body);+ const finishedOutside = finished ? { markedAt: new Date().toISOString(), ...(note ? { note } : {}) } : null;+ await updateProject(req.params.id, { finishedOutside });+ res.json(presentProjectForRead(await getProject(req.params.id)));+}));+// Preview is read-only; Apply rechecks audio and the serialized project basis.router.post('/:id/audio-timing/preview', asyncHandler(async (req, res) => {const input = validateRequest(musicVideoAudioTimingPreviewSchema, req.body);diff --git a/server/routes/musicVideo.test.js b/server/routes/musicVideo.test.jsindex 179d0e848c..b5ecd6bc12 100644--- a/server/routes/musicVideo.test.js+++ b/server/routes/musicVideo.test.js@@ -132,6 +132,24 @@ describe('musicVideo routes', () => {});});+ it('PUT /:id/finished-outside stamps the marker server-side, and clears it, without touching approvals', async () => {+ svc.getProject.mockResolvedValue({ id: 'mv-1', name: 'A' });+ const r = await request(app).put('/api/music-video/mv-1/finished-outside').send({ finished: true, note: 'Made in another editor' });+ expect(r.status).toBe(200);+ const patch = svc.updateProject.mock.calls[0][1];+ expect(Object.keys(patch)).toEqual(['finishedOutside']);+ expect(patch.finishedOutside).toEqual({ markedAt: expect.any(String), note: 'Made in another editor' });+ expect(Number.isNaN(Date.parse(patch.finishedOutside.markedAt))).toBe(false);+ expect(r.body.productionReadiness).toBeDefined();++ await request(app).put('/api/music-video/mv-1/finished-outside').send({ finished: false });+ expect(svc.updateProject.mock.calls[1][1]).toEqual({ finishedOutside: null });++ // The client never chooses the timestamp.+ const forged = await request(app).put('/api/music-video/mv-1/finished-outside').send({ finished: true, markedAt: '2020-01-01' });+ expect(forged.status).toBe(400);+ });+it('GET /midi-sources returns only the newest transcription per track, trimmed (#10203)', async () => {const mk = (id, trackId, createdAt) => ({id, name: id, trackId, scenes: [{ big: true }],