Fix image edit disk upload so stills persist before Generate.

Reject only real handoff frames, return 400 with reason, keep the new still in the client library, and surface missing-still errors from Generate instead of 500s.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-10-12 12:21:20 -05:00
co-authored by Cursor
parent 7dcac5444c
commit 1bab5152f6
7 changed files with 169 additions and 46 deletions
+9 -3
View File
@@ -1,4 +1,4 @@
import { openSync, readSync, closeSync } from 'node:fs'
import { existsSync, openSync, readSync, closeSync } from 'node:fs'
import { execFile } from 'node:child_process'
import { promisify } from 'node:util'
import { getClip, getStill, clipVideoPath, stillPath } from '../library'
@@ -32,13 +32,19 @@ export async function resolveRequestSize(owner: string, request: any) {
const id = request.imageAId || request.identityStillId
if (id) {
const still = getStill(owner, id)
const path = stillPath(owner, id)
if (!existsSync(path)) {
throw createError({ statusCode: 404, statusMessage: 'That still is missing from the library' })
}
if (still.width && still.height) {
dimensions = { width: still.width, height: still.height }
} else {
// Header only — never read the full archive PNG into memory on Generate click
dimensions = imageDimensions(readImageHeader(stillPath(owner, id)))
dimensions = imageDimensions(readImageHeader(path))
}
if (!dimensions) {
throw createError({ statusCode: 400, statusMessage: 'Use a PNG, JPEG, or WebP' })
}
if (!dimensions) throw new Error('Cannot measure the source still.')
}
}
if (video && request.startClipId && !dimensions?.width) throw new Error('Cannot measure the previous clip.')