Skip to content

feat(ui): drag-and-drop reordering for reference images#9081

Open
lstein wants to merge 3 commits intomainfrom
feat/ref-image-reorder-dnd
Open

feat(ui): drag-and-drop reordering for reference images#9081
lstein wants to merge 3 commits intomainfrom
feat/ref-image-reorder-dnd

Conversation

@lstein
Copy link
Copy Markdown
Collaborator

@lstein lstein commented Apr 21, 2026

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:

  • Users can now drag reference image thumbnails left/right to reorder them in the panel. Order is preserved through generation and recall automatically since ref images are already stored as an ordered array that is serialized to graph metadata in order.
  • Adds a refImagesReordered reducer with validation (length match, known ids, no duplicates) and unit tests.
  • UI piece uses the existing pragmatic-drag-and-drop setup, matching the pattern in CanvasEntityGroupList.

Test plan

  • Add 2+ reference images via upload or drag from gallery.
  • Drag one thumbnail left or right of another; confirm the drop indicator appears on the correct edge and the order updates on release.
  • Generate an image and confirm the ref images are applied in the new visual order (e.g., with an IP adapter set, changing the order should change the effect).
  • Recall metadata from a prior generation and confirm the order is preserved.
  • Verify clicking a thumbnail (vs. dragging) still opens/closes the settings panel.
  • pnpm lint and pnpm test:no-watch pass.

🤖 Generated with Claude Code

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>
@lstein lstein added the v6.13.x label Apr 21, 2026
@lstein lstein moved this to 6.13.x Theme: MODELS in Invoke - Community Roadmap Apr 21, 2026
@github-actions github-actions Bot added the frontend PRs that change frontend files label Apr 21, 2026
lstein and others added 2 commits April 20, 2026 21:05
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend PRs that change frontend files v6.13.x

Projects

Status: 6.13.x Theme: MODELS

Development

Successfully merging this pull request may close these issues.

2 participants