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.

feat(canvas): mask noise and denoise limit as layer child rows

Josh Corbett79e311f860ae
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.json
index 1defb1b755..fa1ab9a9a6 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": 840771,
+ "brotliBytes": 841493,
"cssRawBytes": 2159,
"fontRawBytes": 219480,
- "gzipBytes": 839556,
+ "gzipBytes": 840019,
"imageRawBytes": 156376,
- "initialRawBytes": 1956794,
+ "initialRawBytes": 1957790,
"largestAssetRawBytes": 746376,
"otherAssetRawBytes": 0,
- "ownedRawBytes": 70891,
+ "ownedRawBytes": 70892,
"requestCount": 42,
"scriptRequestCount": 26,
"sourceOwners": [
@@ -291,15 +291,15 @@
]
},
"limits": {
- "brotliBytes": 849179,
+ "brotliBytes": 849908,
"cssRawBytes": 2181,
"fontRawBytes": 221675,
- "gzipBytes": 847952,
+ "gzipBytes": 848420,
"imageRawBytes": 157940,
- "initialRawBytes": 1976362,
+ "initialRawBytes": 1977368,
"largestAssetRawBytes": 753840,
"otherAssetRawBytes": 0,
- "ownedRawBytes": 70891,
+ "ownedRawBytes": 70892,
"requestCount": 42,
"scriptRequestCount": 26
},
@@ -309,15 +309,15 @@
},
"editor": {
"baseline": {
- "brotliBytes": 1099628,
+ "brotliBytes": 1100667,
"cssRawBytes": 2159,
"fontRawBytes": 219480,
- "gzipBytes": 1094924,
+ "gzipBytes": 1095727,
"imageRawBytes": 156376,
- "initialRawBytes": 2742512,
+ "initialRawBytes": 2744326,
"largestAssetRawBytes": 746376,
"otherAssetRawBytes": 0,
- "ownedRawBytes": 114602,
+ "ownedRawBytes": 114600,
"requestCount": 97,
"scriptRequestCount": 81,
"sourceOwners": [
@@ -933,15 +933,15 @@
]
},
"limits": {
- "brotliBytes": 1110625,
+ "brotliBytes": 1111674,
"cssRawBytes": 2181,
"fontRawBytes": 221675,
- "gzipBytes": 1105874,
+ "gzipBytes": 1106685,
"imageRawBytes": 157940,
- "initialRawBytes": 2769938,
+ "initialRawBytes": 2771770,
"largestAssetRawBytes": 753840,
"otherAssetRawBytes": 0,
- "ownedRawBytes": 114602,
+ "ownedRawBytes": 114600,
"requestCount": 97,
"scriptRequestCount": 81
},
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.json
index fe25676eff..750c5ec3ae 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": 121.70000000298023,
+ "domContentLoadedMedianMs": 125.90000000596046,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 121.79999999701977,
- "longestTaskMaxMs": 71,
+ "loadMedianMs": 126,
+ "longestTaskMaxMs": 75,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -41,24 +41,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 38,
- "scriptRawBytes": 1633476,
+ "scriptRawBytes": 1633815,
"scriptRequestCount": 34,
- "totalRawBytes": 1817321
+ "totalRawBytes": 1818052
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 38,
- "scriptRawBytes": 1649811,
+ "scriptRawBytes": 1650154,
"scriptRequestCount": 34,
- "totalRawBytes": 1835495
+ "totalRawBytes": 1836233
},
- "routeReadyMedianMs": 274.90000000596046,
+ "routeReadyMedianMs": 275.30000000447035,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@ -85,12 +85,12 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 122.59999999403954,
+ "domContentLoadedMedianMs": 123.80000000447035,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 122.59999999403954,
+ "loadMedianMs": 123.80000000447035,
"longestTaskMaxMs": 73,
"owner": "app",
"projectSwitchMedianMs": 0,
@@ -101,24 +101,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 38,
- "scriptRawBytes": 1633476,
+ "scriptRawBytes": 1633815,
"scriptRequestCount": 34,
- "totalRawBytes": 1817321
+ "totalRawBytes": 1818052
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 38,
- "scriptRawBytes": 1649811,
+ "scriptRawBytes": 1650154,
"scriptRequestCount": 34,
- "totalRawBytes": 1835495
+ "totalRawBytes": 1836233
},
- "routeReadyMedianMs": 294.8999999985099,
+ "routeReadyMedianMs": 293,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@ -145,15 +145,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 116.5,
+ "domContentLoadedMedianMs": 124.39999999850988,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 116.5,
- "longestTaskMaxMs": 102,
+ "loadMedianMs": 124.5,
+ "longestTaskMaxMs": 106,
"owner": "workbench",
- "projectSwitchMedianMs": 35.599999994039536,
+ "projectSwitchMedianMs": 41.100000001490116,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -161,24 +161,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 115,
- "scriptRawBytes": 3265126,
+ "scriptRawBytes": 3265821,
"scriptRequestCount": 110,
- "totalRawBytes": 3605347
+ "totalRawBytes": 3606434
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 115,
- "scriptRawBytes": 3297778,
+ "scriptRawBytes": 3298480,
"scriptRequestCount": 110,
- "totalRawBytes": 3641401
+ "totalRawBytes": 3642499
},
- "routeReadyMedianMs": 666.5,
+ "routeReadyMedianMs": 690.8999999985099,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -205,15 +205,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 123.89999999850988,
+ "domContentLoadedMedianMs": 124.79999999701977,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 124.10000000149012,
- "longestTaskMaxMs": 208,
+ "loadMedianMs": 124.89999999850988,
+ "longestTaskMaxMs": 203,
"owner": "workbench",
- "projectSwitchMedianMs": 70.20000000298023,
+ "projectSwitchMedianMs": 78.29999999701977,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -221,24 +221,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 115,
- "scriptRawBytes": 3265126,
+ "scriptRawBytes": 3265821,
"scriptRequestCount": 110,
- "totalRawBytes": 3605347
+ "totalRawBytes": 3606434
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 115,
- "scriptRawBytes": 3297778,
+ "scriptRawBytes": 3298480,
"scriptRequestCount": 110,
- "totalRawBytes": 3641401
+ "totalRawBytes": 3642499
},
- "routeReadyMedianMs": 469.20000000298023,
+ "routeReadyMedianMs": 478.20000000298023,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -247,31 +247,31 @@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 264292,
+ "largestAssetRawBytes": 268619,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 419536,
+ "scriptRawBytes": 424961,
"scriptRequestCount": 7,
- "totalRawBytes": 419536
+ "totalRawBytes": 424961
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 266935,
+ "largestAssetRawBytes": 271306,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 423732,
+ "scriptRawBytes": 429211,
"scriptRequestCount": 7,
- "totalRawBytes": 423732
+ "totalRawBytes": 429211
},
- "domContentLoadedMedianMs": 118.79999999701977,
+ "domContentLoadedMedianMs": 121.70000000298023,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.2000000029802322,
- "layoutReturnSwitchMedianMs": 58.5,
- "layoutSwitchMedianMs": 92.30000000447035,
- "loadMedianMs": 118.89999999850988,
- "longestTaskMaxMs": 137,
+ "layoutAckMedianMs": 2.399999998509884,
+ "layoutReturnSwitchMedianMs": 56.899999998509884,
+ "layoutSwitchMedianMs": 99.10000000149012,
+ "loadMedianMs": 121.79999999701977,
+ "longestTaskMaxMs": 132,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -281,24 +281,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 122,
- "scriptRawBytes": 3684662,
+ "scriptRawBytes": 3690782,
"scriptRequestCount": 117,
- "totalRawBytes": 4024883
+ "totalRawBytes": 4031395
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 122,
- "scriptRawBytes": 3721509,
+ "scriptRawBytes": 3727690,
"scriptRequestCount": 117,
- "totalRawBytes": 4065132
+ "totalRawBytes": 4071709
},
- "routeReadyMedianMs": 1068.8999999985099,
+ "routeReadyMedianMs": 1071,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@ -307,31 +307,31 @@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 264292,
+ "largestAssetRawBytes": 268619,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 419536,
+ "scriptRawBytes": 424961,
"scriptRequestCount": 7,
- "totalRawBytes": 419536
+ "totalRawBytes": 424961
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 266935,
+ "largestAssetRawBytes": 271306,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 423732,
+ "scriptRawBytes": 429211,
"scriptRequestCount": 7,
- "totalRawBytes": 423732
+ "totalRawBytes": 429211
},
- "domContentLoadedMedianMs": 122.60000000149012,
+ "domContentLoadedMedianMs": 121.40000000596046,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.399999998509884,
- "layoutReturnSwitchMedianMs": 46.79999999701977,
- "layoutSwitchMedianMs": 88.40000000596046,
- "loadMedianMs": 122.69999999552965,
- "longestTaskMaxMs": 207,
+ "layoutAckMedianMs": 2.600000001490116,
+ "layoutReturnSwitchMedianMs": 50.600000001490116,
+ "layoutSwitchMedianMs": 92.30000000447035,
+ "loadMedianMs": 121.60000000149012,
+ "longestTaskMaxMs": 205,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -341,24 +341,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 122,
- "scriptRawBytes": 3684662,
+ "scriptRawBytes": 3690782,
"scriptRequestCount": 117,
- "totalRawBytes": 4024883
+ "totalRawBytes": 4031395
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 122,
- "scriptRawBytes": 3721509,
+ "scriptRawBytes": 3727690,
"scriptRequestCount": 117,
- "totalRawBytes": 4065132
+ "totalRawBytes": 4071709
},
- "routeReadyMedianMs": 1184.6999999955297,
+ "routeReadyMedianMs": 1209,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@ -385,13 +385,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383447
},
- "domContentLoadedMedianMs": 120.30000000447035,
+ "domContentLoadedMedianMs": 122.60000000149012,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.399999998509884,
- "layoutReturnSwitchMedianMs": 35.19999999552965,
- "layoutSwitchMedianMs": 92.5,
- "loadMedianMs": 120.5,
- "longestTaskMaxMs": 108,
+ "layoutAckMedianMs": 2.2999999970197678,
+ "layoutReturnSwitchMedianMs": 35.5,
+ "layoutSwitchMedianMs": 93.40000000596046,
+ "loadMedianMs": 122.80000000447035,
+ "longestTaskMaxMs": 104,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -401,24 +401,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 122,
- "scriptRawBytes": 3629363,
+ "scriptRawBytes": 3630058,
"scriptRequestCount": 116,
- "totalRawBytes": 3984997
+ "totalRawBytes": 3986084
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 122,
- "scriptRawBytes": 3665657,
+ "scriptRawBytes": 3666359,
"scriptRequestCount": 116,
- "totalRawBytes": 4024847
+ "totalRawBytes": 4025945
},
- "routeReadyMedianMs": 1067.5,
+ "routeReadyMedianMs": 1060.2999999970198,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "empty"
},
@@ -445,13 +445,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383447
},
- "domContentLoadedMedianMs": 124.70000000298023,
+ "domContentLoadedMedianMs": 120.89999999850988,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.899999998509884,
- "layoutReturnSwitchMedianMs": 43.30000000447035,
- "layoutSwitchMedianMs": 136.10000000149012,
- "loadMedianMs": 124.80000000447035,
- "longestTaskMaxMs": 388,
+ "layoutAckMedianMs": 3.6999999955296516,
+ "layoutReturnSwitchMedianMs": 43.19999999552965,
+ "layoutSwitchMedianMs": 129.5,
+ "loadMedianMs": 121,
+ "longestTaskMaxMs": 381,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -461,24 +461,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 122,
- "scriptRawBytes": 3629363,
+ "scriptRawBytes": 3630058,
"scriptRequestCount": 116,
- "totalRawBytes": 3984997
+ "totalRawBytes": 3986084
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 122,
- "scriptRawBytes": 3665657,
+ "scriptRawBytes": 3666359,
"scriptRequestCount": 116,
- "totalRawBytes": 4024847
+ "totalRawBytes": 4025945
},
- "routeReadyMedianMs": 1259.2999999970198,
+ "routeReadyMedianMs": 1226.2999999970198,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "representative"
},
@@ -505,12 +505,12 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 123.89999999850988,
+ "domContentLoadedMedianMs": 123.39999999850988,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 29.19999999552965,
- "loadMedianMs": 124,
+ "layoutSwitchMedianMs": 27.5,
+ "loadMedianMs": 123.5,
"longestTaskMaxMs": 106,
"owner": "gallery",
"projectSwitchMedianMs": 0,
@@ -521,24 +521,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 115,
- "scriptRawBytes": 3265126,
+ "scriptRawBytes": 3265821,
"scriptRequestCount": 110,
- "totalRawBytes": 3605347
+ "totalRawBytes": 3606434
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 115,
- "scriptRawBytes": 3297778,
+ "scriptRawBytes": 3298480,
"scriptRequestCount": 110,
- "totalRawBytes": 3641401
+ "totalRawBytes": 3642499
},
- "routeReadyMedianMs": 1306.2999999970198,
+ "routeReadyMedianMs": 1298.7999999970198,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -565,12 +565,12 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 123.10000000149012,
+ "domContentLoadedMedianMs": 125.5,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 95.10000000149012,
- "loadMedianMs": 123.30000000447035,
+ "layoutSwitchMedianMs": 96.79999999701977,
+ "loadMedianMs": 125.60000000149012,
"longestTaskMaxMs": 197,
"owner": "gallery",
"projectSwitchMedianMs": 0,
@@ -581,24 +581,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 158022,
+ "otherRawBytes": 158414,
"requestCount": 115,
- "scriptRawBytes": 3265126,
+ "scriptRawBytes": 3265821,
"scriptRequestCount": 110,
- "totalRawBytes": 3605347
+ "totalRawBytes": 3606434
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 159603,
+ "otherRawBytes": 159999,
"requestCount": 115,
- "scriptRawBytes": 3297778,
+ "scriptRawBytes": 3298480,
"scriptRequestCount": 110,
- "totalRawBytes": 3641401
+ "totalRawBytes": 3642499
},
- "routeReadyMedianMs": 1506.2999999970198,
+ "routeReadyMedianMs": 1506.3999999985099,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
}
@@ -2869,6 +2869,7 @@
"source:src/workbench/widgets/layers/LayersPanelFooter.tsx",
"source:src/workbench/widgets/layers/LayersTree.tsx",
"source:src/workbench/widgets/layers/LayersWidgetView.tsx",
+ "source:src/workbench/widgets/layers/MaskModifierSettings.tsx",
"source:src/workbench/widgets/layers/RasterLayerFilterSection.tsx",
"source:src/workbench/widgets/layers/ReferenceImageSettings.tsx",
"source:src/workbench/widgets/layers/RegionalGuidanceSettings.tsx",
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index cdc5a25a6e..ba4a8e958e 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -2595,7 +2595,9 @@
"showSelectedOnCanvas": "Show selected on canvas",
"toggleActive": "Toggle layer active",
"hideModifiers": "Hide modifiers",
- "showModifiers": "Show modifiers"
+ "showModifiers": "Show modifiers",
+ "addDenoiseLimit": "Add denoise limit",
+ "addNoise": "Add noise"
},
"control": {
"apply": "Apply",
@@ -3022,7 +3024,13 @@
"disable": "Disable",
"enable": "Enable",
"parentDisabled": "Layer is disabled",
- "toggleActive": "Toggle active"
+ "toggleActive": "Toggle active",
+ "denoise": "Denoise limit",
+ "denoiseHelp": "Caps how strongly generation may repaint the masked area.",
+ "noise": "Noise",
+ "noiseHelp": "Adds noise inside the masked area before generation.",
+ "removeDenoise": "Remove denoise limit",
+ "removeNoise": "Remove noise"
}
},
"gallery": {
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
index b14c9e6c00..b42386e213 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
@@ -244,11 +244,24 @@ export interface CanvasRegionalGuidanceLayerContract extends CanvasLayerBaseCont
isHidden?: boolean;
}
+/** A mask's noise modifier; disabling keeps the tuned level out of generation without losing it. */
+export interface CanvasMaskNoiseContract {
+ level: number;
+ isEnabled: boolean;
+}
+
+/** A mask's denoise-limit modifier; disabled or absent, generation uses the default limit. */
+export interface CanvasMaskDenoiseContract {
+ limit: number;
+ isEnabled: boolean;
+}
+
export interface CanvasInpaintMaskLayerContract extends CanvasLayerBaseContract {
type: 'inpaint_mask';
mask: CanvasMaskContract;
- noiseLevel?: number;
- denoiseLimit?: number;
+ /** Absent ⇒ the modifier was never added; the Layers tree projects it as a child row. */
+ noise?: CanvasMaskNoiseContract;
+ denoise?: CanvasMaskDenoiseContract;
/**
* Whether this layer's on-canvas preview is suppressed. DISPLAY ONLY — a
* hidden layer still affects generation exactly as it would if visible, which
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.test.ts
index 08eb0676f1..4a855906e4 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.test.ts
@@ -707,6 +707,31 @@ describe('createDocumentModel', () => {
).toEqual({ status: 'unchanged' });
});
+ it('round-trips a mask modifier through add, toggle and null-remove with passing postconditions', () => {
+ const project = projectWith(flat(), 'i1');
+ const noise = { isEnabled: true, level: 0.25 };
+ const added = roundTrip(project, {
+ before: { layerType: 'inpaint_mask', noise: null },
+ config: { layerType: 'inpaint_mask', noise },
+ id: 'i1',
+ type: 'patch-config',
+ });
+ const toggled = roundTrip(added.after, {
+ before: { layerType: 'inpaint_mask', noise },
+ config: { layerType: 'inpaint_mask', noise: { ...noise, isEnabled: false } },
+ id: 'i1',
+ type: 'patch-config',
+ });
+ const removed = roundTrip(toggled.after, {
+ before: { layerType: 'inpaint_mask', noise: { ...noise, isEnabled: false } },
+ config: { layerType: 'inpaint_mask', noise: null },
+ id: 'i1',
+ type: 'patch-config',
+ });
+ const mask = getDocumentLeaves(removed.after.canvas.document).find((leaf) => leaf.id === 'i1')!;
+ expect(Object.hasOwn(mask, 'noise')).toBe(false);
+ });
+
it('round-trips config, source and flag commands through the reducer, groups included', () => {
const project = projectWith(tree(), 'r1');
const control = roundTrip(project, {
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/postconditions.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/postconditions.ts
index 531d9a8075..14f1327742 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/postconditions.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/postconditions.ts
@@ -64,7 +64,11 @@ export const isPatchApplied = (node: CanvasNodeContract, patch: CanvasLayerBaseP
: node[key] === patch[key];
});
-/** Whether every field named by `config` already holds its value; nested partials compare field by field. */
+/**
+ * Whether every field named by `config` already holds its value; nested
+ * partials compare field by field, and a `null` config value asserts the
+ * field's ABSENCE — the reducer deletes the key for it.
+ */
export const isConfigApplied = (node: CanvasNodeContract, config: CanvasLayerConfigPatch): boolean => {
if (node.type !== config.layerType) {
return false;
@@ -75,6 +79,9 @@ export const isConfigApplied = (node: CanvasNodeContract, config: CanvasLayerCon
return true;
}
const current = target[key];
+ if (value === null) {
+ return current === undefined;
+ }
return isRecord(value) && isRecord(current) && (key === 'adapter' || key === 'mask')
? Object.entries(value).every(([field, expected]) => sameValue(current[field], expected))
: sameValue(current, value);
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts
index 130277f8ac..d245fdfc9c 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts
@@ -1958,13 +1958,13 @@ describe('createCanvasEngine', () => {
it('cropLayerToBbox preserves mask fill/noise/denoise configuration while replacing pixels and offset', async () => {
const layer: CanvasInpaintMaskLayerContract = {
...maskLayer('mask'),
- denoiseLimit: 0.45,
+ denoise: { isEnabled: true, limit: 0.45 },
mask: {
bitmap: { height: 10, imageName: 'mask-img', width: 10 },
fill: { color: '#123456', style: 'crosshatch' },
offset: { x: 0, y: 0 },
},
- noiseLevel: 0.25,
+ noise: { isEnabled: true, level: 0.25 },
};
const document = { ...makeDoc(), bbox: { height: 7, width: 6, x: 2, y: 3 }, stacks: stacksFrom([layer]) };
const { projectId, store } = createReducerBackedStore(document);
@@ -1978,9 +1978,9 @@ describe('createCanvasEngine', () => {
expect(await engine.layers.cropLayerToBbox('mask')).toEqual({ status: 'cropped' });
expect(getDocumentLeaves(engine.document.getDocument()!)[0]).toMatchObject({
- denoiseLimit: 0.45,
+ denoise: { isEnabled: true, limit: 0.45 },
mask: { bitmap: null, fill: layer.mask.fill, offset: { x: 2, y: 3 } },
- noiseLevel: 0.25,
+ noise: { isEnabled: true, level: 0.25 },
transform: { rotation: 0, scaleX: 1, scaleY: 1, x: 0, y: 0 },
type: 'inpaint_mask',
});
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/mutationContracts.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/mutationContracts.ts
index bd5b8a8ca3..5568d36584 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/mutationContracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/mutationContracts.ts
@@ -15,6 +15,8 @@ import type {
CanvasLayerContract,
CanvasLayerSourceContract,
CanvasMaskContract,
+ CanvasMaskDenoiseContract,
+ CanvasMaskNoiseContract,
CanvasRasterLayerContractV2,
CanvasRegionalGuidanceLayerContract,
CanvasStagingAreaContractV2,
@@ -51,7 +53,13 @@ export type CanvasLayerConfigPatch =
autoNegative?: boolean;
referenceImages?: CanvasRegionalGuidanceLayerContract['referenceImages'];
}
- | { layerType: 'inpaint_mask'; mask?: Partial<CanvasMaskContract>; noiseLevel?: number; denoiseLimit?: number };
+ | {
+ layerType: 'inpaint_mask';
+ mask?: Partial<CanvasMaskContract>;
+ /** `null` removes the modifier; absent leaves it untouched. */
+ noise?: CanvasMaskNoiseContract | null;
+ denoise?: CanvasMaskDenoiseContract | null;
+ };
export type CanvasProjectMutation =
| {
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/compositeForGeneration.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/compositeForGeneration.test.ts
index 6b4ffbf452..177bbef79d 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/compositeForGeneration.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/compositeForGeneration.test.ts
@@ -310,13 +310,13 @@ const inpaintMask = (
overrides: Partial<{ denoiseLimit: number; noiseLevel: number }> = {}
): CanvasLayerContract => ({
blendMode: 'normal',
- denoiseLimit: overrides.denoiseLimit,
+ ...(overrides.denoiseLimit === undefined ? {} : { denoise: { isEnabled: true, limit: overrides.denoiseLimit } }),
id,
isEnabled: true,
isLocked: false,
mask: { bitmap: imageRef(`${id}-bmp`, 64, 48), fill: { color: '#ff0000', style: 'solid' } },
name: id,
- noiseLevel: overrides.noiseLevel,
+ ...(overrides.noiseLevel === undefined ? {} : { noise: { isEnabled: true, level: overrides.noiseLevel } }),
opacity: 1,
transform: { rotation: 0, scaleX: 1, scaleY: 1, x: 0, y: 0 },
type: 'inpaint_mask',
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationComposite.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationComposite.test.ts
index b352686113..d4bf3dfd3f 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationComposite.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationComposite.test.ts
@@ -68,7 +68,7 @@ const inpaintMaskLayer = (id: string, noiseLevel?: number): CanvasLayerContract
isLocked: false,
mask: { bitmap: { height: 64, imageName: `${id}-bmp`, width: 64 }, fill: { color: '#ff0000', style: 'solid' } },
name: id,
- ...(noiseLevel !== undefined ? { noiseLevel } : {}),
+ ...(noiseLevel !== undefined ? { noise: { isEnabled: true, level: noiseLevel } } : {}),
opacity: 1,
transform: { rotation: 0, scaleX: 1, scaleY: 1, x: 0, y: 0 },
type: 'inpaint_mask',
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.test.ts
index 100acd32b4..6ad504b040 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.test.ts
@@ -220,14 +220,18 @@ const inpaintMask = (
overrides: Partial<{
bitmap: CanvasImageRef | null;
noiseLevel: number;
+ noiseEnabled: boolean;
denoiseLimit: number;
+ denoiseEnabled: boolean;
isEnabled: boolean;
isHidden: boolean;
offset: { x: number; y: number };
}> = {}
): CanvasLayerContract => ({
blendMode: 'normal',
- denoiseLimit: overrides.denoiseLimit,
+ ...(overrides.denoiseLimit === undefined
+ ? {}
+ : { denoise: { isEnabled: overrides.denoiseEnabled ?? true, limit: overrides.denoiseLimit } }),
id,
isEnabled: overrides.isEnabled ?? true,
isHidden: overrides.isHidden,
@@ -238,7 +242,9 @@ const inpaintMask = (
...(overrides.offset ? { offset: overrides.offset } : {}),
},
name: id,
- noiseLevel: overrides.noiseLevel,
+ ...(overrides.noiseLevel === undefined
+ ? {}
+ : { noise: { isEnabled: overrides.noiseEnabled ?? true, level: overrides.noiseLevel } }),
opacity: 1,
transform: { rotation: 0, scaleX: 1, scaleY: 1, x: 0, y: 0 },
type: 'inpaint_mask',
@@ -287,6 +293,14 @@ describe('planComposites — inpaint-mask entries', () => {
expect(entry!.maskLayers![0]!.attributeValue).toBe(0.4);
});
+ it('treats a disabled denoise modifier as the legacy default (disabled === absent)', () => {
+ const entry = entryOfKind(
+ makeDoc([inpaintMask('m1', { denoiseEnabled: false, denoiseLimit: 0.4 })]),
+ 'inpaint-mask'
+ );
+ expect(entry!.maskLayers![0]!.attributeValue).toBe(1);
+ });
+
it('unions multiple masks into the denoise-limit entry', () => {
const doc = makeDoc([inpaintMask('a', { denoiseLimit: 0.3 }), inpaintMask('b')]);
const entry = entryOfKind(doc, 'inpaint-mask');
@@ -308,6 +322,14 @@ describe('planComposites — noise-mask entries', () => {
expect(entry!.maskLayers![0]!.attributeValue).toBe(0.15);
});
+ it('treats a disabled noise modifier as absent, never as noise 0', () => {
+ const kinds = planComposites(
+ makeDoc([inpaintMask('m1', { noiseEnabled: false, noiseLevel: 0.4 })]),
+ BBOX
+ ).entries.map((e) => e.kind);
+ expect(kinds).toEqual(['base-raster', 'inpaint-mask']);
+ });
+
it('treats noiseLevel 0 as defined (included), distinct from undefined (excluded)', () => {
const entry = entryOfKind(makeDoc([inpaintMask('m1', { noiseLevel: 0 })]), 'noise-mask');
expect(entry).toBeDefined();
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.ts b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.ts
index 3c37c2d80e..1a2fff3ac8 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-operations/generationCompositePlan.ts
@@ -128,11 +128,11 @@ const deriveMaskKey = (kind: string, bbox: Rect, layers: CompositeMaskLayerRef[]
* Plans the composites required to invoke `document` over `bbox`:
* - one `base-raster` entry (the initial image);
* - one `inpaint-mask` entry (grayscale denoise-limit mask) when enabled inpaint
- * masks with content exist — an undefined `denoiseLimit` resolves to the legacy
- * default (1.0, full denoise);
- * - one `noise-mask` entry when at least one such mask defines a `noiseLevel`
- * (masks with an undefined `noiseLevel` are excluded, mirroring legacy — they
- * must NOT be treated as noise 0).
+ * masks with content exist — an absent OR DISABLED `denoise` modifier resolves
+ * to the legacy default (1.0, full denoise);
+ * - one `noise-mask` entry when at least one such mask carries an ENABLED
+ * `noise` modifier (absent and disabled are equivalent, mirroring legacy —
+ * they must NOT be treated as noise 0).
*/
export const planComposites = (document: CanvasDocumentContractV3, bbox: Rect): CompositePlan => {
const entries: CompositeEntry[] = [planBaseRasterComposite(document, bbox)];
@@ -141,7 +141,7 @@ export const planComposites = (document: CanvasDocumentContractV3, bbox: Rect):
if (maskLayers.length > 0) {
const denoiseRefs = maskLayers.map((layer) =>
- toMaskLayerRef(layer, layer.denoiseLimit ?? DEFAULT_MASK_DENOISE_LIMIT)
+ toMaskLayerRef(layer, layer.denoise?.isEnabled ? layer.denoise.limit : DEFAULT_MASK_DENOISE_LIMIT)
);
entries.push({
bbox,
@@ -152,8 +152,8 @@ export const planComposites = (document: CanvasDocumentContractV3, bbox: Rect):
});
const noiseRefs = maskLayers
- .filter((layer) => layer.noiseLevel !== undefined)
- .map((layer) => toMaskLayerRef(layer, layer.noiseLevel as number));
+ .filter((layer) => layer.noise?.isEnabled)
+ .map((layer) => toMaskLayerRef(layer, layer.noise!.level));
if (noiseRefs.length > 0) {
entries.push({
diff --git a/invokeai/frontend/webv2/src/workbench/canvasMigration.ts b/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
index d653c4bb1d..b16b076d24 100644
--- a/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
@@ -206,10 +206,10 @@ const zCanvasLayer = z.discriminatedUnion('type', [
type: z.literal('regional_guidance'),
}),
zLayerBase.extend({
- denoiseLimit: zFiniteNumber.optional(),
+ denoise: z.object({ isEnabled: z.boolean(), limit: zFiniteNumber }).optional(),
isHidden: z.boolean().optional(),
mask: zMask,
- noiseLevel: zFiniteNumber.optional(),
+ noise: z.object({ isEnabled: z.boolean(), level: zFiniteNumber }).optional(),
type: z.literal('inpaint_mask'),
}),
]);
diff --git a/invokeai/frontend/webv2/src/workbench/canvasProjectMutations.ts b/invokeai/frontend/webv2/src/workbench/canvasProjectMutations.ts
index 264ad1e5ff..ec9933b59f 100644
--- a/invokeai/frontend/webv2/src/workbench/canvasProjectMutations.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvasProjectMutations.ts
@@ -544,12 +544,26 @@ const patchLayerConfig = (layer: CanvasLayerContract, config: CanvasLayerConfigP
};
}
if (layer.type === 'inpaint_mask' && config.layerType === 'inpaint_mask') {
- return {
+ const next = {
...layer,
...(config.mask ? { mask: { ...layer.mask, ...config.mask } } : {}),
- ...(Object.hasOwn(config, 'noiseLevel') ? { noiseLevel: config.noiseLevel } : {}),
- ...(Object.hasOwn(config, 'denoiseLimit') ? { denoiseLimit: config.denoiseLimit } : {}),
};
+ // `null` removes the modifier; absent leaves it untouched.
+ if (Object.hasOwn(config, 'noise')) {
+ if (config.noise) {
+ next.noise = config.noise;
+ } else {
+ delete next.noise;
+ }
+ }
+ if (Object.hasOwn(config, 'denoise')) {
+ if (config.denoise) {
+ next.denoise = config.denoise;
+ } else {
+ delete next.denoise;
+ }
+ }
+ return next;
}
return layer;
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/InpaintMaskSettings.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/InpaintMaskSettings.tsx
index d2eb41b9b8..77636e3b13 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/InpaintMaskSettings.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/InpaintMaskSettings.tsx
@@ -1,9 +1,9 @@
-import type { SelectValueChangeDetails, SliderValueChangeDetails } from '@chakra-ui/react';
+import type { SelectValueChangeDetails } from '@chakra-ui/react';
import type { CanvasInpaintMaskLayerContract, CanvasMaskFillContract } from '@workbench/canvas-engine/api';
import type { CanvasStructuralEngine } from '@workbench/widgets/layers/layerOps';
import { createListCollection, HStack, Stack } from '@chakra-ui/react';
-import { Button, ColorPicker, Field, IconButton, Select, Slider, Tooltip } from '@platform/ui';
+import { Button, ColorPicker, Field, IconButton, Select, Tooltip } from '@platform/ui';
import { armMaskTintTarget } from '@workbench/widgets/canvas/color-system/maskTintTarget';
import { type CanvasPreparedEngine, usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';
import { PaletteIcon } from 'lucide-react';
@@ -22,35 +22,24 @@ const MASK_FILL_STYLES: readonly CanvasMaskFillContract['style'][] = [
'vertical',
];
-const formatUnitPercent = (value: number): string => `${Math.round(value * 100)}%`;
-
-const noiseConfig = (value: number | undefined) => ({ layerType: 'inpaint_mask', noiseLevel: value }) as const;
-const denoiseConfig = (value: number | undefined) => ({ layerType: 'inpaint_mask', denoiseLimit: value }) as const;
-
interface InpaintMaskSettingsProps {
engine: (CanvasStructuralEngine & CanvasPreparedEngine) | null;
layer: CanvasInpaintMaskLayerContract;
}
/**
- * Per-layer settings for a selected inpaint mask, rendered as a section under the
- * layers-panel header region (plan §1.3): fill colour + style, noise level and
- * denoise-limit sliders (0–1), and an in-place mask invert. `noiseLevel` /
- * `denoiseLimit` are wired to the contract now (consumed by the NEXT task's graph
- * builder); they have no generation effect yet. Fill/noise/denoise edits go
- * through the canvas undo stack as prepared `patch-config` edits;
- * invert is an engine pixel op (its own undoable image patch).
+ * Per-layer settings for a selected inpaint mask: fill colour + style and an
+ * in-place mask invert. Noise and denoise limit are NOT here — they live as
+ * child rows in the Layers tree, each opening its own dedicated Properties
+ * editor (`MaskModifierSettings`). Fill edits go through the canvas undo stack
+ * as prepared `patch-config` edits; invert is an engine pixel op.
*/
export const InpaintMaskSettings = ({ engine, layer }: InpaintMaskSettingsProps) => {
const { t } = useTranslation();
const commitPrepared = usePreparedCommit(engine);
const fillBeforeRef = useRef<CanvasMaskFillContract | null>(null);
- const noiseBeforeRef = useRef<{ value: number | undefined } | null>(null);
- const denoiseBeforeRef = useRef<{ value: number | undefined } | null>(null);
const fill = layer.mask.fill;
- const noiseLevel = layer.noiseLevel ?? 0;
- const denoiseLimit = layer.denoiseLimit ?? 1;
const styleCollection = useMemo(
() =>
@@ -115,91 +104,12 @@ export const InpaintMaskSettings = ({ engine, layer }: InpaintMaskSettingsProps)
[commitFill, fill]
);
- const handleNoiseChange = useCallback(
- ({ value }: SliderValueChangeDetails) => {
- const next = value[0];
- if (next === undefined || !Number.isFinite(next)) {
- return;
- }
- if (
- !applyStructuralPreview(engine, {
- config: noiseConfig(next),
- id: layer.id,
- type: 'updateCanvasLayerConfig',
- })
- ) {
- return;
- }
- noiseBeforeRef.current ??= { value: layer.noiseLevel };
- },
- [engine, layer]
- );
-
- const handleNoiseChangeEnd = useCallback(
- ({ value }: SliderValueChangeDetails) => {
- const next = value[0];
- const before = noiseBeforeRef.current ? noiseBeforeRef.current.value : layer.noiseLevel;
- noiseBeforeRef.current = null;
- if (next === undefined || !Number.isFinite(next)) {
- return;
- }
- commitPrepared(t('widgets.layers.maskFill.noiseLevel'), (model) =>
- model.prepare({ before: noiseConfig(before), config: noiseConfig(next), id: layer.id, type: 'patch-config' })
- );
- },
- [commitPrepared, layer.id, layer.noiseLevel, t]
- );
-
- const handleDenoiseChange = useCallback(
- ({ value }: SliderValueChangeDetails) => {
- const next = value[0];
- if (next === undefined || !Number.isFinite(next)) {
- return;
- }
- if (
- !applyStructuralPreview(engine, {
- config: denoiseConfig(next),
- id: layer.id,
- type: 'updateCanvasLayerConfig',
- })
- ) {
- return;
- }
- denoiseBeforeRef.current ??= { value: layer.denoiseLimit };
- },
- [engine, layer]
- );
-
- const handleDenoiseChangeEnd = useCallback(
- ({ value }: SliderValueChangeDetails) => {
- const next = value[0];
- const before = denoiseBeforeRef.current ? denoiseBeforeRef.current.value : layer.denoiseLimit;
- denoiseBeforeRef.current = null;
- if (next === undefined || !Number.isFinite(next)) {
- return;
- }
- commitPrepared(t('widgets.layers.maskFill.denoiseLimit'), (model) =>
- model.prepare({
- before: denoiseConfig(before),
- config: denoiseConfig(next),
- id: layer.id,
- type: 'patch-config',
- })
- );
- },
- [commitPrepared, layer.denoiseLimit, layer.id, t]
- );
-
const handleInvert = useCallback(() => {
engine?.layers.invertMask(layer.id);
}, [engine, layer.id]);
const styleValue = useMemo(() => [fill.style], [fill.style]);
const colorAria = t('widgets.layers.maskFill.color');
- const noiseValue = useMemo(() => [noiseLevel], [noiseLevel]);
- const denoiseValue = useMemo(() => [denoiseLimit], [denoiseLimit]);
- const noiseAria = useMemo(() => [t('widgets.layers.maskFill.noiseLevel')], [t]);
- const denoiseAria = useMemo(() => [t('widgets.layers.maskFill.denoiseLimit')], [t]);
return (
<Stack gap="2">
@@ -236,34 +146,6 @@ export const InpaintMaskSettings = ({ engine, layer }: InpaintMaskSettingsProps)
/>
</Field>
</HStack>
- <Field label={t('widgets.layers.maskFill.noiseLevel')}>
- <Slider
- aria-label={noiseAria}
- formatValue={formatUnitPercent}
- max={1}
- min={0}
- size="sm"
- step={0.01}
- value={noiseValue}
- withThumbTooltip
- onValueChange={handleNoiseChange}
- onValueChangeEnd={handleNoiseChangeEnd}
- />
- </Field>
- <Field label={t('widgets.layers.maskFill.denoiseLimit')}>
- <Slider
- aria-label={denoiseAria}
- formatValue={formatUnitPercent}
- max={1}
- min={0}
- size="sm"
- step={0.01}
- value={denoiseValue}
- withThumbTooltip
- onValueChange={handleDenoiseChange}
- onValueChangeEnd={handleDenoiseChangeEnd}
- />
- </Field>
<Button disabled={!engine} size="xs" variant="outline" onClick={handleInvert}>
{t('widgets.layers.maskFill.invert')}
</Button>
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildMenu.tsx
index 454544be09..8b6e628082 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildMenu.tsx
@@ -6,9 +6,10 @@ import { CircleIcon, CircleOffIcon, XIcon } from 'lucide-react';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import type { ProjectedChildRow } from './layerChildRows';
import type { LayerRowCommands, LayerSurfaceAnchor } from './layerRowCommands';
+import { layerChildRemoveLabelKey, type ProjectedChildRow } from './layerChildRows';
+
type MenuPositioning = ComponentProps<typeof Menu.Root>['positioning'];
/** The context menu of a projected child row: toggle it, or remove it. */
@@ -57,7 +58,7 @@ export const LayerChildMenu = ({
<Menu.Item color="fg.error" disabled={editingLocked} value="remove" onSelect={handleRemove}>
<HStack gap="2">
<Icon as={XIcon} boxSize="3.5" />
- <Text fontSize="xs">{t('widgets.layers.regionalGuidance.removeReferenceImage')}</Text>
+ <Text fontSize="xs">{t(layerChildRemoveLabelKey(child.kind))}</Text>
</HStack>
</Menu.Item>
</MenuContent>
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildRow.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildRow.tsx
index 5c313de1bd..33a7e7f5de 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildRow.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildRow.tsx
@@ -3,11 +3,11 @@ import type { CSSProperties, KeyboardEvent, MouseEvent } from 'react';
import { Box, Icon, Text } from '@chakra-ui/react';
import { useDroppable } from '@dnd-kit/core';
import { Row } from '@platform/ui';
-import { ImageIcon } from 'lucide-react';
+import { GaugeIcon, ImageIcon, WavesIcon, type LucideIcon } from 'lucide-react';
import { memo, useCallback, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
-import type { ProjectedChildRow } from './layerChildRows';
+import type { LayerChildRowKind, ProjectedChildRow } from './layerChildRows';
import type { LayerRowCommands } from './layerRowCommands';
import { LayerActiveDot, ROW_SELECTION_FOCUS } from './LayerActiveDot';
@@ -16,6 +16,24 @@ import { anchorFromPoint } from './layerRowCommands';
const THUMBNAIL_IMG_STYLE: CSSProperties = { height: '100%', objectFit: 'cover', width: '100%' };
+const CHILD_ROW_GLYPHS: Record<LayerChildRowKind, LucideIcon> = {
+ 'mask-denoise': GaugeIcon,
+ 'mask-noise': WavesIcon,
+ 'reference-image': ImageIcon,
+};
+
+/** The row's display name; reference images are numbered, singleton modifiers named by kind. */
+const childRowName = (child: ProjectedChildRow, t: (key: string) => string): string => {
+ switch (child.kind) {
+ case 'reference-image':
+ return `${t('widgets.layers.regionalGuidance.referenceImage')} ${child.posInSet}`;
+ case 'mask-noise':
+ return t('widgets.layers.modifiers.noise');
+ case 'mask-denoise':
+ return t('widgets.layers.modifiers.denoise');
+ }
+};
+
interface LayerChildRowProps {
child: ProjectedChildRow;
commands: LayerRowCommands;
@@ -56,7 +74,7 @@ const LayerChildRowComponent = ({
},
[setDropRef]
);
- const name = `${t('widgets.layers.regionalGuidance.referenceImage')} ${child.posInSet}`;
+ const name = childRowName(child, t);
const indentStyle = useMemo(() => ({ paddingLeft: `${child.depth * LAYER_TREE_INDENT_PX}px` }), [child.depth]);
const handleSelect = useCallback(() => commands.selectChild(child), [child, commands]);
@@ -148,12 +166,17 @@ const LayerChildRowComponent = ({
{child.image ? (
<img alt="" draggable={false} src={child.image.thumbnailUrl} style={THUMBNAIL_IMG_STYLE} />
) : (
- <Icon as={ImageIcon} boxSize="3" />
+ <Icon as={CHILD_ROW_GLYPHS[child.kind]} boxSize="3" />
)}
</Box>
<Text color={muted ? 'fg.muted' : undefined} flex="1" fontSize="2xs" fontWeight="600" minW="0" truncate>
{name}
</Text>
+ {child.value !== null ? (
+ <Text color="fg.subtle" flexShrink={0} fontSize="2xs" fontVariantNumeric="tabular-nums">
+ {`${Math.round(child.value * 100)}%`}
+ </Text>
+ ) : null}
</Row>
</Box>
);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
index a2512d3600..16de0a9a14 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
@@ -2,6 +2,8 @@ import type {
CanvasDocumentContractV3,
CanvasLayerContract,
CanvasMaskContract,
+ CanvasMaskDenoiseContract,
+ CanvasMaskNoiseContract,
BooleanRasterOperation,
LayerStackMoveKind,
RegionalGuidanceReferenceImage,
@@ -119,7 +121,11 @@ type LayerConfigPatch =
autoNegative?: boolean;
referenceImages?: RegionalGuidanceReferenceImage[];
}
- | { layerType: 'inpaint_mask'; noiseLevel?: number; denoiseLimit?: number };
+ | {
+ layerType: 'inpaint_mask';
+ noise?: CanvasMaskNoiseContract | null;
+ denoise?: CanvasMaskDenoiseContract | null;
+ };
const PANEL_POSITIONING: MenuPositioning = { placement: 'bottom-end' };
@@ -702,6 +708,31 @@ const LayerMenu = ({
[getActionLabel, layer, patchConfig]
);
+ const handleAddMaskModifier = useCallback(
+ (field: 'noise' | 'denoise') => {
+ if (layer.type !== 'inpaint_mask') {
+ return;
+ }
+ // A modifier that appeared since the menu rendered must not be stomped by the default.
+ if (layer[field] !== undefined) {
+ return;
+ }
+ // Legacy defaults: noise starts at 25%, the denoise limit at 80%.
+ const value = field === 'noise' ? { isEnabled: true, level: 0.25 } : { isEnabled: true, limit: 0.8 };
+ commitPrepared(
+ t(field === 'noise' ? 'widgets.layers.actions.addNoise' : 'widgets.layers.actions.addDenoiseLimit'),
+ (model) =>
+ model.prepare({
+ before: { [field]: null, layerType: 'inpaint_mask' },
+ config: { [field]: value, layerType: 'inpaint_mask' },
+ id: layer.id,
+ type: 'patch-config',
+ })
+ );
+ },
+ [commitPrepared, layer, t]
+ );
+
const handleAddReferenceImage = useCallback(() => {
if (layer.type !== 'regional_guidance') {
return;
@@ -721,6 +752,7 @@ const LayerMenu = ({
const effects = useMemo<LayerContextActionEffects>(
() => ({
+ addMaskModifier: handleAddMaskModifier,
addReferenceImage: handleAddReferenceImage,
booleanMerge: handleBooleanRaster,
convertTo: (target) => {
@@ -761,6 +793,7 @@ const LayerMenu = ({
[
convert,
getActionLabel,
+ handleAddMaskModifier,
handleAddReferenceImage,
handleBooleanRaster,
handleCopyTo,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerSurfaceHost.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerSurfaceHost.tsx
index f2e7e27458..19634faf1a 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerSurfaceHost.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerSurfaceHost.tsx
@@ -3,13 +3,13 @@ import type { CanvasProjectMutation } from '@workbench/canvasProjectMutations';
import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';
import type { Dispatch } from 'react';
-import { getDocumentLayer, getDocumentNode } from '@workbench/canvas-engine/api';
+import { getDocumentNode } from '@workbench/canvas-engine/api';
import { useCallback, useMemo } from 'react';
-import type { ProjectedChildRow } from './layerChildRows';
import type { LayerRowCommands, LayerSurfaceAnchor } from './layerRowCommands';
import { LayerChildMenu } from './LayerChildMenu';
+import { getLayerChildItem, type ProjectedChildRow } from './layerChildRows';
import { CanvasLayerContextMenu, type LayerContextMenuEngine } from './LayerContextMenu';
import { LayerGroupContextMenu, type LayerGroupContextMenuEngine } from './LayerGroupContextMenu';
import { LayerStackMenu } from './LayerStackMenu';
@@ -63,9 +63,7 @@ export const LayerSurfaceHost = ({
return null;
}
const { child } = surface;
- const owner = getDocumentLayer(document, child.layerId);
- const item =
- owner?.type === 'regional_guidance' ? owner.referenceImages.find((ref) => ref.id === child.itemId) : undefined;
+ const item = getLayerChildItem(document, child.layerId, child.itemId);
if (!item) {
return null;
}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx
index da2ecb6189..0606ac3e00 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx
@@ -97,7 +97,15 @@ void i18n.use(initReactI18next).init({
toggleActive: 'Toggle layer active',
toggleVisibility: 'Toggle visibility',
},
- modifiers: { disable: 'Disable', enable: 'Enable', toggleActive: 'Toggle active' },
+ modifiers: {
+ denoise: 'Denoise limit',
+ disable: 'Disable',
+ enable: 'Enable',
+ noise: 'Noise',
+ removeDenoise: 'Remove denoise limit',
+ removeNoise: 'Remove noise',
+ toggleActive: 'Toggle active',
+ },
regionalGuidance: {
referenceImage: 'Reference image',
referenceImages: 'Reference images',
@@ -200,6 +208,19 @@ const Harness = ({ initialNodes }: { initialNodes: CanvasNodeContract[] }) => {
<output data-testid="selected-layer" style={HIDDEN}>
{document.selectedLayerId ?? 'none'}
</output>
+ <output data-testid="mask-modifiers" style={HIDDEN}>
+ {(() => {
+ const layer = getDocumentLayer(document, 'mask');
+ return layer?.type === 'inpaint_mask'
+ ? [
+ layer.noise ? `noise:${layer.noise.isEnabled ? 'on' : 'off'}:${layer.noise.level}` : null,
+ layer.denoise ? `denoise:${layer.denoise.isEnabled ? 'on' : 'off'}:${layer.denoise.limit}` : null,
+ ]
+ .filter(Boolean)
+ .join(',') || 'empty'
+ : 'none';
+ })()}
+ </output>
<output data-testid="regional-refs" style={HIDDEN}>
{(() => {
const layer = getDocumentLayer(document, 'rg');
@@ -609,6 +630,25 @@ describe('LayersTree projected child rows', () => {
expect(getLayerChildSelection()).toBeNull();
});
+ it('projects mask noise and denoise rows whose dots and Delete edit the modifiers', async () => {
+ await renderTree([
+ layerContract('mask', 'inpaint_mask', {
+ denoise: { isEnabled: true, limit: 0.8 },
+ name: 'Mask',
+ noise: { isEnabled: true, level: 0.25 },
+ }),
+ ]);
+ expect(treeitem('Noise')).toHaveAttribute('aria-level', '3');
+ expect(treeitem('Denoise limit')).toHaveAttribute('aria-posinset', '2');
+ const dot = treeitem('Noise').querySelector<HTMLButtonElement>('button[aria-label="Toggle active"]')!;
+ await act(() => userEvent.click(dot));
+ expect(output('mask-modifiers')).toBe('noise:off:0.25,denoise:on:0.8');
+ treeitem('Denoise limit').focus();
+ await act(() => userEvent.keyboard('{Delete}'));
+ expect(output('mask-modifiers')).toBe('noise:off:0.25');
+ expect(document.activeElement).toBe(treeitem('Mask'));
+ });
+
it('walks child rows from the keyboard and routes their context menu', async () => {
await renderTree(regionWithRefs());
treeitem('Region').focus();
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
index e794c01a0c..f335accdbe 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
@@ -30,6 +30,7 @@ import type { LayerStackActionsEngine } from './useLayerStackActions';
import { LayerChildRow } from './LayerChildRow';
import {
+ layerChildRemoveLabelKey,
layerChildRowCommand,
layerChildRowKey,
projectLayerChildRows,
@@ -333,7 +334,7 @@ export const LayersTree = ({
return;
}
const { panel: current, projectId: project } = latest.current;
- const outcome = runStructural(t('widgets.layers.regionalGuidance.removeReferenceImage'), command);
+ const outcome = runStructural(t(layerChildRemoveLabelKey(child.kind)), command);
// The removed row's focus lands on its owner, not wherever the primary sits.
if (outcome.status === 'committed' && current.focusId === child.key) {
setLayerPanelFocus(project, current.primaryId, child.layerId);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/MaskModifierSettings.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/MaskModifierSettings.tsx
new file mode 100644
index 0000000000..dafba09498
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/MaskModifierSettings.tsx
@@ -0,0 +1,124 @@
+import type { SliderValueChangeDetails } from '@chakra-ui/react';
+import type { CanvasInpaintMaskLayerContract } from '@workbench/canvas-engine/api';
+import type { CanvasStructuralEngine } from '@workbench/widgets/layers/layerOps';
+
+import { Stack, Text } from '@chakra-ui/react';
+import { Field, Slider } from '@platform/ui';
+import { type CanvasPreparedEngine, usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';
+import { useCallback, useMemo, useRef } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { applyStructuralPreview } from './layerOps';
+
+/**
+ * The dedicated Properties editor of a mask's noise or denoise-limit child
+ * row — the view its tree sub-selection opens. Only the magnitude lives here;
+ * the row's dot enables it and the row's menu removes it. Dragging previews
+ * live and commits once on release.
+ */
+
+type MaskModifierKind = 'mask-noise' | 'mask-denoise';
+
+const FIELD_OF: Record<MaskModifierKind, 'noise' | 'denoise'> = { 'mask-denoise': 'denoise', 'mask-noise': 'noise' };
+const LABEL_OF: Record<MaskModifierKind, string> = {
+ 'mask-denoise': 'widgets.layers.maskFill.denoiseLimit',
+ 'mask-noise': 'widgets.layers.maskFill.noiseLevel',
+};
+const HELP_OF: Record<MaskModifierKind, string> = {
+ 'mask-denoise': 'widgets.layers.modifiers.denoiseHelp',
+ 'mask-noise': 'widgets.layers.modifiers.noiseHelp',
+};
+
+const formatUnitPercent = (value: number): string => `${Math.round(value * 100)}%`;
+
+export const MaskModifierSettings = ({
+ engine,
+ kind,
+ layer,
+}: {
+ engine: (CanvasStructuralEngine & CanvasPreparedEngine) | null;
+ kind: MaskModifierKind;
+ layer: CanvasInpaintMaskLayerContract;
+}) => {
+ const { t } = useTranslation();
+ const commitPrepared = usePreparedCommit(engine);
+ const field = FIELD_OF[kind];
+ const modifier = layer[field];
+ const beforeRef = useRef<typeof modifier | null>(null);
+
+ const handleChange = useCallback(
+ ({ value }: SliderValueChangeDetails) => {
+ const next = value[0];
+ if (next === undefined || !Number.isFinite(next) || !modifier) {
+ return;
+ }
+ // Live modifier as the base: only the magnitude previews, a mid-gesture
+ // enable toggle stays put.
+ const config = {
+ layerType: 'inpaint_mask',
+ [field]: field === 'noise' ? { ...modifier, level: next } : { ...modifier, limit: next },
+ } as const;
+ if (applyStructuralPreview(engine, { config, id: layer.id, type: 'updateCanvasLayerConfig' })) {
+ beforeRef.current ??= modifier;
+ }
+ },
+ [engine, field, layer.id, modifier]
+ );
+
+ const handleChangeEnd = useCallback(
+ ({ value }: SliderValueChangeDetails) => {
+ const next = value[0];
+ const before = beforeRef.current ?? modifier;
+ beforeRef.current = null;
+ if (next === undefined || !Number.isFinite(next) || !before || !modifier) {
+ return;
+ }
+ // The commit changes only the magnitude: `isEnabled` stays live, so a
+ // toggle landing mid-gesture is not silently reverted.
+ const committed = { ...before, isEnabled: modifier.isEnabled };
+ commitPrepared(t(LABEL_OF[kind]), (model) =>
+ model.prepare({
+ before: { layerType: 'inpaint_mask', [field]: committed },
+ config: {
+ layerType: 'inpaint_mask',
+ [field]: field === 'noise' ? { ...committed, level: next } : { ...committed, limit: next },
+ },
+ id: layer.id,
+ type: 'patch-config',
+ })
+ );
+ },
+ [commitPrepared, field, kind, layer.id, modifier, t]
+ );
+
+ const sliderValue = useMemo(
+ () => [modifier ? ('level' in modifier ? modifier.level : modifier.limit) : 0],
+ [modifier]
+ );
+ const sliderAria = useMemo(() => [t(LABEL_OF[kind])], [kind, t]);
+
+ if (!modifier) {
+ return null;
+ }
+ return (
+ <Stack gap="2">
+ <Field label={t(LABEL_OF[kind])}>
+ <Slider
+ aria-label={sliderAria}
+ formatValue={formatUnitPercent}
+ max={1}
+ min={0}
+ size="sm"
+ step={0.01}
+ value={sliderValue}
+ withThumbTooltip
+ onValueChange={handleChange}
+ onValueChangeEnd={handleChangeEnd}
+ />
+ </Field>
+ <Text color="fg.muted" fontSize="2xs">
+ {t(HELP_OF[kind])}
+ </Text>
+ </Stack>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
index ee53ed0292..305ed8c289 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
@@ -3,7 +3,7 @@ import type { RegionalGuidanceReferenceImage } from '@workbench/canvas-engine/ap
import { documentFrom, layerContract } from '@workbench/canvas-engine/document-model/documentFixtures.testStub';
import { describe, expect, it } from 'vitest';
-import { layerChildRowCommand, layerChildRowKey, projectLayerChildRows } from './layerChildRows';
+import { getLayerChildItem, layerChildRowCommand, layerChildRowKey, projectLayerChildRows } from './layerChildRows';
import { buildLayerStackRows } from './layerTreeRows';
const referenceImage = (id: string, overrides: Partial<RegionalGuidanceReferenceImage> = {}) => ({
@@ -113,3 +113,53 @@ describe('layerChildRowCommand', () => {
expect(layerChildRowCommand(document, target, { isEnabled: true, type: 'set-enabled' })).toBeNull();
});
});
+
+describe('mask modifier rows', () => {
+ const maskWith = (overrides = {}) => layerContract('m1', 'inpaint_mask', overrides);
+ const maskRow = (document: ReturnType<typeof documentFrom>) =>
+ buildLayerStackRows(document.stacks, new Set()).inpaint_mask.rows.find((row) => row.id === 'm1')!;
+
+ it('projects noise then denoise rows with their values and enablement', () => {
+ const document = documentFrom([
+ maskWith({ denoise: { isEnabled: false, limit: 0.8 }, noise: { isEnabled: true, level: 0.25 } }),
+ ]);
+ const rows = projectLayerChildRows(maskRow(document).vm);
+ expect(rows.map((row) => [row.kind, row.itemId, row.isEnabled, row.value, row.posInSet, row.setSize])).toEqual([
+ ['mask-noise', 'noise', true, 0.25, 1, 2],
+ ['mask-denoise', 'denoise', false, 0.8, 2, 2],
+ ]);
+ expect(projectLayerChildRows(maskRow(documentFrom([maskWith()])).vm)).toEqual([]);
+ });
+
+ it('toggles and removes a modifier through null-clearing patches', () => {
+ const document = documentFrom([maskWith({ noise: { isEnabled: true, level: 0.25 } })]);
+ const toggle = layerChildRowCommand(
+ document,
+ { itemId: 'noise', layerId: 'm1' },
+ { isEnabled: false, type: 'set-enabled' }
+ );
+ expect(toggle).toMatchObject({
+ before: { layerType: 'inpaint_mask', noise: { isEnabled: true, level: 0.25 } },
+ config: { layerType: 'inpaint_mask', noise: { isEnabled: false, level: 0.25 } },
+ id: 'm1',
+ });
+ const remove = layerChildRowCommand(document, { itemId: 'noise', layerId: 'm1' }, { type: 'remove' });
+ expect(remove).toMatchObject({ config: { layerType: 'inpaint_mask', noise: null } });
+ expect(layerChildRowCommand(document, { itemId: 'denoise', layerId: 'm1' }, { type: 'remove' })).toBeNull();
+ expect(
+ layerChildRowCommand(document, { itemId: 'noise', layerId: 'm1' }, { isEnabled: true, type: 'set-enabled' })
+ ).toBeNull();
+ });
+
+ it('resolves live child items across kinds', () => {
+ const document = documentFrom([
+ maskWith({ noise: { isEnabled: false, level: 0.5 } }),
+ regionalWith([referenceImage('ref1')]),
+ ]);
+ expect(getLayerChildItem(document, 'm1', 'noise')).toEqual({ isEnabled: false, kind: 'mask-noise' });
+ expect(getLayerChildItem(document, 'm1', 'denoise')).toBeNull();
+ expect(getLayerChildItem(document, 'rg1', 'ref1')).toEqual({ isEnabled: true, kind: 'reference-image' });
+ expect(getLayerChildItem(document, 'rg1', 'gone')).toBeNull();
+ expect(getLayerChildItem(document, 'gone', 'noise')).toBeNull();
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
index 50a9e815f4..883d803c41 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
@@ -1,5 +1,6 @@
import type {
CanvasDocumentContractV3,
+ CanvasInpaintMaskLayerContract,
DocumentCommand,
LayerStackKind,
SemanticNode,
@@ -12,13 +13,17 @@ export { layerChildRowKey };
/**
* The Layers panel's projected child rows: per-layer modifiers (reference
- * images today) presented as rows beneath the layer that owns them. Rows are
- * a pure projection of config the layer already carries — the document keeps
- * its closed node union, and every edit round-trips through the same
- * `patch-config` seam the Properties pane uses.
+ * images, mask noise and denoise limit) presented as rows beneath the layer
+ * that owns them. Rows are a pure projection of config the layer already
+ * carries — the document keeps its closed node union, and every edit
+ * round-trips through the same `patch-config` seam the Properties pane uses.
*/
-export type LayerChildRowKind = 'reference-image';
+export type LayerChildRowKind = 'reference-image' | 'mask-noise' | 'mask-denoise';
+
+/** The synthetic item ids of a mask's singleton modifiers. */
+export const MASK_NOISE_ITEM_ID = 'noise';
+export const MASK_DENOISE_ITEM_ID = 'denoise';
export interface ProjectedChildRow {
/** Tree key, also the row's DOM id: `child:{layerId}:{itemId}`. */
@@ -35,70 +40,173 @@ export interface ProjectedChildRow {
/** The owning layer and its ancestors are enabled; a gated dot when not. */
readonly parentContributing: boolean;
readonly image: { readonly imageName: string; readonly thumbnailUrl: string } | null;
+ /** The modifier's 0–1 magnitude, shown beside the name; `null` for reference images. */
+ readonly value: number | null;
}
export type LayerChildRowAction = { type: 'set-enabled'; isEnabled: boolean } | { type: 'remove' };
+/** A child row's live item facts, resolved from the document; `null` when it is gone. */
+export interface LayerChildItem {
+ readonly kind: LayerChildRowKind;
+ readonly isEnabled: boolean;
+}
+
const EMPTY_CHILD_ROWS: readonly ProjectedChildRow[] = [];
const childRowsByNode = new WeakMap<SemanticNode, readonly ProjectedChildRow[]>();
+const baseRow = (vm: SemanticNode) => ({
+ depth: vm.depth + 1,
+ layerId: vm.node.id,
+ parentContributing: vm.contributionEnabled,
+ stack: vm.stack,
+});
+
+const maskModifierRows = (vm: SemanticNode, layer: CanvasInpaintMaskLayerContract): ProjectedChildRow[] => {
+ const items = [
+ layer.noise
+ ? {
+ isEnabled: layer.noise.isEnabled,
+ itemId: MASK_NOISE_ITEM_ID,
+ kind: 'mask-noise' as const,
+ value: layer.noise.level,
+ }
+ : null,
+ layer.denoise
+ ? {
+ isEnabled: layer.denoise.isEnabled,
+ itemId: MASK_DENOISE_ITEM_ID,
+ kind: 'mask-denoise' as const,
+ value: layer.denoise.limit,
+ }
+ : null,
+ ].filter((item) => item !== null);
+ return items.map((item, index) => ({
+ ...baseRow(vm),
+ ...item,
+ image: null,
+ key: layerChildRowKey(layer.id, item.itemId),
+ posInSet: index + 1,
+ setSize: items.length,
+ }));
+};
+
/** The child rows a layer projects; the identical array while the node is unchanged. */
export const projectLayerChildRows = (vm: SemanticNode): readonly ProjectedChildRow[] => {
const { node } = vm;
- if (node.type !== 'regional_guidance' || node.referenceImages.length === 0) {
- return EMPTY_CHILD_ROWS;
- }
const cached = childRowsByNode.get(vm);
if (cached) {
return cached;
}
- const setSize = node.referenceImages.length;
- const rows = node.referenceImages.map((ref, index): ProjectedChildRow => ({
- depth: vm.depth + 1,
- image: ref.config.image
- ? { imageName: ref.config.image.imageName, thumbnailUrl: ref.config.image.thumbnailUrl }
- : null,
- isEnabled: ref.isEnabled,
- itemId: ref.id,
- key: layerChildRowKey(node.id, ref.id),
- kind: 'reference-image',
- layerId: node.id,
- parentContributing: vm.contributionEnabled,
- posInSet: index + 1,
- setSize,
- stack: vm.stack,
- }));
+ let rows: readonly ProjectedChildRow[];
+ if (node.type === 'regional_guidance' && node.referenceImages.length > 0) {
+ const setSize = node.referenceImages.length;
+ rows = node.referenceImages.map((ref, index): ProjectedChildRow => ({
+ ...baseRow(vm),
+ image: ref.config.image
+ ? { imageName: ref.config.image.imageName, thumbnailUrl: ref.config.image.thumbnailUrl }
+ : null,
+ isEnabled: ref.isEnabled,
+ itemId: ref.id,
+ key: layerChildRowKey(node.id, ref.id),
+ kind: 'reference-image',
+ posInSet: index + 1,
+ setSize,
+ value: null,
+ }));
+ } else if (node.type === 'inpaint_mask' && (node.noise || node.denoise)) {
+ rows = maskModifierRows(vm, node);
+ } else {
+ return EMPTY_CHILD_ROWS;
+ }
childRowsByNode.set(vm, rows);
return rows;
};
+/** Resolves a child row's item from the live document; `null` when the layer or item is gone. */
+export const getLayerChildItem = (
+ document: CanvasDocumentContractV3,
+ layerId: string,
+ itemId: string
+): LayerChildItem | null => {
+ const layer = getDocumentLayer(document, layerId);
+ if (layer?.type === 'regional_guidance') {
+ const ref = layer.referenceImages.find((entry) => entry.id === itemId);
+ return ref ? { isEnabled: ref.isEnabled, kind: 'reference-image' } : null;
+ }
+ if (layer?.type === 'inpaint_mask') {
+ if (itemId === MASK_NOISE_ITEM_ID && layer.noise) {
+ return { isEnabled: layer.noise.isEnabled, kind: 'mask-noise' };
+ }
+ if (itemId === MASK_DENOISE_ITEM_ID && layer.denoise) {
+ return { isEnabled: layer.denoise.isEnabled, kind: 'mask-denoise' };
+ }
+ }
+ return null;
+};
+
+/** The i18n key naming a child row's removal, for menus and history entries alike. */
+export const layerChildRemoveLabelKey = (kind: LayerChildRowKind): string => {
+ switch (kind) {
+ case 'reference-image':
+ return 'widgets.layers.regionalGuidance.removeReferenceImage';
+ case 'mask-noise':
+ return 'widgets.layers.modifiers.removeNoise';
+ case 'mask-denoise':
+ return 'widgets.layers.modifiers.removeDenoise';
+ }
+};
+
+type PatchConfigCommand = Extract<DocumentCommand, { type: 'patch-config' }>;
+
/**
* The document command a child-row action resolves to, or `null` when the
* layer or item is gone or the action changes nothing. Both sides of the patch
- * carry the whole array, exactly as the Properties pane commits it.
+ * carry the modifier's whole value, exactly as the Properties editors commit.
*/
export const layerChildRowCommand = (
document: CanvasDocumentContractV3,
target: Pick<ProjectedChildRow, 'layerId' | 'itemId'>,
action: LayerChildRowAction
-): Extract<DocumentCommand, { type: 'patch-config' }> | null => {
+): PatchConfigCommand | null => {
const layer = getDocumentLayer(document, target.layerId);
- if (layer?.type !== 'regional_guidance' || !layer.referenceImages.some((ref) => ref.id === target.itemId)) {
- return null;
+ if (layer?.type === 'regional_guidance') {
+ if (!layer.referenceImages.some((ref) => ref.id === target.itemId)) {
+ return null;
+ }
+ const before = layer.referenceImages;
+ const next =
+ action.type === 'remove'
+ ? before.filter((ref) => ref.id !== target.itemId)
+ : before.map((ref) => (ref.id === target.itemId ? { ...ref, isEnabled: action.isEnabled } : ref));
+ if (action.type === 'set-enabled' && before.every((ref, index) => next[index]!.isEnabled === ref.isEnabled)) {
+ return null;
+ }
+ return {
+ before: { layerType: 'regional_guidance', referenceImages: [...before] },
+ config: { layerType: 'regional_guidance', referenceImages: next },
+ id: target.layerId,
+ type: 'patch-config',
+ };
}
- const before = layer.referenceImages;
- const next =
- action.type === 'remove'
- ? before.filter((ref) => ref.id !== target.itemId)
- : before.map((ref) => (ref.id === target.itemId ? { ...ref, isEnabled: action.isEnabled } : ref));
- if (action.type === 'set-enabled' && before.every((ref, index) => next[index]!.isEnabled === ref.isEnabled)) {
- return null;
+ if (layer?.type === 'inpaint_mask') {
+ const field =
+ target.itemId === MASK_NOISE_ITEM_ID ? 'noise' : target.itemId === MASK_DENOISE_ITEM_ID ? 'denoise' : null;
+ const current = field ? layer[field] : undefined;
+ if (!field || !current) {
+ return null;
+ }
+ const next = action.type === 'remove' ? null : { ...current, isEnabled: action.isEnabled };
+ if (next && next.isEnabled === current.isEnabled) {
+ return null;
+ }
+ return {
+ before: { [field]: current, layerType: 'inpaint_mask' },
+ config: { [field]: next, layerType: 'inpaint_mask' },
+ id: target.layerId,
+ type: 'patch-config',
+ };
}
- return {
- before: { layerType: 'regional_guidance', referenceImages: [...before] },
- config: { layerType: 'regional_guidance', referenceImages: next },
- id: target.layerId,
- type: 'patch-config',
- };
+ return null;
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildSelection.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildSelection.ts
index db2894027c..f1d1b100b1 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildSelection.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildSelection.ts
@@ -2,7 +2,8 @@ import type { CanvasDocumentContractV3 } from '@workbench/canvas-engine/api';
import { registerAccountOwnedResource } from '@platform/state/accountLifecycle';
import { createExternalStore } from '@platform/state/externalStore';
-import { getDocumentLayer } from '@workbench/canvas-engine/api';
+
+import { getLayerChildItem } from './layerChildRows';
/**
* The panel's sub-selection: the one projected child row being edited. Widget
@@ -37,12 +38,10 @@ export const reconcileLayerChildSelection = (projectId: string, document: Canvas
if (!selection || selection.projectId !== projectId) {
return;
}
- if (document.selectedLayerId !== selection.layerId) {
- clearLayerChildSelection();
- return;
- }
- const layer = getDocumentLayer(document, selection.layerId);
- if (layer?.type !== 'regional_guidance' || !layer.referenceImages.some((ref) => ref.id === selection.itemId)) {
+ if (
+ document.selectedLayerId !== selection.layerId ||
+ !getLayerChildItem(document, selection.layerId, selection.itemId)
+ ) {
clearLayerChildSelection();
}
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts
index 107c1d9068..832a26efc3 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts
@@ -89,6 +89,7 @@ const makeState = (
};
const makeEffects = (): LayerContextActionEffects => ({
+ addMaskModifier: vi.fn(),
addReferenceImage: vi.fn(),
booleanMerge: vi.fn(() => Promise.resolve()),
toggleHidden: vi.fn(),
@@ -477,6 +478,8 @@ describe('getLayerContextActions', () => {
'control-transparency-effect',
'regional-auto-negative',
'add-reference-image',
+ 'add-noise',
+ 'add-denoise-limit',
'merge-down',
'merge-selected',
'toggle-visibility',
@@ -499,6 +502,21 @@ describe('getLayerContextActions', () => {
expect(rasterActions.some((action) => action.id === 'add-reference-image')).toBe(false);
});
+ it('offers add-noise and add-denoise-limit only while the mask lacks that modifier', () => {
+ const bare = getLayerContextActions(makeState(makeLayer('inpaint_mask')));
+ expect(byId(bare, 'add-noise').isDisabled).toBe(false);
+ expect(byId(bare, 'add-denoise-limit').isDisabled).toBe(false);
+ const configured = getLayerContextActions(
+ makeState({
+ ...makeLayer('inpaint_mask'),
+ denoise: { isEnabled: false, limit: 0.8 },
+ noise: { isEnabled: true, level: 0.25 },
+ } as CanvasLayerContract)
+ );
+ expect(configured.some((action) => action.id === 'add-noise')).toBe(false);
+ expect(configured.some((action) => action.id === 'add-denoise-limit')).toBe(false);
+ });
+
it('still allows non-destructive copy and export from a locked layer when interaction is free', () => {
const actions = getLayerContextActions(makeState({ ...rasterLayer, isLocked: true }));
expect(byId(actions, 'copy-to-clipboard').isDisabled).toBe(false);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
index aa87489786..d27296d1a9 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
@@ -24,6 +24,7 @@ import {
EyeIcon,
EyeOffIcon,
FolderPlusIcon,
+ GaugeIcon,
ImageIcon,
ImagePlusIcon,
LockIcon,
@@ -32,6 +33,7 @@ import {
PencilIcon,
SaveIcon,
ScanSearchIcon,
+ WavesIcon,
SlidersHorizontalIcon,
Trash2Icon,
WorkflowIcon,
@@ -41,6 +43,8 @@ import { canConvertRasterControl, canMergeLayerDown } from './layerOps';
export type LayerContextActionId =
| 'add-reference-image'
+ | 'add-noise'
+ | 'add-denoise-limit'
| 'merge-selected'
| 'move-to-front'
| 'move-forward'
@@ -128,6 +132,7 @@ export interface LayerContextActionEffects {
convertTo(target: LayerType): void;
patchConfig(kind: LayerConfigPatchKind): void;
addReferenceImage(): void;
+ addMaskModifier(field: 'noise' | 'denoise'): void;
mergeDown(): void;
toggleVisibility(): void;
toggleHidden(): void;
@@ -501,6 +506,30 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini
section: 'primary',
supportedLayerTypes: REGIONAL_ONLY,
},
+ {
+ defaultLabel: 'Add noise',
+ handler: ({ effects }) => effects.addMaskModifier('noise'),
+ icon: WavesIcon,
+ id: 'add-noise',
+ isEnabled: isLayerMutable,
+ isVisible: (context) => context.layer.type === 'inpaint_mask' && context.layer.noise === undefined,
+ labelKey: 'widgets.layers.actions.addNoise',
+ order: 55,
+ section: 'primary',
+ supportedLayerTypes: INPAINT_ONLY,
+ },
+ {
+ defaultLabel: 'Add denoise limit',
+ handler: ({ effects }) => effects.addMaskModifier('denoise'),
+ icon: GaugeIcon,
+ id: 'add-denoise-limit',
+ isEnabled: isLayerMutable,
+ isVisible: (context) => context.layer.type === 'inpaint_mask' && context.layer.denoise === undefined,
+ labelKey: 'widgets.layers.actions.addDenoiseLimit',
+ order: 56,
+ section: 'primary',
+ supportedLayerTypes: INPAINT_ONLY,
+ },
{
defaultLabel: 'Extract masked area',
handler: ({ effects }) => effects.extractMaskedArea(),
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts
index e18e390dda..7efe477563 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts
@@ -108,7 +108,7 @@ describe('getLayerContextMenuLayout', () => {
expect(summarize(inpaint)[1]).toEqual({
id: 'primary',
- items: ['rename', 'fit-to-bbox', 'extract-masked-area'],
+ items: ['rename', 'fit-to-bbox', 'add-noise', 'add-denoise-limit', 'extract-masked-area'],
presentation: 'list',
});
expect(summarize(regional)[1]).toEqual({
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerRowSummary.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerRowSummary.test.ts
index 175902f7f0..7afdea82be 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerRowSummary.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerRowSummary.test.ts
@@ -28,7 +28,12 @@ describe('layerRowSummary', () => {
expect(layerRowSummary({ ...regional, positivePrompt: ' a red barn ' } as typeof regional, t)).toBe('a red barn');
expect(layerRowSummary(regional, t)).toBe('widgets.layers.types.regional_guidance');
const mask = layerContract('m', 'inpaint_mask');
- expect(layerRowSummary({ ...mask, denoiseLimit: 0.6, noiseLevel: 0.2 } as typeof mask, t)).toBe(
+ expect(
+ layerRowSummary(
+ { ...mask, denoise: { isEnabled: true, limit: 0.6 }, noise: { isEnabled: true, level: 0.2 } } as typeof mask,
+ t
+ )
+ ).toBe(
'widgets.layers.types.inpaint_mask · widgets.layers.summary.denoiseLimit:60 · widgets.layers.summary.noise:20'
);
});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerRowSummary.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerRowSummary.ts
index 0240d50369..d4aeaf5fe6 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerRowSummary.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerRowSummary.ts
@@ -32,11 +32,11 @@ export const layerRowSummary = (layer: CanvasLayerContract, t: TFunction): strin
}
case 'inpaint_mask': {
const parts = [t('widgets.layers.types.inpaint_mask')];
- if (layer.denoiseLimit !== undefined) {
- parts.push(t('widgets.layers.summary.denoiseLimit', { value: Math.round(layer.denoiseLimit * 100) }));
+ if (layer.denoise?.isEnabled) {
+ parts.push(t('widgets.layers.summary.denoiseLimit', { value: Math.round(layer.denoise.limit * 100) }));
}
- if (layer.noiseLevel !== undefined && layer.noiseLevel > 0) {
- parts.push(t('widgets.layers.summary.noise', { value: Math.round(layer.noiseLevel * 100) }));
+ if (layer.noise?.isEnabled && layer.noise.level > 0) {
+ parts.push(t('widgets.layers.summary.noise', { value: Math.round(layer.noise.level * 100) }));
}
return parts.join(' · ');
}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
index a0525f6658..2e7c797019 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
@@ -8,7 +8,9 @@ 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 { MASK_DENOISE_ITEM_ID, MASK_NOISE_ITEM_ID } from '@workbench/widgets/layers/layerChildRows';
import { useLayerChildSelection } from '@workbench/widgets/layers/layerChildSelection';
+import { MaskModifierSettings } from '@workbench/widgets/layers/MaskModifierSettings';
import { RasterLayerFilterSection } from '@workbench/widgets/layers/RasterLayerFilterSection';
import { ReferenceImageSettings } from '@workbench/widgets/layers/ReferenceImageSettings';
import { RegionalGuidanceSettings } from '@workbench/widgets/layers/RegionalGuidanceSettings';
@@ -42,26 +44,16 @@ export const LayerSection = ({ disabled }: { disabled: boolean }) => {
// A sub-selected child row takes over the section: its own editor, its own name.
const projectId = useActiveProjectId();
const childSelection = useLayerChildSelection();
- const childIndex =
- layer?.type === 'regional_guidance' &&
- childSelection?.projectId === projectId &&
- childSelection.layerId === layer.id
- ? layer.referenceImages.findIndex((ref) => ref.id === childSelection.itemId)
- : -1;
- const childRefId = childIndex >= 0 ? childSelection!.itemId : null;
+ const child = resolveChildEditor(layer, childSelection?.projectId === projectId ? childSelection : null, t);
return (
<PropertiesSection
disabled={disabled}
- subtitle={
- childRefId
- ? `${t('widgets.layers.regionalGuidance.referenceImage')} ${childIndex + 1}`
- : (layer?.name ?? t('widgets.transform.noSelection'))
- }
+ subtitle={child ? child.subtitle : (layer?.name ?? t('widgets.transform.noSelection'))}
title={t('widgets.properties.sections.layer')}
>
- {layer?.type === 'regional_guidance' && childRefId ? (
- <ReferenceImageSettings key={`${layer.id}:${childRefId}`} engine={engine} layer={layer} refId={childRefId} />
+ {child && layer ? (
+ <ChildEditor key={`${layer.id}:${child.itemId}`} child={child} engine={engine} layer={layer} />
) : layer ? (
<LayerTypeSettings documentRevision={documentRevision} engine={engine} layer={layer} />
) : (
@@ -71,6 +63,60 @@ export const LayerSection = ({ disabled }: { disabled: boolean }) => {
);
};
+interface ChildEditorTarget {
+ readonly kind: 'reference-image' | 'mask-noise' | 'mask-denoise';
+ readonly itemId: string;
+ readonly subtitle: string;
+}
+
+/** What the sub-selection edits, or `null` when it does not belong to `layer`. */
+const resolveChildEditor = (
+ layer: CanvasLayerContract | null,
+ selection: { layerId: string; itemId: string } | null,
+ t: (key: string) => string
+): ChildEditorTarget | null => {
+ if (!layer || !selection || selection.layerId !== layer.id) {
+ return null;
+ }
+ if (layer.type === 'regional_guidance') {
+ const index = layer.referenceImages.findIndex((ref) => ref.id === selection.itemId);
+ return index >= 0
+ ? {
+ itemId: selection.itemId,
+ kind: 'reference-image',
+ subtitle: `${t('widgets.layers.regionalGuidance.referenceImage')} ${index + 1}`,
+ }
+ : null;
+ }
+ if (layer.type === 'inpaint_mask') {
+ if (selection.itemId === MASK_NOISE_ITEM_ID && layer.noise) {
+ return { itemId: selection.itemId, kind: 'mask-noise', subtitle: t('widgets.layers.modifiers.noise') };
+ }
+ if (selection.itemId === MASK_DENOISE_ITEM_ID && layer.denoise) {
+ return { itemId: selection.itemId, kind: 'mask-denoise', subtitle: t('widgets.layers.modifiers.denoise') };
+ }
+ }
+ return null;
+};
+
+const ChildEditor = ({
+ child,
+ engine,
+ layer,
+}: {
+ child: ChildEditorTarget;
+ engine: LayerSectionEngine | null;
+ layer: CanvasLayerContract;
+}) => {
+ if (child.kind === 'reference-image' && layer.type === 'regional_guidance') {
+ return <ReferenceImageSettings engine={engine} layer={layer} refId={child.itemId} />;
+ }
+ if ((child.kind === 'mask-noise' || child.kind === 'mask-denoise') && layer.type === 'inpaint_mask') {
+ return <MaskModifierSettings engine={engine} kind={child.kind} layer={layer} />;
+ }
+ return null;
+};
+
/** Dispatches to the correct per-type settings block for the layer. */
const LayerTypeSettings = ({
documentRevision,
diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
index f6acf2f301..400f74a33c 100644
--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts
@@ -4807,10 +4807,10 @@ describe('workbenchReducer canvas v2 layer reducers', () => {
state = workbenchReducer(state, {
config: {
- denoiseLimit: 0.8,
+ denoise: { isEnabled: true, limit: 0.8 },
layerType: 'inpaint_mask',
mask: { bitmap: { contentHash: 'h', height: 20, imageName: 'mask.png', width: 30 }, offset: { x: 4, y: 5 } },
- noiseLevel: 0.25,
+ noise: { isEnabled: true, level: 0.25 },
},
id: 'm',
type: 'updateCanvasLayerConfig',
@@ -4823,8 +4823,8 @@ describe('workbenchReducer canvas v2 layer reducers', () => {
expect(layer.mask.bitmap).toMatchObject({ imageName: 'mask.png', width: 30, height: 20 });
expect(layer.mask.offset).toEqual({ x: 4, y: 5 });
expect(layer.mask.fill).toEqual({ color: '#e07575', style: 'diagonal' });
- expect(layer.noiseLevel).toBe(0.25);
- expect(layer.denoiseLimit).toBe(0.8);
+ expect(layer.noise).toEqual({ isEnabled: true, level: 0.25 });
+ expect(layer.denoise).toEqual({ isEnabled: true, limit: 0.8 });
}
// A fill-only patch replaces the fill while keeping the bitmap.
@@ -4840,16 +4840,16 @@ describe('workbenchReducer canvas v2 layer reducers', () => {
}
});
- it('removes optional config fields when a patch explicitly sets them to undefined', () => {
+ it('removes optional config fields when a patch explicitly clears them', () => {
const configuredMask: CanvasInpaintMaskLayerContract = {
blendMode: 'normal',
- denoiseLimit: 0.8,
+ denoise: { isEnabled: true, limit: 0.8 },
id: 'm',
isEnabled: true,
isLocked: false,
mask: { bitmap: null, fill: { color: '#e07575', style: 'diagonal' } },
name: 'm',
- noiseLevel: 0.25,
+ noise: { isEnabled: true, level: 0.25 },
opacity: 1,
transform: { rotation: 0, scaleX: 1, scaleY: 1, x: 0, y: 0 },
type: 'inpaint_mask',
@@ -4860,7 +4860,7 @@ describe('workbenchReducer canvas v2 layer reducers', () => {
]);
state = workbenchReducer(state, {
- config: { denoiseLimit: undefined, layerType: 'inpaint_mask', noiseLevel: undefined },
+ config: { denoise: null, layerType: 'inpaint_mask', noise: null },
id: 'm',
type: 'updateCanvasLayerConfig',
});
@@ -4875,8 +4875,9 @@ describe('workbenchReducer canvas v2 layer reducers', () => {
expect(mask?.type).toBe('inpaint_mask');
if (mask?.type === 'inpaint_mask') {
- expect(mask.noiseLevel).toBeUndefined();
- expect(mask.denoiseLimit).toBeUndefined();
+ expect(mask.noise).toBeUndefined();
+ expect(mask.denoise).toBeUndefined();
+ expect(Object.hasOwn(mask, 'noise')).toBe(false);
}
expect(control?.type).toBe('control');
if (control?.type === 'control') {