Fix Photos Add, Remove, and Replace against the library picker.

Remove clears the Photos array and backing image fields; Add opens the picker with disk upload and drops empty drafts on cancel.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-26 17:06:39 -05:00
co-authored by Cursor
parent 50319e03a9
commit e06afe4a17
4 changed files with 121 additions and 41 deletions
+4 -1
View File
@@ -301,6 +301,8 @@ export function photosFromRequest(request = {}) {
/**
* Apply Photos → request fields. Call before validate / queue.
* If Edit+Qwen has cards but no Photo to change, promote the first card.
* When `photos` is an explicit array (even empty), it is source of truth —
* do not resurrect cards from leftover imageAId / identityStillId.
*/
export function applyPhotosToRequest(raw = {}) {
const next = { ...raw }
@@ -309,8 +311,9 @@ export function applyPhotosToRequest(raw = {}) {
if (!Array.isArray(next.photos)) next.photos = []
return next
}
const photosProvided = Array.isArray(raw.photos)
let photos = normalizePhotos(next.photos, plan)
if (!photos.length && (next.imageAId || next.identityStillId || next.imageBId)) {
if (!photosProvided && !photos.length && (next.imageAId || next.identityStillId || next.imageBId)) {
photos = normalizePhotos(photosFromRequest(next), plan)
}
// Promote first card to Photo to change when Edit needs it.