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(ui): keep the image map's selection and layout honest against main

Lincoln Stein401d0c1a26b2
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.json
index 62ed1c7498..d80bafaeb8 100644
--- a/invokeai/frontend/webv2/performance/architecture-baseline.json
+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json
@@ -2,10 +2,10 @@
"build": {
"launchpad": {
"baseline": {
- "brotliBytes": 830646,
+ "brotliBytes": 830656,
"cssRawBytes": 2159,
"fontRawBytes": 219480,
- "gzipBytes": 829164,
+ "gzipBytes": 829163,
"imageRawBytes": 156376,
"initialRawBytes": 1928860,
"largestAssetRawBytes": 746314,
@@ -279,10 +279,10 @@
]
},
"limits": {
- "brotliBytes": 838953,
+ "brotliBytes": 838963,
"cssRawBytes": 2181,
"fontRawBytes": 221675,
- "gzipBytes": 837456,
+ "gzipBytes": 837455,
"imageRawBytes": 157940,
"initialRawBytes": 1948149,
"largestAssetRawBytes": 753778,
@@ -297,12 +297,12 @@
},
"editor": {
"baseline": {
- "brotliBytes": 1020113,
+ "brotliBytes": 1020191,
"cssRawBytes": 2159,
"fontRawBytes": 219480,
- "gzipBytes": 1015457,
+ "gzipBytes": 1015483,
"imageRawBytes": 156376,
- "initialRawBytes": 2499734,
+ "initialRawBytes": 2500067,
"largestAssetRawBytes": 746314,
"otherAssetRawBytes": 0,
"ownedRawBytes": 105623,
@@ -812,12 +812,12 @@
]
},
"limits": {
- "brotliBytes": 1030315,
+ "brotliBytes": 1030393,
"cssRawBytes": 2181,
"fontRawBytes": 221675,
- "gzipBytes": 1025612,
+ "gzipBytes": 1025638,
"imageRawBytes": 157940,
- "initialRawBytes": 2524732,
+ "initialRawBytes": 2525068,
"largestAssetRawBytes": 753778,
"otherAssetRawBytes": 0,
"ownedRawBytes": 105623,
@@ -829,7 +829,7 @@
"source": "src/app/WorkbenchApp.tsx"
}
},
- "capturedAt": "2026-08-13",
+ "capturedAt": "2026-08-14",
"developmentInvalidation": {
"platformUiBarrel": {
"specifier": "@platform/ui",
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.json
index ddd5c12b61..fb58faff3e 100644
--- a/invokeai/frontend/webv2/performance/browser-baseline.json
+++ b/invokeai/frontend/webv2/performance/browser-baseline.json
@@ -1,6 +1,6 @@
{
"browserExecutable": "/home/lstein/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome",
- "capturedAt": "2026-08-13",
+ "capturedAt": "2026-08-14",
"routes": [
{
"activatedResourceBaseline": {
@@ -25,11 +25,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 88.80000019073486,
+ "domContentLoadedMedianMs": 93.7000002861023,
"id": "launchpad",
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 88.80000019073486,
- "longestTaskMaxMs": 53,
+ "loadMedianMs": 93.7000002861023,
+ "longestTaskMaxMs": 57,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -56,7 +56,7 @@
"scriptRequestCount": 32,
"totalRawBytes": 1777536
},
- "routeReadyMedianMs": 197.40000009536743,
+ "routeReadyMedianMs": 201.5,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@ -83,11 +83,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 88.5,
+ "domContentLoadedMedianMs": 89.69999980926514,
"id": "launchpad",
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 88.5,
- "longestTaskMaxMs": 57,
+ "loadMedianMs": 89.7999997138977,
+ "longestTaskMaxMs": 54,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -114,7 +114,7 @@
"scriptRequestCount": 32,
"totalRawBytes": 1777536
},
- "routeReadyMedianMs": 211.90000009536743,
+ "routeReadyMedianMs": 214.39999961853027,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@ -141,13 +141,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 108,
+ "domContentLoadedMedianMs": 108.30000019073486,
"id": "editor-minimal",
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 108,
- "longestTaskMaxMs": 75,
+ "loadMedianMs": 108.30000019073486,
+ "longestTaskMaxMs": 76,
"owner": "workbench",
- "projectSwitchMedianMs": 29.09999990463257,
+ "projectSwitchMedianMs": 29.40000009536743,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -157,9 +157,9 @@
"largestAssetRawBytes": 746314,
"otherRawBytes": 134821,
"requestCount": 110,
- "scriptRawBytes": 3322352,
+ "scriptRawBytes": 3322685,
"scriptRequestCount": 104,
- "totalRawBytes": 3654785
+ "totalRawBytes": 3655118
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -168,11 +168,11 @@
"largestAssetRawBytes": 753778,
"otherRawBytes": 136170,
"requestCount": 110,
- "scriptRawBytes": 3355576,
+ "scriptRawBytes": 3355912,
"scriptRequestCount": 104,
- "totalRawBytes": 3691333
+ "totalRawBytes": 3691670
},
- "routeReadyMedianMs": 589.8000001907349,
+ "routeReadyMedianMs": 589.1999998092651,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -199,10 +199,10 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 92.90000009536743,
+ "domContentLoadedMedianMs": 94.5,
"id": "editor-minimal",
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 92.90000009536743,
+ "loadMedianMs": 94.5,
"longestTaskMaxMs": 72,
"owner": "workbench",
"projectSwitchMedianMs": 49,
@@ -215,9 +215,9 @@
"largestAssetRawBytes": 746314,
"otherRawBytes": 134821,
"requestCount": 110,
- "scriptRawBytes": 3322352,
+ "scriptRawBytes": 3322685,
"scriptRequestCount": 104,
- "totalRawBytes": 3654785
+ "totalRawBytes": 3655118
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -226,11 +226,11 @@
"largestAssetRawBytes": 753778,
"otherRawBytes": 136170,
"requestCount": 110,
- "scriptRawBytes": 3355576,
+ "scriptRawBytes": 3355912,
"scriptRequestCount": 104,
- "totalRawBytes": 3691333
+ "totalRawBytes": 3691670
},
- "routeReadyMedianMs": 591.9000000953674,
+ "routeReadyMedianMs": 602.5999999046326,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -257,11 +257,11 @@
"scriptRequestCount": 5,
"totalRawBytes": 286567
},
- "domContentLoadedMedianMs": 91.80000019073486,
+ "domContentLoadedMedianMs": 92.90000009536743,
"id": "editor-canvas",
- "layoutSwitchMedianMs": 54.299999713897705,
- "loadMedianMs": 91.80000019073486,
- "longestTaskMaxMs": 73,
+ "layoutSwitchMedianMs": 54.40000009536743,
+ "loadMedianMs": 92.90000009536743,
+ "longestTaskMaxMs": 78,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -273,9 +273,9 @@
"largestAssetRawBytes": 746314,
"otherRawBytes": 134821,
"requestCount": 115,
- "scriptRawBytes": 3606081,
+ "scriptRawBytes": 3606414,
"scriptRequestCount": 109,
- "totalRawBytes": 3938514
+ "totalRawBytes": 3938847
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -284,11 +284,11 @@
"largestAssetRawBytes": 753778,
"otherRawBytes": 136170,
"requestCount": 115,
- "scriptRawBytes": 3642142,
+ "scriptRawBytes": 3642479,
"scriptRequestCount": 109,
- "totalRawBytes": 3977900
+ "totalRawBytes": 3978236
},
- "routeReadyMedianMs": 998.0999999046326,
+ "routeReadyMedianMs": 997.5,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@ -315,10 +315,10 @@
"scriptRequestCount": 5,
"totalRawBytes": 286567
},
- "domContentLoadedMedianMs": 89.7000002861023,
+ "domContentLoadedMedianMs": 91.09999990463257,
"id": "editor-canvas",
- "layoutSwitchMedianMs": 138.09999990463257,
- "loadMedianMs": 89.7000002861023,
+ "layoutSwitchMedianMs": 139.40000009536743,
+ "loadMedianMs": 91.09999990463257,
"longestTaskMaxMs": 263,
"owner": "canvas",
"projectSwitchMedianMs": 0,
@@ -331,9 +331,9 @@
"largestAssetRawBytes": 746314,
"otherRawBytes": 134821,
"requestCount": 115,
- "scriptRawBytes": 3606081,
+ "scriptRawBytes": 3606414,
"scriptRequestCount": 109,
- "totalRawBytes": 3938514
+ "totalRawBytes": 3938847
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -342,11 +342,11 @@
"largestAssetRawBytes": 753778,
"otherRawBytes": 136170,
"requestCount": 115,
- "scriptRawBytes": 3642142,
+ "scriptRawBytes": 3642479,
"scriptRequestCount": 109,
- "totalRawBytes": 3977900
+ "totalRawBytes": 3978236
},
- "routeReadyMedianMs": 1105.5999999046326,
+ "routeReadyMedianMs": 1106.5,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@ -373,11 +373,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 97.80000019073486,
+ "domContentLoadedMedianMs": 102.09999990463257,
"id": "editor-workflow",
- "layoutSwitchMedianMs": 52.10000038146973,
- "loadMedianMs": 97.80000019073486,
- "longestTaskMaxMs": 77,
+ "layoutSwitchMedianMs": 54,
+ "loadMedianMs": 102.09999990463257,
+ "longestTaskMaxMs": 73,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -389,9 +389,9 @@
"largestAssetRawBytes": 746314,
"otherRawBytes": 134821,
"requestCount": 110,
- "scriptRawBytes": 3322352,
+ "scriptRawBytes": 3322685,
"scriptRequestCount": 104,
- "totalRawBytes": 3654785
+ "totalRawBytes": 3655118
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -400,11 +400,11 @@
"largestAssetRawBytes": 753778,
"otherRawBytes": 136170,
"requestCount": 110,
- "scriptRawBytes": 3355576,
+ "scriptRawBytes": 3355912,
"scriptRequestCount": 104,
- "totalRawBytes": 3691333
+ "totalRawBytes": 3691670
},
- "routeReadyMedianMs": 996.0999999046326,
+ "routeReadyMedianMs": 1011.5999999046326,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -431,11 +431,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 90.40000009536743,
+ "domContentLoadedMedianMs": 89.90000009536743,
"id": "editor-workflow",
- "layoutSwitchMedianMs": 81,
- "loadMedianMs": 90.40000009536743,
- "longestTaskMaxMs": 255,
+ "layoutSwitchMedianMs": 82,
+ "loadMedianMs": 89.90000009536743,
+ "longestTaskMaxMs": 261,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -447,9 +447,9 @@
"largestAssetRawBytes": 746314,
"otherRawBytes": 134821,
"requestCount": 110,
- "scriptRawBytes": 3322352,
+ "scriptRawBytes": 3322685,
"scriptRequestCount": 104,
- "totalRawBytes": 3654785
+ "totalRawBytes": 3655118
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -458,11 +458,11 @@
"largestAssetRawBytes": 753778,
"otherRawBytes": 136170,
"requestCount": 110,
- "scriptRawBytes": 3355576,
+ "scriptRawBytes": 3355912,
"scriptRequestCount": 104,
- "totalRawBytes": 3691333
+ "totalRawBytes": 3691670
},
- "routeReadyMedianMs": 1049.5,
+ "routeReadyMedianMs": 1049,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -489,10 +489,10 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 95.90000009536743,
+ "domContentLoadedMedianMs": 94.7999997138977,
"id": "editor-gallery",
- "layoutSwitchMedianMs": 28.200000286102295,
- "loadMedianMs": 95.90000009536743,
+ "layoutSwitchMedianMs": 28.40000009536743,
+ "loadMedianMs": 94.7999997138977,
"longestTaskMaxMs": 73,
"owner": "gallery",
"projectSwitchMedianMs": 0,
@@ -505,9 +505,9 @@
"largestAssetRawBytes": 746314,
"otherRawBytes": 134821,
"requestCount": 110,
- "scriptRawBytes": 3322352,
+ "scriptRawBytes": 3322685,
"scriptRequestCount": 104,
- "totalRawBytes": 3654785
+ "totalRawBytes": 3655118
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -516,11 +516,11 @@
"largestAssetRawBytes": 753778,
"otherRawBytes": 136170,
"requestCount": 110,
- "scriptRawBytes": 3355576,
+ "scriptRawBytes": 3355912,
"scriptRequestCount": 104,
- "totalRawBytes": 3691333
+ "totalRawBytes": 3691670
},
- "routeReadyMedianMs": 1242.0999999046326,
+ "routeReadyMedianMs": 1238.0999999046326,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -547,11 +547,11 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 86.7999997138977,
+ "domContentLoadedMedianMs": 92.40000009536743,
"id": "editor-gallery",
- "layoutSwitchMedianMs": 66.09999990463257,
- "loadMedianMs": 86.7999997138977,
- "longestTaskMaxMs": 100,
+ "layoutSwitchMedianMs": 66.60000038146973,
+ "loadMedianMs": 92.40000009536743,
+ "longestTaskMaxMs": 96,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -563,9 +563,9 @@
"largestAssetRawBytes": 746314,
"otherRawBytes": 134821,
"requestCount": 110,
- "scriptRawBytes": 3322352,
+ "scriptRawBytes": 3322685,
"scriptRequestCount": 104,
- "totalRawBytes": 3654785
+ "totalRawBytes": 3655118
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -574,11 +574,11 @@
"largestAssetRawBytes": 753778,
"otherRawBytes": 136170,
"requestCount": 110,
- "scriptRawBytes": 3355576,
+ "scriptRawBytes": 3355912,
"scriptRequestCount": 104,
- "totalRawBytes": 3691333
+ "totalRawBytes": 3691670
},
- "routeReadyMedianMs": 1317.5,
+ "routeReadyMedianMs": 1326.2000002861023,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapWidgetView.tsx
index 951addc170..029b9420be 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapWidgetView.tsx
@@ -2,16 +2,25 @@ import type { WidgetViewProps } from '@workbench/widgetContracts';
import { Button, Center, Spinner, Stack, Text } from '@chakra-ui/react';
import { ensureImageMapLoaded, imageMapStore, refreshImageMapPoints } from '@workbench/image-map/imageMapStore';
-import { lazy, useEffect } from 'react';
+import { lazy, Suspense, useEffect } from 'react';
-// Lazy so the plotly bundle (its own vite chunk) loads only when the widget
-// is actually shown; WidgetRenderer supplies the Suspense fallback.
+// Lazy so the plotly bundle (its own vite chunk, ~1.5MB) loads only when the
+// widget is actually shown.
const ImageMapPlot = lazy(() => import('./ImageMapPlot'));
const handleRefresh = () => {
void refreshImageMapPoints();
};
+// Module scope: an inline element would be a new value on every render, which
+// is both what react-perf/jsx-no-jsx-as-prop forbids and pointless here — the
+// fallback never varies.
+const plotLoadingFallback = (
+ <Center h="full">
+ <Spinner size="lg" />
+ </Center>
+);
+
/**
* Semantic map of the gallery: every image embedded by the backend's image
* index, projected to 2D with UMAP and colored by cluster. Clicking a point
@@ -41,7 +50,19 @@ export const ImageMapWidgetView = (_props: WidgetViewProps) => {
// A working map beats a full-screen error: when a refresh fails but prior
// points exist, keep showing them (the next successful refresh recovers).
if (data && data.points.length > 0) {
- return <ImageMapPlot />;
+ // Its own boundary, rather than leaning on WidgetRenderer's. That one wraps
+ // the whole widget, so suspending on the plotly chunk replaced the entire
+ // panel — header and actions menu included — with a skeleton frame, and
+ // then held the resolved content for React's fallback throttle on top. It
+ // also sits above `loadWidget`, which preloads only the implementation
+ // chunk and cannot reach this nested import, so a preset switch onto an
+ // already-loaded map suspended anyway. Confining it here keeps the frame
+ // mounted and the spinner where the plot will appear.
+ return (
+ <Suspense fallback={plotLoadingFallback}>
+ <ImageMapPlot />
+ </Suspense>
+ );
}
if (loadState === 'idle' || loadState === 'loading') {
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.browser.test.tsx
index 27bb8e9bfe..a438fb54b3 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.browser.test.tsx
@@ -4,6 +4,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
const mocks = vi.hoisted(() => ({
resolveMany: vi.fn(),
+ selectBoard: vi.fn(),
selectItem: vi.fn(),
}));
@@ -13,7 +14,9 @@ vi.mock('@features/gallery', () => ({
}));
vi.mock('@workbench/WorkbenchContext', () => ({
- useWorkbenchCommands: () => ({ gallery: { selectItem: mocks.selectItem } }),
+ useWorkbenchCommands: () => ({
+ gallery: { selectBoard: mocks.selectBoard, selectItem: mocks.selectItem },
+ }),
}));
import { useSelectMapImage } from './useSelectMapImage';
@@ -74,6 +77,7 @@ afterEach(async () => {
await unmount();
}
mocks.resolveMany.mockReset();
+ mocks.selectBoard.mockReset();
mocks.selectItem.mockReset();
});
@@ -88,6 +92,31 @@ describe('useSelectMapImage', () => {
expect(mocks.selectItem.mock.calls[0]?.[0]).toEqual({ image_name: 'a.png' });
});
+ it("selects the image's board before the image itself", async () => {
+ // The map spans every accessible board, but selectGalleryItem stamps the
+ // navigation query from whatever list the gallery is currently showing. A
+ // cross-board click without this left that query describing a list the
+ // image was never in, and Preview's next/prev found no cursor and went
+ // dead until the user re-selected from the grid.
+ mocks.resolveMany.mockResolvedValue([{ boardId: 'board-portraits', image_name: 'a.png' }]);
+ await mount();
+
+ await flush(() => handle.click?.('a.png'));
+
+ expect(mocks.selectBoard).toHaveBeenCalledWith('board-portraits');
+ expect(mocks.selectBoard.mock.invocationCallOrder[0]).toBeLessThan(mocks.selectItem.mock.invocationCallOrder[0]);
+ });
+
+ it('does not touch the board for a click that never resolves an image', async () => {
+ mocks.resolveMany.mockResolvedValue([]);
+ await mount();
+
+ await flush(() => handle.click?.('gone.png'));
+
+ expect(mocks.selectBoard).not.toHaveBeenCalled();
+ expect(mocks.selectItem).not.toHaveBeenCalled();
+ });
+
it('ignores a slow click that resolves after a newer one', async () => {
const slow = deferred<{ image_name: string }[]>();
const fast = deferred<{ image_name: string }[]>();
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.ts b/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.ts
index f715aa3532..688a36c29f 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.ts
@@ -36,6 +36,22 @@ export const useSelectMapImage = (): ((imageName: string) => void) => {
return;
}
+ // Select the image's board first. The map spans every accessible
+ // board, but `selectGalleryItem` stamps `selectedImageQuery` from
+ // whatever list the gallery is CURRENTLY showing — it takes the
+ // selection on faith as "an item from the visible page". Selecting a
+ // point from another board without this left the stored query
+ // describing a list the image was never in, so Preview's next/prev
+ // found no cursor and went dead until the user re-selected from the
+ // grid. Mirrors the command palette's reveal-in-gallery.
+ //
+ // This lands the gallery on page 0 of that board (selectGalleryBoard
+ // resets the page), so next/prev works whenever the image is on the
+ // first page. Placing it exactly would need the board's ordering,
+ // which only the gallery query knows — Preview does it that way, from
+ // pages it has already loaded. The query is at least coherent now:
+ // it describes a real list, and any grid selection re-anchors it.
+ commands.gallery.selectBoard(image.boardId);
commands.gallery.selectItem(legacyGeneratedImageToGalleryItem(image));
})
.catch(() => {
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 4fe252e1e4..4f2fc854fa 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -401,6 +401,46 @@ describe('workbench widget region defaults', () => {
expect(getActiveProject(hydratedCustomized).widgetRegions.right.instanceIds).toEqual(['gallery', 'layers']);
});
+ it('adds Image Map to an untouched pre-image-map right rail so it does not read as drifted', () => {
+ // The built-in presets now list image-map. A project persisted before that
+ // keeps the old rail, so without this migration every existing user's
+ // layout compares unequal to the preset it was loaded from: the topbar
+ // shows an unsaved-changes dot and offers to revert a layout they never
+ // edited, and the widget itself is only reachable from the enable menu.
+ const initial = createInitialWorkbenchState();
+ const withRightIds = (instanceIds: Project['widgetRegions']['right']['instanceIds']): WorkbenchState => ({
+ ...initial,
+ projects: initial.projects.map((project) => ({
+ ...project,
+ widgetRegions: {
+ ...project.widgetRegions,
+ right: { ...project.widgetRegions.right, instanceIds },
+ },
+ })),
+ });
+ const preImageMapDefault = withRightIds(['gallery', 'preview', 'queue', 'layers', 'diagnostics', 'project']);
+ const customized = withRightIds(['preview', 'gallery', 'queue']);
+
+ const hydratedDefault = workbenchReducer(initial, { state: preImageMapDefault, type: 'hydrateWorkbench' });
+ const hydratedCustomized = workbenchReducer(initial, { state: customized, type: 'hydrateWorkbench' });
+
+ expect(getActiveProject(hydratedDefault).widgetRegions.right.instanceIds).toEqual([
+ 'gallery',
+ 'image-map',
+ 'preview',
+ 'queue',
+ 'layers',
+ 'diagnostics',
+ 'project',
+ ]);
+ // A rail the user actually arranged is still theirs.
+ expect(getActiveProject(hydratedCustomized).widgetRegions.right.instanceIds).toEqual([
+ 'preview',
+ 'gallery',
+ 'queue',
+ ]);
+ });
+
it('adds Upscale to untouched legacy left rails while preserving customized rails', () => {
const initial = createInitialWorkbenchState();
const withoutUpscaleInstance = Object.fromEntries(
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
index d7a98734bc..ca6fd72507 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@ -1205,6 +1205,18 @@ const isLegacyDefaultRightRegion = (region: WidgetRegionState): boolean =>
region.instanceIds.length === LEGACY_RIGHT_REGION_WIDGET_IDS.length &&
region.instanceIds.every((widgetId, index) => widgetId === LEGACY_RIGHT_REGION_WIDGET_IDS[index]);
+// The right rail as it shipped before the image map existed. A project
+// persisted with exactly this arrangement is an untouched default, not a
+// customization, so it gains the new widget the way a fresh project would.
+const PRE_IMAGE_MAP_DEFAULT_RIGHT_REGION_WIDGET_IDS: WidgetId[] = [
+ 'gallery',
+ 'preview',
+ 'queue',
+ 'layers',
+ 'diagnostics',
+ 'project',
+];
+
const ensureRightRegion = (rightRegion: WidgetRegionState | undefined): WidgetRegionState => {
const defaultRightRegion = createWidgetRegions().right;
@@ -1216,7 +1228,33 @@ const ensureRightRegion = (rightRegion: WidgetRegionState | undefined): WidgetRe
return { ...rightRegion, instanceIds: defaultRightRegion.instanceIds };
}
- return rightRegion;
+ if (rightRegion.instanceIds.includes('image-map')) {
+ return rightRegion;
+ }
+
+ const isPreImageMapDefault =
+ rightRegion.instanceIds.length === PRE_IMAGE_MAP_DEFAULT_RIGHT_REGION_WIDGET_IDS.length &&
+ rightRegion.instanceIds.every(
+ (widgetId, index) => widgetId === PRE_IMAGE_MAP_DEFAULT_RIGHT_REGION_WIDGET_IDS[index]
+ );
+
+ if (!isPreImageMapDefault) {
+ // A customized rail is left alone, matching how `upscale` was introduced.
+ return rightRegion;
+ }
+
+ // Without this, adding the widget to the built-in presets makes every
+ // existing project read as drifted from the preset it was loaded from — the
+ // topbar shows an unsaved-changes dot, and offers to revert a layout the user
+ // never edited. Migrating the persisted rail keeps the two in step, and is
+ // also the only way the widget is discoverable without hunting through the
+ // enable menu.
+ const galleryIndex = rightRegion.instanceIds.indexOf('gallery');
+ const instanceIds = [...rightRegion.instanceIds];
+
+ instanceIds.splice(galleryIndex === -1 ? instanceIds.length : galleryIndex + 1, 0, 'image-map');
+
+ return { ...rightRegion, instanceIds };
};
const getCenterWidgetIdFromViewId = (centerViewId: CenterViewId): WidgetInstanceId => {