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
feat(canvas): footer actions and a selection-aware layer menu
Josh Corbettc5674c1e78ac
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.jsonindex c44fae434d..e3ae8648a0 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": 840429,+ "brotliBytes": 839937,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 839151,+ "gzipBytes": 838725,"imageRawBytes": 156376,- "initialRawBytes": 1954944,+ "initialRawBytes": 1954479,"largestAssetRawBytes": 746376,"otherAssetRawBytes": 0,- "ownedRawBytes": 70889,+ "ownedRawBytes": 70891,"requestCount": 42,"scriptRequestCount": 26,"sourceOwners": [@@ -290,15 +290,15 @@]},"limits": {- "brotliBytes": 848834,+ "brotliBytes": 848337,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 847543,+ "gzipBytes": 847113,"imageRawBytes": 157940,- "initialRawBytes": 1974494,+ "initialRawBytes": 1974024,"largestAssetRawBytes": 753840,"otherAssetRawBytes": 0,- "ownedRawBytes": 70889,+ "ownedRawBytes": 70891,"requestCount": 42,"scriptRequestCount": 26},@@ -308,12 +308,12 @@},"editor": {"baseline": {- "brotliBytes": 1099132,+ "brotliBytes": 1098809,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 1094397,+ "gzipBytes": 1094053,"imageRawBytes": 156376,- "initialRawBytes": 2740501,+ "initialRawBytes": 2740036,"largestAssetRawBytes": 746376,"otherAssetRawBytes": 0,"ownedRawBytes": 114602,@@ -931,12 +931,12 @@]},"limits": {- "brotliBytes": 1110124,+ "brotliBytes": 1109798,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 1105341,+ "gzipBytes": 1104994,"imageRawBytes": 157940,- "initialRawBytes": 2767907,+ "initialRawBytes": 2767437,"largestAssetRawBytes": 753840,"otherAssetRawBytes": 0,"ownedRawBytes": 114602,diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.jsonindex 389bd23b0d..ca9f1adbba 100644--- a/invokeai/frontend/webv2/performance/browser-baseline.json+++ b/invokeai/frontend/webv2/performance/browser-baseline.json@@ -25,13 +25,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 111.79999999888241,+ "domContentLoadedMedianMs": 113.5,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 111.90000000037253,- "longestTaskMaxMs": 65,+ "loadMedianMs": 113.60000000149012,+ "longestTaskMaxMs": 68,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -41,24 +41,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 38,- "scriptRawBytes": 1630971,+ "scriptRawBytes": 1630506,"scriptRequestCount": 34,- "totalRawBytes": 1815107+ "totalRawBytes": 1814297},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 38,- "scriptRawBytes": 1647281,+ "scriptRawBytes": 1646812,"scriptRequestCount": 34,- "totalRawBytes": 1833259+ "totalRawBytes": 1832440},- "routeReadyMedianMs": 249.19999999925494,+ "routeReadyMedianMs": 248.10000000149012,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "empty"},@@ -85,13 +85,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 112.19999999925494,+ "domContentLoadedMedianMs": 112.90000000037253,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 112.29999999888241,- "longestTaskMaxMs": 69,+ "loadMedianMs": 113,+ "longestTaskMaxMs": 66,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -101,24 +101,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 38,- "scriptRawBytes": 1630971,+ "scriptRawBytes": 1630506,"scriptRequestCount": 34,- "totalRawBytes": 1815107+ "totalRawBytes": 1814297},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 38,- "scriptRawBytes": 1647281,+ "scriptRawBytes": 1646812,"scriptRequestCount": 34,- "totalRawBytes": 1833259+ "totalRawBytes": 1832440},- "routeReadyMedianMs": 264.19999999925494,+ "routeReadyMedianMs": 267.40000000037253,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "representative"},@@ -145,15 +145,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 109.70000000111759,+ "domContentLoadedMedianMs": 111.30000000074506,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 109.90000000037253,- "longestTaskMaxMs": 95,+ "loadMedianMs": 111.40000000037253,+ "longestTaskMaxMs": 94,"owner": "workbench",- "projectSwitchMedianMs": 35.59999999962747,+ "projectSwitchMedianMs": 31.09999999962747,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -161,24 +161,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 115,- "scriptRawBytes": 3262164,+ "scriptRawBytes": 3261694,"scriptRequestCount": 110,- "totalRawBytes": 3602676+ "totalRawBytes": 3601861},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 115,- "scriptRawBytes": 3294786,+ "scriptRawBytes": 3294311,"scriptRequestCount": 110,- "totalRawBytes": 3638703+ "totalRawBytes": 3637880},- "routeReadyMedianMs": 647.2999999988824,+ "routeReadyMedianMs": 646.5,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -205,15 +205,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 112.09999999962747,+ "domContentLoadedMedianMs": 113.70000000111759,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 112.19999999925494,- "longestTaskMaxMs": 168,+ "loadMedianMs": 113.80000000074506,+ "longestTaskMaxMs": 180,"owner": "workbench",- "projectSwitchMedianMs": 67,+ "projectSwitchMedianMs": 68,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -221,24 +221,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 115,- "scriptRawBytes": 3262164,+ "scriptRawBytes": 3261694,"scriptRequestCount": 110,- "totalRawBytes": 3602676+ "totalRawBytes": 3601861},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 115,- "scriptRawBytes": 3294786,+ "scriptRawBytes": 3294311,"scriptRequestCount": 110,- "totalRawBytes": 3638703+ "totalRawBytes": 3637880},- "routeReadyMedianMs": 419.5,+ "routeReadyMedianMs": 424.7000000011176,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -247,31 +247,31 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 254285,+ "largestAssetRawBytes": 251489,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 407075,+ "scriptRawBytes": 407671,"scriptRequestCount": 7,- "totalRawBytes": 407075+ "totalRawBytes": 407671},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 256828,+ "largestAssetRawBytes": 254004,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 411146,+ "scriptRawBytes": 411748,"scriptRequestCount": 7,- "totalRawBytes": 411146+ "totalRawBytes": 411748},- "domContentLoadedMedianMs": 112.59999999962747,+ "domContentLoadedMedianMs": 112.5,"id": "editor-canvas",- "layoutAckMedianMs": 2.299999998882413,- "layoutReturnSwitchMedianMs": 52.100000001490116,- "layoutSwitchMedianMs": 77.59999999962747,+ "layoutAckMedianMs": 2.099999999627471,+ "layoutReturnSwitchMedianMs": 50.90000000037253,+ "layoutSwitchMedianMs": 88.59999999962747,"loadMedianMs": 112.59999999962747,- "longestTaskMaxMs": 125,+ "longestTaskMaxMs": 115,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -281,24 +281,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 122,- "scriptRawBytes": 3669239,+ "scriptRawBytes": 3669365,"scriptRequestCount": 117,- "totalRawBytes": 4009751+ "totalRawBytes": 4009532},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 122,- "scriptRawBytes": 3705932,+ "scriptRawBytes": 3706059,"scriptRequestCount": 117,- "totalRawBytes": 4049849+ "totalRawBytes": 4049628},- "routeReadyMedianMs": 1019,+ "routeReadyMedianMs": 1018,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "empty"},@@ -307,31 +307,31 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 254285,+ "largestAssetRawBytes": 251489,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 407075,+ "scriptRawBytes": 407671,"scriptRequestCount": 7,- "totalRawBytes": 407075+ "totalRawBytes": 407671},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 256828,+ "largestAssetRawBytes": 254004,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 411146,+ "scriptRawBytes": 411748,"scriptRequestCount": 7,- "totalRawBytes": 411146+ "totalRawBytes": 411748},- "domContentLoadedMedianMs": 112.29999999888241,+ "domContentLoadedMedianMs": 111.09999999962747,"id": "editor-canvas",- "layoutAckMedianMs": 2.300000000745058,- "layoutReturnSwitchMedianMs": 44.59999999962747,- "layoutSwitchMedianMs": 80.70000000111759,- "loadMedianMs": 112.40000000037253,- "longestTaskMaxMs": 183,+ "layoutAckMedianMs": 2.5,+ "layoutReturnSwitchMedianMs": 40.59999999962747,+ "layoutSwitchMedianMs": 84.70000000111759,+ "loadMedianMs": 111.09999999962747,+ "longestTaskMaxMs": 182,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -341,24 +341,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 122,- "scriptRawBytes": 3669239,+ "scriptRawBytes": 3669365,"scriptRequestCount": 117,- "totalRawBytes": 4009751+ "totalRawBytes": 4009532},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 122,- "scriptRawBytes": 3705932,+ "scriptRawBytes": 3706059,"scriptRequestCount": 117,- "totalRawBytes": 4049849+ "totalRawBytes": 4049628},- "routeReadyMedianMs": 1108.9000000003725,+ "routeReadyMedianMs": 1090.2999999988824,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "representative"},@@ -385,13 +385,13 @@"scriptRequestCount": 6,"totalRawBytes": 383457},- "domContentLoadedMedianMs": 114.19999999925494,+ "domContentLoadedMedianMs": 112.09999999962747,"id": "editor-workflow",- "layoutAckMedianMs": 2.199999999254942,- "layoutReturnSwitchMedianMs": 31.800000000745058,- "layoutSwitchMedianMs": 88.09999999962747,- "loadMedianMs": 114.40000000037253,- "longestTaskMaxMs": 96,+ "layoutAckMedianMs": 2.300000000745058,+ "layoutReturnSwitchMedianMs": 30.90000000037253,+ "layoutSwitchMedianMs": 86.09999999962747,+ "loadMedianMs": 112.19999999925494,+ "longestTaskMaxMs": 89,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -401,24 +401,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 122,- "scriptRawBytes": 3626411,+ "scriptRawBytes": 3625941,"scriptRequestCount": 116,- "totalRawBytes": 3982336+ "totalRawBytes": 3981521},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 122,- "scriptRawBytes": 3662676,+ "scriptRawBytes": 3662201,"scriptRequestCount": 116,- "totalRawBytes": 4022160+ "totalRawBytes": 4021337},- "routeReadyMedianMs": 1042.8999999985099,+ "routeReadyMedianMs": 1009.0999999996275,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "empty"},@@ -445,13 +445,13 @@"scriptRequestCount": 6,"totalRawBytes": 383457},- "domContentLoadedMedianMs": 115.90000000037253,+ "domContentLoadedMedianMs": 114.59999999962747,"id": "editor-workflow",- "layoutAckMedianMs": 2.400000000372529,- "layoutReturnSwitchMedianMs": 38.90000000037253,- "layoutSwitchMedianMs": 124.29999999888241,- "loadMedianMs": 116.09999999962747,- "longestTaskMaxMs": 327,+ "layoutAckMedianMs": 2.5,+ "layoutReturnSwitchMedianMs": 38.59999999962747,+ "layoutSwitchMedianMs": 122.80000000074506,+ "loadMedianMs": 114.69999999925494,+ "longestTaskMaxMs": 345,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -461,24 +461,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 122,- "scriptRawBytes": 3626411,+ "scriptRawBytes": 3625941,"scriptRequestCount": 116,- "totalRawBytes": 3982336+ "totalRawBytes": 3981521},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 122,- "scriptRawBytes": 3662676,+ "scriptRawBytes": 3662201,"scriptRequestCount": 116,- "totalRawBytes": 4022160+ "totalRawBytes": 4021337},- "routeReadyMedianMs": 1156.199999999255,+ "routeReadyMedianMs": 1133.7000000011176,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "representative"},@@ -505,13 +505,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 109.59999999962747,+ "domContentLoadedMedianMs": 109.80000000074506,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 26,- "loadMedianMs": 109.79999999888241,- "longestTaskMaxMs": 94,+ "layoutSwitchMedianMs": 25.90000000037253,+ "loadMedianMs": 109.90000000037253,+ "longestTaskMaxMs": 93,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -521,24 +521,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 115,- "scriptRawBytes": 3262164,+ "scriptRawBytes": 3261694,"scriptRequestCount": 110,- "totalRawBytes": 3602676+ "totalRawBytes": 3601861},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 115,- "scriptRawBytes": 3294786,+ "scriptRawBytes": 3294311,"scriptRequestCount": 110,- "totalRawBytes": 3638703+ "totalRawBytes": 3637880},- "routeReadyMedianMs": 1217.5999999996275,+ "routeReadyMedianMs": 1240.300000000745,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -565,13 +565,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 113.10000000149012,+ "domContentLoadedMedianMs": 113.40000000037253,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 80.20000000111759,- "loadMedianMs": 113.20000000111759,- "longestTaskMaxMs": 170,+ "layoutSwitchMedianMs": 84,+ "loadMedianMs": 113.5,+ "longestTaskMaxMs": 172,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -581,24 +581,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 158313,+ "otherRawBytes": 157968,"requestCount": 115,- "scriptRawBytes": 3262164,+ "scriptRawBytes": 3261694,"scriptRequestCount": 110,- "totalRawBytes": 3602676+ "totalRawBytes": 3601861},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159897,+ "otherRawBytes": 159548,"requestCount": 115,- "scriptRawBytes": 3294786,+ "scriptRawBytes": 3294311,"scriptRequestCount": 110,- "totalRawBytes": 3638703+ "totalRawBytes": 3637880},- "routeReadyMedianMs": 1402,+ "routeReadyMedianMs": 1413.300000000745,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"}@@ -2847,11 +2847,11 @@"source:src/workbench/widgets/layers/ControlLayerSettings.tsx","source:src/workbench/widgets/layers/ControlLayerWarningIcon.tsx","source:src/workbench/widgets/layers/InpaintMaskSettings.tsx",+ "source:src/workbench/widgets/layers/LayerBlendRow.tsx","source:src/workbench/widgets/layers/LayerContextMenu.tsx","source:src/workbench/widgets/layers/LayerFilterControls.tsx","source:src/workbench/widgets/layers/LayerFilterOperationButton.tsx","source:src/workbench/widgets/layers/LayerGroupContextMenu.tsx",- "source:src/workbench/widgets/layers/LayerMultiSelectionActions.tsx","source:src/workbench/widgets/layers/LayerRow.tsx","source:src/workbench/widgets/layers/LayerStackHeader.tsx","source:src/workbench/widgets/layers/LayerStackMenu.tsx",@@ -2901,6 +2901,7 @@"source:src/workbench/widgets/layers/runLayerWorkflow.ts","source:src/workbench/widgets/layers/selectedModel.ts","source:src/workbench/widgets/layers/useAddLayer.ts",+ "source:src/workbench/widgets/layers/useLayerSelectionCommands.ts","source:src/workbench/widgets/layers/useLayerStackActions.ts","source:src/workbench/widgets/layers/useSelectedMainModel.ts","source:src/workbench/widgets/layers/useSelectedModelBase.ts",diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex f7d3939cb7..b66f13f77c 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -2535,12 +2535,10 @@"disableAutoNegative": "Disable auto-negative","disableTransparencyEffect": "Disable transparent preview","disabled": "Enable the layer before using this action.",- "disableSelected": "Disable selected layers","duplicate": "Duplicate layer","duplicateSelected": "Duplicate selected layers","empty": "This layer has no content.","enableAutoNegative": "Enable auto-negative",- "enableSelected": "Enable selected layers","enableTransparencyEffect": "Enable transparent preview","exclude": "Exclude layer below","extractMaskedArea": "Extract masked area",@@ -2550,16 +2548,12 @@"intersect": "Intersect with layer below","mergeSelected": "Merge selected layers","lock": "Lock layer",- "lockSelected": "Lock selected layers",+ "lockSelected": "Lock selected","locked": "Unlock the layer before using this action.","mergeDown": "Merge down","missing": "The layer no longer exists.","moveBackward": "Move backward","moveForward": "Move forward",- "moveSelectedBackward": "Move selected layers backward",- "moveSelectedForward": "Move selected layers forward",- "moveSelectedToBack": "Move selected layers to back",- "moveSelectedToFront": "Move selected layers to front","moveToBack": "Move to back","moveToFront": "Move to front","notReady": "The layer content is still loading. Try again shortly.",@@ -2570,8 +2564,6 @@"runWorkflow": "Run workflow","saveLayerToAssets": "Save layer to assets","select": "Select {{name}}",- "selectedCount_one": "{{count}} layer selected",- "selectedCount_other": "{{count}} layers selected","selectObject": "Select object","show": "Show layer","showOnCanvas": "Show on canvas",@@ -2583,11 +2575,10 @@"transform": "Transform","unsupported": "This action is not supported for this layer.","unlock": "Unlock layer",- "unlockSelected": "Unlock selected layers",+ "unlockSelected": "Unlock selected","group": "Group layers","groupSelected": "Group selected layers","ungroup": "Ungroup",- "ungroupSelected": "Ungroup selected groups","newGroup": "New group","expandGroup": "Expand group","collapseGroup": "Collapse group",@@ -2596,7 +2587,17 @@"outdent": "Move out of the group","groupLocked": "Locked by a group","groupDisabled": "Disabled by a group",- "groupHidden": "Hidden by a group"+ "groupHidden": "Hidden by a group",+ "duplicateCount_one": "Duplicate layer",+ "duplicateCount_other": "Duplicate {{count}} layers",+ "groupCount_one": "Group layer",+ "groupCount_other": "Group {{count}} layers",+ "deleteCount_one": "Delete layer",+ "deleteCount_other": "Delete {{count}} layers",+ "hideSelected": "Hide selected",+ "showSelected": "Show selected",+ "hideSelectedOnCanvas": "Hide selected on canvas",+ "showSelectedOnCanvas": "Show selected on canvas"},"control": {"apply": "Apply",diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.test.tssimilarity index 81%rename from invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.test.tsrename to invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.test.tsindex db639f0088..bdcf8f1f90 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.test.ts@@ -1,9 +1,9 @@import { createEmptyPaintLayer } from '@workbench/widgets/layers/layerOps';import { describe, expect, it } from 'vitest';-import { isLayerEditingDisabled } from './LayerSection';+import { isLayerEditingDisabled } from './LayerBlendRow';-describe('LayerSection editing state', () => {+describe('LayerBlendRow editing state', () => {it('disables layer controls without a selection or while engine editing is locked', () => {const layer = createEmptyPaintLayer('Layer', 'layer');expect(isLayerEditingDisabled(null, false)).toBe(true);diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.tsxnew file mode 100644index 0000000000..617721f255--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.tsx@@ -0,0 +1,301 @@+import type { NumberInput as ChakraNumberInput, SelectValueChangeDetails } from '@chakra-ui/react';+import type {+ CanvasBlendMode,+ CanvasDocumentContractV3,+ CanvasLayerContract,+ CanvasMaskFillContract,+} from '@workbench/canvas-engine/api';+import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';++import { Box, createListCollection, Flex, HStack, NumberInput } from '@chakra-ui/react';+import { ColorPicker, Field, Select } from '@platform/ui';+import { getDocumentLayer } from '@workbench/canvas-engine/api';+import { useCanvasDocumentEditingLocked } from '@workbench/widgets/canvas/engineStoreHooks';+import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';+import { applyStructuralPreview, CANVAS_BLEND_MODES } from '@workbench/widgets/layers/layerOps';+import { useActiveProjectSelector } from '@workbench/WorkbenchContext';+import { useCallback, useMemo, useRef } from 'react';+import { useTranslation } from 'react-i18next';++type LayerBlendRowEngine = Pick<CanvasEngineHandle, 'document' | 'exports' | 'interaction' | 'layers' | 'projectId'>;++const SELECT_POSITIONING = { placement: 'bottom-start', sameWidth: true } as const;++const clamp01 = (value: number): number => Math.min(1, Math.max(0, value));++/** A mask layer whose fill colour the row's swatch edits (inpaint mask / region). */+type MaskLayer = Extract<CanvasLayerContract, { type: 'inpaint_mask' | 'regional_guidance' }>;++const isMaskLayer = (layer: CanvasLayerContract | null): layer is MaskLayer =>+ layer !== null && (layer.type === 'inpaint_mask' || layer.type === 'regional_guidance');++// Reference equality is exact: the document index hands back the same node+// object until the layer itself changes.+const selectSelectedLayer = (project: {+ canvas: { document: Pick<CanvasDocumentContractV3, 'stacks' | 'selectedLayerId'> };+}): CanvasLayerContract | null => getDocumentLayer(project.canvas.document, project.canvas.document.selectedLayerId);++export const isLayerEditingDisabled = (layer: CanvasLayerContract | null, editingLocked: boolean): boolean =>+ !layer || editingLocked;++/**+ * The fixed blend-mode + opacity row above the layer tree, Photoshop-style. It+ * edits the selected layer and simply disables without one — the row never+ * appears or disappears.+ */+export const LayerBlendRow = ({ engine }: { engine: LayerBlendRowEngine | null }) => {+ const layer = useActiveProjectSelector(selectSelectedLayer);+ const editingLocked = useCanvasDocumentEditingLocked(engine);++ return (+ <Flex align="center" flexShrink={0} gap="2" px="2" py="1">+ <BlendModeControl editingLocked={editingLocked} engine={engine} layer={layer} />+ <OpacityRow editingLocked={editingLocked} engine={engine} layer={layer} />+ </Flex>+ );+};++interface BlendModeOption {+ label: string;+ value: CanvasBlendMode;+}++const BlendModeControl = ({+ editingLocked,+ engine,+ layer,+}: {+ editingLocked: boolean;+ engine: LayerBlendRowEngine | null;+ layer: CanvasLayerContract | null;+}) => {+ const commitPrepared = usePreparedCommit(engine);+ const { t } = useTranslation();+ const disabled = isLayerEditingDisabled(layer, editingLocked);+ const blendMode = layer?.blendMode ?? 'normal';+ const blendCollection = useMemo(+ () =>+ createListCollection<BlendModeOption>({+ items: CANVAS_BLEND_MODES.map((mode) => ({ label: t(`widgets.layers.blendModes.${mode}`), value: mode })),+ }),+ [t]+ );+ const blendValue = useMemo(() => [blendMode], [blendMode]);++ const handleBlendChange = useCallback(+ ({ value }: SelectValueChangeDetails<BlendModeOption>) => {+ const mode = value[0] as CanvasBlendMode | undefined;+ if (!layer || !mode || mode === layer.blendMode) {+ return;+ }+ commitPrepared(t('widgets.layers.actions.blendMode'), (model) =>+ model.prepare({ id: layer.id, patch: { blendMode: mode }, type: 'patch' })+ );+ },+ [commitPrepared, layer, t]+ );++ return (+ <Field disabled={disabled} flex="1.5" label={t('widgets.layers.actions.blendMode')} orientation="horizontal">+ <Select+ aria-label={t('widgets.layers.actions.blendMode')}+ collection={blendCollection}+ disabled={disabled}+ minW="7rem"+ positioning={SELECT_POSITIONING}+ size="xs"+ value={blendValue}+ valueText={t(`widgets.layers.blendModes.${blendMode}`)}+ w="full"+ onValueChange={handleBlendChange}+ />+ </Field>+ );+};++const OpacityRow = ({+ editingLocked,+ engine,+ layer,+}: {+ editingLocked: boolean;+ engine: LayerBlendRowEngine | null;+ layer: CanvasLayerContract | null;+}) => {+ const commitPrepared = usePreparedCommit(engine);+ const { t } = useTranslation();+ // The uncommitted opacity edit: captured once per gesture. `before` is the+ // pre-gesture value (the undo target); `latest` tracks the live value because+ // React may not have re-rendered between the live dispatch and the commit+ // trigger (both can fire inside one browser event), so `layer.opacity` from the+ // render closure can be stale at commit time.+ const pendingRef = useRef<{ id: string; before: number; latest: number } | null>(null);+ const disabled = isLayerEditingDisabled(layer, editingLocked);+ const opacityPercent = useMemo(() => String(Math.round((layer?.opacity ?? 1) * 100)), [layer?.opacity]);++ // Records ONE history entry spanning the pending gesture (a spinner press,+ // an arrow-key press, or a typed value committed via Enter/blur).+ const commitPending = useCallback(() => {+ const pending = pendingRef.current;+ pendingRef.current = null;+ if (!pending || pending.before === pending.latest) {+ return;+ }+ commitPrepared(t('widgets.layers.actions.opacity'), (model) =>+ model.prepare({+ before: { opacity: pending.before },+ id: pending.id,+ patch: { opacity: pending.latest },+ type: 'patch',+ })+ );+ }, [commitPrepared, t]);++ const handleOpacityChange = useCallback(+ ({ valueAsNumber }: ChakraNumberInput.ValueChangeDetails) => {+ if (!layer || !Number.isFinite(valueAsNumber)) {+ return;+ }+ // If a pending edit belongs to a previously selected layer, flush it first+ // so its history entry is never attributed to the new layer.+ if (pendingRef.current && pendingRef.current.id !== layer.id) {+ commitPending();+ }+ const next = clamp01(valueAsNumber / 100);+ if (+ !applyStructuralPreview(engine, {+ id: layer.id,+ patch: { opacity: next },+ type: 'updateCanvasLayer',+ })+ ) {+ return;+ }+ if (pendingRef.current === null) {+ pendingRef.current = { before: layer.opacity, id: layer.id, latest: next };+ } else {+ pendingRef.current.latest = next;+ }+ },+ [commitPending, engine, layer]+ );++ // Commit per completed interaction: each spinner click (fires on release, so a+ // press-and-hold repeat is one gesture), each arrow/paging key release, Enter,+ // and blur (typed values).+ const handleInputKeyUp = useCallback(+ (event: { key: string }) => {+ if (['ArrowDown', 'ArrowUp', 'End', 'Enter', 'Home', 'PageDown', 'PageUp'].includes(event.key)) {+ commitPending();+ }+ },+ [commitPending]+ );++ // Flush a still-pending edit if the row unmounts mid-gesture (e.g. the panel+ // closes right after a spinner click) so the edit is never lost to history.+ const flushOnUnmountRef = useCallback(+ (node: HTMLDivElement | null) => {+ if (node) {+ return () => commitPending();+ }+ return undefined;+ },+ [commitPending]+ );++ return (+ <Field disabled={disabled} label={t('widgets.layers.actions.opacity')} orientation="horizontal">+ <HStack ref={flushOnUnmountRef} gap="2">+ <NumberInput.Root+ disabled={disabled}+ max={100}+ min={0}+ size="xs"+ step={1}+ value={opacityPercent}+ w="20"+ onValueChange={handleOpacityChange}+ >+ <NumberInput.Control onClick={commitPending} />+ <NumberInput.Input+ aria-label={t('widgets.layers.actions.opacity')}+ onBlur={commitPending}+ onKeyUp={handleInputKeyUp}+ />+ </NumberInput.Root>+ {isMaskLayer(layer) ? <MaskFillSwatch disabled={editingLocked} engine={engine} layer={layer} /> : null}+ </HStack>+ </Field>+ );+};++/**+ * The selected mask layer's fill-colour swatch (legacy `ActionBarFill`): a colour+ * swatch that opens the picker. Live edits during the drag are un-recorded; the+ * final colour lands as one undoable history entry, mirroring the slider pattern.+ */+const MaskFillSwatch = ({+ disabled,+ engine,+ layer,+}: {+ disabled: boolean;+ engine: LayerBlendRowEngine | null;+ layer: MaskLayer;+}) => {+ const commitPrepared = usePreparedCommit(engine);+ const { t } = useTranslation();+ const fillBeforeRef = useRef<CanvasMaskFillContract | null>(null);+ const fill = layer.mask.fill;++ const patchFill = useCallback(+ (next: CanvasMaskFillContract, before: CanvasMaskFillContract) => {+ const configFor = (value: CanvasMaskFillContract) =>+ layer.type === 'inpaint_mask'+ ? ({ layerType: 'inpaint_mask', mask: { fill: value } } as const)+ : ({ layerType: 'regional_guidance', mask: { fill: value } } as const);+ commitPrepared(t('widgets.layers.maskFill.fill'), (model) =>+ model.prepare({ before: configFor(before), config: configFor(next), id: layer.id, type: 'patch-config' })+ );+ },+ [commitPrepared, layer.id, layer.type, t]+ );++ const handleColorChange = useCallback(+ (hex: string) => {+ const next = { ...fill, color: hex };+ const config =+ layer.type === 'inpaint_mask'+ ? ({ layerType: 'inpaint_mask', mask: { fill: next } } as const)+ : ({ layerType: 'regional_guidance', mask: { fill: next } } as const);+ if (!applyStructuralPreview(engine, { config, id: layer.id, type: 'updateCanvasLayerConfig' })) {+ return;+ }+ if (fillBeforeRef.current === null) {+ fillBeforeRef.current = fill;+ }+ },+ [engine, fill, layer.id, layer.type]+ );++ const handleColorChangeEnd = useCallback(+ (hex: string) => {+ const before = fillBeforeRef.current ?? fill;+ fillBeforeRef.current = null;+ patchFill({ ...before, color: hex }, before);+ },+ [fill, patchFill]+ );++ return (+ <Box aria-disabled={disabled} inert={disabled} opacity={disabled ? 0.5 : 1}>+ <ColorPicker+ aria-label={t('widgets.layers.maskFill.color')}+ value={fill.color}+ onValueChange={handleColorChange}+ onValueChangeEnd={handleColorChangeEnd}+ />+ </Box>+ );+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsxindex 26fa94d98b..85582fb496 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx@@ -11,22 +11,32 @@ import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngiimport type { LucideIcon } from 'lucide-react';import type { ComponentProps, Dispatch, ReactNode } from 'react';-import { HStack, Icon, Menu, Portal, Text } from '@chakra-ui/react';+import { HStack, Icon, Kbd, Menu, Portal, Text } from '@chakra-ui/react';import { galleryTransfers } from '@features/gallery';import { useModelsSelector } from '@features/models';import { IconButton, MenuContent, RenameDialog, Tooltip } from '@platform/ui';import {+ canMergeSelectedRasters,+ getDocumentIndex,getDocumentLayer,getSourceContentRect,+ isGroupNode,+ isHideableLayer,isNodeHidden,+ isOverlayStack,lookupDocumentNodeState,renderableSourceOf,} from '@workbench/canvas-engine/api';import { getCanvasOperations } from '@workbench/canvas-operations/api';+import { formatHotkeyForPlatform } from '@workbench/hotkeys/keys';import { publishLayerPanelSelection, readLayerPanelState, useLayerPanelState } from '@workbench/layerPanelState';import { useNotify } from '@workbench/useNotify';import { isCanvasInteractionLocked } from '@workbench/widgets/canvas/canvasInteractionLock';-import { useCanvasDocumentEditingLocked, useLayerThumbnailVersion } from '@workbench/widgets/canvas/engineStoreHooks';+import {+ useCanvasDocumentEditingLocked,+ useCanvasRasterContentEpoch,+ useLayerThumbnailVersion,+} from '@workbench/widgets/canvas/engineStoreHooks';import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';import { useActiveProjectId, useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';import {@@ -262,17 +272,34 @@ const LayerMenu = ({const reorder = useCallback((kind: LayerStackMoveKind, label: string) => {- commitPrepared(label, (model) => model.prepare({ ids: [layer.id], kind, type: 'move' }));+ commitPrepared(label, (model) =>+ model.prepare({ ids: actionTargets({ layer, selectedIds }), kind, type: 'move' })+ );},- [commitPrepared, layer.id]+ [commitPrepared, layer, selectedIds]);const canGroup = canGroupSelection(engine?.document.model() ?? null, actionTargets({ layer, selectedIds }));+ // Un-memoized on purpose, like `canGroup`: it reads live raster content+ // (`hasExportableLayerContent`), which the content epoch re-renders for.+ useCanvasRasterContentEpoch(engine);+ const mergeModel = engine?.document.model() ?? null;+ const mergeTargets = actionTargets({ layer, selectedIds });+ const canMerge =+ !!engine &&+ !!mergeModel &&+ mergeTargets.length > 1 &&+ canMergeSelectedRasters(mergeModel.document, mergeModel.compileLeaves(), new Set(mergeTargets), (layerId) =>+ engine.exports.hasExportableLayerContent(layerId)+ );+ const canDeleteSelection = !!mergeModel && mergeModel.refusalFor({ ids: mergeTargets, type: 'remove' }) === null;const hiddenByAncestor =(lookupDocumentNodeState(document, layer.id)?.documentHidden ?? false) && !isNodeHidden(layer);const actionState = useMemo<LayerContextActionState>(() => ({+ canDeleteSelection,canGroupSelection: canGroup,+ canMergeSelection: canMerge,hiddenByAncestor,canRunWorkflow: workflowAvailability.canRunWorkflow,document,@@ -285,7 +312,9 @@ const LayerMenu = ({}),[hiddenByAncestor,+ canDeleteSelection,canGroup,+ canMerge,document,engine,hasSupportedContent,@@ -301,16 +330,10 @@ const LayerMenu = ({const getActionLabel = useCallback((id: LayerContextActionId) => {- if (id === 'duplicate') {- const panelSelection = readLayerPanelState(projectId, document.selectedLayerId);- if (panelSelection.selectedIds.includes(layer.id) && panelSelection.selectedIds.length > 1) {- return t('widgets.layers.actions.duplicateSelected');- }- }const action = actions.find((entry) => entry.id === id);- return action ? t(action.labelKey, { defaultValue: action.defaultLabel }) : id;+ return action ? t(action.labelKey, { count: action.labelCount, defaultValue: action.defaultLabel }) : id;},- [actions, document.selectedLayerId, layer.id, projectId, t]+ [actions, t]);const makeStatusError = useCallback(@@ -348,8 +371,9 @@ const LayerMenu = ({}, [commitPrepared, document.selectedLayerId, engine, layer.id, notify, projectId, t]);const handleDelete = useCallback(() => {- commitPrepared(t('widgets.layers.actions.delete'), (model) => model.prepare({ ids: [layer.id], type: 'remove' }));- }, [commitPrepared, layer.id, t]);+ const ids = actionTargets({ layer, selectedIds });+ commitPrepared(getActionLabel('delete'), (model) => model.prepare({ ids, type: 'remove' }));+ }, [commitPrepared, getActionLabel, layer, selectedIds]);const handleGroup = useCallback(() => {const ids = actionTargets({ layer, selectedIds });@@ -359,6 +383,19 @@ const LayerMenu = ({}}, [engine, layer, makeStatusError, projectId, selectedIds, t]);+ const handleMergeSelected = useCallback(() => {+ if (!engine) {+ return;+ }+ void engine.layers.mergeSelectedRasterLayers(actionTargets({ layer, selectedIds })).then((result) => {+ if (result === 'not-ready') {+ notify.error(t('widgets.layers.actions.actionFailed'), t('widgets.layers.groupActions.mergeNotReady'));+ } else if (result === 'over-budget') {+ notify.error(t('widgets.layers.actions.actionFailed'), t('widgets.layers.groupActions.mergeOverBudget'));+ }+ });+ }, [engine, layer, notify, selectedIds, t]);+const handleMerge = useCallback(() => {// Pixel work: engine-only, and not recorded on the undo history.engine?.layers.mergeLayerDown(layer.id);@@ -414,18 +451,58 @@ const LayerMenu = ({);const handleToggleVisibility = useCallback(() => {+ const targets = actionTargets({ layer, selectedIds });+ if (targets.length > 1) {+ const index = getDocumentIndex(document);+ const isEnabled = !targets.every((id) => index.byId.get(id)?.node.isEnabled ?? true);+ commitPrepared(+ t(isEnabled ? 'widgets.layers.actions.showSelected' : 'widgets.layers.actions.hideSelected'),+ (model) => model.prepare({ type: 'set-enabled', updates: targets.map((id) => ({ id, isEnabled })) })+ );+ return;+ }patchBase(t('widgets.layers.actions.toggleVisibility'), { isEnabled: !layer.isEnabled });- }, [layer.isEnabled, patchBase, t]);+ }, [commitPrepared, document, layer, patchBase, selectedIds, t]);const handleToggleHidden = useCallback(() => {+ const targets = actionTargets({ layer, selectedIds });+ if (targets.length > 1) {+ const index = getDocumentIndex(document);+ const nodes = targets.flatMap((id) => {+ const entry = index.byId.get(id);+ if (!entry) {+ return [];+ }+ // Mirrors the model: overlay-stack groups can hide; leaves ask isHideableLayer.+ return (isGroupNode(entry.node) ? isOverlayStack(entry.stack) : isHideableLayer(entry.node))+ ? [entry.node]+ : [];+ });+ const isHidden = !nodes.every((node) => isNodeHidden(node));+ commitPrepared(+ t(isHidden ? 'widgets.layers.actions.hideSelectedOnCanvas' : 'widgets.layers.actions.showSelectedOnCanvas'),+ (model) => model.prepare({ type: 'set-hidden', updates: nodes.map((node) => ({ id: node.id, isHidden })) })+ );+ return;+ }commitPrepared(t('widgets.layers.actions.toggleHidden'), (model) =>model.prepare({ type: 'set-hidden', updates: [{ id: layer.id, isHidden: !isNodeHidden(layer) }] }));- }, [commitPrepared, layer, t]);+ }, [commitPrepared, document, layer, selectedIds, t]);const handleToggleLock = useCallback(() => {+ const targets = actionTargets({ layer, selectedIds });+ if (targets.length > 1) {+ const index = getDocumentIndex(document);+ const isLocked = !targets.every((id) => index.byId.get(id)?.node.isLocked ?? false);+ commitPrepared(+ t(isLocked ? 'widgets.layers.actions.lockSelected' : 'widgets.layers.actions.unlockSelected'),+ (model) => model.prepare({ type: 'set-locked', updates: targets.map((id) => ({ id, isLocked })) })+ );+ return;+ }patchBase(t('widgets.layers.actions.toggleLock'), { isLocked: !layer.isLocked });- }, [layer.isLocked, patchBase, t]);+ }, [commitPrepared, document, layer, patchBase, selectedIds, t]);const openRename = useCallback(() => setDialogKind('rename'), [setDialogKind]);const closeDialog = useCallback(() => setDialogKind(null), [setDialogKind]);@@ -661,6 +738,7 @@ const LayerMenu = ({group: handleGroup,fitToBbox: handleFitToBbox,mergeDown: handleMerge,+ mergeSelected: handleMergeSelected,openProperties: handleOpenProperties,openRename,openRunWorkflow,@@ -687,6 +765,7 @@ const LayerMenu = ({handleExtractMaskedArea,handleFitToBbox,handleGroup,+ handleMergeSelected,handleLayerConfigAction,handleMerge,handleOpenProperties,@@ -1057,7 +1136,7 @@ const LayerMenuIconActionItem = ({}: {action: LayerContextAction;runAction: (action: LayerContextAction) => void;- t: (key: string, options: { defaultValue: string }) => string;+ t: (key: string, options: { count?: number; defaultValue: string }) => string;}) => {const onSelect = useCallback(() => runAction(action), [action, runAction]);@@ -1065,7 +1144,7 @@ const LayerMenuIconActionItem = ({<LayerMenuIconItemdisabled={action.isDisabled}icon={action.icon}- label={t(action.labelKey, { defaultValue: action.defaultLabel })}+ label={t(action.labelKey, { count: action.labelCount, defaultValue: action.defaultLabel })}value={action.id}onSelect={onSelect}/>@@ -1079,7 +1158,7 @@ const LayerMenuActionItem = ({}: {action: LayerContextAction;runAction: (action: LayerContextAction) => void;- t: (key: string, options: { defaultValue: string }) => string;+ t: (key: string, options: { count?: number; defaultValue: string }) => string;}) => {const onSelect = useCallback(() => runAction(action), [action, runAction]);@@ -1087,8 +1166,9 @@ const LayerMenuActionItem = ({<LayerMenuItemcolor={action.tone === 'danger' ? 'fg.error' : undefined}disabled={action.isDisabled}+ hint={action.hint}icon={action.icon}- label={t(action.labelKey, { defaultValue: action.defaultLabel })}+ label={t(action.labelKey, { count: action.labelCount, defaultValue: action.defaultLabel })}value={action.id}onSelect={onSelect}/>@@ -1098,6 +1178,7 @@ const LayerMenuActionItem = ({const LayerMenuItem = ({color,disabled,+ hint,icon,label,onSelect,@@ -1105,6 +1186,8 @@ const LayerMenuItem = ({}: {color?: string;disabled?: boolean;+ /** A raw hotkey string, formatted per platform and shown as trailing keycaps. */+ hint?: string;icon: LucideIcon;label: string;onSelect: () => void;@@ -1116,6 +1199,15 @@ const LayerMenuItem = ({<Text flex="1" fontSize="xs">{label}</Text>+ {hint ? (+ <HStack flexShrink={0} gap="0.5">+ {formatHotkeyForPlatform(hint).map((part) => (+ <Kbd key={part} size="sm" textTransform="lowercase">+ {part}+ </Kbd>+ ))}+ </HStack>+ ) : null}</HStack></Menu.Item>);diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerMultiSelectionActions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerMultiSelectionActions.tsxdeleted file mode 100644index 2e5f9193ae..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerMultiSelectionActions.tsx+++ /dev/null@@ -1,354 +0,0 @@-import type { CanvasDocumentContractV3, LayerStackMoveKind } from '@workbench/canvas-engine/api';-import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';-import type { KeyboardEvent } from 'react';--import { HStack, Text } from '@chakra-ui/react';-import { toaster } from '@platform/ui';-import { IconButton } from '@platform/ui/Button';-import { Tooltip } from '@platform/ui/Tooltip';-import { canMergeSelectedRasters, getDocumentIndex } from '@workbench/canvas-engine/api';-import { publishLayerPanelSelection } from '@workbench/layerPanelState';-import { useCanvasRasterContentEpoch } from '@workbench/widgets/canvas/engineStoreHooks';-import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';-import {- ArrowDownIcon,- ArrowUpIcon,- ChevronsDownIcon,- ChevronsUpIcon,- CopyIcon,- EyeIcon,- EyeOffIcon,- FolderMinusIcon,- FolderPlusIcon,- LockIcon,- LockOpenIcon,- MergeIcon,- Trash2Icon,-} from 'lucide-react';-import { useCallback, useMemo, useState } from 'react';-import { useTranslation } from 'react-i18next';--import { groupLayers, ungroupLayers } from './layerGroupCommands';--type MultiSelectionEngine = Pick<CanvasEngineHandle, 'document' | 'exports' | 'interaction' | 'layers'>;-const BULK_TOOLTIP_POSITIONING = { placement: 'top' } as const;--interface LayerMultiSelectionActionsProps {- document: CanvasDocumentContractV3;- editingLocked: boolean;- engine: MultiSelectionEngine | null;- projectId: string;- selectedIds: readonly string[];-}--export const LayerMultiSelectionActions = ({- document,- editingLocked,- engine,- projectId,- selectedIds,-}: LayerMultiSelectionActionsProps) => {- const commitPrepared = usePreparedCommit(engine);- const { t } = useTranslation();- useCanvasRasterContentEpoch(engine);- const selected = useMemo(() => {- const index = getDocumentIndex(document);- return selectedIds.map((id) => index.byId.get(id)).filter((entry) => entry !== undefined);- }, [document, selectedIds]);- const allEnabled = selected.every((entry) => entry.node.isEnabled);- const allLocked = selected.every((entry) => entry.node.isLocked);- const model = engine?.document.model() ?? null;- const none = selected.length === 0;- // Enablement comes from the same authority that will run the command, so nothing here can refuse later.- const canGroup =- !none && !!model && model.refusalFor({ groupId: '\0probe', ids: selectedIds, name: '', type: 'group' }) === null;- const canUngroup = !none && !!model && model.refusalFor({ ids: selectedIds, type: 'ungroup' }) === null;- const canDelete = !none && !!model && model.refusalFor({ ids: selectedIds, type: 'remove' }) === null;- const canMergeSelected =- !!engine &&- !!model &&- canMergeSelectedRasters(model.document, model.compileLeaves(), new Set(selectedIds), (layerId) =>- engine.exports.hasExportableLayerContent(layerId)- );-- const duplicateSelected = useCallback(async () => {- try {- const result = await engine?.layers.duplicateLayers(selectedIds);- if (result?.status === 'duplicated') {- publishLayerPanelSelection({- primaryId: result.selectedLayerId,- projectId,- selectedIds: result.duplicateIds,- });- return;- }- if (result?.status === 'busy') {- return;- }- } catch {- // Reducer rejection is failure-atomic; surface the same actionable result as a refusal.- }- if (engine) {- toaster.create({ title: t('widgets.layers.actions.copyFailed'), type: 'warning' });- }- }, [engine, projectId, selectedIds, t]);-- const mergeSelected = useCallback(() => {- if (!engine) {- return;- }- void engine.layers.mergeSelectedRasterLayers(selectedIds).then((result) => {- if (result === 'not-ready') {- toaster.create({ title: t('widgets.layers.groupActions.mergeNotReady'), type: 'warning' });- } else if (result === 'over-budget') {- toaster.create({ title: t('widgets.layers.groupActions.mergeOverBudget'), type: 'warning' });- }- });- }, [engine, selectedIds, t]);-- const reorder = useCallback(- (kind: LayerStackMoveKind, label: string) => {- commitPrepared(label, (model) => model.prepare({ ids: selectedIds, kind, type: 'move' }));- },- [commitPrepared, selectedIds]- );-- const moveToFront = useCallback(- () => reorder('front', t('widgets.layers.actions.moveSelectedToFront')),- [reorder, t]- );- const moveForward = useCallback(- () => reorder('forward', t('widgets.layers.actions.moveSelectedForward')),- [reorder, t]- );- const moveBackward = useCallback(- () => reorder('backward', t('widgets.layers.actions.moveSelectedBackward')),- [reorder, t]- );- const moveToBack = useCallback(() => reorder('back', t('widgets.layers.actions.moveSelectedToBack')), [reorder, t]);-- const toggleEnabled = useCallback(() => {- const isEnabled = !allEnabled;- commitPrepared(- t(isEnabled ? 'widgets.layers.actions.enableSelected' : 'widgets.layers.actions.disableSelected'),- (model) => model.prepare({ type: 'set-enabled', updates: selectedIds.map((id) => ({ id, isEnabled })) })- );- }, [allEnabled, commitPrepared, selectedIds, t]);-- const toggleLocked = useCallback(() => {- const isLocked = !allLocked;- commitPrepared(- t(isLocked ? 'widgets.layers.actions.lockSelected' : 'widgets.layers.actions.unlockSelected'),- (model) => model.prepare({ type: 'set-locked', updates: selectedIds.map((id) => ({ id, isLocked })) })- );- }, [allLocked, commitPrepared, selectedIds, t]);-- const groupSelected = useCallback(- () => groupLayers(engine, projectId, selectedIds, t('widgets.layers.actions.groupSelected')),- [engine, projectId, selectedIds, t]- );- const ungroupSelected = useCallback(- () => ungroupLayers(engine, selectedIds, t('widgets.layers.actions.ungroupSelected')),- [engine, selectedIds, t]- );-- const deleteSelected = useCallback(() => {- commitPrepared(t('widgets.layers.actions.deleteSelected'), (model) =>- model.prepare({ ids: selectedIds, type: 'remove' })- );- }, [commitPrepared, selectedIds, t]);-- const actions = useMemo<readonly BulkAction[]>(- () => [- {- disabled: editingLocked || none,- icon: ChevronsUpIcon,- id: 'front',- label: t('widgets.layers.actions.moveSelectedToFront'),- run: moveToFront,- },- {- disabled: editingLocked || none,- icon: ArrowUpIcon,- id: 'forward',- label: t('widgets.layers.actions.moveSelectedForward'),- run: moveForward,- },- {- disabled: editingLocked || none,- icon: ArrowDownIcon,- id: 'backward',- label: t('widgets.layers.actions.moveSelectedBackward'),- run: moveBackward,- },- {- disabled: editingLocked || none,- icon: ChevronsDownIcon,- id: 'back',- label: t('widgets.layers.actions.moveSelectedToBack'),- run: moveToBack,- },- {- disabled: editingLocked || !engine || !canGroup,- icon: FolderPlusIcon,- id: 'group',- label: t('widgets.layers.actions.groupSelected'),- run: groupSelected,- },- {- disabled: editingLocked || !engine || !canUngroup,- icon: FolderMinusIcon,- id: 'ungroup',- label: t('widgets.layers.actions.ungroupSelected'),- run: ungroupSelected,- },- {- disabled: editingLocked || none,- icon: allEnabled ? EyeOffIcon : EyeIcon,- id: 'enable',- label: t(allEnabled ? 'widgets.layers.actions.disableSelected' : 'widgets.layers.actions.enableSelected'),- run: toggleEnabled,- },- {- disabled: editingLocked || none,- icon: allLocked ? LockOpenIcon : LockIcon,- id: 'lock',- label: t(allLocked ? 'widgets.layers.actions.unlockSelected' : 'widgets.layers.actions.lockSelected'),- run: toggleLocked,- },- {- disabled: editingLocked || !engine || none,- icon: CopyIcon,- id: 'duplicate',- label: t('widgets.layers.actions.duplicateSelected'),- run: duplicateSelected,- },- {- disabled: editingLocked || !engine || !canMergeSelected,- icon: MergeIcon,- id: 'merge',- label: t('widgets.layers.actions.mergeSelected'),- run: mergeSelected,- },- {- colorPalette: 'red',- disabled: editingLocked || !canDelete,- icon: Trash2Icon,- id: 'delete',- label: t('widgets.layers.actions.deleteSelected'),- run: deleteSelected,- },- ],- [- allEnabled,- allLocked,- canDelete,- canGroup,- canMergeSelected,- canUngroup,- deleteSelected,- duplicateSelected,- editingLocked,- engine,- groupSelected,- mergeSelected,- moveBackward,- moveForward,- moveToBack,- moveToFront,- none,- t,- toggleEnabled,- toggleLocked,- ungroupSelected,- ]- );- return (- <BulkActionToolbar- actions={actions}- label={t('widgets.layers.actions.selectedCount', { count: selected.length })}- />- );-};--export default LayerMultiSelectionActions;--interface BulkAction {- colorPalette?: string;- disabled: boolean;- icon: typeof ArrowUpIcon;- id: string;- label: string;- run: () => void;-}--/**- * One tab stop for the whole toolbar; arrows, Home and End move between the enabled buttons. The focus- * bookkeeping lives here so tracking it never re-runs the eligibility above.- */-const BulkActionToolbar = ({ actions, label }: { actions: readonly BulkAction[]; label: string }) => {- const [activeId, setActiveId] = useState<string | null>(null);- const enabled = actions.filter((action) => !action.disabled);- const tabStopId = enabled.some((action) => action.id === activeId) ? activeId : (enabled[0]?.id ?? null);- const onKeyDown = useCallback((event: KeyboardEvent<HTMLElement>) => {- if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) {- return;- }- const buttons = [...event.currentTarget.querySelectorAll<HTMLButtonElement>('button:not(:disabled)')];- const current = buttons.indexOf(event.target as HTMLButtonElement);- if (buttons.length === 0 || current === -1) {- return;- }- event.preventDefault();- const next =- event.key === 'Home'- ? 0- : event.key === 'End'- ? buttons.length - 1- : (current + (event.key === 'ArrowRight' ? 1 : buttons.length - 1)) % buttons.length;- buttons[next]!.focus();- }, []);- return (- <HStack aria-label={label} gap="0.5" minH="10" px="2" role="toolbar" onKeyDown={onKeyDown}>- <Text color="fg.muted" flex="1" fontSize="2xs" fontWeight="700">- {label}- </Text>- {actions.map((action) => (- <BulkActionButton- key={action.id}- action={action}- tabIndex={action.id === tabStopId ? 0 : -1}- onFocus={setActiveId}- />- ))}- </HStack>- );-};--const BulkActionButton = ({- action: { colorPalette, disabled, icon: Icon, id, label, run },- onFocus,- tabIndex,-}: {- action: BulkAction;- onFocus: (id: string) => void;- tabIndex: number;-}) => {- const handleFocus = useCallback(() => onFocus(id), [id, onFocus]);- return (- <Tooltip content={label} positioning={BULK_TOOLTIP_POSITIONING}>- <IconButton- aria-label={label}- colorPalette={colorPalette}- disabled={disabled}- size="xs"- tabIndex={tabIndex}- variant="ghost"- onClick={run}- onFocus={handleFocus}- >- <Icon />- </IconButton>- </Tooltip>- );-};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersPanelFooter.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersPanelFooter.tsxindex b97a936094..e38285a914 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersPanelFooter.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersPanelFooter.tsx@@ -1,8 +1,18 @@+import type { LucideIcon } from 'lucide-react';+import { HStack, Input, Text } from '@chakra-ui/react';+import { IconButton } from '@platform/ui/Button';+import { Tooltip } from '@platform/ui/Tooltip';+import { CopyIcon, FolderPlusIcon, Trash2Icon } from 'lucide-react';import { memo, useCallback } from 'react';import { useTranslation } from 'react-i18next';+import type { LayerSelectionCommands } from './useLayerSelectionCommands';++const ACTION_TOOLTIP_POSITIONING = { placement: 'top' } as const;+interface LayersPanelFooterProps {+ commands: LayerSelectionCommands;degraded: boolean;filter: string;groupCount: number;@@ -11,8 +21,14 @@ interface LayersPanelFooterProps {onFilterChange: (filter: string) => void;}-/** The stable footer: document summary and name filter; nothing here appears or disappears. */+/**+ * The stable footer — the panel's one action strip: name filter, document+ * summary, and the top-frequency selection verbs (duplicate, group, delete).+ * Everything else lives in the context menu; nothing here appears or+ * disappears — controls disable instead.+ */const LayersPanelFooterComponent = ({+ commands,degraded,filter,groupCount,@@ -41,8 +57,56 @@ const LayersPanelFooterComponent = ({? t('widgets.layers.footer.degraded'): `${t('widgets.layers.footer.layers', { count: leafCount })} · ${t('widgets.layers.footer.groups', { count: groupCount })} · ${t('widgets.layers.footer.selected', { count: selectedCount })}`}</Text>+ <HStack gap="0.5">+ <FooterAction+ disabled={!commands.canDuplicate}+ icon={CopyIcon}+ label={t('widgets.layers.actions.duplicateSelected')}+ onRun={commands.duplicateSelected}+ />+ <FooterAction+ disabled={!commands.canGroup}+ icon={FolderPlusIcon}+ label={t('widgets.layers.actions.groupSelected')}+ onRun={commands.groupSelected}+ />+ <FooterAction+ colorPalette="red"+ disabled={!commands.canDelete}+ icon={Trash2Icon}+ label={t('widgets.layers.actions.deleteSelected')}+ onRun={commands.deleteSelected}+ />+ </HStack></HStack>);};+const FooterAction = ({+ colorPalette,+ disabled,+ icon: ActionIcon,+ label,+ onRun,+}: {+ colorPalette?: string;+ disabled: boolean;+ icon: LucideIcon;+ label: string;+ onRun: () => void;+}) => (+ <Tooltip content={label} positioning={ACTION_TOOLTIP_POSITIONING}>+ <IconButton+ aria-label={label}+ colorPalette={colorPalette}+ disabled={disabled}+ size="2xs"+ variant="ghost"+ onClick={onRun}+ >+ <ActionIcon />+ </IconButton>+ </Tooltip>+);+export const LayersPanelFooter = memo(LayersPanelFooterComponent);diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsxindex 585c81d39f..5c5d3a2a3c 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx@@ -14,7 +14,7 @@ import { useTranslation } from 'react-i18next';import type { LayerSurfaceAnchor } from './layerRowCommands';import type { LayerColorPaneLayout, LayerEditorPaneLayout, LayerTreeTabId } from './panes/editorPaneLayout';-import { LayerMultiSelectionActions } from './LayerMultiSelectionActions';+import { LayerBlendRow } from './LayerBlendRow';import { LAYER_PANEL_DEGRADE_THRESHOLD } from './layerPanelRows';import { useCurrentLayerPropertiesRequest } from './layerPropertiesRequestStore';import { anchorFromPoint } from './layerRowCommands';@@ -31,13 +31,14 @@ import {} from './panes/editorPaneLayout';import { HistoryPane } from './panes/HistoryPane';import { LAYER_TREE_PANEL_ID, LayerColorPane, LayerEditorPanes, LayerTreeStrip } from './panes/LayerEditorPanes';+import { useLayerSelectionCommands } from './useLayerSelectionCommands';/*** The layers panel: the Color pane at the top, then the flexible middle region tabbed between- * the virtualized tree of the four stacks (with its selection toolbar and footer) and the edit- * history, and the editor panes (Properties, Transform, Overview) at the bottom — the selected- * layer's own editors live in the Properties pane. Regions keep their geometry; their controls- * disable instead of appearing and disappearing.+ * the layers view (blend/opacity row, the virtualized tree of the four stacks, and the footer+ * action strip) and the edit history, with the editor panes (Properties, Transform, Overview)+ * at the bottom — the selected layer's other editors live in the Properties pane. Regions keep+ * their geometry; their controls disable instead of appearing and disappearing.*/export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {const { t } = useTranslation();@@ -66,6 +67,7 @@ export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {[stacks]);+ const selectionCommands = useLayerSelectionCommands(engine, projectId, panel.selectedIds, editingLocked);const handleFilter = useCallback((filter: string) => setLayerPanelFilter(projectId, selectedLayerId, filter),[projectId, selectedLayerId]@@ -128,8 +130,9 @@ export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {direction="column"flex="1"id={LAYER_TREE_PANEL_ID}- // The toolbar (40px) + tree floor (128px) + footer (40px); anything- // less lets the unshrinkable rows paint under the editor panes.+ // The blend row (32px control + 8px padding) + tree floor (128px) ++ // footer (40px); anything less lets the unshrinkable rows paint under+ // the editor panes.minH="13rem"overflow="hidden"role="tabpanel"@@ -138,13 +141,7 @@ export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {<HistoryPane />) : (<>- <LayerMultiSelectionActions- document={document}- editingLocked={editingLocked}- engine={engine}- projectId={projectId}- selectedIds={panel.selectedIds}- />+ <LayerBlendRow engine={engine} />{nodeCount === 0 ? (<Flexalign="center"@@ -183,6 +180,7 @@ export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {</Flex>)}<LayersPanelFooter+ commands={selectionCommands}degraded={degraded}filter={panel.filter}groupCount={counts.groups}diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.tsindex 231c4f05f6..953e9978d7 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts@@ -79,6 +79,8 @@ const makeState = (hasWorkflowBindings: true,interactionLocked: false,canGroupSelection: true,+ canDeleteSelection: true,+ canMergeSelection: true,layer,selectedIds: [layer.id],...overrides,@@ -97,6 +99,7 @@ const makeEffects = (): LayerContextActionEffects => ({fitToBbox: vi.fn(),group: vi.fn(),mergeDown: vi.fn(),+ mergeSelected: vi.fn(),openProperties: vi.fn(),openRename: vi.fn(),openRunWorkflow: vi.fn(),@@ -425,6 +428,12 @@ describe('getLayerContextActions', () => {const regional = createRegionalGuidanceLayer('Interaction region', 0, 'interaction-region');const contexts = [makeState(raster, { document: rasterDocument, interactionLocked: true }),+ // A multi-selection context so the selection-only verbs are visible.+ makeState(raster, {+ document: rasterDocument,+ interactionLocked: true,+ selectedIds: [raster.id, 'interaction-raster-b'],+ }),makeState(nonEmptyControlLayer, { interactionLocked: true }),makeState(inpaint, { interactionLocked: true }),makeState(regional, { interactionLocked: true }),@@ -471,6 +480,7 @@ describe('getLayerContextActions', () => {'inpaint-noise','inpaint-denoise-limit','merge-down',+ 'merge-selected','toggle-visibility','toggle-hidden','toggle-lock',@@ -491,7 +501,10 @@ describe('getLayerContextActions', () => {it('disables locked-layer mutations but keeps toggle lock enabled', () => {const lockedRaster = { ...rasterLayer, isLocked: true };const below = paintLayer('below-locked-raster');- const actions = getLayerContextActions(makeState(lockedRaster, { document: makeDocument([lockedRaster, below]) }));+ // The menu's model probe refuses removing a locked selection.+ const actions = getLayerContextActions(+ makeState(lockedRaster, { canDeleteSelection: false, document: makeDocument([lockedRaster, below]) })+ );for (const id of ['fit-to-bbox',diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.tsindex 8ed46bb3e1..879d153644 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts@@ -39,6 +39,7 @@ import {import { canConvertRasterControl, canMergeLayerDown } from './layerOps';export type LayerContextActionId =+ | 'merge-selected'| 'move-to-front'| 'move-forward'| 'move-backward'@@ -98,6 +99,10 @@ export interface LayerContextActionState {selectedIds: readonly string[];/** The model's answer for grouping `actionTargets`, asked by the menu that owns the engine. */canGroupSelection: boolean;+ /** The model's answer for removing `actionTargets`, asked the same way. */+ canDeleteSelection: boolean;+ /** Whether the whole multi-selection can merge into one raster, asked the same way. */+ canMergeSelection: boolean;/** A group above the layer hides it on the canvas; the layer's own flag cannot override that. */hiddenByAncestor: boolean;}@@ -105,6 +110,7 @@ export interface LayerContextActionState {export interface LayerContextActionEffects {reorder(kind: LayerStackMoveKind, actionId: LayerContextActionId): void;duplicate(): void;+ mergeSelected(): void;group(): void;openRename(): void;openRunWorkflow(): void;@@ -144,22 +150,28 @@ export interface LayerContextActionDefinition {order: number;supportedLayerTypes: readonly LayerType[];tone?: 'danger';+ /** A raw hotkey string (e.g. `mod+]`) shown as a trailing hint on the item. */+ hint?: string;isVisible(context: LayerContextActionState): boolean;isEnabled(context: LayerContextActionState): boolean;handler(context: LayerContextActionRuntimeContext): void | Promise<void>;getDefaultLabel?(context: LayerContextActionState): string;getLabelKey?(context: LayerContextActionState): string;+ /** Interpolated into the label's plural key; the selection size for selection verbs. */+ getLabelCount?(context: LayerContextActionState): number;}export interface LayerContextAction {id: LayerContextActionId;labelKey: string;defaultLabel: string;+ labelCount?: number;icon: LucideIcon;section: LayerContextMenuSectionId;submenu?: LayerContextSubmenuId;order: number;tone?: 'danger';+ hint?: string;isDisabled: boolean;handler(context: LayerContextActionRuntimeContext): void | Promise<void>;}@@ -186,6 +198,17 @@ const layerEntry = (context: LayerContextActionState) => getDocumentIndex(contex/** The nodes a selection-wide action applies to: the whole selection when the layer is in it. */export const actionTargets = (context: Pick<LayerContextActionState, 'layer' | 'selectedIds'>): readonly string[] =>context.selectedIds.includes(context.layer.id) ? context.selectedIds : [context.layer.id];++const targetCount = (context: LayerContextActionState): number => actionTargets(context).length;+const isMultiTarget = (context: LayerContextActionState): boolean => targetCount(context) > 1;+const targetNodes = (context: LayerContextActionState) => {+ const index = getDocumentIndex(context.document);+ return actionTargets(context).flatMap((id) => index.byId.get(id)?.node ?? []);+};+const allTargetsEnabled = (context: LayerContextActionState): boolean =>+ targetNodes(context).every((node) => node.isEnabled);+const allTargetsLocked = (context: LayerContextActionState): boolean =>+ targetNodes(context).every((node) => node.isLocked);/** Locked in its own right or by a group above it: content edits are refused either way. */const isLayerFrozen = (context: LayerContextActionState): boolean =>context.layer.isLocked || (layerEntry(context)?.ancestorsLocked ?? false);@@ -265,6 +288,7 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefinidefaultLabel: 'Move to front',handler: ({ effects }) => effects.reorder('front', 'move-to-front'),icon: ArrowUpToLineIcon,+ hint: 'mod+shift+]',id: 'move-to-front',isEnabled: canMoveForward,isVisible: alwaysVisible,@@ -278,6 +302,7 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefinidefaultLabel: 'Move forward',handler: ({ effects }) => effects.reorder('forward', 'move-forward'),icon: ArrowUpIcon,+ hint: 'mod+]',id: 'move-forward',isEnabled: canMoveForward,isVisible: alwaysVisible,@@ -291,6 +316,7 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefinidefaultLabel: 'Move backward',handler: ({ effects }) => effects.reorder('backward', 'move-backward'),icon: ArrowDownIcon,+ hint: 'mod+[',id: 'move-backward',isEnabled: canMoveBackward,isVisible: alwaysVisible,@@ -304,6 +330,7 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefinidefaultLabel: 'Move to back',handler: ({ effects }) => effects.reorder('back', 'move-to-back'),icon: ArrowDownToLineIcon,+ hint: 'mod+shift+[',id: 'move-to-back',isEnabled: canMoveBackward,isVisible: alwaysVisible,@@ -315,6 +342,10 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini},{defaultLabel: 'Duplicate',+ getDefaultLabel: (context) => (isMultiTarget(context) ? `Duplicate ${targetCount(context)} layers` : 'Duplicate'),+ getLabelCount: targetCount,+ getLabelKey: (context) =>+ isMultiTarget(context) ? 'widgets.layers.actions.duplicateCount' : 'widgets.layers.actions.duplicate',handler: ({ effects }) => effects.duplicate(),icon: CopyIcon,id: 'duplicate',@@ -327,6 +358,10 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini},{defaultLabel: 'Group layers',+ getDefaultLabel: (context) => (isMultiTarget(context) ? `Group ${targetCount(context)} layers` : 'Group layers'),+ getLabelCount: targetCount,+ getLabelKey: (context) =>+ isMultiTarget(context) ? 'widgets.layers.actions.groupCount' : 'widgets.layers.actions.group',handler: ({ effects }) => effects.group(),icon: FolderPlusIcon,id: 'group',@@ -550,6 +585,18 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefinisection: 'operations',supportedLayerTypes: ALL_LAYER_TYPES,},+ {+ defaultLabel: 'Merge selected layers',+ handler: ({ effects }) => effects.mergeSelected(),+ icon: MergeIcon,+ id: 'merge-selected',+ isEnabled: (context) => isInteractionFree(context) && context.canMergeSelection,+ isVisible: isMultiTarget,+ labelKey: 'widgets.layers.actions.mergeSelected',+ order: 1,+ section: 'operations',+ supportedLayerTypes: ALL_LAYER_TYPES,+ },{defaultLabel: 'Intersect with layer below',handler: ({ effects }) => effects.booleanMerge('intersect'),@@ -758,9 +805,23 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini},{defaultLabel: 'Toggle visibility',- getDefaultLabel: (context) => (context.layer.isEnabled ? 'Hide' : 'Show'),- getIcon: (context) => (context.layer.isEnabled ? EyeOffIcon : EyeIcon),- getLabelKey: (context) => (context.layer.isEnabled ? 'widgets.layers.actions.hide' : 'widgets.layers.actions.show'),+ getDefaultLabel: (context) =>+ isMultiTarget(context)+ ? allTargetsEnabled(context)+ ? 'Hide selected'+ : 'Show selected'+ : context.layer.isEnabled+ ? 'Hide'+ : 'Show',+ getIcon: (context) => (allTargetsEnabled(context) ? EyeOffIcon : EyeIcon),+ getLabelKey: (context) =>+ isMultiTarget(context)+ ? allTargetsEnabled(context)+ ? 'widgets.layers.actions.hideSelected'+ : 'widgets.layers.actions.showSelected'+ : context.layer.isEnabled+ ? 'widgets.layers.actions.hide'+ : 'widgets.layers.actions.show',handler: ({ effects }) => effects.toggleVisibility(),icon: EyeIcon,id: 'toggle-visibility',@@ -789,10 +850,23 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini},{defaultLabel: 'Toggle lock',- getDefaultLabel: (context) => (context.layer.isLocked ? 'Unlock' : 'Lock'),- getIcon: (context) => (context.layer.isLocked ? LockOpenIcon : LockIcon),+ getDefaultLabel: (context) =>+ isMultiTarget(context)+ ? allTargetsLocked(context)+ ? 'Unlock selected'+ : 'Lock selected'+ : context.layer.isLocked+ ? 'Unlock'+ : 'Lock',+ getIcon: (context) => (allTargetsLocked(context) ? LockOpenIcon : LockIcon),getLabelKey: (context) =>- context.layer.isLocked ? 'widgets.layers.actions.unlock' : 'widgets.layers.actions.lock',+ isMultiTarget(context)+ ? allTargetsLocked(context)+ ? 'widgets.layers.actions.unlockSelected'+ : 'widgets.layers.actions.lockSelected'+ : context.layer.isLocked+ ? 'widgets.layers.actions.unlock'+ : 'widgets.layers.actions.lock',handler: ({ effects }) => effects.toggleLock(),icon: LockIcon,id: 'toggle-lock',@@ -805,10 +879,14 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini},{defaultLabel: 'Delete',+ getDefaultLabel: (context) => (isMultiTarget(context) ? `Delete ${targetCount(context)} layers` : 'Delete'),+ getLabelCount: targetCount,+ getLabelKey: (context) =>+ isMultiTarget(context) ? 'widgets.layers.actions.deleteCount' : 'widgets.layers.actions.delete',handler: ({ effects }) => effects.delete(),icon: Trash2Icon,id: 'delete',- isEnabled: isLayerMutable,+ isEnabled: (context) => isInteractionFree(context) && context.canDeleteSelection,isVisible: alwaysVisible,labelKey: 'widgets.layers.actions.delete',order: 0,@@ -832,9 +910,11 @@ export const getLayerContextActions = (context: LayerContextActionState): LayerC).map((definition) => ({defaultLabel: definition.getDefaultLabel?.(context) ?? definition.defaultLabel,handler: definition.handler,+ hint: definition.hint,icon: definition.getIcon?.(context) ?? definition.icon,id: definition.id,isDisabled: !definition.isEnabled(context),+ labelCount: definition.getLabelCount?.(context),labelKey: definition.getLabelKey?.(context) ?? definition.labelKey,order: definition.order,section: definition.section,diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.tsindex 7050a66c91..b6db059f5b 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts@@ -49,6 +49,8 @@ const actionsFor = (layer: CanvasLayerContract, layers: readonly CanvasLayerContinteractionLocked: false,selectedIds: [layer.id],canGroupSelection: true,+ canDeleteSelection: true,+ canMergeSelection: true,layer,});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsxindex 0b76247c8b..40e84151a3 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx@@ -1,26 +1,17 @@-import type { NumberInput as ChakraNumberInput, SelectValueChangeDetails } from '@chakra-ui/react';-import type {- CanvasBlendMode,- CanvasDocumentContractV3,- CanvasLayerContract,- CanvasMaskFillContract,-} from '@workbench/canvas-engine/api';+import type { CanvasDocumentContractV3, CanvasLayerContract } from '@workbench/canvas-engine/api';import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';-import { Box, createListCollection, Flex, HStack, NumberInput, Stack, Switch, Text } from '@chakra-ui/react';-import { ColorPicker, Field, Select } from '@platform/ui';+import { Stack, Switch, Text } from '@chakra-ui/react';import { getDocumentLayer } from '@workbench/canvas-engine/api';-import { useCanvasDocumentEditingLocked } from '@workbench/widgets/canvas/engineStoreHooks';import { useCanvasEngine } from '@workbench/widgets/canvas/useCanvasEngine';import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';import { AdjustmentsPopover } from '@workbench/widgets/layers/AdjustmentsPopover';import { ControlLayerSettings } from '@workbench/widgets/layers/ControlLayerSettings';import { InpaintMaskSettings } from '@workbench/widgets/layers/InpaintMaskSettings';-import { applyStructuralPreview, CANVAS_BLEND_MODES } from '@workbench/widgets/layers/layerOps';import { RasterLayerFilterSection } from '@workbench/widgets/layers/RasterLayerFilterSection';import { RegionalGuidanceSettings } from '@workbench/widgets/layers/RegionalGuidanceSettings';import { useActiveProjectSelector } from '@workbench/WorkbenchContext';-import { useCallback, useMemo, useRef } from 'react';+import { useCallback } from 'react';import { useTranslation } from 'react-i18next';import { GroupSelectedNotice } from './GroupSelectedNotice';@@ -28,16 +19,6 @@ import { PropertiesSection } from './PropertiesSection';type LayerSectionEngine = Pick<CanvasEngineHandle, 'document' | 'exports' | 'interaction' | 'layers' | 'projectId'>;-const SELECT_POSITIONING = { placement: 'bottom-start', sameWidth: true } as const;--const clamp01 = (value: number): number => Math.min(1, Math.max(0, value));--/** A mask layer whose fill colour the header swatch edits (inpaint mask / region). */-type MaskLayer = Extract<CanvasLayerContract, { type: 'inpaint_mask' | 'regional_guidance' }>;--const isMaskLayer = (layer: CanvasLayerContract | null): layer is MaskLayer =>- layer !== null && (layer.type === 'inpaint_mask' || layer.type === 'regional_guidance');-// Reference equality is exact: the document index hands back the same node// object until the layer itself changes, and the section renders the whole// layer, so a narrower comparison would serve stale views of it.@@ -45,21 +26,17 @@ const selectSelectedLayer = (project: {canvas: { document: Pick<CanvasDocumentContractV3, 'stacks' | 'selectedLayerId'> };}): CanvasLayerContract | null => getDocumentLayer(project.canvas.document, project.canvas.document.selectedLayerId);-export const isLayerEditingDisabled = (layer: CanvasLayerContract | null, editingLocked: boolean): boolean =>- !layer || editingLocked;-/**- * The Layer section of the Properties pane: the selected layer's blend mode,- * opacity, mask fill and type-specific settings (moved out of the Layers- * header and its per-row popover). Every editor commits through the same- * document seams it always did — this is the one implementation, reparented.+ * The Layer section of the Properties pane: the selected layer's type-specific+ * settings (blend mode and opacity live in the fixed row above the tree —+ * `LayerBlendRow`). Every editor commits through the same document seams it+ * always did — this is the one implementation, reparented.*/export const LayerSection = ({ disabled }: { disabled: boolean }) => {const { t } = useTranslation();const engine = useCanvasEngine();const layer = useActiveProjectSelector(selectSelectedLayer);const documentRevision = useActiveProjectSelector((project) => project.canvas.documentRevision);- const editingLocked = useCanvasDocumentEditingLocked(engine);return (<PropertiesSection@@ -68,13 +45,7 @@ export const LayerSection = ({ disabled }: { disabled: boolean }) => {title={t('widgets.properties.sections.layer')}>{layer ? (- <Stack gap="2">- <Flex align="center" gap="2">- <BlendModeControl editingLocked={editingLocked} engine={engine} layer={layer} />- <OpacityRow editingLocked={editingLocked} engine={engine} layer={layer} />- </Flex>- <LayerTypeSettings documentRevision={documentRevision} engine={engine} layer={layer} />- </Stack>+ <LayerTypeSettings documentRevision={documentRevision} engine={engine} layer={layer} />) : (<GroupSelectedNotice />)}@@ -159,248 +130,3 @@ const RasterLayerSettings = ({</Stack>);};--interface BlendModeOption {- label: string;- value: CanvasBlendMode;-}--const BlendModeControl = ({- editingLocked,- engine,- layer,-}: {- editingLocked: boolean;- engine: LayerSectionEngine | null;- layer: CanvasLayerContract | null;-}) => {- const commitPrepared = usePreparedCommit(engine);- const { t } = useTranslation();- const disabled = isLayerEditingDisabled(layer, editingLocked);- const blendMode = layer?.blendMode ?? 'normal';- const blendCollection = useMemo(- () =>- createListCollection<BlendModeOption>({- items: CANVAS_BLEND_MODES.map((mode) => ({ label: t(`widgets.layers.blendModes.${mode}`), value: mode })),- }),- [t]- );- const blendValue = useMemo(() => [blendMode], [blendMode]);-- const handleBlendChange = useCallback(- ({ value }: SelectValueChangeDetails<BlendModeOption>) => {- const mode = value[0] as CanvasBlendMode | undefined;- if (!layer || !mode || mode === layer.blendMode) {- return;- }- commitPrepared(t('widgets.layers.actions.blendMode'), (model) =>- model.prepare({ id: layer.id, patch: { blendMode: mode }, type: 'patch' })- );- },- [commitPrepared, layer, t]- );-- return (- <Field disabled={disabled} flex="1.5" label={t('widgets.layers.actions.blendMode')} orientation="horizontal">- <Select- aria-label={t('widgets.layers.actions.blendMode')}- collection={blendCollection}- disabled={disabled}- minW="7rem"- positioning={SELECT_POSITIONING}- size="xs"- value={blendValue}- valueText={t(`widgets.layers.blendModes.${blendMode}`)}- w="full"- onValueChange={handleBlendChange}- />- </Field>- );-};--const OpacityRow = ({- editingLocked,- engine,- layer,-}: {- editingLocked: boolean;- engine: LayerSectionEngine | null;- layer: CanvasLayerContract | null;-}) => {- const commitPrepared = usePreparedCommit(engine);- const { t } = useTranslation();- // The uncommitted opacity edit: captured once per gesture. `before` is the- // pre-gesture value (the undo target); `latest` tracks the live value because- // React may not have re-rendered between the live dispatch and the commit- // trigger (both can fire inside one browser event), so `layer.opacity` from the- // render closure can be stale at commit time.- const pendingRef = useRef<{ id: string; before: number; latest: number } | null>(null);- const disabled = isLayerEditingDisabled(layer, editingLocked);- const opacityPercent = useMemo(() => String(Math.round((layer?.opacity ?? 1) * 100)), [layer?.opacity]);-- // Records ONE history entry spanning the pending gesture (a spinner press,- // an arrow-key press, or a typed value committed via Enter/blur).- const commitPending = useCallback(() => {- const pending = pendingRef.current;- pendingRef.current = null;- if (!pending || pending.before === pending.latest) {- return;- }- commitPrepared(t('widgets.layers.actions.opacity'), (model) =>- model.prepare({- before: { opacity: pending.before },- id: pending.id,- patch: { opacity: pending.latest },- type: 'patch',- })- );- }, [commitPrepared, t]);-- const handleOpacityChange = useCallback(- ({ valueAsNumber }: ChakraNumberInput.ValueChangeDetails) => {- if (!layer || !Number.isFinite(valueAsNumber)) {- return;- }- // If a pending edit belongs to a previously selected layer, flush it first- // so its history entry is never attributed to the new layer.- if (pendingRef.current && pendingRef.current.id !== layer.id) {- commitPending();- }- const next = clamp01(valueAsNumber / 100);- if (- !applyStructuralPreview(engine, {- id: layer.id,- patch: { opacity: next },- type: 'updateCanvasLayer',- })- ) {- return;- }- if (pendingRef.current === null) {- pendingRef.current = { before: layer.opacity, id: layer.id, latest: next };- } else {- pendingRef.current.latest = next;- }- },- [commitPending, engine, layer]- );-- // Commit per completed interaction: each spinner click (fires on release, so a- // press-and-hold repeat is one gesture), each arrow/paging key release, Enter,- // and blur (typed values).- const handleInputKeyUp = useCallback(- (event: { key: string }) => {- if (['ArrowDown', 'ArrowUp', 'End', 'Enter', 'Home', 'PageDown', 'PageUp'].includes(event.key)) {- commitPending();- }- },- [commitPending]- );-- // Flush a still-pending edit if the row unmounts mid-gesture (e.g. the panel- // closes right after a spinner click) so the edit is never lost to history.- const flushOnUnmountRef = useCallback(- (node: HTMLDivElement | null) => {- if (node) {- return () => commitPending();- }- return undefined;- },- [commitPending]- );-- return (- <Field disabled={disabled} label={t('widgets.layers.actions.opacity')} orientation="horizontal">- <HStack ref={flushOnUnmountRef} gap="2">- <NumberInput.Root- disabled={disabled}- max={100}- min={0}- size="xs"- step={1}- value={opacityPercent}- w="20"- onValueChange={handleOpacityChange}- >- <NumberInput.Control onClick={commitPending} />- <NumberInput.Input- aria-label={t('widgets.layers.actions.opacity')}- onBlur={commitPending}- onKeyUp={handleInputKeyUp}- />- </NumberInput.Root>- {isMaskLayer(layer) ? <MaskFillSwatch disabled={editingLocked} engine={engine} layer={layer} /> : null}- </HStack>- </Field>- );-};--/**- * The selected mask layer's fill-colour swatch (legacy `ActionBarFill`): a colour- * swatch that opens the picker. Live edits during the drag are un-recorded; the- * final colour lands as one undoable history entry, mirroring the slider pattern.- */-const MaskFillSwatch = ({- disabled,- engine,- layer,-}: {- disabled: boolean;- engine: LayerSectionEngine | null;- layer: MaskLayer;-}) => {- const commitPrepared = usePreparedCommit(engine);- const { t } = useTranslation();- const fillBeforeRef = useRef<CanvasMaskFillContract | null>(null);- const fill = layer.mask.fill;-- const patchFill = useCallback(- (next: CanvasMaskFillContract, before: CanvasMaskFillContract) => {- const configFor = (value: CanvasMaskFillContract) =>- layer.type === 'inpaint_mask'- ? ({ layerType: 'inpaint_mask', mask: { fill: value } } as const)- : ({ layerType: 'regional_guidance', mask: { fill: value } } as const);- commitPrepared(t('widgets.layers.maskFill.fill'), (model) =>- model.prepare({ before: configFor(before), config: configFor(next), id: layer.id, type: 'patch-config' })- );- },- [commitPrepared, layer.id, layer.type, t]- );-- const handleColorChange = useCallback(- (hex: string) => {- const next = { ...fill, color: hex };- const config =- layer.type === 'inpaint_mask'- ? ({ layerType: 'inpaint_mask', mask: { fill: next } } as const)- : ({ layerType: 'regional_guidance', mask: { fill: next } } as const);- if (!applyStructuralPreview(engine, { config, id: layer.id, type: 'updateCanvasLayerConfig' })) {- return;- }- if (fillBeforeRef.current === null) {- fillBeforeRef.current = fill;- }- },- [engine, fill, layer.id, layer.type]- );-- const handleColorChangeEnd = useCallback(- (hex: string) => {- const before = fillBeforeRef.current ?? fill;- fillBeforeRef.current = null;- patchFill({ ...before, color: hex }, before);- },- [fill, patchFill]- );-- return (- <Box aria-disabled={disabled} inert={disabled} opacity={disabled ? 0.5 : 1}>- <ColorPicker- aria-label={t('widgets.layers.maskFill.color')}- value={fill.color}- onValueChange={handleColorChange}- onValueChangeEnd={handleColorChangeEnd}- />- </Box>- );-};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/useLayerSelectionCommands.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/useLayerSelectionCommands.tsnew file mode 100644index 0000000000..8cd51b3c49--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/useLayerSelectionCommands.ts@@ -0,0 +1,94 @@+import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';++import { toaster } from '@platform/ui';+import { publishLayerPanelSelection } from '@workbench/layerPanelState';+import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';+import { useCallback, useMemo } from 'react';+import { useTranslation } from 'react-i18next';++import { groupLayers } from './layerGroupCommands';++type SelectionEngine = Pick<CanvasEngineHandle, 'document' | 'exports' | 'interaction' | 'layers'>;++export interface LayerSelectionCommands {+ canDelete: boolean;+ canDuplicate: boolean;+ canGroup: boolean;+ deleteSelected: () => void;+ duplicateSelected: () => void;+ groupSelected: () => void;+}++/**+ * The footer's selection verbs: duplicate, group, delete. Enablement comes+ * from the same model authority that runs the command, so nothing here can+ * refuse later; everything acts on the panel's current selection.+ */+export const useLayerSelectionCommands = (+ engine: SelectionEngine | null,+ projectId: string,+ selectedIds: readonly string[],+ editingLocked: boolean+): LayerSelectionCommands => {+ const commitPrepared = usePreparedCommit(engine);+ const { t } = useTranslation();+ const model = engine?.document.model() ?? null;+ const none = selectedIds.length === 0;+ const canGroup =+ !editingLocked &&+ !none &&+ !!model &&+ model.refusalFor({ groupId: '\0probe', ids: selectedIds, name: '', type: 'group' }) === null;+ const canDelete =+ !editingLocked && !none && !!model && model.refusalFor({ ids: selectedIds, type: 'remove' }) === null;+ const canDuplicate = !editingLocked && !none && !!engine;++ const duplicateSelected = useCallback(async (): Promise<void> => {+ try {+ const result = await engine?.layers.duplicateLayers(selectedIds);+ if (result?.status === 'duplicated') {+ publishLayerPanelSelection({+ primaryId: result.selectedLayerId,+ projectId,+ selectedIds: result.duplicateIds,+ });+ return;+ }+ if (result?.status === 'busy') {+ return;+ }+ } catch {+ // Reducer rejection is failure-atomic; surface the same actionable result as a refusal.+ }+ if (engine) {+ toaster.create({ title: t('widgets.layers.actions.copyFailed'), type: 'warning' });+ }+ }, [engine, projectId, selectedIds, t]);++ const groupSelected = useCallback(+ () => groupLayers(engine, projectId, selectedIds, t('widgets.layers.actions.groupSelected')),+ [engine, projectId, selectedIds, t]+ );++ const deleteSelected = useCallback(() => {+ commitPrepared(t('widgets.layers.actions.deleteSelected'), (model) =>+ model.prepare({ ids: selectedIds, type: 'remove' })+ );+ }, [commitPrepared, selectedIds, t]);++ const runDuplicate = useCallback(() => {+ void duplicateSelected();+ }, [duplicateSelected]);++ return useMemo(+ () => ({+ canDelete,+ canDuplicate,+ canGroup,+ deleteSelected,+ duplicateSelected: runDuplicate,+ groupSelected,+ }),+ [canDelete, canDuplicate, canGroup, deleteSelected, groupSelected, runDuplicate]+ );+};