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
Open Cast & Sets images in the preview modal instead of the raw file
Claude9da7e80cb75f
diff --git a/client/src/components/musicVideo/AutopilotPanel.jsx b/client/src/components/musicVideo/AutopilotPanel.jsxindex d7c7511fa0..5aa9a43624 100644--- a/client/src/components/musicVideo/AutopilotPanel.jsx+++ b/client/src/components/musicVideo/AutopilotPanel.jsx@@ -115,9 +115,12 @@ function RunView({ run, production, codeFirst, project, readiness }) {{(run.pilot.scenes || []).map((pilot) => {const excerpt = project.excerpts?.find((e) => e.id === pilot.excerptId);return <div key={pilot.sceneId} className="space-y-0.5">- <p>{pilot.operation}: {pilot.sceneId} · {pilot.status || 'pending'}- {excerpt?.filename && <> · <a href={`/data/videos/${excerpt.filename}`} target="_blank" rel="noreferrer" className="text-port-accent underline">Watch pilot</a></>}- </p>+ <p>{pilot.operation}: {pilot.sceneId} · {pilot.status || 'pending'}</p>+ {/* Inline, not a raw-file link: a Home Screen app opens that in place with no way back. */}+ {excerpt?.filename && <details>+ <summary className="cursor-pointer text-port-accent min-h-[44px] sm:min-h-0 py-1">Watch pilot</summary>+ <video src={`/data/videos/${encodeURIComponent(excerpt.filename)}`} controls playsInline preload="metadata" className="mt-1 w-full max-h-64 rounded bg-black" />+ </details>}{pilot.evidence && <p className="text-port-text-muted">Continuous analysis: {pilot.evidence.continuous ? 'verified' : 'unverified'} · Sampled frames: {formatCount(pilot.evidence.continuousFrames)} · Temporal alignment: {pilot.evidence.temporal?.status || 'unverified'}</p>}{pilot.repair && <p className="text-port-warning">Repair: {pilot.repair.category} · {pilot.repair.reason} Replacement generation spend for this repair stage: {formatUsd(pilot.repair.expectedGenerationSpendUsd)}.</p>}</div>;diff --git a/client/src/components/musicVideo/AutopilotPanel.test.jsx b/client/src/components/musicVideo/AutopilotPanel.test.jsxindex 6dfa6fc0c3..4bf373e6d7 100644--- a/client/src/components/musicVideo/AutopilotPanel.test.jsx+++ b/client/src/components/musicVideo/AutopilotPanel.test.jsx@@ -379,7 +379,8 @@ describe('AutopilotPanel budgeted pilot evidence (#9351)', () => {expect(screen.getByLabelText('Production budget')).toHaveTextContent('Expected next spend: unpriced');expect(screen.getByLabelText('Production pilot evidence')).toHaveTextContent('Temporal alignment: unverified');expect(screen.getByLabelText('Production pilot evidence')).toHaveTextContent('Repair: temporal-alignment');- expect(screen.getByRole('link', { name: 'Watch pilot' })).toHaveAttribute('href', '/data/videos/synthetic-pilot.mp4');+ expect(screen.queryByRole('link', { name: 'Watch pilot' })).not.toBeInTheDocument();+ expect(screen.getByText('Watch pilot').closest('details').querySelector('video')).toHaveAttribute('src', '/data/videos/synthetic-pilot.mp4');expect(api.startMusicVideoProduction).not.toHaveBeenCalled();expect(api.resumeMusicVideoProduction).not.toHaveBeenCalled();});diff --git a/client/src/components/musicVideo/CastAndSetsCheckin.jsx b/client/src/components/musicVideo/CastAndSetsCheckin.jsxindex 43cecb4a52..7d815671a9 100644--- a/client/src/components/musicVideo/CastAndSetsCheckin.jsx+++ b/client/src/components/musicVideo/CastAndSetsCheckin.jsx@@ -37,7 +37,7 @@ function statusLine(stage) {* concept, style, subjects or song changed since (`stale`, from the server's* readiness) says what changed and offers Keep approved beside Rebuild (#10141).*/-export default function CastAndSetsCheckin({ id, project, stale = null, busy, onOpenSheet, onApprove, onRegenerate, onEditDirection, onResume, onRebuild, onReconfirm, onRevert, onSkip }) {+export default function CastAndSetsCheckin({ id, project, stale = null, busy, onOpenSheet, onOpenPreview, onApprove, onRegenerate, onEditDirection, onResume, onRebuild, onReconfirm, onRevert, onSkip }) {const stage = project.castAndSets;if (!stage) return null;const working = WORKING.has(stage.status) && !stage.interrupted;@@ -70,7 +70,7 @@ export default function CastAndSetsCheckin({ id, project, stale = null, busy, on))}</div>)}- <CastAndSetsReferenceProgress stage={stage} />+ <CastAndSetsReferenceProgress stage={stage} onOpenPreview={onOpenPreview} /><div className="flex flex-wrap gap-2">{sheet && (<button type="button" onClick={() => onOpenSheet(sheet.id)} className={`${buttonClass} border border-port-border`}>diff --git a/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx b/client/src/components/musicVideo/CastAndSetsCheckin.test.jsxindex ef8dce3282..6a3f2ae804 100644--- a/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx+++ b/client/src/components/musicVideo/CastAndSetsCheckin.test.jsx@@ -3,6 +3,7 @@ import { act, fireEvent, render, screen, within } from '@testing-library/react';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import CastSetsStage from './stages/CastSetsStage.jsx';import useMusicVideoCastAndSets from '../../hooks/useMusicVideoCastAndSets';+import { castAndSetsPreviewItems } from './CastAndSetsReferenceProgress.jsx';const { listeners, api, getMediaJob } = vi.hoisted(() => ({listeners: new Map(),@@ -34,11 +35,11 @@ const plan = {const project = (images = {}, extra = {}) => ({ id: 'example-project', castAndSets: { revision: 1, status: 'imaging', plan, images, moodImages: [{ kind: 'image-ref', filename: 'mood.png' }], ...extra } });const done = (filename, prompt) => ({ status: 'done', jobId: `job-${filename}`, imageId: filename, submittedPrompt: prompt, submittedRevision: 1, submittedReferences: [{ kind: 'image-ref', filename: 'mood.png' }] });let selectProject;-function Harness({ initial, locked = true }) {+function Harness({ initial, locked = true, openPreview = vi.fn() }) {const [value, setValue] = useState(initial);selectProject = setValue;const actions = useMusicVideoCastAndSets({ project: value, replaceProject: setValue });- return <CastSetsStage board={{ project: value, locked, castSets: actions, kickoff: { running: locked }, devArtifacts: { busy: false }, openArtifact: vi.fn(), approveCastAndSets: actions.approve, skipCastAndSets: actions.skip, ...DRAFTS }} />;+ return <CastSetsStage board={{ project: value, locked, castSets: actions, kickoff: { running: locked }, devArtifacts: { busy: false }, openArtifact: vi.fn(), openPreview, approveCastAndSets: actions.approve, skipCastAndSets: actions.skip, ...DRAFTS }} />;}const stage = (next) => emit('music-video:cast-and-sets', { projectId: next.id, project: next });const card = (name) => within(screen.getByRole('article', { name }));@@ -97,9 +98,17 @@ describe('Cast & Sets incremental references', () => {await stage(reloaded);view.unmount();getMediaJob.mockClear();- render(<Harness initial={reloaded} />);+ const openPreview = vi.fn();+ render(<Harness initial={reloaded} openPreview={openPreview} />);expect(card('Keeper').getByText('New submitted prompt')).toBeInTheDocument();- expect(card('Keeper').getByRole('link', { name: 'Keeper — generated reference' })).toHaveAttribute('href', '/data/images/keeper-new.png');+ // Taps open the page lightbox, never the raw file (a Home Screen app has no back from that).+ expect(card('Keeper').queryByRole('link')).not.toBeInTheDocument();+ fireEvent.click(card('Keeper').getByRole('button', { name: 'Preview Keeper' }));+ fireEvent.click(card('Keeper').getByRole('button', { name: 'Keeper input: mood.png' }));+ expect(openPreview.mock.calls).toEqual([['image:keeper-new.png'], ['image-ref:mood.png']]);+ const items = castAndSetsPreviewItems(reloaded.castAndSets);+ expect(items.find((i) => i.key === 'image:keeper-new.png')).toMatchObject({ previewUrl: '/data/images/keeper-new.png', prompt: 'New submitted prompt' });+ expect(items.find((i) => i.key === 'image-ref:mood.png')).toMatchObject({ previewUrl: '/data/image-refs/mood.png' });expect(card('Wardrobe').getByText('Interrupted')).toBeInTheDocument();expect(screen.getByRole('button', { name: 'Resume' })).toBeDisabled();expect(getMediaJob).not.toHaveBeenCalled();diff --git a/client/src/components/musicVideo/CastAndSetsReferenceProgress.jsx b/client/src/components/musicVideo/CastAndSetsReferenceProgress.jsxindex 0f911ffc1b..8341c341cc 100644--- a/client/src/components/musicVideo/CastAndSetsReferenceProgress.jsx+++ b/client/src/components/musicVideo/CastAndSetsReferenceProgress.jsx@@ -1,9 +1,47 @@import useMediaJobProgress from '../../hooks/useMediaJobProgress';import { formatCount } from '../../utils/formatters';+import { normalizeImage } from '../media/normalize.js';const imageSource = ({ kind, filename }) => `/data/${kind === 'image-ref' ? 'image-refs' : 'images'}/${encodeURIComponent(filename)}`;+// Reference sheets live under /data/image-refs, so they get their own key+// prefix and can't collide with a same-named gallery image (usePreviewRoute).+export const castAndSetsPreviewKey = ({ kind, filename }) => `${kind === 'image-ref' ? 'image-ref' : 'image'}:${filename}`;-function ReferenceCard({ item, stage }) {+function previewItem(ref, prompt) {+ const item = normalizeImage({ filename: ref.filename, path: imageSource(ref), prompt });+ return ref.kind === 'image-ref' ? { ...item, key: castAndSetsPreviewKey(ref) } : item;+}++// Submitted inputs once the job is recorded, else what the plan will send.+function cardReferences(item, stage) {+ const image = stage.images?.[item.key] || {};+ if (typeof image.submittedPrompt === 'string') return image.submittedReferences || [];+ return [+ ...(item.refKeys || []).flatMap((key) => stage.images?.[key]?.imageId+ ? [{ kind: 'image', filename: stage.images[key].imageId }] : []),+ ...(item.moodRefs ? stage.moodImages || [] : []),+ ];+}++/**+ * Lightbox items for every image the check-in shows: each generated reference+ * and the inputs it was (or will be) conditioned on. Taps open these in the+ * page's MediaPreview instead of navigating to the raw file, which strands a+ * Home Screen app with no back control.+ */+export function castAndSetsPreviewItems(stage) {+ if (!stage) return [];+ const items = [];+ for (const item of Object.values(stage.plan || {})) {+ const image = stage.images?.[item.key] || {};+ const label = item.label || item.key;+ if (image.imageId) items.push(previewItem({ kind: 'image', filename: image.imageId }, image.submittedPrompt || item.prompt || label));+ for (const ref of cardReferences(item, stage)) if (ref?.filename) items.push(previewItem(ref, `${label} input`));+ }+ return items;+}++function ReferenceCard({ item, stage, onOpenPreview }) {const image = stage.images?.[item.key] || {};// Old images remain visible during regeneration, but only a persisted done// record can bypass the new job's subscription.@@ -30,12 +68,7 @@ function ReferenceCard({ item, stage }) {else if (waiting.length) status = `Waiting for ${waiting.join(', ')}`;const submitted = typeof image.submittedPrompt === 'string';- const plannedReferences = [- ...(item.refKeys || []).flatMap((key) => stage.images?.[key]?.imageId- ? [{ kind: 'image', filename: stage.images[key].imageId }] : []),- ...(item.moodRefs ? stage.moodImages || [] : []),- ];- const references = submitted ? image.submittedReferences || [] : plannedReferences;+ const references = cardReferences(item, stage);const src = filename ? imageSource({ kind: 'image', filename }) : null;return (<article className="min-w-0 rounded border border-port-border bg-port-bg p-2 space-y-2" aria-label={item.label || item.key}>@@ -49,10 +82,11 @@ function ReferenceCard({ item, stage }) {</figure>}{src && (<figure className="space-y-1">- <a href={src} target="_blank" rel="noreferrer" className="block rounded focus-visible:outline focus-visible:outline-port-accent">+ <button type="button" onClick={() => onOpenPreview?.(castAndSetsPreviewKey({ kind: 'image', filename }))}+ aria-label={`Preview ${item.label || item.key}`} className="block w-full rounded focus-visible:outline focus-visible:outline-port-accent"><img src={src} alt={`${item.label || item.key} — ${previous ? 'previous revision' : 'generated reference'}`}className={`w-full ${currentImage ? 'max-h-24' : 'max-h-64'} rounded object-contain`} loading="lazy" />- </a>+ </button>{(previous || retained) && <figcaption className="text-[11px] text-port-text-muted">{previous ? 'Previous revision — replacement pending' : `Retained from revision ${formatCount(image.submittedRevision)}`}</figcaption>}</figure>)}@@ -70,10 +104,10 @@ function ReferenceCard({ item, stage }) {<p className="text-port-text-muted">{submitted ? 'Submitted image inputs' : 'Planned image inputs'}</p><div className="flex flex-wrap gap-2">{references.map((ref, index) => (- <a key={`${ref.kind}:${ref.filename}:${index}`} href={imageSource(ref)} target="_blank" rel="noreferrer"+ <button type="button" key={`${ref.kind}:${ref.filename}:${index}`} onClick={() => onOpenPreview?.(castAndSetsPreviewKey(ref))}className="min-w-0 w-16 rounded focus-visible:outline focus-visible:outline-port-accent" title={ref.filename}><img src={imageSource(ref)} alt={`${item.label || item.key} input: ${ref.filename}`} className="h-16 w-16 rounded object-contain" loading="lazy" />- </a>+ </button>))}</div></div>@@ -83,12 +117,12 @@ function ReferenceCard({ item, stage }) {);}-export default function CastAndSetsReferenceProgress({ stage }) {+export default function CastAndSetsReferenceProgress({ stage, onOpenPreview }) {const items = Object.values(stage.plan || {});if (!items.length) return null;return (<div className="grid min-w-0 grid-cols-[repeat(auto-fit,minmax(min(100%,15rem),1fr))] gap-2" aria-label="Cast and set references">- {items.map((item) => <ReferenceCard key={item.key} item={item} stage={stage} />)}+ {items.map((item) => <ReferenceCard key={item.key} item={item} stage={stage} onOpenPreview={onOpenPreview} />)}</div>);}diff --git a/client/src/components/musicVideo/DevArtifactDrawer.jsx b/client/src/components/musicVideo/DevArtifactDrawer.jsxindex bbf6eee930..82c065decc 100644--- a/client/src/components/musicVideo/DevArtifactDrawer.jsx+++ b/client/src/components/musicVideo/DevArtifactDrawer.jsx@@ -5,6 +5,7 @@ import DevArtifactPreview from './DevArtifactPreview.jsx';import Pill from '../ui/Pill.jsx';import { musicVideoDevArtifactFileUrl } from '../../services/apiMusicVideo.js';import { timeAgo } from '../../utils/formatters.js';+import { isStandalonePwa } from '../../lib/standaloneDownload.js';import { DEV_ARTIFACT_KIND_LABELS, DEV_ARTIFACT_STATUS } from './DevArtifactsPanel.jsx';const buttonClass = 'flex items-center gap-1 rounded px-3 py-1.5 text-sm min-h-[44px] sm:min-h-0 disabled:opacity-50';@@ -73,10 +74,13 @@ export default function DevArtifactDrawer({<option key={v.version} value={v.version}>v{v.version}{v.version === artifact.version ? ' (current)' : ''} · {timeAgo(v.createdAt)}</option>))}</select>- <a href={musicVideoDevArtifactFileUrl(project.id, artifact.id, shown === artifact.version ? null : shown)} target="_blank" rel="noreferrer noopener"- className="flex items-center gap-1 text-port-accent min-h-[44px] sm:min-h-0">- <ExternalLink size={12} aria-hidden="true" /> Open in a tab- </a>+ {/* A Home Screen app opens same-origin links in place with no back control. */}+ {!isStandalonePwa() && (+ <a href={musicVideoDevArtifactFileUrl(project.id, artifact.id, shown === artifact.version ? null : shown)} target="_blank" rel="noreferrer noopener"+ className="flex items-center gap-1 text-port-accent min-h-[44px] sm:min-h-0">+ <ExternalLink size={12} aria-hidden="true" /> Open in a tab+ </a>+ )}</div><DevArtifactPreview projectId={project.id} artifact={artifact} version={shown} /></div>diff --git a/client/src/components/musicVideo/stages/CastSetsStage.jsx b/client/src/components/musicVideo/stages/CastSetsStage.jsxindex 26281ead57..d1dfc52a5c 100644--- a/client/src/components/musicVideo/stages/CastSetsStage.jsx+++ b/client/src/components/musicVideo/stages/CastSetsStage.jsx@@ -142,6 +142,7 @@ export default function CastSetsStage({ board }) {stale={board.productionReadiness?.castAndSets?.stale || null}busy={locked || castSets.busy || kickoff.running}onOpenSheet={board.openArtifact}+ onOpenPreview={board.openPreview}onApprove={board.approveCastAndSets}onRegenerate={() => castSets.regenerate()}onEditDirection={castSets.editDirection}diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 6a1426864f..5f2181d69c 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -57,6 +57,7 @@ import useMusicVideoTakes from '../hooks/useMusicVideoTakes.js';import useMusicVideoTreatment, { aiSkipLabel } from '../hooks/useMusicVideoTreatment.js';import useHydratedPreviewRoute from '../hooks/useHydratedPreviewRoute.js';import { normalizeImage, normalizeVideo } from '../components/media/normalize.js';+import { castAndSetsPreviewItems } from '../components/musicVideo/CastAndSetsReferenceProgress.jsx';import { useVideoFileSrc } from '../hooks/useVideoFileSrc.js';import MediaPreview from '../components/media/MediaPreview.jsx';import MidiInstallModal from '../components/install/MidiInstallModal.jsx';@@ -1011,6 +1012,8 @@ export default function MusicVideo() {items.push(videoItem(take.assetId, `${take.assetId}.mp4`, take.prompt || scene.prompt || ''));}}+ // Cast & sets references and their inputs open here too, never as a raw file.+ items.push(...castAndSetsPreviewItems(selected.castAndSets));// Scenes can reuse the same frame/clip (Make's generation controls surface a// "Repetition: N unique frames" badge). Dedupe by key so prev/next and// openPreview's .find() land on a single item rather than the first of