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.

Merge remote-tracking branch 'origin/main' into feat/biggg-canvas-enhancements

Josh Corbettcdf0f1b1b306
diff --cc invokeai/frontend/webv2/performance/architecture-baseline.json
index 8c784704fc,28e86a7384..9a94e00019
--- a/invokeai/frontend/webv2/performance/architecture-baseline.json
+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json
@@@ -2,17 -2,17 +2,17 @@@
"build": {
"launchpad": {
"baseline": {
- "brotliBytes": 841899,
- "brotliBytes": 837716,
++ "brotliBytes": 842332,
"cssRawBytes": 2159,
"fontRawBytes": 219480,
- "gzipBytes": 840891,
- "gzipBytes": 836624,
++ "gzipBytes": 841167,
"imageRawBytes": 156376,
- "initialRawBytes": 1960354,
- "largestAssetRawBytes": 746376,
- "initialRawBytes": 1948152,
- "largestAssetRawBytes": 746355,
++ "initialRawBytes": 1961176,
++ "largestAssetRawBytes": 746400,
"otherAssetRawBytes": 0,
- "ownedRawBytes": 70904,
- "ownedRawBytes": 69169,
- "requestCount": 41,
- "scriptRequestCount": 25,
++ "ownedRawBytes": 70960,
+ "requestCount": 42,
+ "scriptRequestCount": 26,
"sourceOwners": [
"package:@ark-ui/react",
"package:@chakra-ui/react",
@@@ -291,17 -287,17 +291,17 @@@
]
},
"limits": {
- "brotliBytes": 850318,
- "brotliBytes": 846094,
++ "brotliBytes": 850756,
"cssRawBytes": 2181,
"fontRawBytes": 221675,
- "gzipBytes": 849300,
- "gzipBytes": 844991,
++ "gzipBytes": 849579,
"imageRawBytes": 157940,
- "initialRawBytes": 1979958,
- "largestAssetRawBytes": 753840,
- "initialRawBytes": 1967634,
- "largestAssetRawBytes": 753819,
++ "initialRawBytes": 1980788,
++ "largestAssetRawBytes": 753864,
"otherAssetRawBytes": 0,
- "ownedRawBytes": 70904,
- "ownedRawBytes": 69169,
- "requestCount": 41,
- "scriptRequestCount": 25
++ "ownedRawBytes": 70960,
+ "requestCount": 42,
+ "scriptRequestCount": 26
},
"owner": "app",
"remediationTicket": "set-performance-budgets",
@@@ -309,17 -305,17 +309,17 @@@
},
"editor": {
"baseline": {
- "brotliBytes": 1104007,
- "brotliBytes": 1057991,
++ "brotliBytes": 1111234,
"cssRawBytes": 2159,
"fontRawBytes": 219480,
- "gzipBytes": 1099574,
- "gzipBytes": 1053293,
++ "gzipBytes": 1106583,
"imageRawBytes": 156376,
- "initialRawBytes": 2755775,
- "largestAssetRawBytes": 746376,
- "initialRawBytes": 2603620,
- "largestAssetRawBytes": 746355,
++ "initialRawBytes": 2776741,
++ "largestAssetRawBytes": 746400,
"otherAssetRawBytes": 0,
- "ownedRawBytes": 114628,
- "requestCount": 97,
- "scriptRequestCount": 81,
- "ownedRawBytes": 113925,
- "requestCount": 96,
- "scriptRequestCount": 80,
++ "ownedRawBytes": 114915,
++ "requestCount": 98,
++ "scriptRequestCount": 82,
"sourceOwners": [
"package:@ark-ui/react",
"package:@chakra-ui/react",
@@@ -835,10 -768,9 +835,11 @@@
"source:src/workbench/projects/syncedPersistence.ts",
"source:src/workbench/projects/useProjectActions.ts",
"source:src/workbench/projects/useProjectFileActions.ts",
+ "source:src/workbench/queue-integration/QueueProgressRail.tsx",
"source:src/workbench/queue-integration/useActiveQueueProgress.ts",
"source:src/workbench/queueHistoryNormalization.ts",
+ "source:src/workbench/refusedProjectStorage.ts",
+ "source:src/workbench/settings/SettingsButton.tsx",
"source:src/workbench/settings/SettingsDialogHost.tsx",
"source:src/workbench/settings/settingsDialogStore.ts",
"source:src/workbench/settings/store.ts",
@@@ -934,17 -866,17 +936,17 @@@
]
},
"limits": {
- "brotliBytes": 1115048,
- "brotliBytes": 1068571,
++ "brotliBytes": 1122347,
"cssRawBytes": 2181,
"fontRawBytes": 221675,
- "gzipBytes": 1110570,
- "gzipBytes": 1063826,
++ "gzipBytes": 1117649,
"imageRawBytes": 157940,
- "initialRawBytes": 2783333,
- "largestAssetRawBytes": 753840,
- "initialRawBytes": 2629657,
- "largestAssetRawBytes": 753819,
++ "initialRawBytes": 2804509,
++ "largestAssetRawBytes": 753864,
"otherAssetRawBytes": 0,
- "ownedRawBytes": 114628,
- "requestCount": 97,
- "scriptRequestCount": 81
- "ownedRawBytes": 113925,
- "requestCount": 96,
- "scriptRequestCount": 80
++ "ownedRawBytes": 114915,
++ "requestCount": 98,
++ "scriptRequestCount": 82
},
"owner": "workbench",
"remediationTicket": "deepen-widget-registry-loading",
diff --cc invokeai/frontend/webv2/performance/browser-baseline.json
index 23946f7337,c67d329e3b..8c48ffed6f
--- a/invokeai/frontend/webv2/performance/browser-baseline.json
+++ b/invokeai/frontend/webv2/performance/browser-baseline.json
@@@ -25,13 -25,13 +25,13 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 122.59999999403954,
- "domContentLoadedMedianMs": 90.39999999850988,
++ "domContentLoadedMedianMs": 107.80000000004657,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 122.7999999821186,
- "longestTaskMaxMs": 76,
- "loadMedianMs": 90.5,
- "longestTaskMaxMs": 56,
++ "loadMedianMs": 107.90000000002328,
++ "longestTaskMaxMs": 66,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@@ -40,25 -40,25 +40,25 @@@
"cssRawBytes": 2159,
"fontRawBytes": 23664,
"imageRawBytes": 0,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 37,
- "scriptRawBytes": 1625511,
- "scriptRequestCount": 33,
- "totalRawBytes": 1803979
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
++ "otherRawBytes": 164949,
+ "requestCount": 38,
- "scriptRawBytes": 1636776,
++ "scriptRawBytes": 1638536,
+ "scriptRequestCount": 34,
- "totalRawBytes": 1825225
++ "totalRawBytes": 1829308
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 37,
- "scriptRawBytes": 1641767,
- "scriptRequestCount": 33,
- "totalRawBytes": 1822019
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
++ "otherRawBytes": 166599,
+ "requestCount": 38,
- "scriptRawBytes": 1653144,
++ "scriptRawBytes": 1654922,
+ "scriptRequestCount": 34,
- "totalRawBytes": 1843478
++ "totalRawBytes": 1847602
},
- "routeReadyMedianMs": 269.69999998807907,
- "routeReadyMedianMs": 209.60000000149012,
++ "routeReadyMedianMs": 243.59999999997672,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@@ -85,13 -85,13 +85,13 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 136.7000000178814,
- "domContentLoadedMedianMs": 94.09999999776483,
++ "domContentLoadedMedianMs": 108.19999999995343,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 136.80000001192093,
- "longestTaskMaxMs": 83,
- "loadMedianMs": 94.09999999776483,
- "longestTaskMaxMs": 56,
++ "loadMedianMs": 108.29999999993015,
++ "longestTaskMaxMs": 67,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@@ -100,25 -100,25 +100,25 @@@
"cssRawBytes": 2159,
"fontRawBytes": 23664,
"imageRawBytes": 0,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 37,
- "scriptRawBytes": 1625511,
- "scriptRequestCount": 33,
- "totalRawBytes": 1803979
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
++ "otherRawBytes": 164949,
+ "requestCount": 38,
- "scriptRawBytes": 1636776,
++ "scriptRawBytes": 1638536,
+ "scriptRequestCount": 34,
- "totalRawBytes": 1825225
++ "totalRawBytes": 1829308
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 37,
- "scriptRawBytes": 1641767,
- "scriptRequestCount": 33,
- "totalRawBytes": 1822019
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
++ "otherRawBytes": 166599,
+ "requestCount": 38,
- "scriptRawBytes": 1653144,
++ "scriptRawBytes": 1654922,
+ "scriptRequestCount": 34,
- "totalRawBytes": 1843478
++ "totalRawBytes": 1847602
},
- "routeReadyMedianMs": 326,
- "routeReadyMedianMs": 223.19999999925494,
++ "routeReadyMedianMs": 257.5,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@@ -145,40 -145,40 +145,40 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 134.2000000178814,
- "domContentLoadedMedianMs": 93.10000000149012,
++ "domContentLoadedMedianMs": 109.69999999995343,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 134.40000000596046,
- "longestTaskMaxMs": 114,
- "loadMedianMs": 93.30000000074506,
- "longestTaskMaxMs": 79,
++ "loadMedianMs": 109.80000000004657,
++ "longestTaskMaxMs": 90,
"owner": "workbench",
- "projectSwitchMedianMs": 44.900000005960464,
- "projectSwitchMedianMs": 27.600000001490116,
++ "projectSwitchMedianMs": 33.199999999953434,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
"cssRawBytes": 2159,
"fontRawBytes": 23664,
"imageRawBytes": 156376,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 115,
- "scriptRawBytes": 3207341,
- "scriptRequestCount": 110,
- "totalRawBytes": 3542185
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
- "requestCount": 115,
- "scriptRawBytes": 3288069,
- "scriptRequestCount": 110,
- "totalRawBytes": 3632894
++ "otherRawBytes": 164949,
++ "requestCount": 116,
++ "scriptRawBytes": 3320473,
++ "scriptRequestCount": 111,
++ "totalRawBytes": 3667621
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 115,
- "scriptRawBytes": 3239415,
- "scriptRequestCount": 110,
- "totalRawBytes": 3577607
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
- "requestCount": 115,
- "scriptRawBytes": 3320950,
- "scriptRequestCount": 110,
- "totalRawBytes": 3669223
++ "otherRawBytes": 166599,
++ "requestCount": 116,
++ "scriptRawBytes": 3353678,
++ "scriptRequestCount": 111,
++ "totalRawBytes": 3704298
},
- "routeReadyMedianMs": 724.6999999880791,
- "routeReadyMedianMs": 590.6000000014901,
++ "routeReadyMedianMs": 642.0999999999767,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@@ -205,40 -205,40 +205,40 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 128.30000001192093,
- "domContentLoadedMedianMs": 91.69999999925494,
++ "domContentLoadedMedianMs": 111.29999999993015,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 128.5,
- "longestTaskMaxMs": 225,
- "loadMedianMs": 91.69999999925494,
- "longestTaskMaxMs": 156,
++ "loadMedianMs": 111.39999999990687,
++ "longestTaskMaxMs": 157,
"owner": "workbench",
- "projectSwitchMedianMs": 86.09999999403954,
- "projectSwitchMedianMs": 46.30000000074506,
++ "projectSwitchMedianMs": 62.800000000046566,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
"cssRawBytes": 2159,
"fontRawBytes": 23664,
"imageRawBytes": 156376,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 115,
- "scriptRawBytes": 3207341,
- "scriptRequestCount": 110,
- "totalRawBytes": 3542185
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
- "requestCount": 115,
- "scriptRawBytes": 3288069,
- "scriptRequestCount": 110,
- "totalRawBytes": 3632894
++ "otherRawBytes": 164949,
++ "requestCount": 116,
++ "scriptRawBytes": 3320473,
++ "scriptRequestCount": 111,
++ "totalRawBytes": 3667621
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 115,
- "scriptRawBytes": 3239415,
- "scriptRequestCount": 110,
- "totalRawBytes": 3577607
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
- "requestCount": 115,
- "scriptRawBytes": 3320950,
- "scriptRequestCount": 110,
- "totalRawBytes": 3669223
++ "otherRawBytes": 166599,
++ "requestCount": 116,
++ "scriptRawBytes": 3353678,
++ "scriptRequestCount": 111,
++ "totalRawBytes": 3704298
},
- "routeReadyMedianMs": 508.09999999403954,
- "routeReadyMedianMs": 351.5,
++ "routeReadyMedianMs": 414,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@@ -247,31 -247,31 +247,31 @@@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 314995,
- "largestAssetRawBytes": 137669,
++ "largestAssetRawBytes": 315002,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 482406,
- "scriptRawBytes": 316007,
++ "scriptRawBytes": 482471,
"scriptRequestCount": 7,
- "totalRawBytes": 482406
- "totalRawBytes": 316007
++ "totalRawBytes": 482471
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 318145,
- "largestAssetRawBytes": 139046,
++ "largestAssetRawBytes": 318153,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 487231,
- "scriptRawBytes": 319168,
++ "scriptRawBytes": 487296,
"scriptRequestCount": 7,
- "totalRawBytes": 487231
- "totalRawBytes": 319168
++ "totalRawBytes": 487296
},
- "domContentLoadedMedianMs": 135.10000002384186,
- "domContentLoadedMedianMs": 91.59999999776483,
++ "domContentLoadedMedianMs": 110.10000000009313,
"id": "editor-canvas",
- "layoutAckMedianMs": 3.4000000059604645,
- "layoutReturnSwitchMedianMs": 64.09999999403954,
- "layoutSwitchMedianMs": 98,
- "loadMedianMs": 135.2000000178814,
- "longestTaskMaxMs": 158,
- "layoutAckMedianMs": 2.100000001490116,
- "layoutReturnSwitchMedianMs": 34.69999999925494,
- "layoutSwitchMedianMs": 66.30000000074506,
- "loadMedianMs": 91.59999999776483,
- "longestTaskMaxMs": 81,
++ "layoutAckMedianMs": 2.1000000000931323,
++ "layoutReturnSwitchMedianMs": 51.59999999997672,
++ "layoutSwitchMedianMs": 89.19999999995343,
++ "loadMedianMs": 110.10000000009313,
++ "longestTaskMaxMs": 118,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@@ -280,25 -280,25 +280,25 @@@
"cssRawBytes": 2159,
"fontRawBytes": 23664,
"imageRawBytes": 156376,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 122,
- "scriptRawBytes": 3523348,
- "scriptRequestCount": 117,
- "totalRawBytes": 3858192
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
- "requestCount": 122,
- "scriptRawBytes": 3770475,
- "scriptRequestCount": 117,
- "totalRawBytes": 4115300
++ "otherRawBytes": 164949,
++ "requestCount": 123,
++ "scriptRawBytes": 3802944,
++ "scriptRequestCount": 118,
++ "totalRawBytes": 4150092
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 122,
- "scriptRawBytes": 3558582,
- "scriptRequestCount": 117,
- "totalRawBytes": 3896774
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
- "requestCount": 122,
- "scriptRawBytes": 3808180,
- "scriptRequestCount": 117,
- "totalRawBytes": 4156453
++ "otherRawBytes": 166599,
++ "requestCount": 123,
++ "scriptRawBytes": 3840974,
++ "scriptRequestCount": 118,
++ "totalRawBytes": 4191593
},
- "routeReadyMedianMs": 1118.699999988079,
- "routeReadyMedianMs": 938.0999999977648,
++ "routeReadyMedianMs": 1016.7000000000698,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@@ -307,31 -307,31 +307,31 @@@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 314995,
- "largestAssetRawBytes": 137669,
++ "largestAssetRawBytes": 315002,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 482406,
- "scriptRawBytes": 316007,
++ "scriptRawBytes": 482471,
"scriptRequestCount": 7,
- "totalRawBytes": 482406
- "totalRawBytes": 316007
++ "totalRawBytes": 482471
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 318145,
- "largestAssetRawBytes": 139046,
++ "largestAssetRawBytes": 318153,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 487231,
- "scriptRawBytes": 319168,
++ "scriptRawBytes": 487296,
"scriptRequestCount": 7,
- "totalRawBytes": 487231
- "totalRawBytes": 319168
++ "totalRawBytes": 487296
},
- "domContentLoadedMedianMs": 133.5,
- "domContentLoadedMedianMs": 93.59999999776483,
++ "domContentLoadedMedianMs": 109.90000000002328,
"id": "editor-canvas",
- "layoutAckMedianMs": 3,
- "layoutReturnSwitchMedianMs": 49.900000005960464,
- "layoutSwitchMedianMs": 101.2000000178814,
- "loadMedianMs": 133.59999999403954,
- "longestTaskMaxMs": 229,
- "layoutAckMedianMs": 2.5,
- "layoutReturnSwitchMedianMs": 35,
- "layoutSwitchMedianMs": 149.59999999776483,
- "loadMedianMs": 93.69999999925494,
- "longestTaskMaxMs": 275,
++ "layoutAckMedianMs": 2.599999999976717,
++ "layoutReturnSwitchMedianMs": 48.300000000046566,
++ "layoutSwitchMedianMs": 86.29999999993015,
++ "loadMedianMs": 110.09999999997672,
++ "longestTaskMaxMs": 168,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@@ -340,25 -340,25 +340,25 @@@
"cssRawBytes": 2159,
"fontRawBytes": 23664,
"imageRawBytes": 156376,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 122,
- "scriptRawBytes": 3523348,
- "scriptRequestCount": 117,
- "totalRawBytes": 3858192
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
- "requestCount": 122,
- "scriptRawBytes": 3770475,
- "scriptRequestCount": 117,
- "totalRawBytes": 4115300
++ "otherRawBytes": 164949,
++ "requestCount": 123,
++ "scriptRawBytes": 3802944,
++ "scriptRequestCount": 118,
++ "totalRawBytes": 4150092
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 122,
- "scriptRawBytes": 3558582,
- "scriptRequestCount": 117,
- "totalRawBytes": 3896774
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
- "requestCount": 122,
- "scriptRawBytes": 3808180,
- "scriptRequestCount": 117,
- "totalRawBytes": 4156453
++ "otherRawBytes": 166599,
++ "requestCount": 123,
++ "scriptRawBytes": 3840974,
++ "scriptRequestCount": 118,
++ "totalRawBytes": 4191593
},
- "routeReadyMedianMs": 1314.300000011921,
- "routeReadyMedianMs": 1081.8999999985099,
++ "routeReadyMedianMs": 1101.3000000000466,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@@ -381,17 -381,17 +381,17 @@@
"largestAssetRawBytes": 175720,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 367833,
+ "scriptRawBytes": 367878,
"scriptRequestCount": 6,
- "totalRawBytes": 383401
+ "totalRawBytes": 383445
},
- "domContentLoadedMedianMs": 133.40000000596046,
- "domContentLoadedMedianMs": 89.10000000149012,
++ "domContentLoadedMedianMs": 110.59999999997672,
"id": "editor-workflow",
- "layoutAckMedianMs": 3.2999999821186066,
- "layoutReturnSwitchMedianMs": 36.5,
- "layoutSwitchMedianMs": 91.60000002384186,
- "loadMedianMs": 133.5,
- "longestTaskMaxMs": 126,
- "layoutAckMedianMs": 2,
- "layoutReturnSwitchMedianMs": 30.599999997764826,
- "layoutSwitchMedianMs": 78.10000000149012,
- "loadMedianMs": 89.19999999925494,
- "longestTaskMaxMs": 77,
++ "layoutAckMedianMs": 2.400000000023283,
++ "layoutReturnSwitchMedianMs": 31.400000000023283,
++ "layoutSwitchMedianMs": 86.09999999997672,
++ "loadMedianMs": 110.70000000006985,
++ "longestTaskMaxMs": 91,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@@ -400,25 -400,25 +400,25 @@@
"cssRawBytes": 17572,
"fontRawBytes": 23664,
"imageRawBytes": 156376,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 122,
- "scriptRawBytes": 3571532,
- "scriptRequestCount": 116,
- "totalRawBytes": 3921789
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
- "requestCount": 122,
- "scriptRawBytes": 3652304,
- "scriptRequestCount": 116,
- "totalRawBytes": 4012542
++ "otherRawBytes": 164949,
++ "requestCount": 123,
++ "scriptRawBytes": 3684708,
++ "scriptRequestCount": 117,
++ "totalRawBytes": 4047269
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 122,
- "scriptRawBytes": 3607248,
- "scriptRequestCount": 116,
- "totalRawBytes": 3961007
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
- "requestCount": 122,
- "scriptRawBytes": 3688828,
- "scriptRequestCount": 116,
- "totalRawBytes": 4052668
++ "otherRawBytes": 166599,
++ "requestCount": 123,
++ "scriptRawBytes": 3721556,
++ "scriptRequestCount": 117,
++ "totalRawBytes": 4087742
},
- "routeReadyMedianMs": 1111.5,
- "routeReadyMedianMs": 950.4000000022352,
++ "routeReadyMedianMs": 1004.7999999999302,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "empty"
},
@@@ -441,17 -441,17 +441,17 @@@
"largestAssetRawBytes": 175720,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 367833,
+ "scriptRawBytes": 367878,
"scriptRequestCount": 6,
- "totalRawBytes": 383401
+ "totalRawBytes": 383445
},
- "domContentLoadedMedianMs": 131.30000001192093,
- "domContentLoadedMedianMs": 91.29999999701977,
++ "domContentLoadedMedianMs": 110.19999999995343,
"id": "editor-workflow",
- "layoutAckMedianMs": 3.2999999821186066,
- "layoutReturnSwitchMedianMs": 45.19999998807907,
- "layoutSwitchMedianMs": 145.5,
- "loadMedianMs": 131.59999999403954,
- "longestTaskMaxMs": 422,
- "layoutAckMedianMs": 2.7000000029802322,
- "layoutReturnSwitchMedianMs": 36.5,
- "layoutSwitchMedianMs": 106.89999999850988,
- "loadMedianMs": 91.39999999850988,
- "longestTaskMaxMs": 259,
++ "layoutAckMedianMs": 2.3999999999068677,
++ "layoutReturnSwitchMedianMs": 37.800000000046566,
++ "layoutSwitchMedianMs": 121.5,
++ "loadMedianMs": 110.30000000004657,
++ "longestTaskMaxMs": 316,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@@ -460,25 -460,25 +460,25 @@@
"cssRawBytes": 17572,
"fontRawBytes": 23664,
"imageRawBytes": 156376,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 122,
- "scriptRawBytes": 3571532,
- "scriptRequestCount": 116,
- "totalRawBytes": 3921789
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
- "requestCount": 122,
- "scriptRawBytes": 3652304,
- "scriptRequestCount": 116,
- "totalRawBytes": 4012542
++ "otherRawBytes": 164949,
++ "requestCount": 123,
++ "scriptRawBytes": 3684708,
++ "scriptRequestCount": 117,
++ "totalRawBytes": 4047269
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 122,
- "scriptRawBytes": 3607248,
- "scriptRequestCount": 116,
- "totalRawBytes": 3961007
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
- "requestCount": 122,
- "scriptRawBytes": 3688828,
- "scriptRequestCount": 116,
- "totalRawBytes": 4052668
++ "otherRawBytes": 166599,
++ "requestCount": 123,
++ "scriptRawBytes": 3721556,
++ "scriptRequestCount": 117,
++ "totalRawBytes": 4087742
},
- "routeReadyMedianMs": 1370.199999988079,
- "routeReadyMedianMs": 1075.0999999977648,
++ "routeReadyMedianMs": 1132.5999999999767,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "representative"
},
@@@ -505,13 -505,13 +505,13 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 118.89999997615814,
- "domContentLoadedMedianMs": 92.80000000074506,
++ "domContentLoadedMedianMs": 108.90000000002328,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 30,
- "loadMedianMs": 119,
- "longestTaskMaxMs": 117,
- "layoutSwitchMedianMs": 20.800000000745058,
- "loadMedianMs": 93,
- "longestTaskMaxMs": 79,
++ "layoutSwitchMedianMs": 22.5,
++ "loadMedianMs": 109,
++ "longestTaskMaxMs": 91,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@@ -520,25 -520,25 +520,25 @@@
"cssRawBytes": 2159,
"fontRawBytes": 23664,
"imageRawBytes": 156376,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 115,
- "scriptRawBytes": 3207341,
- "scriptRequestCount": 110,
- "totalRawBytes": 3542185
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
- "requestCount": 115,
- "scriptRawBytes": 3288069,
- "scriptRequestCount": 110,
- "totalRawBytes": 3632894
++ "otherRawBytes": 164949,
++ "requestCount": 116,
++ "scriptRawBytes": 3320473,
++ "scriptRequestCount": 111,
++ "totalRawBytes": 3667621
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 115,
- "scriptRawBytes": 3239415,
- "scriptRequestCount": 110,
- "totalRawBytes": 3577607
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
- "requestCount": 115,
- "scriptRawBytes": 3320950,
- "scriptRequestCount": 110,
- "totalRawBytes": 3669223
++ "otherRawBytes": 166599,
++ "requestCount": 116,
++ "scriptRawBytes": 3353678,
++ "scriptRequestCount": 111,
++ "totalRawBytes": 3704298
},
- "routeReadyMedianMs": 1280,
- "routeReadyMedianMs": 1154.6000000014901,
++ "routeReadyMedianMs": 1218.5999999999767,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@@ -565,13 -565,13 +565,13 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 135.30000001192093,
- "domContentLoadedMedianMs": 92.10000000149012,
++ "domContentLoadedMedianMs": 108,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 106.7999999821186,
- "loadMedianMs": 135.40000000596046,
- "longestTaskMaxMs": 236,
- "layoutSwitchMedianMs": 66,
- "loadMedianMs": 92.20000000298023,
- "longestTaskMaxMs": 131,
++ "layoutSwitchMedianMs": 79.59999999997672,
++ "loadMedianMs": 108.10000000009313,
++ "longestTaskMaxMs": 159,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@@ -580,25 -580,25 +580,25 @@@
"cssRawBytes": 2159,
"fontRawBytes": 23664,
"imageRawBytes": 156376,
- "largestAssetRawBytes": 746355,
- "otherRawBytes": 152645,
- "requestCount": 115,
- "scriptRawBytes": 3207341,
- "scriptRequestCount": 110,
- "totalRawBytes": 3542185
+ "largestAssetRawBytes": 746400,
- "otherRawBytes": 162626,
- "requestCount": 115,
- "scriptRawBytes": 3288069,
- "scriptRequestCount": 110,
- "totalRawBytes": 3632894
++ "otherRawBytes": 164949,
++ "requestCount": 116,
++ "scriptRawBytes": 3320473,
++ "scriptRequestCount": 111,
++ "totalRawBytes": 3667621
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
- "largestAssetRawBytes": 753819,
- "otherRawBytes": 154172,
- "requestCount": 115,
- "scriptRawBytes": 3239415,
- "scriptRequestCount": 110,
- "totalRawBytes": 3577607
+ "largestAssetRawBytes": 753864,
- "otherRawBytes": 164253,
- "requestCount": 115,
- "scriptRawBytes": 3320950,
- "scriptRequestCount": 110,
- "totalRawBytes": 3669223
++ "otherRawBytes": 166599,
++ "requestCount": 116,
++ "scriptRawBytes": 3353678,
++ "scriptRequestCount": 111,
++ "totalRawBytes": 3704298
},
- "routeReadyMedianMs": 1642.4000000059605,
- "routeReadyMedianMs": 1312,
++ "routeReadyMedianMs": 1376,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
}
@@@ -1740,9 -1713,9 +1740,10 @@@
"source:src/workbench/projects/syncedPersistence.ts",
"source:src/workbench/projects/useProjectActions.ts",
"source:src/workbench/projects/useProjectFileActions.ts",
+ "source:src/workbench/queue-integration/QueueProgressRail.tsx",
"source:src/workbench/queue-integration/useActiveQueueProgress.ts",
"source:src/workbench/queueHistoryNormalization.ts",
+ "source:src/workbench/refusedProjectStorage.ts",
"source:src/workbench/settings/SettingsButton.tsx",
"source:src/workbench/settings/SettingsDialogHost.tsx",
"source:src/workbench/settings/settingsDialogStore.ts",
@@@ -2705,9 -2654,9 +2708,10 @@@
"source:src/workbench/projects/syncedPersistence.ts",
"source:src/workbench/projects/useProjectActions.ts",
"source:src/workbench/projects/useProjectFileActions.ts",
+ "source:src/workbench/queue-integration/QueueProgressRail.tsx",
"source:src/workbench/queue-integration/useActiveQueueProgress.ts",
"source:src/workbench/queueHistoryNormalization.ts",
+ "source:src/workbench/refusedProjectStorage.ts",
"source:src/workbench/settings/SettingsButton.tsx",
"source:src/workbench/settings/SettingsDialogHost.tsx",
"source:src/workbench/settings/settingsDialogStore.ts",
@@@ -3867,9 -3755,9 +3873,10 @@@
"source:src/workbench/projects/syncedPersistence.ts",
"source:src/workbench/projects/useProjectActions.ts",
"source:src/workbench/projects/useProjectFileActions.ts",
+ "source:src/workbench/queue-integration/QueueProgressRail.tsx",
"source:src/workbench/queue-integration/useActiveQueueProgress.ts",
"source:src/workbench/queueHistoryNormalization.ts",
+ "source:src/workbench/refusedProjectStorage.ts",
"source:src/workbench/settings/SettingsButton.tsx",
"source:src/workbench/settings/SettingsDialogHost.tsx",
"source:src/workbench/settings/settingsDialogStore.ts",
diff --cc invokeai/frontend/webv2/src/workbench/layoutPresets.test.ts
index f9b41d8bbc,af7bf06008..80fd7352d4
--- a/invokeai/frontend/webv2/src/workbench/layoutPresets.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/layoutPresets.test.ts
@@@ -114,9 -97,18 +122,19 @@@ describe('built-in layout preset descri
center: ['canvas', 'preview'],
left: ['generate', 'upscale', 'video'],
panels: { isBottomOpen: false, isLeftOpen: true, isRightOpen: true },
- right: ['layers', 'preview', 'gallery', 'image-map', 'queue'],
+ // The Edit rail is the Layers panel alone; its editors are panes inside it.
+ right: ['layers'],
},
+ video: {
+ active: { bottom: 'gallery:bottom', center: 'preview', left: 'video', right: 'gallery' },
+ bottom: ['server-status', 'queue-status', 'gallery:bottom', 'notifications', 'autosave-status'],
+ center: ['preview'],
+ // Video leads the rail; Generate and Upscale stay behind it so a still
+ // can be set up without leaving the arrangement.
+ left: ['video', 'generate', 'upscale'],
+ panels: { isBottomOpen: false, isLeftOpen: true, isRightOpen: true },
+ right: ['gallery', 'image-map', 'queue'],
+ },
});
});
});
diff --cc invokeai/frontend/webv2/src/workbench/persistence.test.ts
index d28f543975,36eab829cd..1bc0653ddb
--- a/invokeai/frontend/webv2/src/workbench/persistence.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/persistence.test.ts
@@@ -90,199 -73,201 +91,394 @@@ describe('workbench persistence migrati
expect(hydratePersistedWorkbenchSnapshot(persisted)?.state).toEqual(state);
});
+ it('gates every cached project before stripping transient state', () => {
+ const state = createInitialWorkbenchState();
+ const supported = state.projects[0]!;
+ const future = { ...supported, id: 'future', name: 'Future', canvas: { ...supported.canvas, version: 4 } };
+ const hydrated = hydratePersistedWorkbenchSnapshot({
+ savedAt: '2026-06-09T00:00:00.000Z',
+ state: { ...state, projects: [supported, future] },
+ version: 1,
+ });
+
+ expect(hydrated?.state.projects.map((project) => project.id)).toEqual([supported.id]);
+ expect(hydrated?.refusedProjects).toMatchObject([
+ { projectId: 'future', raw: future, refusal: { status: 'unsupported-version', version: 4 }, source: 'canvas' },
+ ]);
+ });
+
+ it('preserves a project with an invalid queued canvas verbatim in the recovery bucket', async () => {
+ const state = createInitialWorkbenchState();
+ const project = state.projects[0]!;
+ const invalid = {
+ ...project,
+ queue: {
+ items: [
+ {
+ id: 'invalid-queue-item',
+ snapshot: {
+ canvas: {
+ ...project.canvas,
+ document: { ...project.canvas.document, stacks: { raster: [{ id: 'unknown', type: 'future-layer' }] } },
+ },
+ },
+ },
+ ],
+ },
+ };
+
+ storage.set(
+ 'invokeai:v7:webv2:workbench',
+ JSON.stringify({ savedAt: '2026-06-09T00:00:00.000Z', state: { ...state, projects: [invalid] }, version: 1 })
+ );
+
+ const hydrated = await localStorageWorkbenchPersistence.loadWorkbench();
+ const refused = JSON.parse(storage.get('invokeai:v7:webv2:workbench:refused-projects')!) as Record<string, unknown>;
+
+ expect(hydrated?.state.projects).toEqual([]);
+ expect(hydrated?.refusedProjects).toMatchObject([
+ {
+ projectId: project.id,
+ queueItem: { index: 0, itemId: 'invalid-queue-item' },
+ refusal: { status: 'invalid' },
+ source: 'queue-item',
+ },
+ ]);
+ expect(refused[project.id]).toEqual(JSON.parse(JSON.stringify(invalid)));
+ });
+
+ it('repoints a refused active project at the first loadable one', () => {
+ const state = createInitialWorkbenchState();
+ const supported = state.projects[0]!;
+ const future = { ...supported, id: 'future', name: 'Future', canvas: { ...supported.canvas, version: 4 } };
+ const hydrated = hydratePersistedWorkbenchSnapshot({
+ savedAt: '2026-06-09T00:00:00.000Z',
+ state: { ...state, activeProjectId: 'future', projects: [supported, future] },
+ version: 1,
+ });
+
+ expect(hydrated?.state.activeProjectId).toBe(supported.id);
+ });
+
+ it('moves refused projects into a sibling bucket verbatim and forgets them on request', async () => {
+ const state = createInitialWorkbenchState();
+ const supported = state.projects[0]!;
+ const future = { ...supported, id: 'future', name: 'Future', canvas: { ...supported.canvas, version: 4 } };
+
+ storage.set(
+ 'invokeai:v7:webv2:workbench',
+ JSON.stringify({
+ savedAt: '2026-06-09T00:00:00.000Z',
+ state: { ...state, projects: [supported, future] },
+ version: 1,
+ })
+ );
+
+ const hydrated = await localStorageWorkbenchPersistence.loadWorkbench();
+ const cached = JSON.parse(storage.get('invokeai:v7:webv2:workbench')!) as { state: WorkbenchState };
+ const refused = JSON.parse(storage.get('invokeai:v7:webv2:workbench:refused-projects')!) as Record<string, unknown>;
+
+ expect(hydrated?.refusedProjects.map((project) => project.projectId)).toEqual(['future']);
+ expect(cached.state.projects.map((project) => project.id)).toEqual([supported.id]);
+ expect(refused.future).toEqual(JSON.parse(JSON.stringify(future)));
+
+ await localStorageWorkbenchPersistence.saveWorkbench({ ...state, projects: [supported] });
+ expect(storage.get('invokeai:v7:webv2:workbench:refused-projects')).toBeDefined();
+
+ await localStorageWorkbenchPersistence.forgetRefusedProject('future');
+ expect(storage.get('invokeai:v7:webv2:workbench:refused-projects')).toBeUndefined();
+ });
+
+ it('does not remove an unsupported project from the primary cache if recovery retention fails', async () => {
+ const state = createInitialWorkbenchState();
+ const supported = state.projects[0]!;
+ const future = { ...supported, id: 'future', name: 'Future', canvas: { ...supported.canvas, version: 4 } };
+ const storageKey = 'invokeai:v7:webv2:workbench';
+
+ storage.set(
+ storageKey,
+ JSON.stringify({
+ savedAt: '2026-06-09T00:00:00.000Z',
+ state: { ...state, projects: [supported, future] },
+ version: 1,
+ })
+ );
+ const setItem = vi.spyOn(window.localStorage, 'setItem').mockImplementation((key, value) => {
+ if (key.endsWith(':refused-projects')) {
+ throw new DOMException('quota', 'QuotaExceededError');
+ }
+ storage.set(key, value);
+ });
+
+ try {
+ await localStorageWorkbenchPersistence.loadWorkbench();
+ } finally {
+ setItem.mockRestore();
+ }
+
+ const cached = JSON.parse(storage.get(storageKey)!) as { state: WorkbenchState };
+
+ expect(cached.state.projects.map((project) => project.id)).toEqual([supported.id, future.id]);
+ expect(storage.has(`${storageKey}:refused-projects`)).toBe(false);
+ });
+
+ it('does not classify a failed primary-cache compaction as corrupt input', async () => {
+ const state = createInitialWorkbenchState();
+ const supported = state.projects[0]!;
+ const future = { ...supported, id: 'future', name: 'Future', canvas: { ...supported.canvas, version: 4 } };
+ const storageKey = 'invokeai:v7:webv2:workbench';
+
+ storage.set(
+ storageKey,
+ JSON.stringify({
+ savedAt: '2026-06-09T00:00:00.000Z',
+ state: { ...state, projects: [supported, future] },
+ version: 1,
+ })
+ );
+ const setItem = vi.spyOn(window.localStorage, 'setItem').mockImplementation((key, value) => {
+ if (key === storageKey) {
+ throw new DOMException('quota', 'QuotaExceededError');
+ }
+ storage.set(key, value);
+ });
+
+ let hydrated;
+
+ try {
+ hydrated = await localStorageWorkbenchPersistence.loadWorkbench();
+ } finally {
+ setItem.mockRestore();
+ }
+
+ const cached = JSON.parse(storage.get(storageKey)!) as { state: WorkbenchState };
+
+ expect(hydrated?.state.projects.map((project) => project.id)).toEqual([supported.id]);
+ expect(cached.state.projects.map((project) => project.id)).toEqual([supported.id, future.id]);
+ expect(storage.has(`${storageKey}:refused-projects`)).toBe(true);
+ });
+
+ it('does not let a metadata-only refusal erase an existing raw recovery document', async () => {
+ storage.set('invokeai:v7:webv2:workbench:refused-projects', '{"future":{"name":"Local work"}}');
+
+ await localStorageWorkbenchPersistence.retainRefusedProjects([
+ {
+ projectId: 'future',
+ projectName: 'Future',
+ raw: null,
+ refusal: { raw: null, scope: 'document', status: 'unsupported-version', version: 4 },
+ source: 'canvas',
+ },
+ ]);
+
+ expect(JSON.parse(storage.get('invokeai:v7:webv2:workbench:refused-projects')!)).toEqual({
+ future: { name: 'Local work' },
+ });
+ });
+
+ it('clears the refused bucket with the cache', async () => {
+ storage.set('invokeai:v7:webv2:workbench:refused-projects', '{"future":{}}');
+
+ await localStorageWorkbenchPersistence.clearWorkbench();
+
+ expect(storage.get('invokeai:v7:webv2:workbench:refused-projects')).toBeUndefined();
+ });
+
+ it('does not persist a search only this session can resolve, nor the page it left behind', async () => {
+ // The footer paginates the RANKING while a similarity search is on
+ // screen, so this page is a rank page. Cluster members live in an
+ // in-memory registry the next session cannot read, so the ranking is gone
+ // over there — and a rank page read as a board page lands the grid on an
+ // unrelated slice.
+ const state = createInitialWorkbenchState();
+ const project = state.projects[0];
+ const galleryEntry = Object.entries(project?.widgetInstances ?? {}).find(
+ ([, instance]) => instance.typeId === 'gallery'
+ );
+
+ expect(galleryEntry).toBeDefined();
+
+ const [galleryInstanceId, galleryInstance] = galleryEntry!;
+ const values = {
+ ...galleryInstance.state.values,
+ galleryPage: 3,
+ paginationMode: 'paginated',
+ selectedImagePage: 3,
+ selectedImageQuery: {
+ boardId: 'none',
+ galleryView: 'images',
+ imageOrderDir: 'DESC',
+ page: 3,
+ paginationMode: 'paginated',
+ searchTerm: '',
+ },
+ semanticImageQuery: { clusterId: 'cluster-1', kind: 'cluster', label: 'beaches' },
+ };
+ const snapshot = await localStorageWorkbenchPersistence.saveWorkbench({
+ ...state,
+ projects: [
+ {
+ ...project!,
+ widgetInstances: {
+ ...project!.widgetInstances,
+ [galleryInstanceId]: { ...galleryInstance, state: { ...galleryInstance.state, values } },
+ },
+ },
+ ],
+ });
+ const persistedValues = snapshot.state.projects[0]?.widgetInstances[galleryInstanceId]?.state.values;
+
+ expect(persistedValues?.semanticImageQuery).toBeNull();
+ expect(persistedValues?.galleryPage).toBe(0);
+ // The selection's page is stamped from the gallery's, so under a ranking
+ // it is a rank page too — dropping only the grid's would leave Preview
+ // anchored 180 rows from what the grid shows.
+ expect(persistedValues?.selectedImagePage).toBe(0);
+ expect((persistedValues?.selectedImageQuery as { page: number } | undefined)?.page).toBe(0);
+ });
+
+ it('drops a stored search that no longer parses, and the page it left', async () => {
+ // A value that cannot be read back is a search that is gone, whatever
+ // kind it claims: the page indexing its results is as stranded as one
+ // left by a reference this realm cannot resolve.
+ const state = createInitialWorkbenchState();
+ const project = state.projects[0];
+ const galleryEntry = Object.entries(project?.widgetInstances ?? {}).find(
+ ([, instance]) => instance.typeId === 'gallery'
+ );
+ const [galleryInstanceId, galleryInstance] = galleryEntry!;
+ const snapshot = await localStorageWorkbenchPersistence.saveWorkbench({
+ ...state,
+ projects: [
+ {
+ ...project!,
+ widgetInstances: {
+ ...project!.widgetInstances,
+ [galleryInstanceId]: {
+ ...galleryInstance,
+ state: {
+ ...galleryInstance.state,
+ values: {
+ ...galleryInstance.state.values,
+ galleryPage: 3,
+ paginationMode: 'paginated',
+ semanticImageQuery: { kind: 'text', query: '' },
+ },
+ },
+ },
+ },
+ },
+ ],
+ });
+ const persistedValues = snapshot.state.projects[0]?.widgetInstances[galleryInstanceId]?.state.values;
+
+ expect(persistedValues?.semanticImageQuery).toBeNull();
+ expect(persistedValues?.galleryPage).toBe(0);
+ });
+
+ it('drops a session-scoped search on save even while this session can still resolve it', async () => {
+ // In the owning session the registry entry is live, so a test of whether
+ // the reference resolves would strip nothing — and the realm reading this
+ // back cannot resolve it. The save path has to ask what the value IS.
+ const clusterId = registerImageCluster(['a.png', 'b.png'], 'beaches');
+ const state = createInitialWorkbenchState();
+ const project = state.projects[0];
+ const galleryEntry = Object.entries(project?.widgetInstances ?? {}).find(
+ ([, instance]) => instance.typeId === 'gallery'
+ );
+ const [galleryInstanceId, galleryInstance] = galleryEntry!;
+ const snapshot = await localStorageWorkbenchPersistence.saveWorkbench({
+ ...state,
+ projects: [
+ {
+ ...project!,
+ widgetInstances: {
+ ...project!.widgetInstances,
+ [galleryInstanceId]: {
+ ...galleryInstance,
+ state: {
+ ...galleryInstance.state,
+ values: {
+ ...galleryInstance.state.values,
+ galleryPage: 3,
+ paginationMode: 'paginated',
+ semanticImageQuery: { clusterId, kind: 'cluster', label: 'beaches' },
+ },
+ },
+ },
+ },
+ },
+ ],
+ });
+ const persistedValues = snapshot.state.projects[0]?.widgetInstances[galleryInstanceId]?.state.values;
+
+ expect(persistedValues?.semanticImageQuery).toBeNull();
+ expect(persistedValues?.galleryPage).toBe(0);
+ });
+
+ it('drops an infinite window anchor from the local cache on its own', async () => {
+ // The cache is what an offline boot restores from. It has not been
+ // through adoption, so the strip here is the only thing between a
+ // persisted anchor and a gallery reopened stranded mid-board.
+ const state = createInitialWorkbenchState();
+ const project = state.projects[0];
+ const galleryEntry = Object.entries(project?.widgetInstances ?? {}).find(
+ ([, instance]) => instance.typeId === 'gallery'
+ );
+ const [galleryInstanceId, galleryInstance] = galleryEntry!;
+ const snapshot = await localStorageWorkbenchPersistence.saveWorkbench({
+ ...state,
+ projects: [
+ {
+ ...project!,
+ widgetInstances: {
+ ...project!.widgetInstances,
+ [galleryInstanceId]: {
+ ...galleryInstance,
+ state: { ...galleryInstance.state, values: { ...galleryInstance.state.values, galleryPage: 5 } },
+ },
+ },
+ },
+ ],
+ });
+ const persistedValues = snapshot.state.projects[0]?.widgetInstances[galleryInstanceId]?.state.values;
+
+ expect(persistedValues?.galleryPage).toBe(0);
+ });
+
+ it('keeps a paginated page whose search survives the reload', async () => {
+ // A text search is rebuilt from the persisted value, so the page the user
+ // was reading is still a page of the same list.
+ const state = createInitialWorkbenchState();
+ const project = state.projects[0];
+ const galleryEntry = Object.entries(project?.widgetInstances ?? {}).find(
+ ([, instance]) => instance.typeId === 'gallery'
+ );
+ const [galleryInstanceId, galleryInstance] = galleryEntry!;
+ const values = {
+ ...galleryInstance.state.values,
+ galleryPage: 3,
+ paginationMode: 'paginated',
+ semanticImageQuery: { kind: 'text', query: 'sunset' },
+ };
+ const snapshot = await localStorageWorkbenchPersistence.saveWorkbench({
+ ...state,
+ projects: [
+ {
+ ...project!,
+ widgetInstances: {
+ ...project!.widgetInstances,
+ [galleryInstanceId]: { ...galleryInstance, state: { ...galleryInstance.state, values } },
+ },
+ },
+ ],
+ });
+ const persistedValues = snapshot.state.projects[0]?.widgetInstances[galleryInstanceId]?.state.values;
+
+ expect(persistedValues?.semanticImageQuery).toEqual({ kind: 'text', query: 'sunset' });
+ expect(persistedValues?.galleryPage).toBe(3);
+ });
+
it('drops corrupt localStorage snapshots instead of throwing', async () => {
storage.set('invokeai:v7:webv2:workbench', '{not json');
diff --cc invokeai/frontend/webv2/src/workbench/persistence.ts
index c8b1036378,a58e8ae58e..f58a75eaf5
--- a/invokeai/frontend/webv2/src/workbench/persistence.ts
+++ b/invokeai/frontend/webv2/src/workbench/persistence.ts
@@@ -1,43 -1,48 +1,60 @@@
import type { HydratedWorkbenchSnapshot, PersistedWorkbenchSnapshotV1 } from '@workbench/persistenceContracts';
-import type { Project, WorkbenchState } from '@workbench/projectContracts';
+import type { Project, RefusedWorkbenchProject, WorkbenchState } from '@workbench/projectContracts';
- import { getGalleryPage, getGallerySettings } from '@features/gallery/contracts';
+ import { stripInfiniteWindowAnchor, stripSessionScopedGallerySearch } from '@features/gallery/contracts';
import { timeWorkbenchPerf } from './performanceMarks';
+import { gateProjectCanvases } from './projectCanvasGate';
+import {
+ createRefusedProjectStorage,
+ isBrowserStorageAvailable,
+ WORKBENCH_STORAGE_KEY_BASE,
+} from './refusedProjectStorage';
-const BASE_STORAGE_KEY = 'invokeai:v7:webv2:workbench';
const WORKBENCH_SCHEMA_VERSION = 1;
export interface WorkbenchPersistenceService {
loadWorkbench(): Promise<HydratedWorkbenchSnapshot | null>;
saveWorkbench(state: WorkbenchState): Promise<HydratedWorkbenchSnapshot>;
clearWorkbench(): Promise<void>;
+ /** Drops a refused project's retained raw document, e.g. after the project is deleted. */
+ forgetRefusedProject(projectId: string): Promise<void>;
+ /**
+ * Moves raw documents this client cannot open into the recovery bucket without rewriting them.
+ * Returns false when the recovery bucket could not be written.
+ */
+ retainRefusedProjects(refusedProjects: readonly RefusedWorkbenchProject[]): Promise<boolean>;
}
-const isBrowser = (): boolean => typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';
+const isBrowser = isBrowserStorageAvailable;
/**
- * In infinite mode the gallery's `galleryPage` is not a page number but the
- * anchor of a mid-board window, set by a reveal from the image map. That is a
- * "you are here" position for the current session: restored a day later it
- * would open the gallery stranded in the middle of a board, with no page
- * control (the footer's is paginated-only) and no way back to the top short of
- * switching boards. Paginated pages stay persisted — there the value really is
- * the page the user was reading.
+ * Two gallery positions describe the current session only, and both are read
+ * on reload as if they described the board.
+ *
+ * In infinite mode `galleryPage` is not a page number but the anchor of a
+ * mid-board window, set by a reveal from the image map. That is a "you are
+ * here" for this session: restored a day later it would open the gallery
+ * stranded in the middle of a board, with no page control (the footer's is
+ * paginated-only) and no way back to the top short of switching boards.
+ * Paginated pages stay persisted — there the value really is the page the
+ * user was reading.
+ *
+ * A dropped file or an image-map cluster is likewise session-scoped: it names
+ * an entry in an in-memory registry that no other realm can resolve, so the
+ * ranking evaporates on the first parse over there. Nothing observes that
+ * moment, so anything set against the ranking outlives it — and the footer
+ * paginates the RANKING, which makes both the gallery's page and the page
+ * stamped on the selection rank pages that the board listing would then read
+ * as its own. `stripSessionScopedGallerySearch` drops the reference and those
+ * positions together.
+ *
+ * Adoption applies a narrower version of this (see `normalizeWorkbenchProject`):
+ * it can only drop a reference that fails to resolve, because it also runs on
+ * projects that never left this realm. The window anchor below is dropped here
+ * only — telling a foreign document from a live one is what that would need.
*/
- const stripInfiniteWindowAnchor = (project: Project): Project => {
+ const stripSessionScopedGalleryState = (project: Project): Project => {
let didChange = false;
const widgetInstances = Object.fromEntries(
Object.entries(project.widgetInstances).map(([instanceId, instance]) => {
diff --cc invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.test.ts
index fd651962d1,9047849b47..4eaab7266b
--- a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.test.ts
@@@ -1623,15 -796,149 +1623,149 @@@ describe('authoritative project boards'
delete document.widgetStates;
api.__seed(document);
- const hydrated = await service.hydrateProjectFromServer(draft.id);
+ const hydrated = await openServerProject(draft.id);
- expect(galleryBoardIds(hydrated!).projectBoardId).toBe(`board-for-${draft.id}`);
+ expect(galleryBoardIds(hydrated).projectBoardId).toBe(`board-for-${draft.id}`);
});
+ it('does not push a project it only opened, even when hydrating it changed the document', async () => {
+ // Another tab's search ranks a dropped file — a reference only that
+ // session can resolve — and its footer sits on a rank page. Hydrating
+ // that document here drops both. If the baseline were the wire bytes,
+ // the next autosave would read the drop as a local edit and push it,
+ // bumping the revision under the tab that still holds the live search
+ // and forking its next save as "changed elsewhere".
+ const draft = { ...createDraftProject([]), name: 'Ranked elsewhere' };
+ const document = persistence.serializeProjectDocument(draft);
+ const widgetInstances = document.widgetInstances as Record<string, { state: { values: Record<string, unknown> } }>;
+
+ widgetInstances.gallery!.state.values = {
+ ...widgetInstances.gallery!.state.values,
+ galleryPage: 3,
+ paginationMode: 'paginated',
+ semanticImageQuery: { fileId: 'external-1-other-realm', kind: 'file', label: 'dropped.png' },
+ };
+ api.__seed(document);
+ seedSessionBlob({ openProjectIds: [draft.id] });
+
+ const loaded = await service.loadWorkbench();
+ const opened = loaded!.state.projects.find((project) => project.id === draft.id)!;
+ const openedValues = opened.widgetInstances.gallery!.state.values;
+
+ expect(openedValues.semanticImageQuery).toBeNull();
+ expect(openedValues.galleryPage).toBe(0);
+
+ await service.saveWorkbench(stateWithProjects([opened]));
+
+ expect(api.updateProject).not.toHaveBeenCalled();
+ expect(api.__records.get(draft.id)?.revision).toBe(1);
+ });
+
+ it('does not push a project it only opened when the other session left a window anchor', async () => {
+ // The sync baseline is taken from the adopted document; the store is
+ // hydrated from the boot snapshot. Both drop an infinite window's
+ // mid-board anchor, so a project that has only been opened serializes to
+ // its baseline — dropped by one and not the other, the first autosave
+ // would push it unprompted and fork the tab that set it.
+ const draft = { ...createDraftProject([]), name: 'Revealed elsewhere' };
+ const document = persistence.serializeProjectDocument(draft);
+ const widgetInstances = document.widgetInstances as Record<string, { state: { values: Record<string, unknown> } }>;
+
+ widgetInstances.gallery!.state.values = {
+ ...widgetInstances.gallery!.state.values,
+ galleryPage: 5,
+ paginationMode: 'infinite',
+ };
+ api.__seed(document);
+ seedSessionBlob({ openProjectIds: [draft.id] });
+
+ const loaded = await service.loadWorkbench();
+ const opened = loaded!.state.projects.find((project) => project.id === draft.id)!;
+
+ expect(opened.widgetInstances.gallery!.state.values.galleryPage).toBe(0);
+
+ await service.saveWorkbench(stateWithProjects([opened]));
+
+ expect(api.updateProject).not.toHaveBeenCalled();
+ expect(api.__records.get(draft.id)?.revision).toBe(1);
+ });
+
+ it("retries rather than forks when only the other session's ranking moved", async () => {
+ // The other tab paged its ranking: the revision moved and the data changed
+ // only in the positions set against a search this realm cannot resolve.
+ // Compared as this realm holds it, the server's copy is the baseline this
+ // edit started from — a rename here is not in conflict with that.
+ const draft = { ...createDraftProject([]), name: 'Ranked elsewhere' };
+ const document = persistence.serializeProjectDocument(draft);
+ const widgetInstances = document.widgetInstances as Record<string, { state: { values: Record<string, unknown> } }>;
+ const rankedValues = (galleryPage: number) => ({
+ ...widgetInstances.gallery!.state.values,
+ galleryPage,
+ paginationMode: 'paginated',
+ semanticImageQuery: { fileId: 'external-1-other-realm', kind: 'file', label: 'dropped.png' },
+ });
+
+ widgetInstances.gallery!.state.values = rankedValues(3);
+ api.__seed(document);
+ seedSessionBlob({ openProjectIds: [draft.id] });
+
+ const loaded = await service.loadWorkbench();
+ const opened = loaded!.state.projects.find((project) => project.id === draft.id)!;
+ const record = api.__records.get(draft.id)!;
+ const pagedElsewhere = structuredClone(record.data) as typeof document;
+
+ (pagedElsewhere.widgetInstances as typeof widgetInstances).gallery!.state.values = rankedValues(4);
+ api.__records.set(draft.id, { ...record, data: pagedElsewhere, revision: record.revision + 1 });
+
+ const result = await service.saveWorkbench(stateWithProjects([{ ...opened, name: 'Edited here' }]));
+
+ expect(result.conflicts).toHaveLength(0);
+ expect(api.createProject).not.toHaveBeenCalled();
+ expect(api.__records.get(draft.id)?.name).toBe('Edited here');
+ expect(api.__records.get(draft.id)?.revision).toBe(3);
+ });
+
+ it('gives a fork a baseline it will serialize to, so it is not pushed unprompted', async () => {
+ // The fork's store copy is hydrated from the recovered document, which
+ // drops an infinite window anchor. A baseline taken from the wire bytes
+ // would still carry it, and the fork's first autosave would read the drop
+ // as an edit.
+ const project = seedServerProject('Deleted elsewhere');
- const opened = await service.hydrateProjectFromServer(project.id);
- const galleryEntry = Object.entries(opened!.widgetInstances).find(([, instance]) => instance.typeId === 'gallery')!;
++ const opened = await openServerProject(project.id);
++ const galleryEntry = Object.entries(opened.widgetInstances).find(([, instance]) => instance.typeId === 'gallery')!;
+ const [galleryInstanceId, galleryInstance] = galleryEntry;
+ const edited = {
- ...opened!,
++ ...opened,
+ name: 'Edited locally',
+ widgetInstances: {
- ...opened!.widgetInstances,
++ ...opened.widgetInstances,
+ [galleryInstanceId]: {
+ ...galleryInstance,
+ state: {
+ ...galleryInstance.state,
+ values: { ...galleryInstance.state.values, galleryPage: 7, paginationMode: 'infinite' },
+ },
+ },
+ },
+ };
+
+ api.__records.delete(project.id);
+
+ const result = await service.saveWorkbench(stateWithProjects([edited]));
+ const [fork] = result.deletedProjectForks;
+
+ expect(fork!.recoveredProject.widgetInstances[galleryInstanceId]?.state.values.galleryPage).toBe(0);
+ api.updateProject.mockClear();
+
+ await service.saveWorkbench(stateWithProjects([fork!.recoveredProject]));
+
+ expect(api.updateProject).not.toHaveBeenCalled();
+ });
+
it('forks rather than resurrects a project deleted on another device', async () => {
const project = seedServerProject('Deleted elsewhere');
- const opened = await service.hydrateProjectFromServer(project.id);
- const edited = { ...opened!, name: 'Edited locally' };
+ const opened = await openServerProject(project.id);
+ const edited = { ...opened, name: 'Edited locally' };
// Deleted on the other device, after this one had already synced.
api.__records.delete(project.id);
diff --cc invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
index a13ae45c7b,1e17679bb2..49624ef222
--- a/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
+++ b/invokeai/frontend/webv2/src/workbench/projects/syncedPersistence.ts
@@@ -235,126 -194,42 +235,150 @@@ const getSerializedProjectDocument =
* `projectBoardId` is a stale-able cache, so overwriting it here means every path that reads from
* the server agrees on one answer. The saved destination is left alone — it is a deliberate choice.
*/
+const deserializeProjectRecord = (record: ProjectRecordDTO): ProjectLoadResult => {
+ const result = deserializeProjectDocument(
+ applyAuthoritativeProjectBoard(record.data, record.board_id, { selectBoard: false })
+ );
+
+ // Again after rehydration, because the document may have had no gallery values for the first
+ // patch to land in — see `withAuthoritativeProjectBoard`.
+ switch (result.status) {
+ case 'loaded':
+ return { project: withAuthoritativeProjectBoard(result.project, record.board_id), status: 'loaded' };
+ case 'refused':
+ return { refused: { ...result.refused, raw: record.data }, status: 'refused' };
+ default:
+ return result;
+ }
+};
+
+ /**
+ * The baseline a server record establishes for the push comparison.
+ *
+ * It is the serialization of what this realm holds after hydrating the
+ * record, not the raw wire bytes. Hydration can legitimately change a
+ * document — a search only the writing session could resolve is dropped,
+ * along with the pages set against it — and a baseline taken from the bytes
- * would read that as a local edit: the next autosave would push the hydrated
- * copy unprompted, bump the revision under the tab that still holds the live
- * search, and fork that tab's next save as "changed elsewhere" with nobody
- * having edited anything. Taking the baseline after hydration means a project
- * that has only been opened is never pushed, and a real edit here conflicts
- * with a real edit there exactly as before.
++ * would read that as a local edit.
+ */
-const adoptRecordBaseline = (record: ProjectRecordDTO): { project: Project | null; pushedDoc: string } => {
- const project = deserializeProjectRecord(record);
-
- // Serialized directly, not through `getSerializedProjectDocument`: that
- // records the document's cover as a side effect, and a baseline is taken for
- // documents this realm may never adopt — the server's copy during conflict
- // recovery, which on a retry would leave the cover index naming the version
- // the retry then overwrites.
++const adoptRecordBaseline = (record: ProjectRecordDTO): { pushedDoc: string; result: ProjectLoadResult } => {
++ const result = deserializeProjectRecord(record);
++
++ // Do not use `getSerializedProjectDocument` here: taking a comparison
++ // baseline must not record the cover of a document this realm may never
++ // adopt (for example, the server side of conflict recovery).
+ return {
- project,
- pushedDoc: project === null ? JSON.stringify(record.data) : JSON.stringify(serializeProjectDocument(project)),
++ pushedDoc:
++ result.status === 'loaded'
++ ? JSON.stringify(serializeProjectDocument(result.project))
++ : JSON.stringify(record.data),
++ result,
+ };
+ };
+
-const deserializeProjectRecord = (record: ProjectRecordDTO): Project | null => {
- const project = deserializeProjectDocument(
- applyAuthoritativeProjectBoard(record.data, record.board_id, { selectBoard: false })
- );
+const toServerSchemaRefusal = (
+ error: unknown,
+ projectId: string,
+ projectName: string
+): RefusedWorkbenchProject | null => {
+ const compatibility = getProjectCanvasSchemaCompatibilityRefusal(error);
- // Again after rehydration, because the document may have had no gallery values for the first
- // patch to land in — see `withAuthoritativeProjectBoard`.
- return project === null ? null : withAuthoritativeProjectBoard(project, record.board_id);
+ if (!compatibility) {
+ return null;
+ }
+
+ return {
+ projectId,
+ projectName,
+ raw: null,
+ refusal: {
+ raw: null,
+ scope: 'document',
+ status: 'unsupported-version',
+ version: compatibility.minimumCanvasSchemaVersion,
+ },
+ source: 'canvas',
+ };
+};
+
+const toDeclaredSchemaRefusal = (
+ projectId: string,
+ projectName: string,
+ minimumCanvasSchemaVersion: number
+): RefusedWorkbenchProject => ({
+ projectId,
+ projectName,
+ raw: null,
+ refusal: {
+ raw: null,
+ scope: 'document',
+ status: 'unsupported-version',
+ version: minimumCanvasSchemaVersion,
+ },
+ source: 'canvas',
+});
+
+const rememberServerSchemaRefusal = (
+ syncState: SyncedPersistenceState,
+ projectId: string,
+ error: unknown
+): ProjectSchemaRefusal | null => {
+ const refusal = getProjectCanvasSchemaCompatibilityRefusal(error);
+
+ if (refusal) {
+ syncState.schemaRefusals.set(projectId, refusal);
+ }
+
+ return refusal;
+};
+
+const retainSchemaRefusedProject = async (
+ syncState: SyncedPersistenceState,
+ project: Project,
+ refusal: ProjectSchemaRefusal
+): Promise<boolean> => {
+ const raw = serializeProjectDocument(project);
+ const refusedProject: RefusedWorkbenchProject = {
+ projectId: project.id,
+ projectName: project.name,
+ raw,
+ refusal: {
+ raw,
+ scope: 'document',
+ status: 'unsupported-version',
+ version: refusal.minimumCanvasSchemaVersion,
+ },
+ source: 'canvas',
+ };
+ const retained = await syncState.localPersistence.retainRefusedProjects([refusedProject]);
+ assertOwner(syncState);
+
+ // A schema refusal is terminal for this sync lifetime, but its raw document is not safe to omit
+ // from the primary cache until the recovery bucket confirms the write. Keep the latest raw copy
+ // in memory so every later save retries retention before it can replace that cache.
+ syncState.unretainedRefusedProjects = retained
+ ? syncState.unretainedRefusedProjects.filter((candidate) => candidate.projectId !== project.id)
+ : [
+ ...syncState.unretainedRefusedProjects.filter((candidate) => candidate.projectId !== project.id),
+ refusedProject,
+ ];
+
+ return retained;
+};
+
+const ensureRefusedProjectsRetained = async (syncState: SyncedPersistenceState): Promise<boolean> => {
+ if (syncState.unretainedRefusedProjects.length === 0) {
+ return true;
+ }
+
+ const retained = await syncState.localPersistence.retainRefusedProjects(syncState.unretainedRefusedProjects);
+
+ assertOwner(syncState);
+ if (retained) {
+ syncState.unretainedRefusedProjects = [];
+ }
+
+ return retained;
};
/**
@@@ -636,41 -318,17 +660,42 @@@ const pushNewProject = async (syncState
const existing = await apiGetProject(project.id, syncState.owner.signal);
assertOwner(syncState);
- syncState.syncEntries.set(project.id, {
- pushedDoc: adoptRecordBaseline(existing).pushedDoc,
++ const { pushedDoc } = adoptRecordBaseline(existing);
+ const existingEntry: SyncEntry = {
+ minimumCanvasSchemaVersion: existing.minimum_canvas_schema_version,
- pushedDoc: JSON.stringify(existing.data),
++ pushedDoc,
revision: existing.revision,
- });
- syncState.pendingBoardAssignments.push({ boardId: existing.board_id, projectId: project.id });
+ };
+
+ if (JSON.stringify(existing.data) === JSON.stringify(document)) {
+ syncState.collisionProjectIds.delete(project.id);
+ syncState.syncEntries.set(project.id, existingEntry);
+ syncState.pendingBoardAssignments.push({ boardId: existing.board_id, projectId: project.id });
- return true;
+ return { kind: 'acknowledged' };
+ }
+
+ const outcome = await forkProjectAgainstServer(
+ syncState,
+ project,
+ document,
+ existing,
+ Math.max(
+ existing.minimum_canvas_schema_version,
+ syncState.pendingProjectMinimumCanvasSchemaVersions.get(project.id) ?? 1
+ )
+ );
+
+ if (outcome.kind === 'forked') {
+ syncState.collisionProjectIds.delete(project.id);
+ syncState.syncEntries.set(project.id, existingEntry);
+ syncState.pendingBoardAssignments.push({ boardId: existing.board_id, projectId: project.id });
+ }
+
+ return outcome;
} catch {
assertOwner(syncState);
-
- return false;
+ return { kind: 'collision' };
}
}
@@@ -871,64 -368,8 +896,64 @@@ type ConflictOutcome
| { kind: 'adopted' }
| { kind: 'retry' }
| { kind: 'forked'; resolution: ProjectConflictResolution }
+ | { kind: 'schema-refused'; refusal: ProjectSchemaRefusal }
| { kind: 'failed' };
+/** Preserve a divergent local document beside the authoritative server document. */
+const forkProjectAgainstServer = async (
+ syncState: SyncedPersistenceState,
+ project: Project,
+ document: Record<string, unknown>,
+ server: ProjectRecordDTO,
+ retainedMinimumCanvasSchemaVersion: number
+): Promise<Extract<ConflictOutcome, { kind: 'failed' | 'forked' }>> => {
+ const serverResult = deserializeProjectRecord(server);
+
+ if (serverResult.status !== 'loaded') {
+ return { kind: 'failed' };
+ }
+
+ const prepared = await prepareRecoveredDocument(syncState, project, document);
+
+ if (!prepared) {
+ return { kind: 'failed' };
+ }
+
+ const recovery = await createOrAdoptRecoveryProject(
+ syncState,
+ project,
+ document,
+ prepared,
+ retainedMinimumCanvasSchemaVersion
+ );
+ const recoveredResult = deserializeProjectDocument(recovery.recoveredDocument);
+
+ if (recoveredResult.status !== 'loaded') {
+ return { kind: 'failed' };
+ }
+
+ assertOwner(syncState);
+ syncState.syncEntries.set(recovery.recoveredIdentity.id, {
+ minimumCanvasSchemaVersion: recovery.created.minimum_canvas_schema_version,
- pushedDoc: JSON.stringify(recovery.recoveredDocument),
++ pushedDoc: JSON.stringify(serializeProjectDocument(recoveredResult.project)),
+ revision: recovery.created.revision,
+ });
+ syncState.pendingBoardAssignments.push({
+ boardId: recovery.created.board_id,
+ projectId: recovery.recoveredIdentity.id,
+ });
+
+ return {
+ kind: 'forked',
+ resolution: {
+ projectId: project.id,
+ recoveredIdentity: recovery.recoveredIdentity,
+ recoveredProject: recoveredResult.project,
+ serverProject: serverResult.project,
+ },
+ };
+};
+
/**
* A save lost the revision race. Forking is the last resort — only when content actually diverged:
*
@@@ -950,16 -390,15 +975,16 @@@ const recoverConflictingProject = asyn
const server = await apiGetProject(project.id, syncState.owner.signal);
assertOwner(syncState);
- const serverDocJson = JSON.stringify(server.data);
- // Compared as this realm would hold it, the same way the baseline was
- // taken: the wire bytes of an unchanged document differ from the baseline
- // whenever hydration changes it, and that would read a revision that
- // merely drifted as a divergence.
- const { project: serverProject, pushedDoc: serverDocJson } = adoptRecordBaseline(server);
-
- syncState.syncEntries.set(project.id, { pushedDoc: serverDocJson, revision: server.revision });
++ const { pushedDoc: serverDocJson, result: serverResult } = adoptRecordBaseline(server);
+ const serverEntry: SyncEntry = {
+ minimumCanvasSchemaVersion: server.minimum_canvas_schema_version,
+ pushedDoc: serverDocJson,
+ revision: server.revision,
+ };
if (serverDocJson === documentJson) {
+ syncState.syncEntries.set(project.id, serverEntry);
+
return { kind: 'adopted' };
}
@@@ -969,25 -406,43 +994,29 @@@
return { kind: 'retry' };
}
- if (!serverProject) {
++ if (serverResult.status !== 'loaded') {
+ return { kind: 'failed' };
+ }
+
- const { recoveredDocument, recoveredIdentity } = createRecoveredDocument(project, document);
- const recoveredProject = deserializeProjectDocument(recoveredDocument);
+ const outcome = await forkProjectAgainstServer(
+ syncState,
+ project,
+ document,
+ server,
+ Math.max(retainedMinimumCanvasSchemaVersion, server.minimum_canvas_schema_version)
+ );
- if (!recoveredProject) {
- return { kind: 'failed' };
+ if (outcome.kind === 'forked') {
+ syncState.syncEntries.set(project.id, serverEntry);
}
- const created = await apiCreateProject(
- { data: recoveredDocument, name: recoveredIdentity.name, project_id: recoveredIdentity.id },
- syncState.owner.signal
- );
-
+ return outcome;
+ } catch (error) {
assertOwner(syncState);
- syncState.syncEntries.set(recoveredIdentity.id, {
- // As this realm holds it, not the wire bytes: the fork's store copy is
- // hydrated from this document, and a fork whose tab is already closed
- // is a document arriving like any other.
- pushedDoc: JSON.stringify(serializeProjectDocument(recoveredProject)),
- revision: created.revision,
- });
- // Recorded for the same reason the deletion fork records it: the fork is a project the server
- // created, so its board id exists nowhere else. Without this the fork opens with a gallery bound
- // to the original's board — which the conflict left in the server version's hands.
- syncState.pendingBoardAssignments.push({ boardId: created.board_id, projectId: recoveredIdentity.id });
- return {
- kind: 'forked',
- resolution: { projectId: project.id, recoveredIdentity, recoveredProject, serverProject },
- };
- } catch {
- assertOwner(syncState);
+ const refusal = rememberServerSchemaRefusal(syncState, project.id, error);
- return { kind: 'failed' };
+ return refusal ? { kind: 'schema-refused', refusal } : { kind: 'failed' };
}
};
@@@ -1011,213 -464,54 +1040,213 @@@ const forkDeletedProject = async
): Promise<DeletionForkOutcome> => {
assertOwner(syncState);
- const { recoveredDocument, recoveredIdentity } = createRecoveredDocument(project, document);
- const recoveredProject = deserializeProjectDocument(recoveredDocument);
+ const prepared = await prepareRecoveredDocument(syncState, project, document);
+
+ if (!prepared) {
+ return { kind: 'failed' };
+ }
+
+ try {
+ const recovery = await createOrAdoptRecoveryProject(
+ syncState,
+ project,
+ document,
+ prepared,
+ retainedMinimumCanvasSchemaVersion
+ );
+ const recoveredResult = deserializeProjectDocument(recovery.recoveredDocument);
+
+ if (recoveredResult.status !== 'loaded') {
+ return { kind: 'failed' };
+ }
+
+ assertOwner(syncState);
+
+ // Re-read after the create, not just before it. `deleteLibraryProject` marks the id before
+ // issuing its DELETE, but a PUT already on the wire is past that check — the 404 that brought us
+ // here can be this browser's own deletion arriving first. Forking on it would resurrect the
+ // project the person just deleted, as a copy pointing at media the deletion already removed.
+ if (!options?.allowMarkedSource && syncState.deletedProjectIds.has(project.id)) {
+ try {
+ await apiDeleteProject(recovery.recoveredIdentity.id, syncState.owner.signal);
+ } catch {
+ // The fork is an empty private project either way; failing to remove it is clutter, not a
+ // broken state, and it must not replace the deletion's own outcome.
+ }
+
+ assertOwner(syncState);
+ syncState.syncEntries.delete(recovery.recoveredIdentity.id);
+
+ return { kind: 'abandoned' };
+ }
+
+ syncState.syncEntries.set(recovery.recoveredIdentity.id, {
+ minimumCanvasSchemaVersion: recovery.created.minimum_canvas_schema_version,
- pushedDoc: JSON.stringify(recovery.recoveredDocument),
++ pushedDoc: JSON.stringify(serializeProjectDocument(recoveredResult.project)),
+ revision: recovery.created.revision,
+ });
+ syncState.pendingBoardAssignments.push({
+ boardId: recovery.created.board_id,
+ projectId: recovery.recoveredIdentity.id,
+ });
+
+ return {
+ fork: {
+ projectId: project.id,
+ recoveredIdentity: recovery.recoveredIdentity,
+ recoveredProject: recoveredResult.project,
+ },
+ kind: 'forked',
+ };
+ } catch {
+ assertOwner(syncState);
- if (!recoveredProject) {
return { kind: 'failed' };
}
+};
+
+/** Re-key a document whose original id is known unsafe to create, preserving it under a fresh id. */
+const recoverReservedProjectId = async (
+ syncState: SyncedPersistenceState,
+ project: Project,
+ document: Record<string, unknown>,
+ documentJson: string,
+ retainedMinimumCanvasSchemaVersion: number
+): Promise<ProjectPushOutcome> => {
+ const outcome = await forkDeletedProject(syncState, project, document, retainedMinimumCanvasSchemaVersion);
+
+ assertOwner(syncState);
+ if (outcome.kind === 'failed') {
+ syncState.hasPending = true;
+
+ return { documentJson, kind: 'unsynced' };
+ }
+
+ if (outcome.kind === 'forked') {
+ // The recovered server record makes the local bytes crash-durable. Keep the original guarded
+ // until aggregate reconciliation and a cache write replace it with the recovered identity.
+ syncState.forkedProjectIds.add(project.id);
+ syncState.deletedProjectIds.add(project.id);
+ syncState.pendingDeletedForks.push(outcome.fork);
+ }
+
+ return { documentJson, kind: 'superseded' };
+};
+
+/** Resolve tombstones whose DELETE/rollback outcome was lost before replacing any cached bytes. */
+const reconcileUnconfirmedDeletions = async (
+ syncState: SyncedPersistenceState,
+ liveProjects: readonly Project[]
+): Promise<boolean> => {
+ const liveProjectsById = new Map(liveProjects.map((project) => [project.id, project]));
+
+ for (const projectId of syncState.unconfirmedDeletionProjectIds) {
+ const hiddenProject = liveProjectsById.get(projectId) ?? syncState.cachedProjectsById.get(projectId);
+
+ if (!hiddenProject) {
+ return false;
+ }
+
+ const { document, json: documentJson } = getSerializedProjectDocument(syncState, hiddenProject);
+ let record: ProjectRecordDTO;
+
+ try {
+ record = await apiGetProject(projectId, syncState.owner.signal);
+ } catch (error) {
+ assertOwner(syncState);
+
+ if (isProjectNotFoundError(error)) {
+ if (liveProjectsById.has(projectId)) {
+ const recovery = await forkDeletedProject(
+ syncState,
+ hiddenProject,
+ document,
+ syncState.pendingProjectMinimumCanvasSchemaVersions.get(projectId) ?? DEFAULT_PROJECT_CANVAS_SCHEMA_VERSION,
+ { allowMarkedSource: true }
+ );
+
+ assertOwner(syncState);
+ if (recovery.kind !== 'forked') {
+ return false;
+ }
+
+ syncState.pendingDeletedForks.push(recovery.fork);
+ syncState.forkedProjectIds.add(projectId);
+ }
+
+ // DELETE committed. The tombstone remains until the next cache snapshot omits the project.
+ syncState.unconfirmedDeletionProjectIds.delete(projectId);
+ continue;
+ }
- try {
- const created = await apiCreateProject(
- { data: recoveredDocument, name: recoveredIdentity.name, project_id: recoveredIdentity.id },
- syncState.owner.signal
- );
+ return false;
+ }
assertOwner(syncState);
+ const serverDocumentJson = JSON.stringify(record.data);
+ const serverEntry: SyncEntry = {
+ minimumCanvasSchemaVersion: record.minimum_canvas_schema_version,
+ pushedDoc: serverDocumentJson,
+ revision: record.revision,
+ };
+ const serverResult = deserializeProjectRecord(record);
- // Re-read after the create, not just before it. `deleteLibraryProject` marks the id before
- // issuing its DELETE, but a PUT already on the wire is past that check — the 404 that brought us
- // here can be this browser's own deletion arriving first. Forking on it would resurrect the
- // project the person just deleted, as a copy pointing at media the deletion already removed.
- if (syncState.deletedProjectIds.has(project.id)) {
- try {
- await apiDeleteProject(recoveredIdentity.id, syncState.owner.signal);
- } catch {
- // The fork is an empty private project either way; failing to remove it is clutter, not a
- // broken state, and it must not replace the deletion's own outcome.
- }
+ if (serverResult.status !== 'loaded') {
+ const recovery = await forkDeletedProject(
+ syncState,
+ hiddenProject,
+ document,
+ syncState.pendingProjectMinimumCanvasSchemaVersions.get(projectId) ?? DEFAULT_PROJECT_CANVAS_SCHEMA_VERSION,
+ { allowMarkedSource: true }
+ );
assertOwner(syncState);
- syncState.syncEntries.delete(recoveredIdentity.id);
+ if (recovery.kind !== 'forked') {
+ return false;
+ }
- return { kind: 'abandoned' };
+ syncState.syncEntries.set(projectId, serverEntry);
+ syncState.pendingDeletedForks.push(recovery.fork);
+ syncState.forkedProjectIds.add(projectId);
+ syncState.deletedProjectIds.delete(projectId);
+ syncState.unconfirmedDeletionProjectIds.delete(projectId);
+ continue;
}
- syncState.syncEntries.set(recoveredIdentity.id, {
- // As this realm holds it, not the wire bytes: the fork's store copy is
- // hydrated from this document, and a fork whose tab is already closed
- // is a document arriving like any other.
- pushedDoc: JSON.stringify(serializeProjectDocument(recoveredProject)),
- revision: created.revision,
- });
- syncState.pendingBoardAssignments.push({ boardId: created.board_id, projectId: recoveredIdentity.id });
+ if (serverDocumentJson === documentJson) {
+ // DELETE did not commit, but the server already has every cached byte.
+ syncState.syncEntries.set(projectId, serverEntry);
+ syncState.deletedProjectIds.delete(projectId);
+ syncState.unconfirmedDeletionProjectIds.delete(projectId);
+ continue;
+ }
+
+ const outcome = await forkProjectAgainstServer(
+ syncState,
+ hiddenProject,
+ document,
+ record,
+ Math.max(
+ record.minimum_canvas_schema_version,
+ syncState.pendingProjectMinimumCanvasSchemaVersions.get(projectId) ?? DEFAULT_PROJECT_CANVAS_SCHEMA_VERSION
+ )
+ );
- return { fork: { projectId: project.id, recoveredIdentity, recoveredProject }, kind: 'forked' };
- } catch {
assertOwner(syncState);
+ if (outcome.kind !== 'forked') {
+ return false;
+ }
- return { kind: 'failed' };
+ // The server keeps its authoritative project; the hidden cached edit is now a durable recovery.
+ syncState.syncEntries.set(projectId, serverEntry);
+ syncState.pendingConflicts.push(outcome.resolution);
+ syncState.forkedProjectIds.add(projectId);
+ syncState.deletedProjectIds.delete(projectId);
+ syncState.unconfirmedDeletionProjectIds.delete(projectId);
}
+
+ persistSyncMap(syncState);
+ return true;
};
const pushProject = async (syncState: SyncedPersistenceState, project: Project): Promise<ProjectPushOutcome> => {
@@@ -1724,99 -747,11 +1753,98 @@@ const loadFromBackend = async
continue;
}
- const { project, pushedDoc } = adoptRecordBaseline(record);
+ if (load.status === 'deleted') {
+ deletedAfterListProjectIds.add(load.projectId);
+ summaryIds.delete(load.projectId);
+ continue;
+ }
- if (project) {
- serverProjects.push(project);
- syncState.syncEntries.set(record.project_id, { pushedDoc, revision: record.revision });
+ const { record } = load;
- const result = deserializeProjectRecord(record);
++ const { pushedDoc: serverDocJson, result } = adoptRecordBaseline(record);
+
+ if (result.status === 'loaded') {
- const serverDocJson = JSON.stringify(record.data);
+ const localProject = localProjectById.get(record.project_id);
+ const hasPendingLocalEdit = localProject && syncState.pendingProjectIds.has(record.project_id);
+ const serverEntry: SyncEntry = {
+ minimumCanvasSchemaVersion: record.minimum_canvas_schema_version,
+ pushedDoc: serverDocJson,
+ revision: record.revision,
+ };
+
+ if (hasPendingLocalEdit) {
+ const localDocument = serializeProjectDocument(localProject);
+ const localDocJson = JSON.stringify(localDocument);
+
+ if (localDocJson === serverDocJson) {
+ // The acknowledgement landed before the previous runtime could clear its durable
+ // pending marker. The server already has the cached bytes.
+ syncState.pendingProjectIds.delete(record.project_id);
+ syncState.pendingProjectMinimumCanvasSchemaVersions.delete(record.project_id);
+ syncState.collisionProjectIds.delete(record.project_id);
+ syncState.syncEntries.set(record.project_id, serverEntry);
+ serverProjects.push(result.project);
+ } else if (persistedSyncMap.revisions[record.project_id] === record.revision) {
+ // The server is still at the revision this browser last acknowledged. Keep the cached
+ // edit under its original id; the next save can update that revision without clobbering
+ // another writer.
+ syncState.collisionProjectIds.delete(record.project_id);
+ syncState.syncEntries.set(record.project_id, serverEntry);
+ serverProjects.push(withAuthoritativeProjectBoard(localProject, record.board_id));
+ syncState.hasPending = true;
+ } else {
+ // Both sides advanced while this browser was offline. The server keeps the id and the
+ // cached edit becomes a never-synced recovery project, exactly like a live conflict.
+ const pendingRecoveryReservation = syncState.pendingRecoveryIdentities.get(localProject.id);
+ const pendingRecoveryIdentity = pendingRecoveryReservation?.identity;
+ const localDocumentFingerprint = await fingerprintProjectDocument(localDocument);
+ const pendingRecoveryDocument =
+ pendingRecoveryReservation?.sourceDocumentFingerprint === localDocumentFingerprint &&
+ pendingRecoveryIdentity
+ ? applyRecoveredIdentity(localDocument, pendingRecoveryIdentity)
+ : null;
+ const acknowledgedRecoveryRecord = pendingRecoveryIdentity
+ ? loadedRecordById.get(pendingRecoveryIdentity.id)
+ : null;
+ const minimumCanvasSchemaVersion = Math.max(
+ serverEntry.minimumCanvasSchemaVersion,
+ persistedSyncMap.minimumCanvasSchemaVersions[record.project_id] ?? DEFAULT_PROJECT_CANVAS_SCHEMA_VERSION
+ );
+ const recoveredIsAcknowledged = Boolean(
+ acknowledgedRecoveryRecord &&
+ pendingRecoveryDocument &&
+ acknowledgedRecoveryRecord.minimum_canvas_schema_version >= minimumCanvasSchemaVersion &&
+ JSON.stringify(acknowledgedRecoveryRecord.data) === JSON.stringify(pendingRecoveryDocument)
+ );
+ const recoveredDocument = recoveredIsAcknowledged
+ ? pendingRecoveryDocument!
+ : createRecoveredDocument(localProject, localDocument).recoveredDocument;
+ const recovered = deserializeProjectDocument(recoveredDocument);
+
+ serverProjects.push(result.project);
+
+ if (recovered.status === 'loaded') {
+ if (!recoveredIsAcknowledged) {
+ recoveredLocalProjects.push(recovered.project);
+ }
+ recoveredProjectTransitions.push({
+ minimumCanvasSchemaVersion,
+ recoveredIsAcknowledged,
+ recoveredProjectId: recovered.project.id,
+ sourceEntry: serverEntry,
+ sourceProjectId: record.project_id,
+ });
+ syncState.hasPending = true;
+ }
+ }
+ } else {
+ syncState.pendingProjectIds.delete(record.project_id);
+ syncState.pendingProjectMinimumCanvasSchemaVersions.delete(record.project_id);
+ syncState.collisionProjectIds.delete(record.project_id);
+ syncState.syncEntries.set(record.project_id, serverEntry);
+ serverProjects.push(result.project);
+ }
+ } else if (result.status === 'refused') {
+ refusedById.set(result.refused.projectId, result.refused);
}
}
@@@ -2193,31 -945,18 +2221,31 @@@ export const createSyncedWorkbenchPersi
}
};
- const adoptProjectRecord = (record: ProjectRecordDTO): Project | null => {
+ const adoptProjectRecord = (record: ProjectRecordDTO): ProjectLoadResult => {
assertOwner(syncState);
- const result = deserializeProjectRecord(record);
- const { project, pushedDoc } = adoptRecordBaseline(record);
++ const { pushedDoc, result } = adoptRecordBaseline(record);
- if (!project) {
- return null;
+ if (result.status !== 'loaded') {
+ return result;
}
- syncState.syncEntries.set(record.project_id, { pushedDoc, revision: record.revision });
+ syncState.syncEntries.set(record.project_id, {
+ minimumCanvasSchemaVersion: record.minimum_canvas_schema_version,
- pushedDoc: JSON.stringify(record.data),
++ pushedDoc,
+ revision: record.revision,
+ });
+ syncState.deletedProjectIds.delete(record.project_id);
+ syncState.forkedProjectIds.delete(record.project_id);
+ syncState.schemaRefusals.delete(record.project_id);
+ syncState.collisionProjectIds.delete(record.project_id);
+ syncState.pendingProjectIds.delete(record.project_id);
+ syncState.pendingProjectMinimumCanvasSchemaVersions.delete(record.project_id);
+ syncState.pendingRecoveryIdentities.delete(record.project_id);
+ syncState.releasedProjectIds.delete(record.project_id);
+ syncState.unconfirmedDeletionProjectIds.delete(record.project_id);
persistSyncMap(syncState);
- return project;
+ return result;
};
return {
diff --cc invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index 400f74a33c,8fd8d117e5..3710b6c75d
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@@ -12,12 -11,13 +12,16 @@@ import type
import type { GraphContract } from '@workbench/graphContracts';
import type { Project, WorkbenchState } from '@workbench/projectContracts';
- import { GALLERY_RECENT_IMAGE_LIMIT, legacyGeneratedImageToGalleryItem } from '@features/gallery/contracts';
+ import {
+ GALLERY_RECENT_IMAGE_LIMIT,
+ legacyGeneratedImageToGalleryItem,
+ registerImageCluster,
+ } from '@features/gallery/contracts';
import { MAX_PROMPT_HISTORY } from '@features/generation/settings';
import { createDefaultUpscaleWidgetValues } from '@features/upscale';
+import { getDocumentLeaves } from '@workbench/canvas-engine/api';
+import { stacksFrom } from '@workbench/canvas-engine/document-model/documentFixtures.testStub';
+import { stackTopAnchor } from '@workbench/canvas-engine/document/insertionAnchors.testStub';
import { afterEach, describe, expect, it, vi } from 'vitest';
import type { CanvasProjectMutation } from './canvasProjectMutations';
diff --cc invokeai/frontend/webv2/src/workbench/workbenchState.ts
index 5775279ee8,164010d5e5..85ba3adeaa
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts
@@@ -1716,21 -1710,20 +1739,44 @@@ const normalizePromptHistory = (value:
}, []);
};
+/** The project-ingestion path: gate every embedded canvas, then normalize. */
+export const loadWorkbenchProject = (raw: Project): ProjectLoadResult => {
+ const refused = gateProjectCanvases(raw);
+
+ return refused ? { refused, status: 'refused' } : { project: normalizeWorkbenchProject(raw), status: 'loaded' };
+};
+
+/** Normalizes an admitted project; a canvas that somehow fails to reload is kept as-is, never rewritten. */
- export const normalizeWorkbenchProject = (project: Project): Project => {
+ export const normalizeWorkbenchProject = (
+ project: Project,
+ options: {
+ /**
+ * Whether the document is arriving from another realm (a server record,
+ * an import) rather than being kept by this one (the conflict fork that
+ * rescues the live copy). An infinite window's mid-board anchor is a
+ * "you are here" for the session that revealed it: it is dropped from a
+ * document that arrives, and kept for one that stays.
+ */
+ isArriving?: boolean;
+ } = {}
++): Project => {
+ const canvas = loadCanvasState(project.canvas);
+
- return assembleWorkbenchProject(project, cloneCanvas(canvas.status === 'loaded' ? canvas.value : project.canvas));
++ return assembleWorkbenchProject(
++ project,
++ cloneCanvas(canvas.status === 'loaded' ? canvas.value : project.canvas),
++ options
++ );
+};
+
- const assembleWorkbenchProject = (project: Project, canvas: CanvasStateContractV3): Project => {
++const assembleWorkbenchProject = (
++ project: Project,
++ canvas: CanvasStateContractV3,
++ options: {
++ isArriving?: boolean;
++ } = {}
+ ): Project => {
+ const { isArriving = true } = options;
const legacyWidgetRegions = project.widgetRegions as
| Partial<Record<WidgetRegion | 'left-panel' | 'right-panel' | 'status-bar', WidgetRegionState>>
| undefined;
@@@ -3742,25 -3814,31 +3918,31 @@@ export const __workbenchReducerInterna
stackOrder: nextStackOrder(project.floatingWidgets),
};
- return {
- ...project,
- floatingWidgets: { ...project.floatingWidgets, [action.instanceId]: floating },
- widgetRegions: {
- ...project.widgetRegions,
- [hostRegionId]: {
- ...hostRegion,
- activeInstanceId:
- hostRegion.activeInstanceId === action.instanceId
- ? (fallbackInstanceId ?? emptiedActiveInstanceId(hostRegionId, hostRegion))
- : hostRegion.activeInstanceId,
- instanceIds,
- // Floating the last widget out of a rail leaves nothing to show,
- // so the rail collapses rather than standing open and empty —
- // the same repair `toggleRegionWidget` makes.
- isCollapsed: instanceIds.length === 0 ? true : hostRegion.isCollapsed,
+ return applyAutoRouteForRevealedInstance(
+ {
+ ...project,
+ floatingWidgets: { ...project.floatingWidgets, [action.instanceId]: floating },
+ widgetRegions: {
+ ...project.widgetRegions,
+ [hostRegionId]: {
+ ...hostRegion,
+ activeInstanceId:
- hostRegion.activeInstanceId === action.instanceId && fallbackInstanceId
- ? fallbackInstanceId
++ hostRegion.activeInstanceId === action.instanceId
++ ? (fallbackInstanceId ?? emptiedActiveInstanceId(hostRegionId, hostRegion))
+ : hostRegion.activeInstanceId,
+ instanceIds,
+ // Floating the last widget out of a rail leaves nothing to show,
+ // so the rail collapses rather than standing open and empty —
+ // the same repair `toggleRegionWidget` makes.
+ isCollapsed: instanceIds.length === 0 ? true : hostRegion.isCollapsed,
+ },
},
},
- };
+ // The window lands on top of everything, so it is the revealed
+ // surface — not the tab the rail promotes behind it.
+ action.instanceId,
+ context
+ );
});
}
case 'dockFloatingWidget': {
@@@ -3874,29 -3962,35 +4066,35 @@@
const nextFromInstanceIds = fromRegion.instanceIds.filter((instanceId) => instanceId !== action.instanceId);
const nextToInstanceIds = insertAt(toRegion.instanceIds, action.instanceId, action.toIndex);
- return {
- ...project,
- layout: openPanelForRegion(project.layout, action.toRegion),
- widgetRegions: {
- ...project.widgetRegions,
- [action.fromRegion]: {
- ...fromRegion,
- activeInstanceId:
- fromRegion.activeInstanceId === action.instanceId
- ? (nextFromInstanceIds[0] ?? emptiedActiveInstanceId(action.fromRegion, fromRegion))
- : fromRegion.activeInstanceId,
- instanceIds: nextFromInstanceIds,
- isCollapsed:
- action.fromRegion === 'center' ? false : nextFromInstanceIds.length === 0 || fromRegion.isCollapsed,
- },
- [action.toRegion]: {
- ...toRegion,
- activeInstanceId: action.instanceId,
- instanceIds: nextToInstanceIds,
- isCollapsed: false,
+ return applyAutoRouteForRevealedInstance(
+ {
+ ...project,
+ layout: openPanelForRegion(project.layout, action.toRegion),
+ widgetRegions: {
+ ...project.widgetRegions,
+ [action.fromRegion]: {
+ ...fromRegion,
+ activeInstanceId:
+ fromRegion.activeInstanceId === action.instanceId
- ? (nextFromInstanceIds[0] ?? fromRegion.activeInstanceId)
++ ? (nextFromInstanceIds[0] ?? emptiedActiveInstanceId(action.fromRegion, fromRegion))
+ : fromRegion.activeInstanceId,
+ instanceIds: nextFromInstanceIds,
+ isCollapsed:
+ action.fromRegion === 'center' ? false : nextFromInstanceIds.length === 0 || fromRegion.isCollapsed,
+ },
+ [action.toRegion]: {
+ ...toRegion,
+ activeInstanceId: action.instanceId,
+ instanceIds: nextToInstanceIds,
+ isCollapsed: false,
+ },
},
},
- };
+ // The dragged widget lands expanded and selected in the target
+ // region; the tab the source region promotes behind it did not move.
+ action.instanceId,
+ context
+ );
});
}
case 'reorderWidgetInstances': {