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

Show a stale approval once, with Keep approved first and its undo list folded

Claude5ceab070734f
diff --git a/client/src/components/musicVideo/NeedsAttentionBanner.test.jsx b/client/src/components/musicVideo/NeedsAttentionBanner.test.jsx
index 52dc88e41c..bbb98a72dd 100644
--- a/client/src/components/musicVideo/NeedsAttentionBanner.test.jsx
+++ b/client/src/components/musicVideo/NeedsAttentionBanner.test.jsx
@@ -47,6 +47,16 @@ describe('NeedsAttentionBanner (#9940)', () => {
expect(handlers.onRevertApproval).toHaveBeenCalledWith('storyboard', 'concept');
});
+ it('folds many reverts behind one toggle so Keep approved stays the obvious choice', () => {
+ const revertible = Array.from({ length: 26 }, (_, i) => `scene ${i + 1} prompt`);
+ const readiness = { storyboard: { approved: false, problems: [], stale: { changedFields: ['storyboard shots', ...revertible], revertible } } };
+ renderWithRouter(<NeedsAttentionBanner items={deriveAttentionItems({ id: 'mv-example', scenes: [] }, { readiness })} actions={{ onKeepApproval: vi.fn(), onRevertApproval: vi.fn() }} />);
+ const banner = screen.getByRole('region', { name: 'Needs attention' });
+ expect(banner).toHaveTextContent('changed since: storyboard shots, 26 scene prompts.');
+ expect(within(banner).getByText('See 26 changes to Timed storyboard you can undo').closest('details').open).toBe(false);
+ expect(within(banner).getByRole('button', { name: 'Keep Timed storyboard approved' })).toBeVisible();
+ });
+
it('offers Resume and Cancel for an open revision, wired to the id the project holds', () => {
const handlers = actions();
renderWithRouter(<NeedsAttentionBanner items={deriveAttentionItems({ ...stranded, status: 'complete', castAndSets: null })} actions={handlers} />);
diff --git a/client/src/components/musicVideo/StageChecklist.jsx b/client/src/components/musicVideo/StageChecklist.jsx
index 90b8a69a3d..4162774d80 100644
--- a/client/src/components/musicVideo/StageChecklist.jsx
+++ b/client/src/components/musicVideo/StageChecklist.jsx
@@ -1,4 +1,5 @@
import { ArrowRight, CheckCircle2, Circle } from 'lucide-react';
+import StaleApprovalActions from './StaleApprovalActions.jsx';
/**
* The top of every stage tab: what this stage needs before it counts as done
@@ -7,7 +8,8 @@ import { ArrowRight, CheckCircle2, Circle } from 'lucide-react';
* control, a `run` starts the work itself (`onAction` gets either) — unless the
* header's next action already goes there (`headerAnchor`). An item may add a
* quieter `secondary` choice beside it. Run buttons wait while `busy`. A stale
- * approval lists a Revert button per changed input whose approved value was kept.
+ * approval offers a Revert per changed input whose approved value was kept
+ * (folded behind "See N changes" when there are several).
* An `optional` item is listed but never counted toward the step being done.
* An item's `notes` (open change requests) each get a Mark resolved button,
* which calls `onAction({ run: 'resolve-feedback', feedbackId })`.
@@ -61,14 +63,8 @@ export default function StageChecklist({ items, onAction, onRevert, headerAnchor
</ul>
)}
{!item.done && item.revert && onRevert && (
- <div className="mt-1 flex flex-wrap gap-1.5">
- {item.revert.fields.map((field) => (
- <button key={field} type="button" onClick={() => onRevert(item.revert.stage, field)}
- title="Put this back to the value you approved"
- className="min-h-[44px] rounded border border-port-border px-2 py-1 text-xs text-port-accent sm:min-h-0">
- Revert {field}
- </button>
- ))}
+ <div className="mt-1">
+ <StaleApprovalActions revertible={item.revert.fields} busy={busy} onRevert={(field) => onRevert(item.revert.stage, field)} />
</div>
)}
</div>
diff --git a/client/src/components/musicVideo/StaleApprovalActions.jsx b/client/src/components/musicVideo/StaleApprovalActions.jsx
index a907e5ceb3..921930d663 100644
--- a/client/src/components/musicVideo/StaleApprovalActions.jsx
+++ b/client/src/components/musicVideo/StaleApprovalActions.jsx
@@ -1,30 +1,47 @@
-import { CheckCircle2, RotateCcw } from 'lucide-react';
+import { CheckCircle2, ChevronRight, RotateCcw } from 'lucide-react';
+import { formatCount } from '../../utils/formatters.js';
const buttonClass = 'flex items-center gap-1 rounded border border-port-border px-3 py-1.5 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50';
+const keepClass = 'flex items-center gap-1 rounded bg-port-accent px-3 py-1.5 text-sm font-medium text-white min-h-[44px] sm:min-h-0 disabled:opacity-50';
+const chipClass = 'flex items-center gap-1 rounded border border-port-border px-2 py-1 text-xs min-h-[36px] sm:min-h-0 disabled:opacity-50';
+// More reverts than this fold behind one "See N changes" toggle, so Keep approved stays the one obvious choice.
+const INLINE_REVERTS = 2;
/**
* The two ways out of a stale approval, side by side: Keep approved (`onKeep`,
* the approval stands on the current inputs) and a Revert per changed input
- * whose approved value was kept (`revertible` → `onRevert(field)`). `label`
+ * whose approved value was kept (`revertible` → `onRevert(field)`), folded
+ * behind "See N changes" when there are more than a couple. `label`
* names the approval in each button's accessible name, for a surface that lists
* several. Renders nothing when neither applies.
*/
export default function StaleApprovalActions({ revertible, busy = false, onKeep, onRevert, label = null, keepTitle = 'Keep this approved on the current inputs' }) {
const reverts = onRevert ? revertible || [] : [];
if (!onKeep && !reverts.length) return null;
+ const folded = reverts.length > INLINE_REVERTS;
+ // Folded, each revert is a compact chip naming just the input, so a long list stays a few rows on a phone.
+ const revertButtons = reverts.map((field) => (
+ <button key={field} type="button" disabled={busy} onClick={() => onRevert(field)} title="Put this back to the value you approved"
+ aria-label={`Revert ${field}${label ? ` on ${label}` : ''}`} className={folded ? chipClass : buttonClass}>
+ <RotateCcw size={folded ? 12 : 14} aria-hidden="true" /> {folded ? field : `Revert ${field}`}
+ </button>
+ ));
return (
- <div className="flex flex-wrap gap-2">
+ <div className="flex min-w-0 flex-wrap items-start gap-2">
{onKeep && (
- <button type="button" disabled={busy} onClick={onKeep} title={keepTitle} aria-label={label ? `Keep ${label} approved` : undefined} className={`${buttonClass} text-port-accent`}>
+ <button type="button" disabled={busy} onClick={onKeep} title={keepTitle} aria-label={label ? `Keep ${label} approved` : undefined} className={keepClass}>
<CheckCircle2 size={14} aria-hidden="true" /> Keep approved
</button>
)}
- {reverts.map((field) => (
- <button key={field} type="button" disabled={busy} onClick={() => onRevert(field)} title="Put this back to the value you approved"
- aria-label={label ? `Revert ${field} on ${label}` : undefined} className={buttonClass}>
- <RotateCcw size={14} aria-hidden="true" /> Revert {field}
- </button>
- ))}
+ {folded ? (
+ <details className="group min-w-0 basis-full">
+ <summary className="flex min-h-[44px] cursor-pointer list-none items-center gap-1 text-sm text-port-text-muted hover:text-port-accent sm:min-h-0 sm:py-1">
+ <ChevronRight size={14} aria-hidden="true" className="transition-transform group-open:rotate-90" />
+ {`See ${formatCount(reverts.length)} changes${label ? ` to ${label}` : ''} you can undo`}
+ </summary>
+ <div className="mt-1 flex flex-wrap gap-1.5">{revertButtons}</div>
+ </details>
+ ) : revertButtons}
</div>
);
}
diff --git a/client/src/lib/musicVideoAttention.js b/client/src/lib/musicVideoAttention.js
index cd700d0397..d66be8f8d9 100644
--- a/client/src/lib/musicVideoAttention.js
+++ b/client/src/lib/musicVideoAttention.js
@@ -42,6 +42,8 @@ function sectionProgress(project, revision) {
* - `finalRenderAttached` — this tab already shows the final render's progress
* - `readiness` — the server's production readiness, for approvals given on
* inputs that have changed since (#10141)
+ * - `stage` — the step on screen; a stale approval that step already shows
+ * with its own controls is left out of the banner
* - `headerAction` — the header's next action (`{ id, runId }`); a parked run
* it already resumes drops its own Resume so one screen never offers two
* controls for the same run
@@ -49,7 +51,7 @@ function sectionProgress(project, revision) {
* Row shape: `{ id, kind, tone, title, detail, … }` plus the ids the action
* needs — `revisionId` + `canResume` (revision), `runId` (auto-review).
*/
-export function deriveAttentionItems(project, { generatingSceneIds = null, draftRendering = false, finalRenderAttached = false, readiness = project?.productionReadiness, headerAction = null } = {}) {
+export function deriveAttentionItems(project, { generatingSceneIds = null, draftRendering = false, finalRenderAttached = false, readiness = project?.productionReadiness, headerAction = null, stage = null } = {}) {
if (!project) return [];
const items = [];
const spinning = (sceneId) => !!generatingSceneIds?.has?.(sceneId);
@@ -129,7 +131,7 @@ export function deriveAttentionItems(project, { generatingSceneIds = null, draft
detail: 'Reattach to watch its progress or cancel it.',
});
}
- const stale = staleApprovalItem(project, readiness);
+ const stale = staleApprovalItem(project, readiness, stage);
return [...items, ...parkedRunItems(project, headerAction), ...(stale ? [stale] : [])];
}
@@ -144,9 +146,11 @@ const STALE_APPROVALS = [
// One row for every approval given on inputs that have changed since (#10141),
// naming what changed per approval and opening the earliest one. A running
// production replaces takes as its job, so it does not flag its own progress.
-function staleApprovalItem(project, readiness) {
+// An approval the open step already shows (its checklist row, or the Cast & Sets
+// check-in card) is not repeated here.
+function staleApprovalItem(project, readiness, stage) {
if (currentProductionRun(project)?.status === 'running') return null;
- const stale = STALE_APPROVALS.filter(([key]) => readiness?.[key]?.stale);
+ const stale = STALE_APPROVALS.filter(([key, , openTo]) => readiness?.[key]?.stale && openTo.split('#')[0] !== stage);
if (!stale.length) return null;
const describe = ([key, label]) => {
const fields = readiness[key].stale.changedFields || [];
diff --git a/client/src/lib/musicVideoAttention.test.js b/client/src/lib/musicVideoAttention.test.js
index 4fe093e2cf..658a28c29f 100644
--- a/client/src/lib/musicVideoAttention.test.js
+++ b/client/src/lib/musicVideoAttention.test.js
@@ -184,6 +184,12 @@ describe('stale approvals in Needs attention (#10141)', () => {
expect(item.detail).toBe('Cast & Sets check-in — changed since: concept. Art direction — changed since: concept, cast, environments +1 more. Keep the approval, or undo the change.');
});
+ it('leaves out an approval the open step already shows with its own controls', () => {
+ const [onBoard] = deriveAttentionItems(project(), { readiness, stage: 'board' });
+ expect(onBoard.approvals.map((a) => a.stage)).toEqual(['castAndSets', 'art']);
+ expect(deriveAttentionItems(project(), { readiness, stage: 'cast-sets' })).toEqual([]);
+ });
+
it('stays quiet with no stale approval, and while a production run is replacing takes', () => {
expect(deriveAttentionItems(project(), { readiness: { art: { stale: null } } })).toEqual([]);
const producing = project({ productionRuns: [{ id: 'run-1', status: 'running' }], productionRunId: 'run-1' });
diff --git a/client/src/lib/musicVideoStages.js b/client/src/lib/musicVideoStages.js
index 8c2d1b1f9e..472c42558b 100644
--- a/client/src/lib/musicVideoStages.js
+++ b/client/src/lib/musicVideoStages.js
@@ -533,10 +533,28 @@ export function staleApprovalText(stale) {
if (!stale) return null;
return stale.changedFields.length ? `Approved earlier — changed since: ${changedFieldsText(stale.changedFields)}.` : 'Approved earlier — its inputs changed since.';
}
-/** "concept, scene 3 prompt +2 more": the first `limit` changed inputs of a stale approval. */
+const SCENE_FIELD = /^scene \d+ (.+)$/;
+const SCENE_FIELD_PLURALS = { prompt: 'prompts', timing: 'timings', lyrics: 'lyrics', camera: 'cameras' };
+/**
+ * "concept, 26 scene prompts +2 more": the first `limit` changed inputs of a
+ * stale approval, with each per-scene kind (prompt, timing, …) folded into one count.
+ */
export function changedFieldsText(changedFields, limit = 4) {
- const more = changedFields.length > limit ? ` +${changedFields.length - limit} more` : '';
- return `${changedFields.slice(0, limit).join(', ')}${more}`;
+ const scenes = new Map();
+ const labels = [];
+ for (const field of changedFields) {
+ const kind = SCENE_FIELD.exec(field)?.[1];
+ if (!kind) { labels.push(field); continue; }
+ if (!scenes.has(kind)) { scenes.set(kind, []); labels.push({ kind }); }
+ scenes.get(kind).push(field);
+ }
+ const text = labels.map((label) => {
+ if (typeof label === 'string') return label;
+ const fields = scenes.get(label.kind);
+ return fields.length === 1 ? fields[0] : `${formatCount(fields.length)} scene ${SCENE_FIELD_PLURALS[label.kind] || label.kind}`;
+ });
+ const more = text.length > limit ? ` +${text.length - limit} more` : '';
+ return `${text.slice(0, limit).join(', ')}${more}`;
}
const APPROVAL_ANCHORS = { art: 'mv-review-art', storyboard: 'mv-review-storyboard', proof: 'mv-review-proof' };
const APPROVAL_STAGES = { art: 'cast-sets', storyboard: 'board', proof: 'produce' };
@@ -664,11 +682,12 @@ export function stageChecklist(stageId, project, readiness = project?.production
const stale = staleApprovalText(readiness?.[key]?.stale);
// Change requests have their own Feedback row; the approval names the first other blocker, else points there.
const blocker = readiness?.[key]?.problems?.find(notFeedback) || changeRequestBlocker(openChangeRequests(project, key));
+ // A stale approval with nothing else blocking it can be kept as is, right from the row.
+ const keepable = !!stale && !approved && !blocker && key !== 'proof';
return {
id: `approve-${key}`, label: `${label} approved`, done: approved, stale: !!stale,
- detail: approved || !readiness ? null : (stale ? `${stale} Re-approve in the editor below.` : blocker || waitingText),
- // A stale approval with nothing else blocking it can be kept as is, right from the row.
- ...(stale && !approved && !blocker && key !== 'proof'
+ detail: approved || !readiness ? null : (stale ? (keepable ? stale : `${stale} Re-approve in the editor below.`) : blocker || waitingText),
+ ...(keepable
? { action: { label: 'Keep approved', run: 'keep-approval', stage: key }, secondary: { label: `Review ${label.toLowerCase()}`, anchor: APPROVAL_ANCHORS[key], stage: APPROVAL_STAGES[key] } }
: { action: approved ? null : { label: `Review ${label.toLowerCase()}`, anchor: APPROVAL_ANCHORS[key], stage: APPROVAL_STAGES[key] } }),
// Inputs whose approved value the server kept: each gets a Revert button.
diff --git a/client/src/lib/musicVideoStages.test.js b/client/src/lib/musicVideoStages.test.js
index e78823d1ef..401151a79e 100644
--- a/client/src/lib/musicVideoStages.test.js
+++ b/client/src/lib/musicVideoStages.test.js
@@ -1,6 +1,7 @@
import { describe, it, expect } from 'vitest';
import { summarizeMusicVideoProject } from '../../../server/lib/musicVideoSummary.js';
import {
+ changedFieldsText,
MUSIC_VIDEO_STAGES, currentProductionRun, deriveNextAction, deriveStages, projectSpend, boardJobEstimate, listPreviewSources, describeProjectStatus, resolveStageParam, stageChecklist, stepNotes, autopilotStatus, compareMusicVideoProjectsNewestFirst,
} from './musicVideoStages.js';
@@ -492,6 +493,11 @@ describe('stageChecklist', () => {
const stale = { ...readiness, storyboard: { approved: false, problems: ['Review and approve the current art direction first.'], stale: { changedFields: ['art direction', 'cast'] } } };
expect(stageChecklist('board', castProject({ scenes: [scene()] }), stale).at(-1).detail).toMatch(/changed since: art direction, cast/);
});
+ it('counts per-scene changes in a stale approval instead of naming every scene', () => {
+ const prompts = Array.from({ length: 26 }, (_, i) => `scene ${i + 1} prompt`);
+ expect(changedFieldsText(['storyboard shots', ...prompts, 'scene 4 timing'])).toBe('storyboard shots, 26 scene prompts, scene 4 timing');
+ });
+
it('offers Keep approved on a stale approval nothing else blocks, and files feedback on its own row', () => {
const feedback = [{ id: 'fb-1', stage: 'storyboard', target: 'Chorus', text: 'More lyrics on screen', decision: 'request-changes' }];
const stale = { ...NOT_APPROVED, storyboard: { approved: false, problems: [], stale: { changedFields: ['cast'] } } };
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index b1a17e98c8..d9cf21f379 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -1119,6 +1119,7 @@ export default function MusicVideo() {
finalRenderAttached: renderTargetsSelected,
readiness: productionReview.readiness,
headerAction: nextAction,
+ stage: activeStage,
}) : [];
// A checklist row either jumps to the control that settles it or, for work
// the page can start itself (build or resume the cast & sets, fill the art