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

feat: notify when an autonomous or scheduled music video needs the director, and list parked runs in Needs attention (#10156)

Adam Eivy574a848015f6
diff --git a/client/src/components/NotificationDropdown.jsx b/client/src/components/NotificationDropdown.jsx
index 1ba90c5cd3..51d14827d9 100644
--- a/client/src/components/NotificationDropdown.jsx
+++ b/client/src/components/NotificationDropdown.jsx
@@ -1,7 +1,7 @@
import { useState, useRef, useEffect } from 'react';
import { createPortal } from 'react-dom';
import { useNavigate } from 'react-router';
-import { Bell, X, CheckCheck, Trash2, Brain, ListTodo, AlertTriangle, Code, HelpCircle, BellRing, Sparkles } from 'lucide-react';
+import { Bell, X, CheckCheck, Trash2, Brain, ListTodo, AlertTriangle, Code, HelpCircle, BellRing, Film, Sparkles } from 'lucide-react';
import { timeAgo, formatCount } from '../utils/formatters';
import { useActionQueue } from '../hooks/useActionQueue';
import ActionQueuePreview from './ActionQueuePreview';
@@ -50,6 +50,11 @@ const NOTIFICATION_TYPE_CONFIG = {
icon: Sparkles,
color: 'text-port-accent',
bgColor: 'bg-port-accent/20'
+ },
+ music_video_attention: {
+ icon: Film,
+ color: 'text-orange-400',
+ bgColor: 'bg-orange-500/20'
}
};
diff --git a/client/src/components/cos/tabs/schedule/MusicVideoAutopilotBlocker.jsx b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotBlocker.jsx
new file mode 100644
index 0000000000..d3ccb4b518
--- /dev/null
+++ b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotBlocker.jsx
@@ -0,0 +1,49 @@
+import { useEffect, useState } from 'react';
+import { Link } from 'react-router';
+import { AlertTriangle } from 'lucide-react';
+import socket from '../../../../services/socket';
+import { listMusicVideoProjectSummaries } from '../../../../services/apiMusicVideo';
+import { scheduledRunBlocker } from '../../../../lib/musicVideoAutonomous';
+
+/**
+ * Names the project the Autonomous run schedule is parked on (#10156): every
+ * later fire declines while a scheduled run awaits approval, needs the director
+ * or is stopped, so without this the schedule just looks like it does nothing.
+ * Loads once, then follows `music-video:autonomous` pushes — no polling.
+ */
+export default function MusicVideoAutopilotBlocker() {
+ const [blockers, setBlockers] = useState({});
+
+ useEffect(() => {
+ let live = true;
+ const apply = (project) => setBlockers((prev) => {
+ const next = { ...prev };
+ const blocker = scheduledRunBlocker(project);
+ if (blocker) next[project.id] = blocker;
+ else delete next[project?.id];
+ return next;
+ });
+ listMusicVideoProjectSummaries({ limit: 200 }, { silent: true })
+ .then((page) => { if (live) (page?.items || []).forEach(apply); })
+ .catch(() => {});
+ const onRun = (data) => { if (data?.project) apply(data.project); };
+ socket.on('music-video:autonomous', onRun);
+ return () => { live = false; socket.off('music-video:autonomous', onRun); };
+ }, []);
+
+ const parked = Object.values(blockers);
+ if (parked.length === 0) return null;
+ return (
+ <div role="status" className="space-y-1 text-xs text-port-warning">
+ {parked.map((b) => (
+ <p key={b.projectId} className="flex items-start gap-1.5 min-w-0">
+ <AlertTriangle size={12} className="mt-0.5 shrink-0" aria-hidden="true" />
+ <span className="min-w-0 break-words">
+ Waiting on {b.summary}. New runs start once it is cleared.{' '}
+ <Link to={b.link} className="underline text-port-accent">Open project</Link>
+ </span>
+ </p>
+ ))}
+ </div>
+ );
+}
diff --git a/client/src/components/cos/tabs/schedule/MusicVideoAutopilotBlocker.test.jsx b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotBlocker.test.jsx
new file mode 100644
index 0000000000..4230b36f40
--- /dev/null
+++ b/client/src/components/cos/tabs/schedule/MusicVideoAutopilotBlocker.test.jsx
@@ -0,0 +1,39 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, waitFor, act } from '@testing-library/react';
+import { MemoryRouter } from 'react-router';
+
+const handlers = {};
+vi.mock('../../../../services/socket', () => ({
+ default: { on: (e, fn) => { handlers[e] = fn; }, off: vi.fn() },
+}));
+const list = vi.fn();
+vi.mock('../../../../services/apiMusicVideo', () => ({ listMusicVideoProjectSummaries: (...a) => list(...a) }));
+
+const { default: Blocker } = await import('./MusicVideoAutopilotBlocker.jsx');
+
+const renderIt = () => render(<MemoryRouter><Blocker /></MemoryRouter>);
+
+beforeEach(() => list.mockReset());
+
+describe('MusicVideoAutopilotBlocker (#10156)', () => {
+ it('names the scheduled project the run is parked on, links to it, and clears when the run moves on', async () => {
+ list.mockResolvedValue({ items: [
+ { id: 'mv-1', name: 'Parked video', runStatus: 'needs-human', runOrigin: 'schedule' },
+ { id: 'mv-2', name: 'Manual video', runStatus: 'needs-human', runOrigin: 'manual' },
+ ] });
+ renderIt();
+ expect(await screen.findByText(/"Parked video" needs you/)).toBeTruthy();
+ expect(screen.queryByText(/Manual video/)).toBeNull();
+ expect(screen.getByRole('link', { name: 'Open project' }).getAttribute('href')).toBe('/music-video/mv-1/setup');
+
+ act(() => handlers['music-video:autonomous']({ project: { id: 'mv-1', name: 'Parked video', autonomousRun: { status: 'running', brief: { origin: { kind: 'schedule' } } } } }));
+ await waitFor(() => expect(screen.queryByText(/Parked video/)).toBeNull());
+ });
+
+ it('renders nothing when no scheduled run is parked', async () => {
+ list.mockResolvedValue({ items: [{ id: 'mv-1', name: 'Done', runStatus: 'completed', runOrigin: 'schedule' }] });
+ const { container } = renderIt();
+ await waitFor(() => expect(list).toHaveBeenCalled());
+ expect(container.textContent).toBe('');
+ });
+});
diff --git a/client/src/components/cos/tabs/schedule/TaskHeader.jsx b/client/src/components/cos/tabs/schedule/TaskHeader.jsx
index e8fd928bc1..7ac3c3e3b6 100644
--- a/client/src/components/cos/tabs/schedule/TaskHeader.jsx
+++ b/client/src/components/cos/tabs/schedule/TaskHeader.jsx
@@ -1,6 +1,7 @@
import { GitBranch, GitMerge, ListOrdered, Users } from 'lucide-react';
import { taskLabels, badge, statusDot, getTaskStatusGroup, pipelineStages } from './scheduleConstants';
import IntervalBadge from './IntervalBadge';
+import MusicVideoAutopilotBlocker from './MusicVideoAutopilotBlocker';
// Shared task identity row — status dot, monospace name, pipeline + swarm
// badges, and interval badge. Used by both the schedule card and the config
@@ -84,6 +85,7 @@ export default function TaskHeader({ taskType, config, orderStep }) {
))}
</p>
)}
+ {taskType === 'music-video-autopilot' && <MusicVideoAutopilotBlocker />}
{config.runGuidance && <p className="text-xs text-gray-500 line-clamp-2" title={config.runGuidance}>{config.runGuidance}</p>}
{taskLabels(config).length > 0 && (
<div className="flex flex-wrap gap-1">
diff --git a/client/src/components/musicVideo/ExcerptPanel.jsx b/client/src/components/musicVideo/ExcerptPanel.jsx
index 5e0640c87e..7f79de0e1c 100644
--- a/client/src/components/musicVideo/ExcerptPanel.jsx
+++ b/client/src/components/musicVideo/ExcerptPanel.jsx
@@ -5,6 +5,7 @@ import { getMusicVideoSocialCuts } from '../../services/apiMusicVideo.js';
import RevisionPanel, { currentRevision } from './RevisionPanel.jsx';
import AutoReviewPanel from './AutoReviewPanel.jsx';
import { formatCount } from '../../utils/formatters.js';
+import { autoReviewNeedsUser } from '../../lib/musicVideoAttention.js';
const VERDICT_STYLES = {
flagged: 'bg-port-error/20 text-port-error',
@@ -300,7 +301,7 @@ export default function ExcerptPanel({ project, rendering, occupied = rendering,
{['error', 'canceled'].includes(latestAttempt?.status) && <p role="status" className="text-sm text-port-warning">
{latestAttempt.status === 'error' ? `Latest draft attempt failed: ${latestAttempt.error || 'No error details recorded.'}` : 'Latest draft attempt was cancelled.'} Completed drafts are retained. Details are in Earlier and failed attempts.
</p>}
- <details><summary className="cursor-pointer min-h-[44px] py-2 text-sm">Revision and automatic review tools</summary>
+ <details open={autoReviewNeedsUser(project) || undefined}><summary className="cursor-pointer min-h-[44px] py-2 text-sm">Revision and automatic review tools</summary>
{revision && (
<RevisionPanel project={project} busy={revision.busy || occupied}
genScenes={revision.genScenes} genVideoScenes={revision.genVideoScenes}
diff --git a/client/src/components/musicVideo/NeedsAttentionBanner.jsx b/client/src/components/musicVideo/NeedsAttentionBanner.jsx
index 4207c91298..29320f006b 100644
--- a/client/src/components/musicVideo/NeedsAttentionBanner.jsx
+++ b/client/src/components/musicVideo/NeedsAttentionBanner.jsx
@@ -1,5 +1,5 @@
import { useState } from 'react';
-import { AlertTriangle, Link2, Play, X } from 'lucide-react';
+import { AlertTriangle, ExternalLink, Link2, Play, X } from 'lucide-react';
import { Link } from 'react-router';
import { ATTENTION_ANCHOR_ID } from '../../lib/musicVideoAttention.js';
@@ -47,11 +47,56 @@ function ItemActions({ item, busy, actions }) {
<Link2 size={12} aria-hidden="true" /> Reattach
</button>
);
+ case 'autonomous':
+ return (
+ <>
+ {item.canResume && (
+ <button type="button" disabled={busy} aria-label={`${item.resumeLabel} the autonomous run`} onClick={() => actions.onResumeAutonomous?.()} className={PRIMARY}>
+ <Play size={12} aria-hidden="true" /> {item.resumeLabel}
+ </button>
+ )}
+ <OpenLink item={item} />
+ </>
+ );
+ case 'production':
+ return (
+ <>
+ {item.canResume && (
+ <button type="button" disabled={busy} aria-label="Resume production" onClick={() => actions.onResumeProduction?.(item.runId, item.acceptBasis ? { acceptBasis: true } : {})} className={PRIMARY}>
+ <Play size={12} aria-hidden="true" /> Resume
+ </button>
+ )}
+ <OpenLink item={item} />
+ </>
+ );
+ case 'auto-review-parked':
+ return (
+ <>
+ {item.canResume && (
+ <button type="button" disabled={busy} aria-label="Resume the stopped auto-review run" onClick={() => actions.onContinueAutoReview?.(item.runId)} className={PRIMARY}>
+ <Play size={12} aria-hidden="true" /> Resume
+ </button>
+ )}
+ <OpenLink item={item} />
+ <button type="button" disabled={busy} aria-label="Cancel the stopped auto-review run" onClick={() => actions.onCancelAutoReview?.(item.runId)} className={DANGER}>
+ <X size={12} aria-hidden="true" /> Cancel run
+ </button>
+ </>
+ );
default:
return null;
}
}
+// Opens the tab (and anchor) the row's state is cleared from.
+function OpenLink({ item }) {
+ return (
+ <Link to={`/music-video/${encodeURIComponent(item.projectId)}/${item.openTo}`} aria-label={`Open ${item.title}`} className={PRIMARY}>
+ <ExternalLink size={12} aria-hidden="true" /> Open
+ </Link>
+ );
+}
+
/**
* The Music Video header's "Needs attention" banner (#9940): one row per
* server-held state a client-orchestrated workflow can strand — an open
@@ -61,7 +106,8 @@ function ItemActions({ item, busy, actions }) {
* looks permanently stuck. `items` comes from `deriveAttentionItems`; `actions`
* are the page's handlers (`onResumeRevision(id)`, `onCancelRevision(id)`,
* `onResumeCastAndSets()`, `onContinueAutoReview(runId)`,
- * `onCancelAutoReview(runId)`, `onReattachRender()`). Renders nothing when
+ * `onCancelAutoReview(runId)`, `onReattachRender()`, and for the parked-run
+ * rows `onResumeAutonomous()` / `onResumeProduction(runId, opts)`). Renders nothing when
* there is nothing to attend to.
*/
export default function NeedsAttentionBanner({ items, busy = false, actions = {} }) {
diff --git a/client/src/lib/musicVideoAttention.js b/client/src/lib/musicVideoAttention.js
index 794628f031..81d932d52e 100644
--- a/client/src/lib/musicVideoAttention.js
+++ b/client/src/lib/musicVideoAttention.js
@@ -12,6 +12,9 @@
* `NeedsAttentionBanner` renders them and the page wires their actions.
*/
+import { describeAutonomousWait } from './musicVideoAutonomous.js';
+import { RESUMABLE_RUN_STATUSES, currentProductionRun } from './musicVideoStages.js';
+
/** The DOM id of the banner, so a refusal toast can scroll to it. */
export const ATTENTION_ANCHOR_ID = 'mv-needs-attention';
@@ -121,6 +124,79 @@ export function deriveAttentionItems(project, { generatingSceneIds = null, draft
detail: 'Reattach to watch its progress or cancel it.',
});
}
+ return [...items, ...parkedRunItems(project)];
+}
+
+// Auto-review states that wait on the director (#10156): a limit, an unverifiable
+// review, or a halted run. `running` is live work, not a request for the user.
+const AUTO_REVIEW_PARKED = new Set(['needs-human', 'limit-reached', 'stopped']);
+const PRODUCTION_PARKED = new Set(['limit-reached', 'needs-human', 'blocked', 'needs-replan']);
+const AUTONOMOUS_PARKED = new Set(['awaiting-approval', 'needs-human', 'stopped', 'failed']);
+
+/** The newest board-driven auto-review run, when it is parked on the director. Older stopped runs are superseded. */
+export function parkedAutoReview(project) {
+ const run = asList(project?.autoReviews).filter((r) => !r.productionRunId).at(-1);
+ return run && AUTO_REVIEW_PARKED.has(run.status) ? run : null;
+}
+
+/** Whether the Review tab's "Revision and automatic review tools" section should open on its own: a run is live or parked. */
+export const autoReviewNeedsUser = (project) => asList(project?.autoReviews).some((r) => r.status === 'running' && !r.productionRunId) || !!parkedAutoReview(project);
+
+// Rows for runs the server holds that nobody is watching: an autonomous run
+// parked on the director, a production run stopped on a limit, an auto-review
+// that halted. Each is derived from the saved record, so it survives a reload.
+function parkedRunItems(project) {
+ const items = [];
+ const auto = project.autonomousRun;
+ const autoParked = auto && (AUTONOMOUS_PARKED.has(auto.status) || auto.interrupted);
+ if (autoParked) {
+ const interrupted = auto.interrupted && auto.status === 'running';
+ const awaiting = auto.status === 'awaiting-approval';
+ items.push({
+ id: `autonomous:${auto.id}`,
+ kind: 'autonomous',
+ tone: 'warn',
+ title: awaiting ? 'An autonomous run is waiting for your approval' : auto.status === 'failed' ? 'An autonomous run failed' : 'An autonomous run needs you',
+ detail: interrupted ? 'A restart interrupted it. Resume to continue from where it left off.' : describeAutonomousWait(project.name || 'This video', auto),
+ projectId: project.id,
+ canResume: !awaiting,
+ resumeLabel: auto.status === 'failed' ? 'Retry' : 'Resume',
+ openTo: awaiting ? 'setup#mv-auto-edit' : auto.stage === 'produce' ? 'produce' : 'setup',
+ });
+ }
+ const production = currentProductionRun(project);
+ // An autonomous run parked on this production reports the stop itself.
+ const ownedByAuto = autoParked && auto.output?.productionRunId === production?.id;
+ if (production && PRODUCTION_PARKED.has(production.status) && !ownedByAuto) {
+ const reason = production.stopReason || production.error;
+ items.push({
+ id: `production:${production.id}`,
+ kind: 'production',
+ tone: 'warn',
+ title: production.status === 'limit-reached' ? 'Production stopped at its limit' : production.status === 'needs-human' ? 'Production needs you' : 'Production is paused',
+ detail: reason || 'Open Produce to see what it is waiting on.',
+ projectId: project.id,
+ runId: production.id,
+ // Same exits as the header's next action: a needs-human run is cleared on the Produce tab.
+ canResume: RESUMABLE_RUN_STATUSES.has(production.status),
+ acceptBasis: production.status === 'needs-replan',
+ openTo: 'produce',
+ });
+ }
+ const review = parkedAutoReview(project);
+ if (review) {
+ items.push({
+ id: `auto-review-parked:${review.id}`,
+ kind: 'auto-review-parked',
+ tone: 'warn',
+ title: review.status === 'limit-reached' ? 'Auto-review stopped at its limit' : review.status === 'stopped' ? 'Auto-review is stopped' : 'Auto-review needs you',
+ detail: review.stopReason || review.error || 'Open the Review tab to resume it or take over.',
+ projectId: project.id,
+ runId: review.id,
+ canResume: review.status !== 'limit-reached',
+ openTo: 'review',
+ });
+ }
return items;
}
diff --git a/client/src/lib/musicVideoAttention.test.js b/client/src/lib/musicVideoAttention.test.js
index 1746134c66..9bb6c2a8cc 100644
--- a/client/src/lib/musicVideoAttention.test.js
+++ b/client/src/lib/musicVideoAttention.test.js
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
-import { deriveAttentionItems, openRevisionOf } from './musicVideoAttention.js';
+import { autoReviewNeedsUser, deriveAttentionItems, openRevisionOf } from './musicVideoAttention.js';
const scene = (sceneId, extra = {}) => ({ sceneId, ...extra });
const revision = (extra = {}) => ({
@@ -86,9 +86,10 @@ describe('deriveAttentionItems (#9940)', () => {
.toMatchObject([{ kind: 'revision' }]);
// This board is already generating the hand-out.
expect(deriveAttentionItems(project({ revisions: [revision()], autoReviews: [run()] }), { generatingSceneIds: new Set(['scene-a']) })).toEqual([]);
- // A paused run is not "waiting": its open revision is an ordinary revision.
+ // A paused run is not "waiting" for hand-out: its open revision is an ordinary revision,
+ // and the stopped run is listed on its own row (#10156).
expect(deriveAttentionItems(project({ revisions: [revision()], autoReviews: [run({ status: 'stopped' })] })))
- .toMatchObject([{ kind: 'revision' }]);
+ .toMatchObject([{ kind: 'revision' }, { kind: 'auto-review-parked' }]);
});
it('flags a final render the server holds that this tab is not showing', () => {
@@ -115,3 +116,42 @@ describe('openRevisionOf', () => {
expect(openRevisionOf(null)).toBeNull();
});
});
+
+describe('parked runs (#10156)', () => {
+ it('lists an autonomous run awaiting approval with an Open target and no Resume', () => {
+ const [item] = deriveAttentionItems(project({ name: 'Example', autonomousRun: { id: 'auto-1', status: 'awaiting-approval', awaiting: 'lyrics', stage: 'style' } }));
+ expect(item).toMatchObject({ kind: 'autonomous', canResume: false, openTo: 'setup#mv-auto-edit', projectId: 'mv-example' });
+ expect(item.detail).toContain('lyrics');
+ });
+
+ it('lists stopped and failed autonomous runs with a Resume or Retry', () => {
+ const stopped = deriveAttentionItems(project({ autonomousRun: { id: 'a', status: 'stopped', stage: 'song' } }));
+ const failed = deriveAttentionItems(project({ autonomousRun: { id: 'a', status: 'failed', stage: 'produce', error: 'boom' } }));
+ expect(stopped[0]).toMatchObject({ kind: 'autonomous', canResume: true, resumeLabel: 'Resume' });
+ expect(failed[0]).toMatchObject({ canResume: true, resumeLabel: 'Retry', openTo: 'produce' });
+ });
+
+ it('lists a stopped or limit-reached auto-review but not older superseded or healthy ones', () => {
+ const limit = deriveAttentionItems(project({ autoReviews: [run({ id: 'ar-1', status: 'limit-reached', stopReason: 'Reached the limit' })] }));
+ expect(limit).toEqual([expect.objectContaining({ kind: 'auto-review-parked', runId: 'ar-1', canResume: false, openTo: 'review', detail: 'Reached the limit' })]);
+ const stopped = deriveAttentionItems(project({ autoReviews: [run({ id: 'ar-2', status: 'stopped' })] }));
+ expect(stopped[0]).toMatchObject({ kind: 'auto-review-parked', canResume: true });
+ const superseded = deriveAttentionItems(project({ autoReviews: [run({ id: 'old', status: 'stopped' }), run({ id: 'new', status: 'passed' })] }));
+ expect(superseded).toEqual([]);
+ });
+
+ it('lists a production run at its limit, once, even when an autonomous run is parked on it', () => {
+ const production = { id: 'prod-1', status: 'limit-reached', stopReason: 'Spend limit' };
+ const alone = deriveAttentionItems(project({ productionRuns: [production] }));
+ expect(alone).toEqual([expect.objectContaining({ kind: 'production', runId: 'prod-1', openTo: 'produce', detail: 'Spend limit', canResume: true })]);
+ const owned = deriveAttentionItems(project({ productionRuns: [production], autonomousRun: { id: 'a', status: 'needs-human', stage: 'produce', output: { productionRunId: 'prod-1' } } }));
+ expect(owned.map((i) => i.kind)).toEqual(['autonomous']);
+ });
+
+ it('opens the auto-review tools only when a run is live or parked', () => {
+ expect(autoReviewNeedsUser(project())).toBe(false);
+ expect(autoReviewNeedsUser(project({ autoReviews: [run({ status: 'passed' })] }))).toBe(false);
+ expect(autoReviewNeedsUser(project({ autoReviews: [run({ status: 'running' })] }))).toBe(true);
+ expect(autoReviewNeedsUser(project({ autoReviews: [run({ status: 'needs-human' })] }))).toBe(true);
+ });
+});
diff --git a/client/src/lib/musicVideoAutonomous.js b/client/src/lib/musicVideoAutonomous.js
index d5cad3fdad..39822d5915 100644
--- a/client/src/lib/musicVideoAutonomous.js
+++ b/client/src/lib/musicVideoAutonomous.js
@@ -6,6 +6,7 @@ import { musicVideoMediaMode } from '../../../server/lib/musicVideoMediaPolicy.j
import { llmStagesDraftFrom, llmStagesFromDraft } from './musicVideoAutomation.js';
import {
+ autonomousAttentionLink, describeAutonomousWait,
AUTONOMOUS_DEFAULT_LIMITS, AUTONOMOUS_DEFAULT_TOOLS, AUTONOMOUS_LIVE_STATUSES, AUTONOMOUS_SONG_SOURCES, AUTONOMOUS_STAGES,
SUNO_MODEL_PATTERN,
normalizeLocalMusicOptions,
@@ -26,7 +27,9 @@ export {
LOCAL_MUSIC_TYPE_LABELS,
SUNO_LIMITS,
SUNO_VOCAL_GENDERS,
+ autonomousAttentionLink,
autonomousMedium,
+ describeAutonomousWait,
normalizeLocalMusicOptions,
} from '../../../server/lib/musicVideoAutonomous.js';
@@ -193,6 +196,22 @@ export function autonomousStageOutput(run, stageId) {
/** True while the run can still move (or be nudged): the project page keeps its panel prominent. */
export const isAutonomousLive = (run) => !!run && AUTONOMOUS_LIVE_STATUSES.includes(run.status);
+// A scheduled run in one of these states holds the schedule: every later fire declines until it is cleared.
+const SCHEDULE_BLOCKING = new Set(['awaiting-approval', 'needs-human', 'stopped']);
+
+/**
+ * The project the Autonomous run schedule is parked on, as `{ projectId, name, status, link, summary }`,
+ * or null. Reads a full project (socket event) or a list summary (`runStatus` / `runOrigin`).
+ */
+export function scheduledRunBlocker(project) {
+ const run = project?.autonomousRun;
+ const status = run?.status ?? project?.runStatus;
+ const origin = run?.brief?.origin?.kind ?? project?.runOrigin;
+ if (!project?.id || origin !== 'schedule' || !SCHEDULE_BLOCKING.has(status)) return null;
+ const shown = run || { status };
+ return { projectId: project.id, name: project.name, status, link: autonomousAttentionLink(project.id, shown), summary: describeAutonomousWait(project.name, shown) };
+}
+
/** The Schedule-card form's draft for a saved `taskMetadata.musicVideoAutopilot` (the prompt comes from a Brain idea, so there is none). */
export function autopilotDraftFromParams(params) {
const p = params && typeof params === 'object' ? params : {};
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index 4f0944318c..291f6711be 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -1387,7 +1387,7 @@ export default function MusicVideo() {
attention={(
<NeedsAttentionBanner
items={attentionItems}
- busy={revisions.busy || castSets.busy || autoReview.busy || renderJob.reattaching}
+ busy={revisions.busy || castSets.busy || autoReview.busy || autonomous.busy || production.busy || renderJob.reattaching}
actions={{
onResumeRevision: revisions.resume,
onCancelRevision: revisions.cancel,
@@ -1395,6 +1395,8 @@ export default function MusicVideo() {
onContinueAutoReview: (runId) => autoReview.resume(runId),
onCancelAutoReview: (runId) => autoReview.cancel(runId),
onReattachRender: () => renderJob.reattach(selected.id),
+ onResumeAutonomous: () => autonomous.resume(),
+ onResumeProduction: (runId, opts) => production.resume(runId, opts),
}}
/>
)}
diff --git a/server/index.js b/server/index.js
index f6ddb855c2..3b31384546 100644
--- a/server/index.js
+++ b/server/index.js
@@ -558,6 +558,9 @@ runBootSequence({ io, httpServer, localHttpServer, httpsEnabled, port: PORT, hos
// Opt-in listener only: restores host configuration without generating tokens.
// The boot smoke (#8343) opens no listener beyond the API server it probes.
if (!isSmokeBoot()) {
+ // Event-driven notifications for parked Music Video runs (#10156); zero provider calls.
+ import('./services/musicVideo/attentionNotifier.js').then(({ initMusicVideoAttentionNotifier }) => initMusicVideoAttentionNotifier())
+ .catch((err) => console.error(`❌ Music video attention notifier could not start: ${err.message}`));
import('./services/fleetLlmHost.js').then(({ startFleetLlmHost }) => startFleetLlmHost())
.catch(() => console.error('❌ Dedicated model host listener could not start; open AI Providers → Model host setup.'));
// Local file scan only (no provider calls); keeps the federated Claude Code
diff --git a/server/lib/musicVideoAutonomous.js b/server/lib/musicVideoAutonomous.js
index da1bc9ee52..a73c0ee249 100644
--- a/server/lib/musicVideoAutonomous.js
+++ b/server/lib/musicVideoAutonomous.js
@@ -296,3 +296,31 @@ export function pickBrainIdea(ideas, { usedIdeaIds = [], tags = [] } = {}) {
export function ideaToPrompt(idea) {
return [idea?.title, idea?.oneLiner, idea?.notes].map((v) => clean(v, 2000)).filter(Boolean).join('\n\n').slice(0, AUTONOMOUS_PROMPT_MAX);
}
+
+// ---- "needs the director" (#10156) ------------------------------------------------
+
+/** Autonomous-run statuses that raise a PortOS notification: the run needs the director or has finished. */
+export const AUTONOMOUS_ATTENTION_STATUSES = Object.freeze(['awaiting-approval', 'needs-human', 'failed', 'completed']);
+
+const STAGE_TAB = Object.freeze({ brief: 'setup', lyrics: 'setup', style: 'setup', song: 'setup', analyze: 'setup', produce: 'produce' });
+
+/** The Music Video route a parked autonomous run is cleared from: the checkpoint editor, the failed stage's tab, or the finished video. */
+export function autonomousAttentionLink(projectId, run) {
+ const base = `/music-video/${encodeURIComponent(projectId)}`;
+ if (run?.status === 'awaiting-approval') return `${base}/setup#mv-auto-edit`;
+ if (run?.status === 'completed') return `${base}/review`;
+ return `${base}/${STAGE_TAB[run?.stage] || 'setup'}`;
+}
+
+/** One line naming a parked run and why it is waiting — the scheduled task's result and notification text. */
+export function describeAutonomousWait(name, run) {
+ const label = AUTONOMOUS_STAGES.find((s) => s.id === (run?.awaiting || run?.stage))?.label || 'a step';
+ const detail = run?.error ? `: ${trimTo(run.error, 200)}` : '';
+ switch (run?.status) {
+ case 'awaiting-approval': return `"${name}" is waiting for your approval of ${label.toLowerCase()}`;
+ case 'needs-human': return `"${name}" needs you${detail}`;
+ case 'stopped': return `"${name}" was stopped at ${label.toLowerCase()}`;
+ case 'failed': return `"${name}" failed at ${label.toLowerCase()}${detail}`;
+ default: return `"${name}" is still in progress`;
+ }
+}
diff --git a/server/lib/musicVideoSummary.js b/server/lib/musicVideoSummary.js
index baf01a166d..17b9d2ff3d 100644
--- a/server/lib/musicVideoSummary.js
+++ b/server/lib/musicVideoSummary.js
@@ -137,6 +137,8 @@ export function summarizeMusicVideoProject(project, readiness) {
runStatus: project.autonomousRun?.status || run?.status || null,
runInterrupted: Boolean(project.autonomousRun?.interrupted || project.castAndSets?.interrupted || run?.interrupted),
runAwaiting: project.autonomousRun?.status === 'awaiting-approval',
+ // 'schedule' when the Autonomous run task started it — the Schedule card names the project it is parked on (#10156).
+ runOrigin: project.autonomousRun?.brief?.origin?.kind || null,
poster: preview.poster || (preview.kind === 'image' ? preview.src : null),
preview,
spend: projectSpend(project, run),
diff --git a/server/lib/notificationTypes.js b/server/lib/notificationTypes.js
index 50bad2dda6..d2b2555cfa 100644
--- a/server/lib/notificationTypes.js
+++ b/server/lib/notificationTypes.js
@@ -10,7 +10,8 @@ export const NOTIFICATION_CATALOG = {
AGENT_WARNING: { key: 'agent_warning', label: 'Agent Warnings' },
AUTOPILOT_PAUSED: { key: 'autopilot_paused', label: 'Autopilot Paused' },
DAILY_POST_REMINDER: { key: 'daily_post_reminder', label: 'POST Reminders' },
- CREATIVE_COMMISSION: { key: 'creative_commission', label: 'Creative Commissions' }
+ CREATIVE_COMMISSION: { key: 'creative_commission', label: 'Creative Commissions' },
+ MUSIC_VIDEO_ATTENTION: { key: 'music_video_attention', label: 'Music Video Attention' }
};
export const NOTIFICATION_TYPES = Object.fromEntries(
diff --git a/server/services/musicVideo/attentionNotifier.js b/server/services/musicVideo/attentionNotifier.js
new file mode 100644
index 0000000000..e391bc7a0f
--- /dev/null
+++ b/server/services/musicVideo/attentionNotifier.js
@@ -0,0 +1,108 @@
+/**
+ * Music Video "needs you" notifications (#10156).
+ *
+ * The board only reacts to the project it has open, so a scheduled or
+ * autonomous run that parks (or a production run / auto-review that stops on a
+ * limit) used to sit unnoticed for days. This subscribes to the same
+ * `musicVideoEvents` the socket bridge forwards and raises ONE PortOS
+ * notification per parked state, deep-linked to the project and stage:
+ *
+ * - `autonomous` → awaiting-approval, needs-human, failed, completed
+ * - `production` → limit-reached, needs-human, blocked, needs-replan
+ * (skipped when an autonomous run owns it — its own
+ * needs-human notification covers the same stop)
+ * - `auto-review` → limit-reached, needs-human
+ * (skipped when a production run owns it)
+ *
+ * No provider calls: it only reads events and writes notifications. Started
+ * from boot (`initMusicVideoAttentionNotifier`), never by import side effect,
+ * so a test that loads the services never writes the real notification store.
+ */
+
+import { musicVideoEvents } from './events.js';
+import { AUTONOMOUS_ATTENTION_STATUSES, autonomousAttentionLink, describeAutonomousWait } from '../../lib/musicVideoAutonomous.js';
+
+const PRODUCTION_STOPS = new Set(['limit-reached', 'needs-human', 'blocked', 'needs-replan']);
+const AUTO_REVIEW_STOPS = new Set(['limit-reached', 'needs-human']);
+const MAX_REMEMBERED = 500;
+
+const STOP_LABEL = { 'limit-reached': 'hit its limit', 'needs-human': 'needs you', blocked: 'is blocked', 'needs-replan': 'needs a new plan' };
+
+// A run emits on every step, so the same parked state arrives repeatedly; one
+// notification per (run, status, checkpoint) is enough. Bounded, process-local.
+const raised = new Set();
+const firstTime = (key) => {
+ if (raised.has(key)) return false;
+ raised.add(key);
+ if (raised.size > MAX_REMEMBERED) raised.delete(raised.values().next().value);
+ return true;
+};
+
+/** The notification a stopped event warrants, or null. Pure — exported for the tests. */
+export function attentionNotificationFor(kind, { projectId, run, project } = {}) {
+ if (!projectId || !run?.id) return null;
+ const name = project?.name || 'Music video';
+ const base = `/music-video/${encodeURIComponent(projectId)}`;
+ if (kind === 'autonomous') {
+ if (!AUTONOMOUS_ATTENTION_STATUSES.includes(run.status)) return null;
+ const done = run.status === 'completed';
+ return {
+ key: `autonomous:${run.id}:${run.status}:${run.awaiting || run.stage || ''}`,
+ title: done ? 'Music video finished' : 'Music video needs you',
+ description: done ? `"${name}" finished — review it before publishing` : describeAutonomousWait(name, run),
+ priority: done ? 'low' : 'high',
+ link: autonomousAttentionLink(projectId, run),
+ metadata: { projectId, runId: run.id, status: run.status, source: 'autonomous' },
+ };
+ }
+ if (kind === 'production') {
+ if (!PRODUCTION_STOPS.has(run.status)) return null;
+ // An autonomous run waiting on this production reports the stop itself.
+ if (project?.autonomousRun?.output?.productionRunId === run.id) return null;
+ return {
+ key: `production:${run.id}:${run.status}`,
+ title: 'Music video production stopped',
+ description: `"${name}" production ${STOP_LABEL[run.status]}${run.stopReason || run.error ? `: ${String(run.stopReason || run.error).slice(0, 200)}` : ''}`,
+ priority: 'high',
+ link: `${base}/produce`,
+ metadata: { projectId, runId: run.id, status: run.status, source: 'production' },
+ };
+ }
+ if (kind === 'auto-review') {
+ if (!AUTO_REVIEW_STOPS.has(run.status) || run.productionRunId) return null;
+ return {
+ key: `auto-review:${run.id}:${run.status}`,
+ title: 'Music video auto-review stopped',
+ description: `"${name}" auto-review ${STOP_LABEL[run.status]}${run.stopReason ? `: ${String(run.stopReason).slice(0, 200)}` : ''}`,
+ priority: 'high',
+ link: `${base}/review`,
+ metadata: { projectId, runId: run.id, status: run.status, source: 'auto-review' },
+ };
+ }
+ return null;
+}
+
+async function raise(kind, event) {
+ const note = attentionNotificationFor(kind, event);
+ if (!note || !firstTime(note.key)) return;
+ const { addNotification, NOTIFICATION_TYPES } = await import('../notifications.js');
+ const { key: _key, ...fields } = note;
+ await addNotification({ type: NOTIFICATION_TYPES.MUSIC_VIDEO_ATTENTION, ...fields });
+}
+
+let started = false;
+
+/** Subscribe once. Idempotent. */
+export function initMusicVideoAttentionNotifier() {
+ if (started) return;
+ started = true;
+ for (const kind of ['autonomous', 'production', 'auto-review']) {
+ musicVideoEvents.on(kind, (event) => {
+ raise(kind, event).catch((err) => console.error(`❌ Music video notification failed: ${err.message}`));
+ });
+ }
+}
+
+export function __resetAttentionNotifierForTests() {
+ raised.clear();
+}
diff --git a/server/services/musicVideo/attentionNotifier.test.js b/server/services/musicVideo/attentionNotifier.test.js
new file mode 100644
index 0000000000..4496d3050c
--- /dev/null
+++ b/server/services/musicVideo/attentionNotifier.test.js
@@ -0,0 +1,62 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+const addNotification = vi.fn(async () => ({}));
+vi.mock('../notifications.js', () => ({
+ addNotification,
+ NOTIFICATION_TYPES: { MUSIC_VIDEO_ATTENTION: 'music_video_attention' },
+}));
+
+const { musicVideoEvents } = await import('./events.js');
+const { initMusicVideoAttentionNotifier, __resetAttentionNotifierForTests } = await import('./attentionNotifier.js');
+
+initMusicVideoAttentionNotifier();
+initMusicVideoAttentionNotifier(); // idempotent: a second call must not double-subscribe
+
+const settle = () => new Promise((resolve) => setTimeout(resolve, 0));
+const emit = async (event, payload) => { musicVideoEvents.emit(event, payload); await settle(); };
+const project = (extra = {}) => ({ id: 'mv-1', name: 'Example Video', ...extra });
+
+beforeEach(() => {
+ addNotification.mockClear();
+ __resetAttentionNotifierForTests();
+});
+
+describe('music video attention notifications (#10156)', () => {
+ it('raises one deep-linked notification when a scheduled run parks at an approval, however often it re-emits', async () => {
+ const run = { id: 'run-1', status: 'awaiting-approval', awaiting: 'lyrics', stage: 'style' };
+ for (let i = 0; i < 3; i += 1) await emit('autonomous', { projectId: 'mv-1', run, project: project() });
+ expect(addNotification).toHaveBeenCalledTimes(1);
+ expect(addNotification.mock.calls[0][0]).toMatchObject({
+ type: 'music_video_attention',
+ link: '/music-video/mv-1/setup#mv-auto-edit',
+ description: expect.stringContaining('Example Video'),
+ metadata: { projectId: 'mv-1', runId: 'run-1', status: 'awaiting-approval' },
+ });
+ });
+
+ it('notifies for needs-human, failed and completed but not for a running run', async () => {
+ await emit('autonomous', { projectId: 'mv-1', run: { id: 'r', status: 'running', stage: 'produce' }, project: project() });
+ expect(addNotification).not.toHaveBeenCalled();
+ for (const status of ['needs-human', 'failed', 'completed']) {
+ await emit('autonomous', { projectId: 'mv-1', run: { id: 'r', status, stage: 'produce', error: 'boom' }, project: project() });
+ }
+ expect(addNotification.mock.calls.map(([n]) => n.metadata.status)).toEqual(['needs-human', 'failed', 'completed']);
+ expect(addNotification.mock.calls[2][0].link).toBe('/music-video/mv-1/review');
+ });
+
+ it('notifies when production or a board auto-review stops on a limit', async () => {
+ await emit('production', { projectId: 'mv-1', run: { id: 'p-1', status: 'limit-reached', stopReason: 'budget spent' }, project: project() });
+ await emit('auto-review', { projectId: 'mv-1', run: { id: 'a-1', status: 'needs-human', stopReason: 'could not verify' }, project: project() });
+ expect(addNotification.mock.calls.map(([n]) => n.link)).toEqual(['/music-video/mv-1/produce', '/music-video/mv-1/review']);
+ });
+
+ it('stays silent where another notification already covers the stop', async () => {
+ // Production owned by an autonomous run: the run's own needs-human notification covers it.
+ await emit('production', { projectId: 'mv-1', run: { id: 'p-1', status: 'needs-human' }, project: project({ autonomousRun: { output: { productionRunId: 'p-1' } } }) });
+ // Auto-review owned by a production run, a user pause and a passing review.
+ await emit('auto-review', { projectId: 'mv-1', run: { id: 'a-1', status: 'limit-reached', productionRunId: 'p-1' }, project: project() });
+ await emit('auto-review', { projectId: 'mv-1', run: { id: 'a-2', status: 'stopped' }, project: project() });
+ await emit('auto-review', { projectId: 'mv-1', run: { id: 'a-3', status: 'passed' }, project: project() });
+ expect(addNotification).not.toHaveBeenCalled();
+ });
+});
diff --git a/server/services/scheduledHandlers/musicVideoAutopilot.js b/server/services/scheduledHandlers/musicVideoAutopilot.js
index 3df0d237a3..008b1ccd9b 100644
--- a/server/services/scheduledHandlers/musicVideoAutopilot.js
+++ b/server/services/scheduledHandlers/musicVideoAutopilot.js
@@ -20,7 +20,7 @@
import { getIdeas } from '../brainStorage.js';
import { listProjects } from '../musicVideo/projects.js';
-import { AUTONOMOUS_LIVE_STATUSES, ideaToPrompt, normalizeAutopilotParams, pickBrainIdea } from '../../lib/musicVideoAutonomous.js';
+import { AUTONOMOUS_LIVE_STATUSES, autonomousAttentionLink, describeAutonomousWait, ideaToPrompt, normalizeAutopilotParams, pickBrainIdea } from '../../lib/musicVideoAutonomous.js';
const USED_STATUSES = new Set([...AUTONOMOUS_LIVE_STATUSES, 'completed']);
@@ -37,6 +37,15 @@ function priorRuns(projects) {
return { usedIdeaIds, live };
}
+/** The live project this task is waiting on, named for the task result and the Schedule card. */
+const blockingOf = (project) => ({
+ projectId: project.id,
+ name: project.name,
+ status: project.autonomousRun.status,
+ link: autonomousAttentionLink(project.id, project.autonomousRun),
+ summary: describeAutonomousWait(project.name, project.autonomousRun),
+});
+
async function inspect(params) {
const settings = normalizeAutopilotParams(params?.musicVideoAutopilot) || normalizeAutopilotParams({});
const [ideas, projects] = await Promise.all([getIdeas(), listProjects()]);
@@ -47,13 +56,16 @@ async function inspect(params) {
export async function countPending({ params } = {}) {
const { idea, live } = await inspect(params);
- if (live) return { count: 0, detail: `"${live.name}" is still in progress` };
+ if (live) return { count: 0, detail: `waiting on ${blockingOf(live).summary}`, blocking: blockingOf(live) };
return { count: idea ? 1 : 0, detail: idea ? `Next idea: ${idea.title}` : 'No unused active Brain ideas' };
}
export async function run({ params } = {}) {
const { settings, idea, live } = await inspect(params);
- if (live) return { dispatched: false, reason: `a previous autonomous music video ("${live.name}") is still in progress` };
+ if (live) {
+ const blocking = blockingOf(live);
+ return { dispatched: false, reason: `waiting on a previous autonomous music video: ${blocking.summary}`, blocking };
+ }
if (!idea) return { dispatched: false, reason: 'no unused active Brain ideas to turn into a music video' };
const { ideaTags: _ideaTags, ...runSettings } = settings;
const { startAutonomousVideo } = await import('../musicVideo/autonomousService.js');
diff --git a/server/services/scheduledHandlers/musicVideoAutopilot.test.js b/server/services/scheduledHandlers/musicVideoAutopilot.test.js
index 17f6faa5f5..30ab23910c 100644
--- a/server/services/scheduledHandlers/musicVideoAutopilot.test.js
+++ b/server/services/scheduledHandlers/musicVideoAutopilot.test.js
@@ -46,6 +46,15 @@ describe('music-video-autopilot scheduled handler', () => {
expect(startAutonomousVideo).not.toHaveBeenCalled();
});
+ it('names the parked project, why it is waiting and where to clear it, so the Schedule card can show it', async () => {
+ ideas.push(idea('a', '2026-01-01T00:00:00.000Z'));
+ projects.push({ id: 'mv-9', name: 'Parked video', autonomousRun: { status: 'awaiting-approval', awaiting: 'lyrics', stage: 'style', brief: { origin: { kind: 'schedule', ideaId: 'zzz' } } } });
+ const out = await run({ params: {} });
+ expect(out.reason).toContain('"Parked video" is waiting for your approval of lyrics');
+ expect(out.blocking).toMatchObject({ projectId: 'mv-9', status: 'awaiting-approval', link: '/music-video/mv-9/setup#mv-auto-edit' });
+ expect((await countPending({ params: {} })).detail).toContain('Parked video');
+ });
+
it('declines with a reason when no idea is eligible, honoring the tag filter', async () => {
ideas.push(idea('a', '2026-01-01T00:00:00.000Z', { tags: ['poem'] }));
expect(await run({ params: { musicVideoAutopilot: { ideaTags: ['song'] } } })).toMatchObject({ dispatched: false });