Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(gallery): preserve the browsed page when results arrive

Josh Corbett389544ca482a
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 00962e76da..c421f158a4 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -3991,12 +3991,7 @@ describe('workbenchReducer Phase 5 generation flow', () => {
expect(getProjectWidgetValues(getActiveProject(state), 'gallery').galleryPage).toBe(0);
});
- it('releases a mid-board infinite window anchor when a result lands on the viewed board', () => {
- // A deep reveal from the image map anchors the infinite window mid-board.
- // New images land at the TOP of that listing, which the anchored window
- // never covers — and an anchored window also suppresses the recents
- // overlay and the queue placeholders, so without releasing the anchor the
- // user would never see their own generation appear.
+ it('preserves the browsed window when a result lands on the viewed board', () => {
let state = primeGenerate();
state = workbenchReducer(state, { destination: 'gallery', type: 'setInvocationDestination' });
@@ -4015,7 +4010,7 @@ describe('workbenchReducer Phase 5 generation flow', () => {
type: 'routeQueueItemResults',
});
- expect(getProjectWidgetValues(getActiveProject(state), 'gallery').galleryPage).toBe(0);
+ expect(getProjectWidgetValues(getActiveProject(state), 'gallery').galleryPage).toBe(11);
});
it('leaves the window anchor alone when the result lands on a board that is not being viewed', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index 658bac0b11..ae43e8dcf6 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -52,7 +52,6 @@ import type {
import {
getBoundedRecentImages,
- getGalleryPage,
getPersistedSelectedGalleryItemKeys,
stripInfiniteWindowAnchor,
stripUnresolvableGallerySearch,
@@ -2993,22 +2992,8 @@ const updateGalleryWithResultImages = (project: Project, images: GeneratedImageC
const nextSelectedItem = nextSelectedImage ? legacyGeneratedImageToGalleryItem(nextSelectedImage) : undefined;
const nextSelectedItemKey = nextSelectedItem ? toGalleryItemKey(nextSelectedItem) : undefined;
const gallerySettings = getGallerySettings(galleryValues);
- // A deep reveal from the image map anchors the infinite window mid-board.
- // New images land at the TOP of that board's listing, which such a window
- // never covers — and an anchored window also suppresses the recents overlay
- // and the queue placeholders. Release the anchor when an incoming image
- // belongs to the board being viewed, or the user would never see their own
- // generation appear. Scoped to that board: an anchor on some other board's
- // listing has nothing to do with this result.
- const viewedBoardId = typeof galleryValues.selectedBoardId === 'string' ? galleryValues.selectedBoardId : 'none';
- const releasesWindowAnchor =
- gallerySettings.paginationMode === 'infinite' &&
- getGalleryPage(galleryValues) > 0 &&
- newImages.some((image) => image.boardId === viewedBoardId);
-
return updateProjectWidgetValues(project, 'gallery', () => ({
...galleryValues,
- ...(releasesWindowAnchor ? { galleryPage: 0 } : {}),
recentImages: getBoundedRecentImages([...newImages, ...previousImages]),
selectedImage: nextSelectedItem ?? galleryValues.selectedImage,
selectedImageName: nextSelectedItemKey ?? galleryValues.selectedImageName,