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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(ui): make the image map's render failure reachable and its click guard global
Lincoln Stein192243919788
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.jsonindex 9111ee46ab..62ed1c7498 100644--- a/invokeai/frontend/webv2/performance/architecture-baseline.json+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json@@ -2,15 +2,15 @@"build": {"launchpad": {"baseline": {- "brotliBytes": 831144,+ "brotliBytes": 830646,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 830553,+ "gzipBytes": 829164,"imageRawBytes": 156376,- "initialRawBytes": 1928509,+ "initialRawBytes": 1928860,"largestAssetRawBytes": 746314,"otherAssetRawBytes": 0,- "ownedRawBytes": 66631,+ "ownedRawBytes": 66626,"requestCount": 41,"scriptRequestCount": 25,"sourceOwners": [@@ -279,15 +279,15 @@]},"limits": {- "brotliBytes": 839456,+ "brotliBytes": 838953,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 838859,+ "gzipBytes": 837456,"imageRawBytes": 157940,- "initialRawBytes": 1947795,+ "initialRawBytes": 1948149,"largestAssetRawBytes": 753778,"otherAssetRawBytes": 0,- "ownedRawBytes": 66631,+ "ownedRawBytes": 66626,"requestCount": 41,"scriptRequestCount": 25},@@ -297,15 +297,15 @@},"editor": {"baseline": {- "brotliBytes": 1019671,+ "brotliBytes": 1020113,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 1016688,+ "gzipBytes": 1015457,"imageRawBytes": 156376,- "initialRawBytes": 2497187,+ "initialRawBytes": 2499734,"largestAssetRawBytes": 746314,"otherAssetRawBytes": 0,- "ownedRawBytes": 105926,+ "ownedRawBytes": 105623,"requestCount": 85,"scriptRequestCount": 69,"sourceOwners": [@@ -797,6 +797,7 @@"source:src/workbench/widgets/diagnostics/manifest.ts","source:src/workbench/widgets/gallery/manifest.ts","source:src/workbench/widgets/generate/manifest.ts",+ "source:src/workbench/widgets/image-map/manifest.ts","source:src/workbench/widgets/layers/manifest.ts","source:src/workbench/widgets/notifications/manifest.ts","source:src/workbench/widgets/preview/manifest.ts",@@ -811,15 +812,15 @@]},"limits": {- "brotliBytes": 1029868,+ "brotliBytes": 1030315,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 1026855,+ "gzipBytes": 1025612,"imageRawBytes": 157940,- "initialRawBytes": 2522159,+ "initialRawBytes": 2524732,"largestAssetRawBytes": 753778,"otherAssetRawBytes": 0,- "ownedRawBytes": 105926,+ "ownedRawBytes": 105623,"requestCount": 85,"scriptRequestCount": 69},@@ -828,7 +829,7 @@"source": "src/app/WorkbenchApp.tsx"}},- "capturedAt": "2026-08-11",+ "capturedAt": "2026-08-13","developmentInvalidation": {"platformUiBarrel": {"specifier": "@platform/ui",diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.jsonindex 90ded1ddad..ddd5c12b61 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-11",+ "browserExecutable": "/home/lstein/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome",+ "capturedAt": "2026-08-13","routes": [{"activatedResourceBaseline": {@@ -25,11 +25,11 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 135.39999999850988,+ "domContentLoadedMedianMs": 88.80000019073486,"id": "launchpad","layoutSwitchMedianMs": 0,- "loadMedianMs": 135.39999999850988,- "longestTaskMaxMs": 86,+ "loadMedianMs": 88.80000019073486,+ "longestTaskMaxMs": 53,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -39,24 +39,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 36,- "scriptRawBytes": 1598944,+ "scriptRawBytes": 1599292,"scriptRequestCount": 32,- "totalRawBytes": 1759346+ "totalRawBytes": 1759936},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 36,- "scriptRawBytes": 1614934,+ "scriptRawBytes": 1615285,"scriptRequestCount": 32,- "totalRawBytes": 1776940+ "totalRawBytes": 1777536},- "routeReadyMedianMs": 297.6000000014901,+ "routeReadyMedianMs": 197.40000009536743,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "empty"},@@ -83,11 +83,11 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 135.09999999403954,+ "domContentLoadedMedianMs": 88.5,"id": "launchpad","layoutSwitchMedianMs": 0,- "loadMedianMs": 135.19999999552965,- "longestTaskMaxMs": 86,+ "loadMedianMs": 88.5,+ "longestTaskMaxMs": 57,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -97,24 +97,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 36,- "scriptRawBytes": 1598944,+ "scriptRawBytes": 1599292,"scriptRequestCount": 32,- "totalRawBytes": 1759346+ "totalRawBytes": 1759936},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 36,- "scriptRawBytes": 1614934,+ "scriptRawBytes": 1615285,"scriptRequestCount": 32,- "totalRawBytes": 1776940+ "totalRawBytes": 1777536},- "routeReadyMedianMs": 313.80000000447035,+ "routeReadyMedianMs": 211.90000009536743,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "representative"},@@ -141,13 +141,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 133.69999999552965,+ "domContentLoadedMedianMs": 108,"id": "editor-minimal","layoutSwitchMedianMs": 0,- "loadMedianMs": 133.69999999552965,- "longestTaskMaxMs": 115,+ "loadMedianMs": 108,+ "longestTaskMaxMs": 75,"owner": "workbench",- "projectSwitchMedianMs": 41.29999999701977,+ "projectSwitchMedianMs": 29.09999990463257,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -155,24 +155,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 110,- "scriptRawBytes": 3317108,+ "scriptRawBytes": 3322352,"scriptRequestCount": 104,- "totalRawBytes": 3649299+ "totalRawBytes": 3654785},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 110,- "scriptRawBytes": 3350280,+ "scriptRawBytes": 3355576,"scriptRequestCount": 104,- "totalRawBytes": 3685792+ "totalRawBytes": 3691333},- "routeReadyMedianMs": 718.3000000044703,+ "routeReadyMedianMs": 589.8000001907349,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -199,13 +199,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 131.80000000447035,+ "domContentLoadedMedianMs": 92.90000009536743,"id": "editor-minimal","layoutSwitchMedianMs": 0,- "loadMedianMs": 131.80000000447035,- "longestTaskMaxMs": 126,+ "loadMedianMs": 92.90000009536743,+ "longestTaskMaxMs": 72,"owner": "workbench",- "projectSwitchMedianMs": 65.80000000447035,+ "projectSwitchMedianMs": 49,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -213,24 +213,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 110,- "scriptRawBytes": 3317108,+ "scriptRawBytes": 3322352,"scriptRequestCount": 104,- "totalRawBytes": 3649299+ "totalRawBytes": 3654785},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 110,- "scriptRawBytes": 3350280,+ "scriptRawBytes": 3355576,"scriptRequestCount": 104,- "totalRawBytes": 3685792+ "totalRawBytes": 3691333},- "routeReadyMedianMs": 836,+ "routeReadyMedianMs": 591.9000000953674,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -239,29 +239,29 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 135468,+ "largestAssetRawBytes": 135469,"otherRawBytes": 0,"requestCount": 5,- "scriptRawBytes": 283749,+ "scriptRawBytes": 283729,"scriptRequestCount": 5,- "totalRawBytes": 283749+ "totalRawBytes": 283729},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 136823,+ "largestAssetRawBytes": 136824,"otherRawBytes": 0,"requestCount": 5,- "scriptRawBytes": 286587,+ "scriptRawBytes": 286567,"scriptRequestCount": 5,- "totalRawBytes": 286587+ "totalRawBytes": 286567},- "domContentLoadedMedianMs": 135.39999999850988,+ "domContentLoadedMedianMs": 91.80000019073486,"id": "editor-canvas",- "layoutSwitchMedianMs": 86.5,- "loadMedianMs": 135.39999999850988,- "longestTaskMaxMs": 111,+ "layoutSwitchMedianMs": 54.299999713897705,+ "loadMedianMs": 91.80000019073486,+ "longestTaskMaxMs": 73,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -271,24 +271,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 115,- "scriptRawBytes": 3600857,+ "scriptRawBytes": 3606081,"scriptRequestCount": 109,- "totalRawBytes": 3933048+ "totalRawBytes": 3938514},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 115,- "scriptRawBytes": 3636866,+ "scriptRawBytes": 3642142,"scriptRequestCount": 109,- "totalRawBytes": 3972379+ "totalRawBytes": 3977900},- "routeReadyMedianMs": 1201.8000000044703,+ "routeReadyMedianMs": 998.0999999046326,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "empty"},@@ -297,29 +297,29 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 135468,+ "largestAssetRawBytes": 135469,"otherRawBytes": 0,"requestCount": 5,- "scriptRawBytes": 283749,+ "scriptRawBytes": 283729,"scriptRequestCount": 5,- "totalRawBytes": 283749+ "totalRawBytes": 283729},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 136823,+ "largestAssetRawBytes": 136824,"otherRawBytes": 0,"requestCount": 5,- "scriptRawBytes": 286587,+ "scriptRawBytes": 286567,"scriptRequestCount": 5,- "totalRawBytes": 286587+ "totalRawBytes": 286567},- "domContentLoadedMedianMs": 133.60000000149012,+ "domContentLoadedMedianMs": 89.7000002861023,"id": "editor-canvas",- "layoutSwitchMedianMs": 221.69999999552965,- "loadMedianMs": 133.60000000149012,- "longestTaskMaxMs": 445,+ "layoutSwitchMedianMs": 138.09999990463257,+ "loadMedianMs": 89.7000002861023,+ "longestTaskMaxMs": 263,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -329,24 +329,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 115,- "scriptRawBytes": 3600857,+ "scriptRawBytes": 3606081,"scriptRequestCount": 109,- "totalRawBytes": 3933048+ "totalRawBytes": 3938514},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 115,- "scriptRawBytes": 3636866,+ "scriptRawBytes": 3642142,"scriptRequestCount": 109,- "totalRawBytes": 3972379+ "totalRawBytes": 3977900},- "routeReadyMedianMs": 1421.8999999985099,+ "routeReadyMedianMs": 1105.5999999046326,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "representative"},@@ -373,11 +373,11 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 131.20000000298023,+ "domContentLoadedMedianMs": 97.80000019073486,"id": "editor-workflow",- "layoutSwitchMedianMs": 79.10000000149012,- "loadMedianMs": 131.20000000298023,- "longestTaskMaxMs": 113,+ "layoutSwitchMedianMs": 52.10000038146973,+ "loadMedianMs": 97.80000019073486,+ "longestTaskMaxMs": 77,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -387,24 +387,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 110,- "scriptRawBytes": 3317108,+ "scriptRawBytes": 3322352,"scriptRequestCount": 104,- "totalRawBytes": 3649299+ "totalRawBytes": 3654785},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 110,- "scriptRawBytes": 3350280,+ "scriptRawBytes": 3355576,"scriptRequestCount": 104,- "totalRawBytes": 3685792+ "totalRawBytes": 3691333},- "routeReadyMedianMs": 1196.2000000029802,+ "routeReadyMedianMs": 996.0999999046326,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -431,11 +431,11 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 141.59999999403954,+ "domContentLoadedMedianMs": 90.40000009536743,"id": "editor-workflow",- "layoutSwitchMedianMs": 139.89999999850988,- "loadMedianMs": 141.59999999403954,- "longestTaskMaxMs": 517,+ "layoutSwitchMedianMs": 81,+ "loadMedianMs": 90.40000009536743,+ "longestTaskMaxMs": 255,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -445,24 +445,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 110,- "scriptRawBytes": 3317108,+ "scriptRawBytes": 3322352,"scriptRequestCount": 104,- "totalRawBytes": 3649299+ "totalRawBytes": 3654785},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 110,- "scriptRawBytes": 3350280,+ "scriptRawBytes": 3355576,"scriptRequestCount": 104,- "totalRawBytes": 3685792+ "totalRawBytes": 3691333},- "routeReadyMedianMs": 1338.6999999955297,+ "routeReadyMedianMs": 1049.5,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -489,11 +489,11 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 137.39999999850988,+ "domContentLoadedMedianMs": 95.90000009536743,"id": "editor-gallery",- "layoutSwitchMedianMs": 34.899999998509884,- "loadMedianMs": 137.39999999850988,- "longestTaskMaxMs": 113,+ "layoutSwitchMedianMs": 28.200000286102295,+ "loadMedianMs": 95.90000009536743,+ "longestTaskMaxMs": 73,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -503,24 +503,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 110,- "scriptRawBytes": 3317108,+ "scriptRawBytes": 3322352,"scriptRequestCount": 104,- "totalRawBytes": 3649299+ "totalRawBytes": 3654785},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 110,- "scriptRawBytes": 3350280,+ "scriptRawBytes": 3355576,"scriptRequestCount": 104,- "totalRawBytes": 3685792+ "totalRawBytes": 3691333},- "routeReadyMedianMs": 1455.5,+ "routeReadyMedianMs": 1242.0999999046326,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -547,11 +547,11 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 142.09999999403954,+ "domContentLoadedMedianMs": 86.7999997138977,"id": "editor-gallery",- "layoutSwitchMedianMs": 113.39999999850988,- "loadMedianMs": 142.09999999403954,- "longestTaskMaxMs": 172,+ "layoutSwitchMedianMs": 66.09999990463257,+ "loadMedianMs": 86.7999997138977,+ "longestTaskMaxMs": 100,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -561,24 +561,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746314,- "otherRawBytes": 134579,+ "otherRawBytes": 134821,"requestCount": 110,- "scriptRawBytes": 3317108,+ "scriptRawBytes": 3322352,"scriptRequestCount": 104,- "totalRawBytes": 3649299+ "totalRawBytes": 3654785},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753778,- "otherRawBytes": 135925,+ "otherRawBytes": 136170,"requestCount": 110,- "scriptRawBytes": 3350280,+ "scriptRawBytes": 3355576,"scriptRequestCount": 104,- "totalRawBytes": 3685792+ "totalRawBytes": 3691333},- "routeReadyMedianMs": 1627.7999999970198,+ "routeReadyMedianMs": 1317.5,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"}@@ -1769,6 +1769,7 @@"source:src/workbench/widgets/diagnostics/manifest.ts","source:src/workbench/widgets/gallery/manifest.ts","source:src/workbench/widgets/generate/manifest.ts",+ "source:src/workbench/widgets/image-map/manifest.ts","source:src/workbench/widgets/layers/controlModelOptions.ts","source:src/workbench/widgets/layers/layerOps.ts","source:src/workbench/widgets/layers/manifest.ts",@@ -2756,6 +2757,7 @@"source:src/workbench/widgets/diagnostics/manifest.ts","source:src/workbench/widgets/gallery/manifest.ts","source:src/workbench/widgets/generate/manifest.ts",+ "source:src/workbench/widgets/image-map/manifest.ts","source:src/workbench/widgets/layers/AdjustmentsPopover.tsx","source:src/workbench/widgets/layers/ControlLayerSettings.tsx","source:src/workbench/widgets/layers/ControlLayerWarningIcon.tsx",diff --git a/invokeai/frontend/webv2/src/workbench/image-map/imageMap.test.ts b/invokeai/frontend/webv2/src/workbench/image-map/imageMap.test.tsindex 3f03ae50ba..afbc997dd5 100644--- a/invokeai/frontend/webv2/src/workbench/image-map/imageMap.test.ts+++ b/invokeai/frontend/webv2/src/workbench/image-map/imageMap.test.ts@@ -82,7 +82,7 @@ describe('image map api', () => {describe('image map store', () => {beforeEach(() => {mocks.apiFetchJson.mockReset();- imageMapStore.setSnapshot({ data: null, error: null, loadState: 'idle' });+ imageMapStore.setSnapshot({ data: null, error: null, loadState: 'idle', renderError: null });});it('loads points into the snapshot', async () => {@@ -162,3 +162,58 @@ describe('trace builders', () => {expect(layout.yaxis?.showticklabels).toBe(false);});});++describe('map layout stability', () => {+ it('pins uirevision to a constant so pan/zoom survives a data refresh', () => {+ // The whole point of uirevision is that plotly keeps the user's viewport+ // when the traces change. A value derived from the data (a point count, a+ // hash, a timestamp) would compare unequal on every refresh and silently+ // reset the view — which looks identical to "it works" in a static test.+ const first = buildMapLayout();+ const second = buildMapLayout();++ expect(first.uirevision).toBeTruthy();+ expect(first.uirevision).toBe(second.uirevision);+ expect(typeof first.uirevision).toBe('string');+ });+});++describe('snapshot transitions', () => {+ it('clears a previous error once a refresh succeeds', async () => {+ // Asserting `error === null` after a success is vacuous when the fixture+ // starts at null; seed a real error first so the clearing is what is tested.+ imageMapStore.setSnapshot({+ data: null,+ error: 'boom',+ loadState: 'error',+ renderError: null,+ });+ mocks.apiFetchJson.mockResolvedValueOnce({+ cluster_eps: null,+ model_name: null,+ point_count: 0,+ points: [],+ stale: false,+ state: 'ready',+ updated_at: null,+ });++ await refreshImageMapPoints();++ expect(imageMapStore.getSnapshot().error).toBeNull();+ expect(imageMapStore.getSnapshot().loadState).toBe('loaded');+ });++ it('clears a render failure on a successful refresh so the plot can retry', () => {+ // Without this the WebGL error is permanent for the session: the view stops+ // mounting the plot, and nothing else ever resets renderError.+ imageMapStore.setSnapshot({+ data: null,+ error: null,+ loadState: 'loaded',+ renderError: 'The map failed to render (WebGL unavailable).',+ });++ expect(imageMapStore.getSnapshot().renderError).not.toBeNull();+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/image-map/imageMapStore.ts b/invokeai/frontend/webv2/src/workbench/image-map/imageMapStore.tsindex d1f492d1a1..0e3aef6b7d 100644--- a/invokeai/frontend/webv2/src/workbench/image-map/imageMapStore.ts+++ b/invokeai/frontend/webv2/src/workbench/image-map/imageMapStore.ts@@ -20,12 +20,20 @@ export interface ImageMapSnapshot {data: ImageMapPoints | null;loadState: 'idle' | 'loading' | 'loaded' | 'error';error: string | null;+ /**+ * The plot canvas itself failed (WebGL unavailable). Distinct from `error`,+ * which means a fetch failed: with `error` the cached points are still worth+ * showing, whereas here there is nothing that can draw them, so the view must+ * stop mounting the plot and say so.+ */+ renderError: string | null;}const EMPTY_IMAGE_MAP_SNAPSHOT: ImageMapSnapshot = {data: null,error: null,loadState: 'idle',+ renderError: null,};export const imageMapStore = createExternalStore<ImageMapSnapshot>(EMPTY_IMAGE_MAP_SNAPSHOT);@@ -59,7 +67,10 @@ export const refreshImageMapPoints = (): Promise<void> => {return;}- imageMapStore.patchSnapshot({ data, error: null, loadState: 'loaded' });+ // renderError is cleared too: a retry is the user's way out of a+ // transient WebGL failure, so a fresh point set must get a fresh attempt+ // at drawing rather than staying stuck on the previous canvas failure.+ imageMapStore.patchSnapshot({ data, error: null, loadState: 'loaded', renderError: null });}).catch((error: unknown) => {if (!isAccountScopeCurrent(owner)) {diff --git a/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapPlot.tsx b/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapPlot.tsxindex f17b3e5ce5..dffbc3cdac 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapPlot.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapPlot.tsx@@ -50,10 +50,19 @@ const ImageMapPlot = () => {});}).catch(() => {- // WebGL context creation can fail (blocked GPU, context exhaustion);- // an unhandled rejection would bypass the widget failure boundary, so- // surface it through the store's error state instead.- imageMapStore.patchSnapshot({ error: 'The map failed to render (WebGL unavailable).', loadState: 'error' });+ if (disposed) {+ // Symmetry with the .then above: a rejection arriving after unmount+ // must not write a global error on behalf of a dead component.+ return;+ }++ // WebGL context creation can fail (blocked GPU, context exhaustion).+ // Reported as renderError, not the generic error: the data is fine, it+ // is the canvas that is not, so the view has to stop trying to render+ // the plot. Signalling this through `error`/`loadState` alone did+ // nothing, because the view prefers a non-empty point set over any+ // error and would just mount this same failing plot again.+ imageMapStore.patchSnapshot({ renderError: 'The map failed to render (WebGL unavailable).' });});return () => {diff --git a/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapWidgetView.tsxindex 82128d9641..951addc170 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/ImageMapWidgetView.tsx@@ -18,12 +18,26 @@ const handleRefresh = () => {* selects that image in the gallery (and so in Preview).*/export const ImageMapWidgetView = (_props: WidgetViewProps) => {- const { data, error, loadState } = imageMapStore.useSnapshot();+ const { data, error, loadState, renderError } = imageMapStore.useSnapshot();useEffect(() => {ensureImageMapLoaded();}, []);+ // Checked before the plot: this is the canvas failing, not a fetch, so+ // re-mounting the plot would just fail again and render an empty box with no+ // way out. A successful refresh clears it and lets the plot retry.+ if (renderError) {+ return (+ <CenteredMessage+ actionLabel="Retry"+ detail={renderError}+ onAction={handleRefresh}+ title="Image map unavailable"+ />+ );+ }+// 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) {@@ -38,7 +52,7 @@ export const ImageMapWidgetView = (_props: WidgetViewProps) => {);}- if (loadState === 'error') {+ if (loadState === 'error' && !data) {return (<CenteredMessageactionLabel="Retry"@@ -85,6 +99,17 @@ export const ImageMapWidgetView = (_props: WidgetViewProps) => {);}+ if (loadState === 'error') {+ return (+ <CenteredMessage+ actionLabel="Retry"+ detail={error ?? 'Failed to load the image map.'}+ onAction={handleRefresh}+ title="Image map unavailable"+ />+ );+ }+return (<CenteredMessagedetail="Generate or import images and they will appear here, clustered by visual similarity."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.tsxnew file mode 100644index 0000000000..27bb8e9bfe--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.browser.test.tsx@@ -0,0 +1,146 @@+import { act, useEffect } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, describe, expect, it, vi } from 'vitest';++const mocks = vi.hoisted(() => ({+ resolveMany: vi.fn(),+ selectItem: vi.fn(),+}));++vi.mock('@features/gallery', () => ({+ galleryImages: { resolveMany: mocks.resolveMany },+ legacyGeneratedImageToGalleryItem: (image: { image_name: string }) => image,+}));++vi.mock('@workbench/WorkbenchContext', () => ({+ useWorkbenchCommands: () => ({ gallery: { selectItem: mocks.selectItem } }),+}));++import { useSelectMapImage } from './useSelectMapImage';++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++let host: HTMLDivElement | null = null;+let root: Root | null = null;++/** Published from an effect, not during render, so the probe stays render-pure. */+const handle: { click: ((imageName: string) => void) | null } = { click: null };++const Probe = () => {+ const select = useSelectMapImage();++ useEffect(() => {+ handle.click = select;+ }, [select]);++ return null;+};++/** Runs `fn` inside act and drains the microtask queue so promise callbacks land. */+const flush = async (fn: () => void = () => {}) => {+ await act(async () => {+ fn();+ await Promise.resolve();+ });+};++const mount = async () => {+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);+ await flush(() => root?.render(<Probe />));+};++const unmount = async () => {+ await flush(() => root?.unmount());+ host?.remove();+ root = null;+ host = null;+ handle.click = null;+};++/** A promise plus the trigger that settles it, so click ordering can be forced. */+const deferred = <T,>() => {+ let resolve!: (value: T) => void;+ const promise = new Promise<T>((r) => {+ resolve = r;+ });++ return { promise, resolve };+};++afterEach(async () => {+ if (root) {+ await unmount();+ }+ mocks.resolveMany.mockReset();+ mocks.selectItem.mockReset();+});++describe('useSelectMapImage', () => {+ it('dispatches the selection for a click', async () => {+ mocks.resolveMany.mockResolvedValue([{ image_name: 'a.png' }]);+ await mount();++ await flush(() => handle.click?.('a.png'));++ expect(mocks.selectItem).toHaveBeenCalledTimes(1);+ expect(mocks.selectItem.mock.calls[0]?.[0]).toEqual({ image_name: 'a.png' });+ });++ it('ignores a slow click that resolves after a newer one', async () => {+ const slow = deferred<{ image_name: string }[]>();+ const fast = deferred<{ image_name: string }[]>();++ mocks.resolveMany.mockReturnValueOnce(slow.promise).mockReturnValueOnce(fast.promise);+ await mount();++ await flush(() => {+ handle.click?.('slow.png');+ handle.click?.('fast.png');+ });++ await flush(() => {+ fast.resolve([{ image_name: 'fast.png' }]);+ slow.resolve([{ image_name: 'slow.png' }]);+ });++ // Only the most recent click may win, regardless of resolution order.+ expect(mocks.selectItem.mock.calls.map((call) => call[0].image_name)).toEqual(['fast.png']);+ });++ it('ignores a click left in flight across an unmount/remount', async () => {+ // The regression this guards: a per-mount counter is reset by the remount,+ // so the abandoned click compares against a dead counter, passes, and+ // overwrites the newer mount's selection. Reachable by switching the right+ // panel away from the map and back while a hydrate is in flight.+ const stale = deferred<{ image_name: string }[]>();+ const fresh = deferred<{ image_name: string }[]>();++ mocks.resolveMany.mockReturnValueOnce(stale.promise).mockReturnValueOnce(fresh.promise);++ await mount();+ await flush(() => handle.click?.('stale.png'));+ await unmount();++ await mount();+ await flush(() => handle.click?.('fresh.png'));++ await flush(() => {+ fresh.resolve([{ image_name: 'fresh.png' }]);+ stale.resolve([{ image_name: 'stale.png' }]);+ });++ expect(mocks.selectItem.mock.calls.map((call) => call[0].image_name)).toEqual(['fresh.png']);+ });++ it('leaves the selection alone when hydrate fails or the image is gone', async () => {+ mocks.resolveMany.mockRejectedValueOnce(new Error('deleted')).mockResolvedValueOnce([]);+ await mount();++ await flush(() => handle.click?.('gone.png'));+ await flush(() => handle.click?.('missing.png'));++ expect(mocks.selectItem).not.toHaveBeenCalled();+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.ts b/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.tsindex 93613782c5..f715aa3532 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/useSelectMapImage.ts@@ -1,6 +1,15 @@import { galleryImages, legacyGeneratedImageToGalleryItem } from '@features/gallery';import { useWorkbenchCommands } from '@workbench/WorkbenchContext';-import { useCallback, useRef } from 'react';+import { useCallback } from 'react';++/**+ * Module-scoped, deliberately: the thing being guarded — the gallery selection —+ * is global, so the counter has to be too. A `useRef` is per-mount, which leaves+ * a hole whenever the widget unmounts with a hydrate in flight (switching the+ * right-panel tab away and back): the abandoned closure compares against its own+ * dead ref, still passes, and overwrites the newer mount's selection.+ */+let selectionSequence = 0;/*** Turns a map point's image name into the current gallery selection. The map@@ -13,18 +22,17 @@ import { useCallback, useRef } from 'react';*/export const useSelectMapImage = (): ((imageName: string) => void) => {const commands = useWorkbenchCommands();- const sequenceRef = useRef(0);return useCallback((imageName: string) => {- const sequence = ++sequenceRef.current;+ const sequence = ++selectionSequence;galleryImages.resolveMany([imageName]).then((images) => {const image = images.at(0);- if (!image || sequence !== sequenceRef.current) {+ if (!image || sequence !== selectionSequence) {return;}