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: label music video excerpts by role and block deleting the registered proof (#10148)
Adam Eivyde91e7a9c067
diff --git a/client/src/components/musicVideo/ExcerptPanel.jsx b/client/src/components/musicVideo/ExcerptPanel.jsxindex 80c00ff3f4..5e0640c87e 100644--- a/client/src/components/musicVideo/ExcerptPanel.jsx+++ b/client/src/components/musicVideo/ExcerptPanel.jsx@@ -20,6 +20,23 @@ const PLAYER_FRAME = {};const ASPECT_LABELS = { '16:9': '16:9 (YouTube)', '9:16': '9:16 (Shorts, TikTok, Reels)', '1:1': '1:1 (square)' };+const ROLE_LABELS = { proof: 'Proof', prototype: 'Prototype', pilot: 'Pilot', social: 'Social cut', draft: 'Draft' };++/**+ * Role of an excerpt (#10148), derived from where the project registers it:+ * the production-review proof/prototype slots, an auto-review pilot attempt,+ * or its frame (a cut in another aspect than the project's is a social cut).+ */+export function excerptRole(project, excerpt) {+ const review = project?.productionReview;+ if (review?.proof?.excerptId === excerpt.id) return 'proof';+ if (review?.prototype?.excerptId === excerpt.id) return 'prototype';+ const pilotReviewIds = new Set((project?.productionRuns || []).flatMap(r => (r.pilot?.scenes || []).map(p => p.reviewRunId)));+ if ((project?.autoReviews || []).some(r => pilotReviewIds.has(r.id) && r.attempts?.some(a => a.excerptId === excerpt.id))) return 'pilot';+ if (excerpt.aspect && excerpt.aspect !== musicVideoAspect(project)) return 'social';+ return 'draft';+}+const fmt = (sec) => {const s = Math.max(0, Math.round(sec * 10) / 10);const m = Math.floor(s / 60);@@ -56,7 +73,7 @@ function NoteRow({ excerptId, note, busy, onEdit, onDelete, onSeek }) {disabled={busy} className={`p-1 rounded min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 ${note.verdict === 'flagged' ? 'text-port-error' : 'text-port-text-muted'}`}><Flag size={12} /></button>- <button type="button" title="Approve" aria-label="Approve"+ <button type="button" title="Looks good" aria-label="Looks good"onClick={() => onEdit(excerptId, note.id, { verdict: note.verdict === 'approved' ? null : 'approved' })}disabled={busy} className={`p-1 rounded min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 ${note.verdict === 'approved' ? 'text-port-success' : 'text-port-text-muted'}`}><CheckCircle2 size={12} />@@ -72,9 +89,10 @@ function NoteRow({ excerptId, note, busy, onEdit, onDelete, onSeek }) {);}-function ExcerptCard({ excerpt, activeRenderId, connected, deleting, noteBusy, onDelete, onCancel, onAddNote, onEditNote, onDeleteNote, canRevise, onRevise }) {+function ExcerptCard({ excerpt, role, proofApproved, activeRenderId, connected, deleting, noteBusy, onDelete, onCancel, onAddNote, onEditNote, onDeleteNote, canRevise, onRevise }) {const videoRef = useRef(null);const [draft, setDraft] = useState('');+ const [confirmingDelete, setConfirmingDelete] = useState(false);const seek = (t) => { if (videoRef.current) { videoRef.current.currentTime = t; videoRef.current.play?.().catch(() => {}); } };const addNoteHere = () => {if (!draft.trim()) return;@@ -89,6 +107,7 @@ function ExcerptCard({ excerpt, activeRenderId, connected, deleting, noteBusy, o<li className="rounded border border-port-border p-2 space-y-2"><div className="flex flex-wrap items-center justify-between gap-2 text-xs"><span className="font-medium">{fmt(excerpt.startSec)} – {fmt(excerpt.endSec)} <span className="text-port-text-muted">({excerpt.status === 'rendering' && (activeRenderId !== excerpt.id || connected === false) ? 'Checking render status' : STATUS_LABELS[excerpt.status] || excerpt.status})</span>+ <span className="ml-1.5 px-1.5 py-0.5 rounded bg-port-border text-port-text-muted text-[10px]">{ROLE_LABELS[role]}{role === 'proof' && proofApproved ? ' (approved)' : ''}</span>{excerpt.aspect && excerpt.aspect !== '16:9' && <span className="ml-1.5 px-1.5 py-0.5 rounded bg-port-accent/20 text-port-accent text-[10px]">{excerpt.aspect}</span>}</span><div className="flex items-center gap-2">{/* #8987: regenerate ONLY the sections holding a flagged note; the rest stay as approved. */}@@ -99,7 +118,14 @@ function ExcerptCard({ excerpt, activeRenderId, connected, deleting, noteBusy, o)}{excerpt.status === 'rendering'? <button type="button" onClick={() => onCancel(excerpt.id)} className="text-port-error flex items-center gap-1 min-h-[44px] sm:min-h-0"><X size={12} /> Cancel</button>- : <button type="button" disabled={deleting} onClick={() => onDelete(excerpt.id)} className="text-port-error flex items-center gap-1 disabled:opacity-50 min-h-[44px] sm:min-h-0"><Trash2 size={12} /> Delete</button>}+ : role === 'proof'+ ? <span className="text-port-text-muted">Registered proof — revoke approval to delete</span>+ : confirmingDelete+ ? <span className="flex items-center gap-2">+ <button type="button" disabled={deleting} onClick={() => { setConfirmingDelete(false); onDelete(excerpt.id); }} className="text-port-error disabled:opacity-50 min-h-[44px] sm:min-h-0">Confirm delete</button>+ <button type="button" onClick={() => setConfirmingDelete(false)} className="text-port-text-muted min-h-[44px] sm:min-h-0">Keep</button>+ </span>+ : <button type="button" disabled={deleting} onClick={() => setConfirmingDelete(true)} className="text-port-error flex items-center gap-1 disabled:opacity-50 min-h-[44px] sm:min-h-0"><Trash2 size={12} /> Delete</button>}</div></div><p className="text-xs text-port-text-muted">{excerpt.dependencyState?.status === 'stale' ? 'Earlier inputs — retained for reference' : excerpt.dependencyState?.status === 'current' ? 'Matches current inputs · production approval is separate' : 'Draft · approval is separate'}{excerpt.createdAt ? ` · ${new Date(excerpt.createdAt).toISOString().replace('T', ' ').slice(0, 19)} UTC` : ''}</p>@@ -150,10 +176,18 @@ function ExcerptCard({ excerpt, activeRenderId, connected, deleting, noteBusy, oexport default function ExcerptPanel({ project, rendering, occupied = rendering, progress, excerpts, activeRenderId = null, connected, revision = null, autoReview = null, ...actions }) {const newest = [...excerpts].reverse();const latestAttempt = newest[0];- const current = newest.find(e => e.status === 'complete' && e.filename && e.dependencyState?.status !== 'stale');- const visible = newest.filter(e => e.status === 'rendering' || e === current);+ const roleOf = new Map(newest.map(e => [e.id, excerptRole(project, e)]));+ // The latest usable excerpt PER ROLE stays visible, so a new social cut never buries the review draft.+ const currentIds = new Set();+ const seenRoles = new Set();+ for (const e of newest) {+ const role = roleOf.get(e.id);+ if (e.status === 'complete' && e.filename && e.dependencyState?.status !== 'stale' && !seenRoles.has(role)) { seenRoles.add(role); currentIds.add(e.id); }+ }+ const visible = newest.filter(e => e.status === 'rendering' || currentIds.has(e.id));const history = newest.filter(e => !visible.includes(e));- const card = excerpt => <ExcerptCard key={excerpt.id} excerpt={excerpt} activeRenderId={activeRenderId} connected={connected}+ const proofApproved = !!project?.productionReview?.approvals?.proof;+ const card = excerpt => <ExcerptCard key={excerpt.id} excerpt={excerpt} role={roleOf.get(excerpt.id)} proofApproved={proofApproved} activeRenderId={activeRenderId} connected={connected}deleting={actions.deletingId === excerpt.id} noteBusy={actions.noteBusyId}onDelete={actions.deleteExcerpt} onCancel={actions.cancelExcerpt} onAddNote={actions.addNote}onEditNote={actions.editNote} onDeleteNote={actions.deleteNote} canRevise={canRevise} onRevise={revision?.revise} />;diff --git a/client/src/components/musicVideo/ExcerptPanel.test.jsx b/client/src/components/musicVideo/ExcerptPanel.test.jsxindex feb35dc8e8..a09615c232 100644--- a/client/src/components/musicVideo/ExcerptPanel.test.jsx+++ b/client/src/components/musicVideo/ExcerptPanel.test.jsx@@ -84,3 +84,34 @@ it('does not mislabel current footage after it has been approved as production pexpect(screen.getByText(/Matches current inputs/)).toHaveTextContent('production approval is separate');expect(screen.queryByText(/unapproved draft/)).toBeNull();});++describe('ExcerptPanel roles and deletion (#10148)', () => {+ const done = (id, extra = {}) => ({ id, status: 'complete', filename: `${id}.mp4`, startSec: 0, endSec: 12, dependencyState: { status: 'current' }, ...extra });++ it('keeps the review draft visible when a newer social cut renders, and badges both', () => {+ render(<ExcerptPanel project={documentProject} rendering={false} progress={0}+ excerpts={[done('draft'), done('social', { aspect: '9:16' })]} startExcerpt={vi.fn()} />);+ const list = screen.getByRole('list', { name: 'Current draft and active renders' });+ expect(list).toHaveTextContent('Social cut');+ expect(list).toHaveTextContent('Draft');+ expect(screen.queryByText(/Earlier and failed attempts/)).toBeNull();+ });++ it('labels the registered proof and offers no delete for it', () => {+ const project = { ...documentProject, productionReview: { proof: { excerptId: 'p1' } } };+ render(<ExcerptPanel project={project} rendering={false} progress={0}+ excerpts={[done('p1')]} startExcerpt={vi.fn()} />);+ expect(screen.getByText('Proof')).toBeTruthy();+ expect(screen.queryByRole('button', { name: /Delete/ })).toBeNull();+ });++ it('requires a second click to delete an ordinary excerpt', () => {+ const deleteExcerpt = vi.fn();+ render(<ExcerptPanel project={documentProject} rendering={false} progress={0}+ excerpts={[done('d1')]} startExcerpt={vi.fn()} deleteExcerpt={deleteExcerpt} />);+ fireEvent.click(screen.getByRole('button', { name: /Delete/ }));+ expect(deleteExcerpt).not.toHaveBeenCalled();+ fireEvent.click(screen.getByRole('button', { name: 'Confirm delete' }));+ expect(deleteExcerpt).toHaveBeenCalledWith('d1');+ });+});diff --git a/server/routes/musicVideoExcerpt.test.js b/server/routes/musicVideoExcerpt.test.jsindex 0c25a0d9ea..8a52e0a3a6 100644--- a/server/routes/musicVideoExcerpt.test.js+++ b/server/routes/musicVideoExcerpt.test.js@@ -102,6 +102,16 @@ describe('draft excerpt deletion (#8986)', () => {expect(r.body.excerpts).toEqual([]);});+ it('refuses to delete the excerpt registered as the production proof (#10148)', async () => {+ const { project } = await projectWithExcerpt();+ await projects.updateProject(project.id, { productionReview: { proof: { excerptId: 'mve-1', startSec: 10, endSec: 20, basis: 'b' } } });+ const r = await request(app).delete(`${base(project.id)}/excerpt/mve-1`);+ expect(r.status).toBe(409);+ expect(r.body.code).toBe('EXCERPT_REGISTERED_PROOF');+ expect(r.body.error || r.body.message).toMatch(/Revoke/);+ expect((await projects.getProject(project.id)).excerpts).toHaveLength(1);+ });+it('refuses to delete an excerpt whose render is still in flight', async () => {const { project } = await projectWithExcerpt({ status: 'rendering', filename: null, contactSheetFilename: null });const r = await request(app).delete(`${base(project.id)}/excerpt/mve-1`);diff --git a/server/services/musicVideo/excerpt.js b/server/services/musicVideo/excerpt.jsindex 624f4de9a7..10b810505b 100644--- a/server/services/musicVideo/excerpt.js+++ b/server/services/musicVideo/excerpt.js@@ -116,6 +116,9 @@ export function removeExcerptFromProject(project, excerptId) {if (excerpt.status === 'rendering') {throw excerptError(409, 'EXCERPT_RENDERING', 'Cancel the in-progress render before deleting this excerpt');}+ if (project.productionReview?.proof?.excerptId === excerptId) {+ throw excerptError(409, 'EXCERPT_REGISTERED_PROOF', 'This excerpt is the registered production proof. Revoke its approval or register a different proof before deleting it');+ }return { project: { ...project, excerpts: projectExcerpts(project).filter((e) => e.id !== excerptId) }, excerpt };}