Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: derive the copied reference's extension from its real bytes (#8961)
[._.]/ Adam Eivy269c2b7b8ad0
diff --git a/client/src/components/apps/LaunchVideoPanel.jsx b/client/src/components/apps/LaunchVideoPanel.jsxindex 6e090e43b1..c6146a63e4 100644--- a/client/src/components/apps/LaunchVideoPanel.jsx+++ b/client/src/components/apps/LaunchVideoPanel.jsx@@ -215,7 +215,7 @@ function LaunchVideoForm({ appId, onQueued }) {</ul>}</fieldset>}<p className="text-sm text-port-text-muted">These options are submitted together. Follow and cancel the run in CoS agents.</p>- <button type="submit" className={buttonClass} disabled={running || !formats.length || duration === '' || (music && !generateMusic && !musicTrack)}>{running ? 'Queuing…' : 'Queue launch video'}</button>+ <button type="submit" className={buttonClass} disabled={running || referenceUploading || !formats.length || duration === '' || (music && !generateMusic && !musicTrack)}>{running ? 'Queuing…' : 'Queue launch video'}</button></form>;}diff --git a/server/routes/apps/launchVideos.js b/server/routes/apps/launchVideos.jsindex db9781414c..27a06720eb 100644--- a/server/routes/apps/launchVideos.js+++ b/server/routes/apps/launchVideos.js@@ -71,13 +71,15 @@ async function resolveStyleReferenceSource(dataRoot, { source, kind, filename })if (info.size > MAX_STYLE_REFERENCE_BYTES) {throw new ServerError('Style reference file is too large', { status: 400 });}- if (kind === 'image') {- const handle = await open(sourcePath, 'r');- const head = Buffer.alloc(16);- await handle.read(head, 0, 16, 0).finally(() => handle.close());- if (!detectImageFormat(head)) throw new ServerError('Style reference is not a recognized image', { status: 400 });- }- return sourcePath;+ if (kind !== 'image') return { path: sourcePath, ext: extname(sourcePath) || '.mp4' };+ const handle = await open(sourcePath, 'r');+ const head = Buffer.alloc(16);+ await handle.read(head, 0, 16, 0).finally(() => handle.close());+ const detected = detectImageFormat(head);+ if (!detected) throw new ServerError('Style reference is not a recognized image', { status: 400 });+ // The real extension, not the client-controlled filename's: a genuine PNG+ // saved under a misleading name (or none) must not be copied in as one.+ return { path: sourcePath, ext: detected.ext };}router.post('/:id/launch-videos/publish', loadApp, asyncHandler(async (req, res) => {@@ -226,9 +228,8 @@ router.post('/:id/launch-videos', loadApp, asyncHandler(async (req, res) => {if (styleReferenceSource) {const referenceDir = join(outputRoot, 'reference');await mkdir(referenceDir, { recursive: true });- const referenceName = `style-reference${extname(styleReferenceSource) || (styleReference.kind === 'video' ? '.mp4' : '.png')}`;- const referencePath = join(referenceDir, referenceName);- await copyFileGuarded(styleReferenceSource, referencePath);+ const referencePath = join(referenceDir, `style-reference${styleReferenceSource.ext}`);+ await copyFileGuarded(styleReferenceSource.path, referencePath);styleReferencePrompt = { referencePaths: [referencePath] };if (styleReference.kind === 'video') {const { encodeReferenceContactSheet } = await import('../../services/htmlComposition/encode.js');diff --git a/server/routes/apps/launchVideos.test.js b/server/routes/apps/launchVideos.test.jsindex 5c2f7117fe..9147b650d5 100644--- a/server/routes/apps/launchVideos.test.js+++ b/server/routes/apps/launchVideos.test.js@@ -233,6 +233,17 @@ describe('style reference (#8961)', () => {expect(await readFile(join(runRoot, 'reference', 'style-reference.jpg'))).toEqual(JPEG_HEADER);});+ it('names the copied reference by its real detected format, not a misleading filename', async () => {+ await mkdir(PATHS.uploads, { recursive: true });+ // A real PNG saved under a `.jpg` name — the destination extension must+ // follow the sniffed bytes, or the agent gets handed an unreadable file.+ await writeFile(join(PATHS.uploads, 'abc12345-mislabeled.jpg'), PNG_HEADER);+ const response = await submit({ styleReference: { kind: 'image', source: 'upload', filename: 'abc12345-mislabeled.jpg' } });+ expect(response.status).toBe(202);+ const runRoot = join(PATHS.data, 'launch-videos', 'example', response.body.runId);+ expect(await readdir(join(runRoot, 'reference'))).toEqual(['style-reference.png']);+ });+it('rejects an oversized reference and a file claiming to be an image that is not one', async () => {await mkdir(PATHS.images, { recursive: true });await writeFile(join(PATHS.images, 'not-an-image.png'), 'plain text, no magic bytes');