feat(ui): drag-and-drop reordering for reference images#9081
feat(ui): drag-and-drop reordering for reference images#9081
Conversation
Reference images are already stored as an ordered array and serialized to metadata in order, so graph building and recall automatically respect the new order. This change adds the UI affordance: users can drag reference image thumbnails left/right to reorder them. - Adds `refImagesReordered` reducer with validation against length mismatch, unknown ids, and duplicates. - Adds `singleRefImageDndSource` and `useRefImageDnd` hook using pragmatic-drag-and-drop with horizontal edges. - Wraps `RefImagePreview` in a draggable container with drop indicator. - Disables native `<img>` drag so pragmatic-dnd receives the gesture. - Adds unit tests for the new reducer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
iOS WebKit collapses a flex item to zero width when the width is only implied by a child's aspect ratio. Set aspectRatio on the wrapper Box directly so the thumbnail tile sizes correctly on iPad Chrome/Safari. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The default iOS "Save Image" / "Copy" callout fires on long-press over the thumbnail, which interferes with drag attempts on iPad. Scope the suppression (WebkitTouchCallout + userSelect) to the ref image wrapper only, leaving gallery and other image views unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
FindingsLow: Reordering decision logic in
|
|
The UI works fine. |
Summary
The image edit models are sensitive to the order of the reference images: I have found that the first image tends to have more weight than the second and subsequent ones. In addition, when the prompt refers to images as "image 1, image 2", etc and you want to swap out one ref image for another, the current UI only allows you to add images to the end of the list, setting up cases in which the prompt has to be edited to accommodate.
This PR enables the order of reference images to be interactively changed by dragging and dropping them:
refImagesReorderedreducer with validation (length match, known ids, no duplicates) and unit tests.CanvasEntityGroupList.Test plan
pnpm lintandpnpm test:no-watchpass.🤖 Generated with Claude Code