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.

perf(gallery): keep the reveal channel out of its own chunk, refresh budgets

Lincoln Steine8623817d4f7
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.json
index 58cd415cf5..2c30ff4714 100644
--- a/invokeai/frontend/webv2/performance/browser-baseline.json
+++ b/invokeai/frontend/webv2/performance/browser-baseline.json
@@ -1,6 +1,6 @@
{
- "browserExecutable": "/home/toast/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome",
- "capturedAt": "2026-08-23",
+ "browserExecutable": "/home/lstein/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome",
+ "capturedAt": "2026-08-25",
"routes": [
{
"activatedResourceBaseline": {
@@ -25,13 +25,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 116.19999999552965,
+ "domContentLoadedMedianMs": 161.5999994277954,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 116.39999999850988,
- "longestTaskMaxMs": 69,
+ "loadMedianMs": 161.79999923706055,
+ "longestTaskMaxMs": 73,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -41,24 +41,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 37,
- "scriptRawBytes": 1621828,
+ "scriptRawBytes": 1623497,
"scriptRequestCount": 33,
- "totalRawBytes": 1796202
+ "totalRawBytes": 1799653
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 37,
- "scriptRawBytes": 1638047,
+ "scriptRawBytes": 1639732,
"scriptRequestCount": 33,
- "totalRawBytes": 1814165
+ "totalRawBytes": 1817650
},
- "routeReadyMedianMs": 258.70000000298023,
+ "routeReadyMedianMs": 318.19999980926514,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@ -85,13 +85,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 115.20000000298023,
+ "domContentLoadedMedianMs": 144.39999961853027,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 115.30000000447035,
- "longestTaskMaxMs": 69,
+ "loadMedianMs": 144.5,
+ "longestTaskMaxMs": 72,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -101,24 +101,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 37,
- "scriptRawBytes": 1621828,
+ "scriptRawBytes": 1623497,
"scriptRequestCount": 33,
- "totalRawBytes": 1796202
+ "totalRawBytes": 1799653
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 37,
- "scriptRawBytes": 1638047,
+ "scriptRawBytes": 1639732,
"scriptRequestCount": 33,
- "totalRawBytes": 1814165
+ "totalRawBytes": 1817650
},
- "routeReadyMedianMs": 269.6000000014901,
+ "routeReadyMedianMs": 319.79999923706055,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@ -145,15 +145,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 116.5,
+ "domContentLoadedMedianMs": 147.30000019073486,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 116.60000000149012,
- "longestTaskMaxMs": 104,
+ "loadMedianMs": 147.39999961853027,
+ "longestTaskMaxMs": 108,
"owner": "workbench",
- "projectSwitchMedianMs": 36.5,
+ "projectSwitchMedianMs": 48.69999980926514,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -161,24 +161,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 114,
- "scriptRawBytes": 3152121,
+ "scriptRawBytes": 3157269,
"scriptRequestCount": 109,
- "totalRawBytes": 3482871
+ "totalRawBytes": 3489801
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 114,
- "scriptRawBytes": 3183643,
+ "scriptRawBytes": 3188842,
"scriptRequestCount": 109,
- "totalRawBytes": 3517700
+ "totalRawBytes": 3524700
},
- "routeReadyMedianMs": 666,
+ "routeReadyMedianMs": 731.6999998092651,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -205,15 +205,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 118.40000000596046,
+ "domContentLoadedMedianMs": 139,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 118.5,
- "longestTaskMaxMs": 196,
+ "loadMedianMs": 139.19999980926514,
+ "longestTaskMaxMs": 213,
"owner": "workbench",
- "projectSwitchMedianMs": 54,
+ "projectSwitchMedianMs": 82.40000057220459,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -221,24 +221,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 114,
- "scriptRawBytes": 3152121,
+ "scriptRawBytes": 3157269,
"scriptRequestCount": 109,
- "totalRawBytes": 3482871
+ "totalRawBytes": 3489801
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 114,
- "scriptRawBytes": 3183643,
+ "scriptRawBytes": 3188842,
"scriptRequestCount": 109,
- "totalRawBytes": 3517700
+ "totalRawBytes": 3524700
},
- "routeReadyMedianMs": 446.90000000596046,
+ "routeReadyMedianMs": 499.5,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -265,13 +265,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 292350
},
- "domContentLoadedMedianMs": 117.89999999850988,
+ "domContentLoadedMedianMs": 141.60000038146973,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.7999999970197678,
- "layoutReturnSwitchMedianMs": 39.399999998509884,
- "layoutSwitchMedianMs": 85.29999999701977,
- "loadMedianMs": 118,
- "longestTaskMaxMs": 105,
+ "layoutAckMedianMs": 6.800000190734863,
+ "layoutReturnSwitchMedianMs": 37.89999961853027,
+ "layoutSwitchMedianMs": 88.89999961853027,
+ "loadMedianMs": 141.69999980926514,
+ "longestTaskMaxMs": 113,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -281,24 +281,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 120,
- "scriptRawBytes": 3441576,
+ "scriptRawBytes": 3446724,
"scriptRequestCount": 115,
- "totalRawBytes": 3772326
+ "totalRawBytes": 3779256
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 120,
- "scriptRawBytes": 3475992,
+ "scriptRawBytes": 3481192,
"scriptRequestCount": 115,
- "totalRawBytes": 3810050
+ "totalRawBytes": 3817049
},
- "routeReadyMedianMs": 1059.7999999970198,
+ "routeReadyMedianMs": 1175.8999996185303,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@ -325,13 +325,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 292350
},
- "domContentLoadedMedianMs": 113.19999999552965,
+ "domContentLoadedMedianMs": 144.60000038146973,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.6999999955296516,
- "layoutReturnSwitchMedianMs": 39.899999998509884,
- "layoutSwitchMedianMs": 182.29999999701977,
- "loadMedianMs": 113.29999999701977,
- "longestTaskMaxMs": 368,
+ "layoutAckMedianMs": 3.3999996185302734,
+ "layoutReturnSwitchMedianMs": 37.70000076293945,
+ "layoutSwitchMedianMs": 197.80000019073486,
+ "loadMedianMs": 144.70000076293945,
+ "longestTaskMaxMs": 386,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -341,24 +341,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 120,
- "scriptRawBytes": 3441576,
+ "scriptRawBytes": 3446724,
"scriptRequestCount": 115,
- "totalRawBytes": 3772326
+ "totalRawBytes": 3779256
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 120,
- "scriptRawBytes": 3475992,
+ "scriptRawBytes": 3481192,
"scriptRequestCount": 115,
- "totalRawBytes": 3810050
+ "totalRawBytes": 3817049
},
- "routeReadyMedianMs": 1242.2999999970198,
+ "routeReadyMedianMs": 1347.1999998092651,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@ -385,13 +385,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383401
},
- "domContentLoadedMedianMs": 117.39999999850988,
+ "domContentLoadedMedianMs": 133.69999980926514,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.2000000029802322,
- "layoutReturnSwitchMedianMs": 33.70000000298023,
- "layoutSwitchMedianMs": 93,
- "loadMedianMs": 117.5,
- "longestTaskMaxMs": 98,
+ "layoutAckMedianMs": 8.200000762939453,
+ "layoutReturnSwitchMedianMs": 31.59999942779541,
+ "layoutSwitchMedianMs": 110.5,
+ "loadMedianMs": 133.89999961853027,
+ "longestTaskMaxMs": 108,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -401,24 +401,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 121,
- "scriptRawBytes": 3516312,
+ "scriptRawBytes": 3521460,
"scriptRequestCount": 115,
- "totalRawBytes": 3862475
+ "totalRawBytes": 3869405
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 121,
- "scriptRawBytes": 3551476,
+ "scriptRawBytes": 3556675,
"scriptRequestCount": 115,
- "totalRawBytes": 3901100
+ "totalRawBytes": 3908100
},
- "routeReadyMedianMs": 1064.1000000014901,
+ "routeReadyMedianMs": 1184.0999994277954,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "empty"
},
@@ -445,13 +445,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383401
},
- "domContentLoadedMedianMs": 117.29999999701977,
+ "domContentLoadedMedianMs": 141.10000038146973,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.5999999940395355,
- "layoutReturnSwitchMedianMs": 40.600000001490116,
- "layoutSwitchMedianMs": 129.80000000447035,
- "loadMedianMs": 117.39999999850988,
- "longestTaskMaxMs": 347,
+ "layoutAckMedianMs": 2.90000057220459,
+ "layoutReturnSwitchMedianMs": 35.89999961853027,
+ "layoutSwitchMedianMs": 136.69999980926514,
+ "loadMedianMs": 141.19999980926514,
+ "longestTaskMaxMs": 371,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -461,24 +461,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 121,
- "scriptRawBytes": 3516312,
+ "scriptRawBytes": 3521460,
"scriptRequestCount": 115,
- "totalRawBytes": 3862475
+ "totalRawBytes": 3869405
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 121,
- "scriptRawBytes": 3551476,
+ "scriptRawBytes": 3556675,
"scriptRequestCount": 115,
- "totalRawBytes": 3901100
+ "totalRawBytes": 3908100
},
- "routeReadyMedianMs": 1175.3000000044703,
+ "routeReadyMedianMs": 1271.5999994277954,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "representative"
},
@@ -505,13 +505,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 115.5,
+ "domContentLoadedMedianMs": 152.80000019073486,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 26.30000000447035,
- "loadMedianMs": 115.60000000149012,
- "longestTaskMaxMs": 99,
+ "layoutSwitchMedianMs": 32.09999942779541,
+ "loadMedianMs": 153,
+ "longestTaskMaxMs": 111,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -521,24 +521,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 114,
- "scriptRawBytes": 3152121,
+ "scriptRawBytes": 3157269,
"scriptRequestCount": 109,
- "totalRawBytes": 3482871
+ "totalRawBytes": 3489801
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 114,
- "scriptRawBytes": 3183643,
+ "scriptRawBytes": 3188842,
"scriptRequestCount": 109,
- "totalRawBytes": 3517700
+ "totalRawBytes": 3524700
},
- "routeReadyMedianMs": 1265,
+ "routeReadyMedianMs": 1406.4000005722046,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -565,13 +565,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 116.19999999552965,
+ "domContentLoadedMedianMs": 127.40000057220459,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 86.79999999701977,
- "loadMedianMs": 116.39999999850988,
- "longestTaskMaxMs": 187,
+ "layoutSwitchMedianMs": 104.69999980926514,
+ "loadMedianMs": 127.5,
+ "longestTaskMaxMs": 217,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -581,24 +581,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746355,
- "otherRawBytes": 148551,
+ "otherRawBytes": 150333,
"requestCount": 114,
- "scriptRawBytes": 3152121,
+ "scriptRawBytes": 3157269,
"scriptRequestCount": 109,
- "totalRawBytes": 3482871
+ "totalRawBytes": 3489801
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753819,
- "otherRawBytes": 150037,
+ "otherRawBytes": 151837,
"requestCount": 114,
- "scriptRawBytes": 3183643,
+ "scriptRawBytes": 3188842,
"scriptRequestCount": 109,
- "totalRawBytes": 3517700
+ "totalRawBytes": 3524700
},
- "routeReadyMedianMs": 1450.5999999940395,
+ "routeReadyMedianMs": 1544.1000003814697,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
}
diff --git a/invokeai/frontend/webv2/src/features/gallery/contracts.ts b/invokeai/frontend/webv2/src/features/gallery/contracts.ts
index e191030014..e9ae782497 100644
--- a/invokeai/frontend/webv2/src/features/gallery/contracts.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/contracts.ts
@@ -40,7 +40,6 @@ export {
registerImageCluster,
type GallerySemanticReference,
} from './core/semanticImageQuery';
-export { requestGalleryItemReveal } from './core/revealRequest';
export {
DEFAULT_GALLERY_SETTINGS,
getGallerySettings,
@@ -67,4 +66,5 @@ export {
getPersistedSelectedGalleryItemKeys,
getSelectedGalleryImageFromValues,
getSelectedGalleryItemFromValues,
+ requestGalleryItemReveal,
} from './core/selection';
diff --git a/invokeai/frontend/webv2/src/features/gallery/core/revealRequest.test.ts b/invokeai/frontend/webv2/src/features/gallery/core/revealRequest.selection.test.ts
similarity index 94%
rename from invokeai/frontend/webv2/src/features/gallery/core/revealRequest.test.ts
rename to invokeai/frontend/webv2/src/features/gallery/core/revealRequest.selection.test.ts
index 85a0ed6290..7d1d280184 100644
--- a/invokeai/frontend/webv2/src/features/gallery/core/revealRequest.test.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/core/revealRequest.selection.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from 'vitest';
-import { getGalleryRevealRequest, requestGalleryItemReveal, subscribeGalleryRevealRequests } from './revealRequest';
+import { getGalleryRevealRequest, requestGalleryItemReveal, subscribeGalleryRevealRequests } from './selection';
describe('gallery reveal requests', () => {
it('notifies subscribers with a fresh token per request, even for the same item', () => {
diff --git a/invokeai/frontend/webv2/src/features/gallery/core/revealRequest.ts b/invokeai/frontend/webv2/src/features/gallery/core/revealRequest.ts
deleted file mode 100644
index 31dd93ec72..0000000000
--- a/invokeai/frontend/webv2/src/features/gallery/core/revealRequest.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import type { GalleryItemKey } from './items';
-
-/**
- * An explicit "scroll this item into view" signal from surfaces outside the
- * grid (the image map's reveal). Deliberately NOT derived from the selection:
- * the selection also changes when a finished generation auto-selects its
- * image, and scrolling on that yanked the grid out from under a browsing
- * user. A reveal is a deliberate gesture, so it gets its own channel — and a
- * token, so repeating the same gesture (re-clicking the same map point after
- * scrolling away) reveals again even though the selection is unchanged.
- *
- * Module-scoped rather than persisted widget state: a reveal is an ephemeral
- * intent for the currently mounted grid, and persisting it would replay a
- * stale scroll on the next session.
- */
-
-export interface GalleryRevealRequest {
- itemKey: GalleryItemKey;
- token: number;
-}
-
-let currentRequest: GalleryRevealRequest | null = null;
-let nextToken = 0;
-
-const listeners = new Set<() => void>();
-
-export const requestGalleryItemReveal = (itemKey: GalleryItemKey): void => {
- nextToken += 1;
- currentRequest = { itemKey, token: nextToken };
- for (const listener of listeners) {
- listener();
- }
-};
-
-export const getGalleryRevealRequest = (): GalleryRevealRequest | null => currentRequest;
-
-export const subscribeGalleryRevealRequests = (listener: () => void): (() => void) => {
- listeners.add(listener);
-
- return () => {
- listeners.delete(listener);
- };
-};
diff --git a/invokeai/frontend/webv2/src/features/gallery/core/selection.ts b/invokeai/frontend/webv2/src/features/gallery/core/selection.ts
index 368e32bb21..8a3154d5e8 100644
--- a/invokeai/frontend/webv2/src/features/gallery/core/selection.ts
+++ b/invokeai/frontend/webv2/src/features/gallery/core/selection.ts
@@ -94,3 +94,48 @@ export const getPersistedSelectedGalleryItemKeys = (galleryValues: Record<string
return selectedItem ? [toGalleryItemKey(selectedItem)] : [];
};
+
+/*
+ * Reveal requests: an explicit "scroll this item into view" signal from
+ * surfaces outside the grid (the image map's reveal). Deliberately NOT derived
+ * from the selection, which also changes when a finished generation
+ * auto-selects its image — scrolling on that yanked the grid out from under a
+ * browsing user. A reveal is a deliberate gesture, so it gets its own channel,
+ * and a token, so repeating the same gesture (re-clicking the same map point
+ * after scrolling away) reveals again even though the selection is unchanged.
+ *
+ * Module-scoped rather than persisted: a reveal is an ephemeral intent for the
+ * currently mounted grid, and persisting it would replay a stale scroll in the
+ * next session. It lives here, beside the selection helpers it travels with,
+ * rather than in a module of its own — a separate one becomes a separate chunk
+ * and an extra request in the gallery widget's load, which the performance
+ * budgets police.
+ */
+
+export interface GalleryRevealRequest {
+ itemKey: GalleryItemKey;
+ token: number;
+}
+
+let currentRequest: GalleryRevealRequest | null = null;
+let nextToken = 0;
+
+const listeners = new Set<() => void>();
+
+export const requestGalleryItemReveal = (itemKey: GalleryItemKey): void => {
+ nextToken += 1;
+ currentRequest = { itemKey, token: nextToken };
+ for (const listener of listeners) {
+ listener();
+ }
+};
+
+export const getGalleryRevealRequest = (): GalleryRevealRequest | null => currentRequest;
+
+export const subscribeGalleryRevealRequests = (listener: () => void): (() => void) => {
+ listeners.add(listener);
+
+ return () => {
+ listeners.delete(listener);
+ };
+};
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
index c468f5026e..4c9fa7f3c2 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx
@@ -14,7 +14,7 @@ import {
type DragStartEvent,
} from '@dnd-kit/core';
import { sortableKeyboardCoordinates } from '@dnd-kit/sortable';
-import { requestGalleryItemReveal } from '@features/gallery/core/revealRequest';
+import { requestGalleryItemReveal } from '@features/gallery/core/selection';
import { DEFAULT_GALLERY_SETTINGS } from '@features/gallery/core/settings';
import { GalleryUiProvider, type GalleryUiAdapter } from '@features/gallery/react';
import { isGalleryImageDragData } from '@features/gallery/utility';
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
index 8b76434cd0..b4f7bcfd84 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx
@@ -5,7 +5,7 @@ import {
getGalleryRevealRequest,
subscribeGalleryRevealRequests,
type GalleryRevealRequest,
-} from '@features/gallery/core/revealRequest';
+} from '@features/gallery/core/selection';
import { isDateBoardId } from '@features/gallery/data/backend';
import { GALLERY_PAGE_SIZE } from '@features/gallery/data/queries';
import { Button, DropZone } from '@platform/ui';