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

Cover art can come from image history, an upload, or a finished cover

Claudebe9316f7ca05
diff --git a/client/src/components/musicVideo/CoverArtPanel.jsx b/client/src/components/musicVideo/CoverArtPanel.jsx
index c1d48b5a4d..2fb0deee27 100644
--- a/client/src/components/musicVideo/CoverArtPanel.jsx
+++ b/client/src/components/musicVideo/CoverArtPanel.jsx
@@ -1,9 +1,10 @@
import { useState } from 'react';
-import { Download, Image as ImageIcon, Sparkles } from 'lucide-react';
+import { Download, Image as ImageIcon, Images, Sparkles } from 'lucide-react';
+import GalleryImagePicker from '../imageGen/GalleryImagePicker';
const MAX_SOURCES = 24;
-/** Images the cover can be made from: cover images made for it, Cast & Sets renders, look references, scene frames, then kit thumbnails. */
+/** Images the cover can be made from: the current one, cover images made for it, Cast & Sets renders, look references, scene frames, then kit thumbnails. */
export function coverArtSources(project) {
const kit = project?.publishKit || {};
const seen = new Set();
@@ -13,6 +14,8 @@ export function coverArtSources(project) {
seen.add(`${kind}:${filename}`);
out.push({ kind, filename, label, src: kind === 'thumbnail' ? `/data/video-thumbnails/${encodeURIComponent(filename)}` : `/data/images/${encodeURIComponent(filename)}` });
};
+ // An image picked from history or uploaded is in none of the lists below.
+ if (kit.coverArt?.source?.kind === 'image') add('image', kit.coverArt.source.filename, 'Current cover image');
for (const f of kit.coverArt?.generated || []) add('image', f, 'Cover image');
for (const [key, img] of Object.entries(project?.castAndSets?.images || {})) add('image', img?.imageId, `Cast & Sets: ${key}`);
for (const ref of project?.visualSpec?.references || []) add('image', ref?.imageId, ref?.label || 'Look reference');
@@ -27,8 +30,9 @@ export function coverArtSources(project) {
* song and steered by what the director types. "Restyle" redrafts the
* lettering from that direction (or adjusts it); "Make a new image" asks an
* image backend for a fresh photo (or an adjusted take on the current one).
- * Any image the project has can be the photo; the title and artist are set
- * on it by code, so the lettering stays sharp.
+ * Any image the project has, or any in image history (or uploaded), can be
+ * the photo; the title and artist are set on it by code, so the lettering
+ * stays sharp. A cover finished elsewhere is used bare ("lettering" off).
*/
export default function CoverArtPanel({ project, publishKit }) {
const art = project?.publishKit?.coverArt || {};
@@ -40,9 +44,12 @@ export default function CoverArtPanel({ project, publishKit }) {
const [focusX, setFocusX] = useState(Number.isFinite(art.focusX) ? art.focusX : 0.5);
const [notes, setNotes] = useState('');
const [adjustImage, setAdjustImage] = useState(false);
+ const [lettering, setLettering] = useState(art.lettering !== false);
+ const [pickerOpen, setPickerOpen] = useState(false);
const busy = publishKit.composing || publishKit.designing || publishKit.requestingImage;
const chosen = art.source ? `${art.source.kind}:${art.source.filename}` : null;
- const look = () => ({ title: title.trim(), ...(tag !== null ? { tag: tag.trim() } : {}), focusX });
+ const look = () => ({ title: title.trim(), ...(tag !== null ? { tag: tag.trim() } : {}), focusX, lettering });
+ const needsTitle = lettering && !title.trim();
const compose = (source) => publishKit.composeCover({ ...(source ? { source: { kind: source.kind, filename: source.filename } } : {}), ...look() });
const generate = () => publishKit.generateCover({
...(notes.trim() ? { notes: notes.trim() } : {}),
@@ -53,20 +60,25 @@ export default function CoverArtPanel({ project, publishKit }) {
return (
<section aria-label="Cover art" className="rounded-lg border border-port-border bg-port-card p-3 space-y-2 text-xs">
<h3 className="text-sm font-medium flex items-center gap-1.5"><ImageIcon size={14} /> Cover art</h3>
- <p className="text-port-text-muted">The square cover Spotify (via DistroKid) and Suno show. Pick an image, and the title and artist are set on it.</p>
+ <p className="text-port-text-muted">The square cover Spotify (via DistroKid) and Suno show. Pick an image, and the title and artist are set on it, or use a finished cover as it is.</p>
<div className="flex flex-col sm:flex-row gap-3">
<div className="w-full sm:w-48 shrink-0 space-y-1">
{art.filename ? (
<>
<img src={`/data/video-thumbnails/${encodeURIComponent(art.filename)}`} alt={`Cover art for ${project?.name || 'the song'}`} className="w-full aspect-square object-cover rounded border border-port-border" />
<a href={`/data/video-thumbnails/${encodeURIComponent(art.filename)}`} download className="text-port-accent flex items-center gap-1 min-h-[44px] sm:min-h-0"><Download size={12} /> Download</a>
+ {art.source?.filename && <p className="text-port-text-muted break-all">From {art.source.filename}</p>}
</>
) : (
<div className="w-full aspect-square rounded border border-dashed border-port-border flex items-center justify-center text-port-text-muted p-2 text-center">No cover yet</div>
)}
</div>
<div className="flex-1 space-y-2 min-w-0">
- <div className="grid grid-cols-2 gap-2">
+ <label htmlFor={idFor('lettering')} className="flex items-center gap-1.5 min-h-[44px] sm:min-h-0">
+ <input id={idFor('lettering')} type="checkbox" checked={lettering} onChange={(e) => setLettering(e.target.checked)} />
+ Set the title and artist on the image (off for a cover that already has its lettering)
+ </label>
+ {lettering && <div className="grid grid-cols-2 gap-2">
<div>
<label htmlFor={idFor('title')} className="block text-[11px] text-port-text-muted">Title on the cover</label>
<input id={idFor('title')} value={title} maxLength={60} onChange={(e) => setTitle(e.target.value)}
@@ -77,13 +89,13 @@ export default function CoverArtPanel({ project, publishKit }) {
<input id={idFor('tag')} value={tag ?? art.tag ?? ''} maxLength={24} placeholder="Artist name" onChange={(e) => setTag(e.target.value)}
className="w-full bg-port-bg border border-port-border rounded px-1.5 py-1 text-xs min-h-[44px] sm:min-h-0" />
</div>
- </div>
+ </div>}
<div>
<label htmlFor={idFor('focus')} className="block text-[11px] text-port-text-muted">Crop position (left to right)</label>
<input id={idFor('focus')} type="range" min={0} max={1} step={0.05} value={focusX} onChange={(e) => setFocusX(Number(e.target.value))}
className="w-full min-h-[44px] sm:min-h-0" />
</div>
- <button type="button" onClick={() => compose(null)} disabled={busy || !art.source || !title.trim()}
+ <button type="button" onClick={() => compose(null)} disabled={busy || !art.source || needsTitle}
className="flex items-center gap-1 bg-port-accent/20 text-port-accent disabled:opacity-50 rounded px-2 py-1.5 min-h-[44px] sm:min-h-0">
{busy ? 'Setting the cover…' : 'Apply to the cover'}
</button>
@@ -94,11 +106,17 @@ export default function CoverArtPanel({ project, publishKit }) {
{art.lastError && !art.pending && <p role="alert" className="text-port-warning">{art.lastError}</p>}
<div className="space-y-1">
- <span className="text-port-text-muted">Cover image: pick one</span>
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <span className="text-port-text-muted">Cover image: pick one</span>
+ <button type="button" onClick={() => setPickerOpen(true)} disabled={busy || needsTitle}
+ className="flex items-center gap-1 text-port-accent disabled:opacity-50 min-h-[44px] sm:min-h-0">
+ <Images size={13} /> Choose from image history or upload
+ </button>
+ </div>
{sources.length ? (
<div className="grid grid-cols-3 sm:grid-cols-6 gap-2">
{sources.map((s) => (
- <button key={`${s.kind}:${s.filename}`} type="button" onClick={() => compose(s)} disabled={busy || !title.trim()}
+ <button key={`${s.kind}:${s.filename}`} type="button" onClick={() => compose(s)} disabled={busy || needsTitle}
aria-pressed={chosen === `${s.kind}:${s.filename}`} aria-label={`Make the cover from ${s.label}`} title={s.label}
className={`rounded overflow-hidden border-2 disabled:opacity-60 ${chosen === `${s.kind}:${s.filename}` ? 'border-port-accent' : 'border-transparent'}`}>
<img src={s.src} alt="" loading="lazy" className="w-full aspect-square object-cover" />
@@ -106,9 +124,11 @@ export default function CoverArtPanel({ project, publishKit }) {
))}
</div>
) : (
- <p className="text-port-text-muted">No images yet. Build the publishing kit for video frames, or make one below.</p>
+ <p className="text-port-text-muted">No images yet. Build the publishing kit for video frames, choose one from image history, or make one below.</p>
)}
</div>
+ <GalleryImagePicker open={pickerOpen} onClose={() => setPickerOpen(false)} allowUpload
+ onSelect={(item) => item?.filename && compose({ kind: 'image', filename: item.filename })} />
<div className="space-y-1 rounded border border-port-border p-2">
{art.rationale && <p className="text-port-text-muted">This song's look: {art.rationale}</p>}
diff --git a/client/src/components/musicVideo/CoverArtPanel.test.jsx b/client/src/components/musicVideo/CoverArtPanel.test.jsx
new file mode 100644
index 0000000000..644a0b6abc
--- /dev/null
+++ b/client/src/components/musicVideo/CoverArtPanel.test.jsx
@@ -0,0 +1,43 @@
+/**
+ * Cover art panel: any image in history (or an upload) can be the cover, and a
+ * cover finished elsewhere is used as it is, with no second title set on it.
+ */
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+import CoverArtPanel, { coverArtSources } from './CoverArtPanel.jsx';
+
+vi.mock('../imageGen/GalleryImagePicker', () => ({
+ default: ({ open, onSelect, allowUpload }) => (open ? (
+ <button type="button" data-upload={String(allowUpload)} onClick={() => onSelect({ filename: 'history-example.png' })}>Pick history-example</button>
+ ) : null),
+}));
+
+const kit = (over = {}) => ({ composeCover: vi.fn(), designCover: vi.fn(), generateCover: vi.fn(), composing: false, designing: false, requestingImage: false, ...over });
+const project = (coverArt = {}) => ({ id: 'mv-1', name: 'Example Song', publishKit: { thumbnails: ['t1.jpg'], coverArt } });
+
+describe('CoverArtPanel', () => {
+ it('makes the cover from an image picked in history, with upload offered in the same picker', () => {
+ const publishKit = kit();
+ render(<CoverArtPanel project={project()} publishKit={publishKit} />);
+ fireEvent.click(screen.getByRole('button', { name: /Choose from image history or upload/ }));
+ const pick = screen.getByRole('button', { name: 'Pick history-example' });
+ expect(pick).toHaveAttribute('data-upload', 'true');
+ fireEvent.click(pick);
+ expect(publishKit.composeCover).toHaveBeenCalledWith(expect.objectContaining({ source: { kind: 'image', filename: 'history-example.png' }, title: 'Example Song', lettering: true }));
+ });
+
+ it('uses a finished cover bare: no title or artist fields, and no title needed', () => {
+ const publishKit = kit();
+ render(<CoverArtPanel project={project({ source: { kind: 'image', filename: 'finished.png' } })} publishKit={publishKit} />);
+ fireEvent.change(screen.getByLabelText('Title on the cover'), { target: { value: '' } });
+ fireEvent.click(screen.getByLabelText(/Set the title and artist on the image/));
+ expect(screen.queryByLabelText('Title on the cover')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Apply to the cover' }));
+ expect(publishKit.composeCover).toHaveBeenCalledWith(expect.objectContaining({ lettering: false }));
+ });
+
+ it('keeps an image picked from history among the sources, marked as the current one', () => {
+ const sources = coverArtSources(project({ source: { kind: 'image', filename: 'history-example.png' } }));
+ expect(sources[0]).toMatchObject({ kind: 'image', filename: 'history-example.png', label: 'Current cover image' });
+ });
+});
diff --git a/client/src/components/musicVideo/PublishKitPanel.test.jsx b/client/src/components/musicVideo/PublishKitPanel.test.jsx
index 1caaec98f1..9fc362a5d7 100644
--- a/client/src/components/musicVideo/PublishKitPanel.test.jsx
+++ b/client/src/components/musicVideo/PublishKitPanel.test.jsx
@@ -66,7 +66,7 @@ describe('PublishKitPanel (#9281)', () => {
expect(screen.getByText('No cover yet')).toBeTruthy();
fireEvent.change(screen.getByLabelText('Title on the cover'), { target: { value: 'Example Retitle' } });
fireEvent.click(screen.getByRole('button', { name: 'Make the cover from Cast & Sets: character' }));
- expect(k.composeCover).toHaveBeenCalledWith({ source: { kind: 'image', filename: 'sheet.png' }, title: 'Example Retitle', focusX: 0.5 });
+ expect(k.composeCover).toHaveBeenCalledWith({ source: { kind: 'image', filename: 'sheet.png' }, title: 'Example Retitle', focusX: 0.5, lettering: true });
fireEvent.click(screen.getByRole('button', { name: 'Make the cover from Video frame 1' }));
expect(k.composeCover).toHaveBeenLastCalledWith(expect.objectContaining({ source: { kind: 'thumbnail', filename: 't1.jpg' } }));
diff --git a/server/lib/musicVideoValidation.js b/server/lib/musicVideoValidation.js
index cd0941a2b9..57058fcbc6 100644
--- a/server/lib/musicVideoValidation.js
+++ b/server/lib/musicVideoValidation.js
@@ -694,6 +694,8 @@ export const musicVideoCoverArtComposeSchema = z.object({
title: z.string().max(60).optional(),
tag: z.string().max(24).optional(),
focusX: z.number().min(0).max(1).optional(),
+ // false = a finished cover from elsewhere: squared and sized, no title or tag set on it.
+ lettering: z.boolean().optional(),
}).strict();
export const musicVideoCoverArtDesignSchema = z.object({
direction: z.string().max(1500).optional(),
diff --git a/server/services/musicVideo/coverArt.js b/server/services/musicVideo/coverArt.js
index 593241ccac..b72351202a 100644
--- a/server/services/musicVideo/coverArt.js
+++ b/server/services/musicVideo/coverArt.js
@@ -13,6 +13,7 @@
* Nothing here runs without a director action (AI Provider Usage Policy).
*
* coverArt: { filename, source: { kind, filename }, title, tag, focusX,
+ * lettering (false = a finished cover, used bare),
* design, imagePrompt, rationale, direction, designedAt,
* composedAt, generated: [galleryFilename…],
* pending: { requestId, jobId, mode, requestedAt } | null,
@@ -112,9 +113,10 @@ async function defaultTag() {
/**
* Compose the cover from `source` with the title and tag, and make it the
* release's cover. Unset fields keep the last cover's (title defaults to the
- * project name, tag to the DistroKid artist).
+ * project name, tag to the DistroKid artist). `lettering: false` uses the
+ * image as a finished cover: squared and sized, with nothing set on it.
*/
-export async function composeProjectCoverArt(projectId, { source = null, title, tag, focusX } = {}) {
+export async function composeProjectCoverArt(projectId, { source = null, title, tag, focusX, lettering } = {}) {
const project = await requireProject(projectId);
const art = projectCoverArt(project);
const from = source || art.source;
@@ -122,11 +124,12 @@ export async function composeProjectCoverArt(projectId, { source = null, title,
const path = sourcePath(project, from);
const next = {
source: { kind: from.kind, filename: basename(from.filename) },
- title: typeof title === 'string' ? title.trim() : (art.title ?? project.name ?? ''),
+ title: typeof title === 'string' ? title.trim() : (art.title || project.name || ''),
tag: typeof tag === 'string' ? tag.trim() : (art.tag ?? await defaultTag()),
focusX: Number.isFinite(focusX) ? focusX : (Number.isFinite(art.focusX) ? art.focusX : 0.5),
+ lettering: typeof lettering === 'boolean' ? lettering : art.lettering !== false,
};
- if (!next.title) throw coverError(422, 'VALIDATION_ERROR', 'Give the cover a title');
+ if (next.lettering && !next.title) throw coverError(422, 'VALIDATION_ERROR', 'Give the cover a title');
await ensureDir(PATHS.videoThumbnails);
const filename = `cover-${String(projectId).slice(3, 11)}-${randomUUID().slice(0, 8)}.jpg`;
await deps.compose({ ...next, design: art.design || null, source: path, out: safeUnder(PATHS.videoThumbnails, filename) });
@@ -166,7 +169,8 @@ export async function designCoverArt(projectId, { direction = '', providerId = n
lastError: null,
}));
console.log(`🖼️ Music Video cover art ${String(projectId).slice(3, 11)}: design ${previous ? 'adjusted' : 'drafted'} (${drafted.design.layout}, ${drafted.design.typeface})`);
- if (art.source) return composeProjectCoverArt(projectId);
+ // Restyling the lettering puts it back on a cover that was used bare.
+ if (art.source) return composeProjectCoverArt(projectId, { lettering: true });
publish(projectId, out.project);
return { project: out.project };
}
@@ -284,7 +288,7 @@ export async function onCoverArtImageSettled({ projectId, requestId, filename =
...(current ? { pending: null } : {}),
}));
if (!current) { publish(projectId, out.project); return true; }
- await composeProjectCoverArt(projectId, { source: { kind: 'image', filename } }).catch(async (err) => {
+ await composeProjectCoverArt(projectId, { source: { kind: 'image', filename }, lettering: true }).catch(async (err) => {
console.error(`❌ Music Video cover art ${String(projectId).slice(3, 11)} compose failed: ${err.message}`);
const failed = await writeCoverArt(projectId, () => ({ lastError: trimTo(`The cover could not be composed: ${err.message}`, 300) }));
publish(projectId, failed.project);
diff --git a/server/services/musicVideo/coverArt.test.js b/server/services/musicVideo/coverArt.test.js
index bc543b8886..abc181d4ba 100644
--- a/server/services/musicVideo/coverArt.test.js
+++ b/server/services/musicVideo/coverArt.test.js
@@ -174,6 +174,23 @@ describe('release cover art', () => {
await expect(cover.designCoverArt(id)).rejects.toMatchObject({ status: 502, code: 'COVER_DESIGN_UNPARSEABLE' });
});
+ it('uses an image from history as a finished cover with no lettering, until a restyle sets it again', async () => {
+ const { id } = await projectWithThumbnail();
+ await mkdir(PATHS.images, { recursive: true });
+ await writeFile(join(PATHS.images, 'finished-example.png'), 'png');
+ const { project } = await cover.composeProjectCoverArt(id, { source: { kind: 'image', filename: 'finished-example.png' }, title: '', lettering: false });
+ expect(project.publishKit.coverArt).toMatchObject({ lettering: false, source: { kind: 'image', filename: 'finished-example.png' } });
+ expect(compose.mock.calls.at(-1)[0]).toMatchObject({ lettering: false, source: join(PATHS.images, 'finished-example.png') });
+ // A recompose (a new crop) keeps it bare; a lettered cover still needs a title.
+ await cover.composeProjectCoverArt(id, { focusX: 0.3 });
+ expect(compose.mock.calls.at(-1)[0].lettering).toBe(false);
+ await expect(cover.composeProjectCoverArt(id, { title: '', lettering: true })).rejects.toMatchObject({ status: 422 });
+
+ const restyled = (await cover.designCoverArt(id, { direction: 'tiny type' })).project.publishKit.coverArt;
+ expect(restyled.lettering).toBe(true);
+ expect(compose.mock.calls.at(-1)[0].lettering).toBe(true);
+ });
+
it("queues on the install's own default image generator, never a fixed one", async () => {
const { id } = await projectWithThumbnail();
cover.__setCoverArtDepsForTests({
@@ -213,6 +230,11 @@ describe('cover lettering', () => {
expect(await sharp(out).metadata()).toMatchObject({ width: 600, height: 600 });
}
+ // A finished cover is only squared and sized: nothing is set over it. The
+ // source is one flat colour, so any lettering or backdrop shows up as variation.
+ await composeCoverArt({ source, out, title: 'Example Song', tag: 'Example Artist', size: 600, lettering: false });
+ expect(Math.max(...(await sharp(out).stats()).channels.map((c) => c.stdev))).toBeLessThan(2);
+
// A portrait phone photo stored landscape with an EXIF rotation crops on the upright image.
const rotated = join(dir, 'rotated.jpg');
await sharp({ create: { width: 640, height: 360, channels: 3, background: '#775533' } }).jpeg().withMetadata({ orientation: 6 }).toFile(rotated);
diff --git a/server/services/musicVideo/coverArtCompose.js b/server/services/musicVideo/coverArtCompose.js
index bd8163c0b1..8516c84278 100644
--- a/server/services/musicVideo/coverArtCompose.js
+++ b/server/services/musicVideo/coverArtCompose.js
@@ -193,8 +193,9 @@ async function measureWidths(sharp, texts, font) {
/**
* Write `out` (a JPEG): `source` cropped to its largest square at `focusX`
* (0 = left edge, 1 = right edge), scaled to `size`, with the song's design on top.
+ * `lettering: false` leaves the image bare: a finished cover designed elsewhere.
*/
-export async function composeCoverArt({ source, out, title, tag = '', design = null, focusX = 0.5, size = COVER_ART_SIZE }, deps = {}) {
+export async function composeCoverArt({ source, out, title, tag = '', design = null, focusX = 0.5, size = COVER_ART_SIZE, lettering = true }, deps = {}) {
const sharp = deps.sharp || (await import('sharp')).default;
// Apply the EXIF orientation first, so the crop is measured on the upright image.
const { data, info } = await sharp(source).rotate().toBuffer({ resolveWithObject: true });
@@ -202,16 +203,18 @@ export async function composeCoverArt({ source, out, title, tag = '', design = n
const fx = Math.min(1, Math.max(0, Number.isFinite(focusX) ? focusX : 0.5));
const left = Math.round((info.width - side) * fx);
const top = Math.round((info.height - side) / 2);
- const d = normalizeCoverDesign(design);
- const widths = {
- title: await measureWidths(sharp, titleLinesFor(title, d, size), titleFont(d, PROBE_PX)),
- tag: await measureWidths(sharp, [tagTextFor(tag, d)], tagFont(d, PROBE_PX)),
- };
- const overlay = Buffer.from(coverOverlaySvg({ title, tag, design: d, size, widths }));
- await sharp(data)
+ let image = sharp(data)
.extract({ left, top, width: side, height: side })
- .resize(size, size, { kernel: 'lanczos3' })
- .composite([{ input: overlay, top: 0, left: 0 }])
+ .resize(size, size, { kernel: 'lanczos3' });
+ if (lettering) {
+ const d = normalizeCoverDesign(design);
+ const widths = {
+ title: await measureWidths(sharp, titleLinesFor(title, d, size), titleFont(d, PROBE_PX)),
+ tag: await measureWidths(sharp, [tagTextFor(tag, d)], tagFont(d, PROBE_PX)),
+ };
+ image = image.composite([{ input: Buffer.from(coverOverlaySvg({ title, tag, design: d, size, widths })), top: 0, left: 0 }]);
+ }
+ await image
.jpeg({ quality: 92, chromaSubsampling: '4:4:4' })
.toFile(out);
return { width: size, height: size };