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

fix: preserve performance intent across saves and shot splits (#9347)

Adam Eivya8689e23952f
diff --git a/client/src/components/musicVideo/AutoReviewPanel.jsx b/client/src/components/musicVideo/AutoReviewPanel.jsx
index 829e6f9139..5e39776ed8 100644
--- a/client/src/components/musicVideo/AutoReviewPanel.jsx
+++ b/client/src/components/musicVideo/AutoReviewPanel.jsx
@@ -54,7 +54,7 @@ function AttemptRow({ attempt }) {
{review ? <span className="uppercase text-[10px] text-port-text-muted">{review.verdict}</span> : <span className="text-port-text-muted">not reviewed yet</span>}
{review && Object.entries(CHECK_LABELS).map(([key, label]) => (
<span key={key} className={`px-1.5 py-0.5 rounded text-[10px] ${CHECK_TONES[review.checks?.[key]] || CHECK_TONES.unverified}`}>
- {label}: {review.checks?.[key] || 'unverified'}
+ {label}: {key === 'lipSync' && review.evidence?.temporal?.status === 'not-applicable' ? 'not applicable' : review.checks?.[key] || 'unverified'}
</span>
))}
</div>
diff --git a/client/src/components/musicVideo/SceneCard.jsx b/client/src/components/musicVideo/SceneCard.jsx
index b84715a2f2..73a29b1c60 100644
--- a/client/src/components/musicVideo/SceneCard.jsx
+++ b/client/src/components/musicVideo/SceneCard.jsx
@@ -86,6 +86,8 @@ export default function SceneCard({
: null;
// Source-clip length, read from the inline player's metadata and keyed to
// the clip it was measured from so a regenerated clip is re-measured.
+ const [speakerDirty, setSpeakerDirty] = useState(false);
+ const [speakerSaving, setSpeakerSaving] = useState(false);
const [clipMeta, setClipMeta] = useState(null);
const clipSec = clipMeta && clipMeta.id === scene.videoHistoryId ? clipMeta.sec : null;
// Pre-#8964 scenes have no `loop` key and keep the legacy loop-to-fill render.
@@ -218,8 +220,13 @@ export default function SceneCard({
<div className="flex flex-wrap items-center gap-2 text-xs">
<label htmlFor={fieldId('speaker')}>Speaker / singer</label>
<input id={fieldId('speaker')} value={scene.performanceSpeaker || ''} maxLength={120}
- onChange={(e) => onEditLocal(scene.sceneId, { performanceSpeaker: e.target.value })}
- onBlur={() => onSave(scene.sceneId, { performanceSpeaker: scene.performanceSpeaker || null })}
+ onChange={(e) => { setSpeakerDirty(true); onEditLocal(scene.sceneId, { performanceSpeaker: e.target.value }); }}
+ onBlur={(e) => {
+ setSpeakerSaving(true);
+ Promise.resolve(onSave(scene.sceneId, { performanceSpeaker: e.target.value || null }))
+ .then((saved) => setSpeakerDirty(saved === false), () => setSpeakerDirty(true))
+ .finally(() => setSpeakerSaving(false));
+ }}
className="bg-port-bg border border-port-border rounded px-2 py-1" placeholder="Intended singer" />
</div>
)}
@@ -397,7 +404,7 @@ export default function SceneCard({
</div>
)}
<button onClick={() => onGenerateVideo(scene)}
- disabled={settingsSaving || !scene.referenceImageId || !!generatingVideo || !!videoBlockedReason || !!performanceBlocked}
+ disabled={settingsSaving || (performance && (speakerDirty || speakerSaving)) || !scene.referenceImageId || !!generatingVideo || !!videoBlockedReason || !!performanceBlocked}
className="flex items-center gap-1 bg-port-border hover:bg-port-border/70 disabled:opacity-50 rounded px-2 py-1.5 text-xs min-h-[44px] sm:min-h-0 whitespace-nowrap"
title={videoBlockedReason || performanceBlocked
|| (!scene.referenceImageId ? 'Generate a reference frame first'
diff --git a/client/src/components/musicVideo/SceneCard.test.jsx b/client/src/components/musicVideo/SceneCard.test.jsx
new file mode 100644
index 0000000000..a11c51e6e3
--- /dev/null
+++ b/client/src/components/musicVideo/SceneCard.test.jsx
@@ -0,0 +1,31 @@
+import { useState } from 'react';
+import { describe, expect, it, vi } from 'vitest';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+vi.mock('../../hooks/useVideoFileSrc.js', () => ({ useVideoFileSrc: () => ({}) }));
+import SceneCard from './SceneCard.jsx';
+
+describe('performance speaker save boundary', () => {
+ it('keeps paid generation disabled until the speaker edit is saved, including a failed save', async () => {
+ let settle;
+ const onSave = vi.fn(() => new Promise((resolve) => { settle = resolve; }));
+ function Harness() {
+ const [scene, setScene] = useState({ sceneId: 's1', shotMode: 'performance', startSec: 0, endSec: 5, referenceImageId: 'frame.png', takes: [] });
+ return <SceneCard scene={scene} index={0} lipSyncBackend="fal" songDurationSec={30}
+ onEditLocal={(_id, patch) => setScene((current) => ({ ...current, ...patch }))} onSave={onSave} />;
+ }
+ render(<Harness />);
+ const input = screen.getByLabelText('Speaker / singer');
+ const generate = screen.getByRole('button', { name: 'Generate video' });
+ expect(generate.disabled).toBe(false);
+ fireEvent.change(input, { target: { value: 'Example Singer' } });
+ expect(generate.disabled).toBe(true);
+ fireEvent.blur(input);
+ expect(onSave).toHaveBeenCalledWith('s1', { performanceSpeaker: 'Example Singer' });
+ expect(generate.disabled).toBe(true);
+ settle(false);
+ await waitFor(() => expect(generate.disabled).toBe(true));
+ fireEvent.blur(input);
+ settle(true);
+ await waitFor(() => expect(generate.disabled).toBe(false));
+ });
+});
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index e0dd55fe74..e6097aaeea 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -499,8 +499,9 @@ export default function MusicVideo() {
replaceProject({ ...selected, scenes: selected.scenes.map((s) => (s.sceneId === sceneId ? { ...s, ...patch } : s)) });
};
const saveScene = (sceneId, patch) => {
- updateMusicVideoScene(selected.id, sceneId, patch, { silent: true })
- .catch((err) => toast.error(err?.message || 'Failed to save scene'));
+ return updateMusicVideoScene(selected.id, sceneId, patch, { silent: true })
+ .then(() => true)
+ .catch((err) => { toast.error(err?.message || 'Failed to save scene'); return false; });
};
// Project-level concept/style (issue #3168) — optimistic-local + silent-PATCH on
diff --git a/server/lib/musicVideoShotTiming.js b/server/lib/musicVideoShotTiming.js
index 0302d4e5c3..2f1f7693ea 100644
--- a/server/lib/musicVideoShotTiming.js
+++ b/server/lib/musicVideoShotTiming.js
@@ -212,7 +212,7 @@ export function clipRelativeCues(cues, windowStartSec, windowEndSec) {
startSec: round6(Math.max(0, cue.startSec - windowStartSec)),
endSec: round6(Math.min(windowEndSec, end) - windowStartSec),
...(Array.isArray(cue.words) ? { words: cue.words
- .filter((word) => Number.isFinite(word.startSec) && Number.isFinite(word.endSec) && word.endSec > windowStartSec && word.startSec < windowEndSec)
+ .filter((word) => word && Number.isFinite(word.startSec) && Number.isFinite(word.endSec) && word.endSec > word.startSec && word.endSec > windowStartSec && word.startSec < windowEndSec)
.map((word) => ({ text: word.text, startSec: round6(Math.max(windowStartSec, word.startSec) - windowStartSec), endSec: round6(Math.min(windowEndSec, word.endSec) - windowStartSec) })) } : {}),
});
}
diff --git a/server/lib/schemaVersions.test.js b/server/lib/schemaVersions.test.js
index bcf4fd757f..9c55da4693 100644
--- a/server/lib/schemaVersions.test.js
+++ b/server/lib/schemaVersions.test.js
@@ -64,6 +64,13 @@ describe('PORTOS_SCHEMA_VERSIONS', () => {
});
describe('buildPortosMeta', () => {
+ it('rejects temporal-evidence projects on a peer that only knows shot intent', async () => {
+ const meta = await buildPortosMeta();
+ expect(meta.schemaVersions.musicVideoProjects).toBe(14);
+ expect(compareSchemaVersions(meta.schemaVersions, { ...meta.schemaVersions, musicVideoProjects: 13 }).ahead)
+ .toContainEqual({ category: 'musicVideoProjects', senderV: 14, receiverV: 13 });
+ });
+
it('returns { portosVersion, schemaVersions } with the live registry', async () => {
const meta = await buildPortosMeta();
expect(meta.portosVersion).toMatch(/^\d+\.\d+\.\d+/);
diff --git a/server/routes/musicVideoAutoReview.test.js b/server/routes/musicVideoAutoReview.test.js
index 7a22363fd9..f886ead5f6 100644
--- a/server/routes/musicVideoAutoReview.test.js
+++ b/server/routes/musicVideoAutoReview.test.js
@@ -438,6 +438,20 @@ describe('temporal performance evidence (#9347)', () => {
expect(h.procs).toHaveLength(1);
});
+ it('a legacy draft with missing section provenance cannot silently pass as having no performances', async () => {
+ const p = await performanceProject();
+ h.verdicts.push(PASS);
+ await start(p.id, { maxAttempts: 2, maxGenerations: 5 });
+ await vi.waitFor(() => expect(h.procs).toHaveLength(1));
+ await projects.mutateProjectRecord(p.id, (current) => ({ project: {
+ ...current, excerpts: current.excerpts.map((excerpt) => ({ ...excerpt, sections: null })),
+ } }));
+ await finishDraft(p.id, 1);
+ const saved = await settled(p.id, (x) => expect(run(x).status).toBe('needs-human'));
+ expect(run(saved).attempts[0].review.checks).toMatchObject({ audioSync: 'pass', lipSync: 'unverified' });
+ expect(run(saved).usage.generations).toBe(0);
+ });
+
it('equal-length synthetic output with measured mouth offset fails only the temporal check', async () => {
const p = await performanceProject();
h.temporalInstalled = true;
diff --git a/server/routes/musicVideoSceneSplit.test.js b/server/routes/musicVideoSceneSplit.test.js
index be8890b2a2..c7b54e0d73 100644
--- a/server/routes/musicVideoSceneSplit.test.js
+++ b/server/routes/musicVideoSceneSplit.test.js
@@ -49,7 +49,7 @@ describe('POST /:id/scenes/:sceneId/split', () => {
it('splits an over-long performance shot at the lyric pauses, keeping the original id, takes and neighbours', async () => {
const before = await projects.addProjectScene(project.id, { label: 'Intro', startSec: 0, endSec: 30 });
const shot = await projects.addProjectScene(project.id, {
- label: 'Verse', prompt: 'singer at the mic', startSec: 30, endSec: 86, shotMode: 'performance', loop: false,
+ label: 'Verse', prompt: 'singer at the mic', startSec: 30, endSec: 86, shotMode: 'performance', performanceSpeaker: 'Example Singer', loop: false,
});
const after = await projects.addProjectScene(project.id, { label: 'Outro', startSec: 86, endSec: 100 });
await projects.updateScene(project.id, shot.sceneId, { referenceImageId: 'singer.png', videoHistoryId: 'clip-whole-verse' });
@@ -64,7 +64,7 @@ describe('POST /:id/scenes/:sceneId/split', () => {
expect(pieces[0].sceneId).toBe(shot.sceneId);
expect(pieces.map((p) => p.label)).toEqual(['Verse · 1/3', 'Verse · 2/3', 'Verse · 3/3']);
expect(pieces.map((p) => p.lyricText)).toEqual(['first line', 'second line', 'third line']);
- expect(pieces[1]).toMatchObject({ shotMode: 'performance', prompt: 'singer at the mic', loop: false, referenceImageId: 'singer.png', videoHistoryId: null });
+ expect(pieces[1]).toMatchObject({ shotMode: 'performance', performanceSpeaker: 'Example Singer', prompt: 'singer at the mic', loop: false, referenceImageId: 'singer.png', videoHistoryId: null });
expect(pieces[1].takes.map((t) => [t.kind, t.assetId])).toEqual([['image', 'singer.png']]);
const stored = await projects.getProject(project.id);
diff --git a/server/services/musicVideo/autoReviewService.js b/server/services/musicVideo/autoReviewService.js
index c0c84363f9..2e24f59bd6 100644
--- a/server/services/musicVideo/autoReviewService.js
+++ b/server/services/musicVideo/autoReviewService.js
@@ -193,7 +193,9 @@ async function reviewDraft(project, run, excerpt) {
? { takeId: scene.videoHistoryId, speaker: instruction?.speaker || null, conditioning: instruction?.audio?.conditioning || null } : null);
return performance ? [{ sceneId: section.sceneId, ...performance, startSec: section.startSec, endSec: section.endSec }] : [];
});
- const temporal = await analyzeTemporalPerformance({ excerptPath, shots });
+ const temporal = !sections.length && project.scenes?.some(isPerformanceScene)
+ ? { version: 1, status: 'unverified', analyzer: null, reason: 'The draft has no performance-section provenance', shots: [] }
+ : await analyzeTemporalPerformance({ excerptPath, shots });
const evidence = { boundaryFrames: hasSheet ? 1 : 0, continuousFrames: frameTimes.length, temporal, excerptStartSec: excerpt.startSec };
let parsed = null;
diff --git a/server/services/musicVideo/projectsLogic.js b/server/services/musicVideo/projectsLogic.js
index 5981b944d6..a362355c3f 100644
--- a/server/services/musicVideo/projectsLogic.js
+++ b/server/services/musicVideo/projectsLogic.js
@@ -605,6 +605,7 @@ export function splitScene(project, sceneId, { backend = null } = {}) {
visualIntent: scene.visualIntent ?? null,
visualLayer: scene.visualLayer ?? 'footage',
shotMode: scene.shotMode ?? 'cutaway',
+ performanceSpeaker: scene.performanceSpeaker ?? null,
...timing,
}),
}, { order: 0 });
diff --git a/server/services/musicVideo/temporalPerformance.js b/server/services/musicVideo/temporalPerformance.js
index 8b15e34c7a..315056d8a1 100644
--- a/server/services/musicVideo/temporalPerformance.js
+++ b/server/services/musicVideo/temporalPerformance.js
@@ -25,7 +25,8 @@ const resultSchema = z.object({
});
const unavailable = (shots, reason, analyzer = null) => ({
version: 1, status: 'unverified', analyzer, reason,
- shots: shots.map((shot) => ({ ...shot, spans: [{ startSec: shot.startSec, endSec: shot.endSec, status: 'unverified', offsetSec: null, confidence: null }] })),
+ omittedShots: Math.max(0, shots.length - 256),
+ shots: shots.slice(0, 256).map((shot) => ({ ...shot, spans: [{ startSec: shot.startSec, endSec: shot.endSec, status: 'unverified', offsetSec: null, confidence: null }] })),
});
// A local executable receives only runtime essentials, never agent/provider or
@@ -36,7 +37,7 @@ const analyzerEnv = () => Object.fromEntries(
);
const invoke = async (command, args, timeout) => {
const { stdout } = await execFileAsync(command, args, safeChildProcessOptions({
- env: analyzerEnv(), timeout, maxBuffer: 256 * 1024,
+ env: analyzerEnv(), timeout, killSignal: 'SIGKILL', maxBuffer: 256 * 1024,
}));
return JSON.parse(stdout);
};
@@ -44,6 +45,7 @@ const invoke = async (command, args, timeout) => {
/** Called only by an explicitly requested draft review. */
export async function analyzeTemporalPerformance({ excerptPath, shots }) {
if (!shots.length) return { version: 1, status: 'not-applicable', analyzer: null, reason: null, shots: [] };
+ if (shots.length > 256) return unavailable(shots, 'The draft exceeds the temporal evidence section limit');
const command = findCommandOnPath('portos-temporal-analyzer');
if (!command || /\.(cmd|bat)$/i.test(command)) return unavailable(shots, 'No supported local temporal analyzer is installed');
const capability = await invoke(command, ['--capabilities'], 5000).then((value) => capabilities.safeParse(value), () => null);