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(layers): color labels on layers and groups

Josh Corbettab8207192a58
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.json
index bb78c0f6a3..7beef71f5a 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": 118.6000000089407,
+ "domContentLoadedMedianMs": 117,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 118.70000000298023,
- "longestTaskMaxMs": 69,
+ "loadMedianMs": 117,
+ "longestTaskMaxMs": 71,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -41,24 +41,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 38,
- "scriptRawBytes": 1636381,
+ "scriptRawBytes": 1636430,
"scriptRequestCount": 34,
- "totalRawBytes": 1822932
+ "totalRawBytes": 1823248
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 38,
- "scriptRawBytes": 1652745,
+ "scriptRawBytes": 1652795,
"scriptRequestCount": 34,
- "totalRawBytes": 1841162
+ "totalRawBytes": 1841481
},
- "routeReadyMedianMs": 260.90000000596046,
+ "routeReadyMedianMs": 263.6000000089407,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@ -85,12 +85,12 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 117.79999999701977,
+ "domContentLoadedMedianMs": 118.90000000596046,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 117.8999999910593,
+ "loadMedianMs": 119.1000000089407,
"longestTaskMaxMs": 70,
"owner": "app",
"projectSwitchMedianMs": 0,
@@ -101,24 +101,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 38,
- "scriptRawBytes": 1636381,
+ "scriptRawBytes": 1636430,
"scriptRequestCount": 34,
- "totalRawBytes": 1822932
+ "totalRawBytes": 1823248
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 0,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 38,
- "scriptRawBytes": 1652745,
+ "scriptRawBytes": 1652795,
"scriptRequestCount": 34,
- "totalRawBytes": 1841162
+ "totalRawBytes": 1841481
},
- "routeReadyMedianMs": 277.09999999403954,
+ "routeReadyMedianMs": 281.1000000089407,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@ -145,15 +145,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 117.79999999701977,
+ "domContentLoadedMedianMs": 121.09999999403954,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 118,
- "longestTaskMaxMs": 113,
+ "loadMedianMs": 121.29999999701977,
+ "longestTaskMaxMs": 99,
"owner": "workbench",
- "projectSwitchMedianMs": 37.69999998807907,
+ "projectSwitchMedianMs": 37.70000000298023,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -161,24 +161,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 115,
- "scriptRawBytes": 3286283,
+ "scriptRawBytes": 3286728,
"scriptRequestCount": 110,
- "totalRawBytes": 3629210
+ "totalRawBytes": 3629922
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 115,
- "scriptRawBytes": 3319146,
+ "scriptRawBytes": 3319596,
"scriptRequestCount": 110,
- "totalRawBytes": 3665503
+ "totalRawBytes": 3666222
},
- "routeReadyMedianMs": 671.2000000029802,
+ "routeReadyMedianMs": 677.5999999940395,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -205,15 +205,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 119.5,
+ "domContentLoadedMedianMs": 118,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 119.6000000089407,
- "longestTaskMaxMs": 200,
+ "loadMedianMs": 118.09999999403954,
+ "longestTaskMaxMs": 184,
"owner": "workbench",
- "projectSwitchMedianMs": 70.90000000596046,
+ "projectSwitchMedianMs": 71,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -221,24 +221,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 115,
- "scriptRawBytes": 3286283,
+ "scriptRawBytes": 3286728,
"scriptRequestCount": 110,
- "totalRawBytes": 3629210
+ "totalRawBytes": 3629922
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 115,
- "scriptRawBytes": 3319146,
+ "scriptRawBytes": 3319596,
"scriptRequestCount": 110,
- "totalRawBytes": 3665503
+ "totalRawBytes": 3666222
},
- "routeReadyMedianMs": 448.70000000298023,
+ "routeReadyMedianMs": 450.19999998807907,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -247,31 +247,31 @@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 297203,
+ "largestAssetRawBytes": 298823,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 455563,
+ "scriptRawBytes": 458453,
"scriptRequestCount": 7,
- "totalRawBytes": 455563
+ "totalRawBytes": 458453
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 300176,
+ "largestAssetRawBytes": 301812,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 460119,
+ "scriptRawBytes": 463038,
"scriptRequestCount": 7,
- "totalRawBytes": 460119
+ "totalRawBytes": 463038
},
- "domContentLoadedMedianMs": 117.8999999910593,
+ "domContentLoadedMedianMs": 119.5,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.2000000029802322,
- "layoutReturnSwitchMedianMs": 54.8999999910593,
- "layoutSwitchMedianMs": 93.70000000298023,
- "loadMedianMs": 118,
- "longestTaskMaxMs": 135,
+ "layoutAckMedianMs": 2.199999988079071,
+ "layoutReturnSwitchMedianMs": 55.69999998807907,
+ "layoutSwitchMedianMs": 95.40000000596046,
+ "loadMedianMs": 119.6000000089407,
+ "longestTaskMaxMs": 127,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -281,24 +281,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 122,
- "scriptRawBytes": 3741846,
+ "scriptRawBytes": 3745181,
"scriptRequestCount": 117,
- "totalRawBytes": 4084773
+ "totalRawBytes": 4088375
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 122,
- "scriptRawBytes": 3779265,
+ "scriptRawBytes": 3782633,
"scriptRequestCount": 117,
- "totalRawBytes": 4125621
+ "totalRawBytes": 4129259
},
- "routeReadyMedianMs": 1060.3999999910593,
+ "routeReadyMedianMs": 1060,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@ -307,31 +307,31 @@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 297203,
+ "largestAssetRawBytes": 298823,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 455563,
+ "scriptRawBytes": 458453,
"scriptRequestCount": 7,
- "totalRawBytes": 455563
+ "totalRawBytes": 458453
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 300176,
+ "largestAssetRawBytes": 301812,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 460119,
+ "scriptRawBytes": 463038,
"scriptRequestCount": 7,
- "totalRawBytes": 460119
+ "totalRawBytes": 463038
},
- "domContentLoadedMedianMs": 117.59999999403954,
+ "domContentLoadedMedianMs": 119.1000000089407,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.4000000059604645,
- "layoutReturnSwitchMedianMs": 45.5,
- "layoutSwitchMedianMs": 92,
- "loadMedianMs": 117.69999998807907,
- "longestTaskMaxMs": 185,
+ "layoutAckMedianMs": 2.7999999970197678,
+ "layoutReturnSwitchMedianMs": 47,
+ "layoutSwitchMedianMs": 91.1000000089407,
+ "loadMedianMs": 119.20000000298023,
+ "longestTaskMaxMs": 188,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -341,24 +341,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 122,
- "scriptRawBytes": 3741846,
+ "scriptRawBytes": 3745181,
"scriptRequestCount": 117,
- "totalRawBytes": 4084773
+ "totalRawBytes": 4088375
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 122,
- "scriptRawBytes": 3779265,
+ "scriptRawBytes": 3782633,
"scriptRequestCount": 117,
- "totalRawBytes": 4125621
+ "totalRawBytes": 4129259
},
- "routeReadyMedianMs": 1155.699999988079,
+ "routeReadyMedianMs": 1169.4000000059605,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@ -385,13 +385,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383461
},
- "domContentLoadedMedianMs": 118.09999999403954,
+ "domContentLoadedMedianMs": 117.09999999403954,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.2999999970197678,
- "layoutReturnSwitchMedianMs": 33.79999999701977,
- "layoutSwitchMedianMs": 91.5,
- "loadMedianMs": 118.29999999701977,
- "longestTaskMaxMs": 98,
+ "layoutAckMedianMs": 2.4000000059604645,
+ "layoutReturnSwitchMedianMs": 34.6000000089407,
+ "layoutSwitchMedianMs": 93.8999999910593,
+ "loadMedianMs": 117.40000000596046,
+ "longestTaskMaxMs": 104,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -401,24 +401,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 122,
- "scriptRawBytes": 3650534,
+ "scriptRawBytes": 3650979,
"scriptRequestCount": 116,
- "totalRawBytes": 4008874
+ "totalRawBytes": 4009586
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 122,
- "scriptRawBytes": 3687040,
+ "scriptRawBytes": 3687489,
"scriptRequestCount": 116,
- "totalRawBytes": 4048963
+ "totalRawBytes": 4049682
},
- "routeReadyMedianMs": 1056,
+ "routeReadyMedianMs": 1060.2999999970198,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "empty"
},
@@ -445,13 +445,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383461
},
- "domContentLoadedMedianMs": 119.8999999910593,
+ "domContentLoadedMedianMs": 122.20000000298023,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.7000000029802322,
- "layoutReturnSwitchMedianMs": 40.599999994039536,
- "layoutSwitchMedianMs": 133.40000000596046,
- "loadMedianMs": 120,
- "longestTaskMaxMs": 358,
+ "layoutAckMedianMs": 2.8999999910593033,
+ "layoutReturnSwitchMedianMs": 42.79999999701977,
+ "layoutSwitchMedianMs": 129.90000000596046,
+ "loadMedianMs": 122.30000001192093,
+ "longestTaskMaxMs": 372,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -461,24 +461,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 122,
- "scriptRawBytes": 3650534,
+ "scriptRawBytes": 3650979,
"scriptRequestCount": 116,
- "totalRawBytes": 4008874
+ "totalRawBytes": 4009586
},
"resourceLimits": {
"cssRawBytes": 17748,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 122,
- "scriptRawBytes": 3687040,
+ "scriptRawBytes": 3687489,
"scriptRequestCount": 116,
- "totalRawBytes": 4048963
+ "totalRawBytes": 4049682
},
- "routeReadyMedianMs": 1173.1000000089407,
+ "routeReadyMedianMs": 1201.2000000029802,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "representative"
},
@@ -505,13 +505,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 121,
+ "domContentLoadedMedianMs": 116.20000000298023,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 25.900000005960464,
- "loadMedianMs": 121.09999999403954,
- "longestTaskMaxMs": 100,
+ "layoutSwitchMedianMs": 26.799999997019768,
+ "loadMedianMs": 116.40000000596046,
+ "longestTaskMaxMs": 107,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -521,24 +521,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 115,
- "scriptRawBytes": 3286283,
+ "scriptRawBytes": 3286728,
"scriptRequestCount": 110,
- "totalRawBytes": 3629210
+ "totalRawBytes": 3629922
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 115,
- "scriptRawBytes": 3319146,
+ "scriptRawBytes": 3319596,
"scriptRequestCount": 110,
- "totalRawBytes": 3665503
+ "totalRawBytes": 3666222
},
- "routeReadyMedianMs": 1274.300000011921,
+ "routeReadyMedianMs": 1267.2000000029802,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -565,13 +565,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 117.29999999701977,
+ "domContentLoadedMedianMs": 121,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 89.3999999910593,
- "loadMedianMs": 117.5,
- "longestTaskMaxMs": 190,
+ "layoutSwitchMedianMs": 95.3999999910593,
+ "loadMedianMs": 121,
+ "longestTaskMaxMs": 194,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -581,24 +581,24 @@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 746376,
- "otherRawBytes": 160728,
+ "otherRawBytes": 160995,
"requestCount": 115,
- "scriptRawBytes": 3286283,
+ "scriptRawBytes": 3286728,
"scriptRequestCount": 110,
- "totalRawBytes": 3629210
+ "totalRawBytes": 3629922
},
"resourceLimits": {
"cssRawBytes": 2181,
"fontRawBytes": 23901,
"imageRawBytes": 157940,
"largestAssetRawBytes": 753840,
- "otherRawBytes": 162336,
+ "otherRawBytes": 162605,
"requestCount": 115,
- "scriptRawBytes": 3319146,
+ "scriptRawBytes": 3319596,
"scriptRequestCount": 110,
- "totalRawBytes": 3665503
+ "totalRawBytes": 3666222
},
- "routeReadyMedianMs": 1454.0999999940395,
+ "routeReadyMedianMs": 1471.699999988079,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
}
@@ -2881,6 +2881,7 @@
"source:src/workbench/widgets/layers/RegionalGuidanceSettings.tsx",
"source:src/workbench/widgets/layers/RunLayerWorkflowDialog.tsx",
"source:src/workbench/widgets/layers/addLayerMenu.ts",
+ "source:src/workbench/widgets/layers/colorLabels.ts",
"source:src/workbench/widgets/layers/controlModelOptions.ts",
"source:src/workbench/widgets/layers/curveEditorMath.ts",
"source:src/workbench/widgets/layers/implementation.ts",
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index b378e71508..bc1e8209fe 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -2957,7 +2957,18 @@
"booleanOperations": "Boolean operations",
"convertTo": "Convert to",
"copyTo": "Copy to",
- "addAdjustment": "Add adjustment"
+ "addAdjustment": "Add adjustment",
+ "colorLabel": "Color label"
+ },
+ "labels": {
+ "none": "None",
+ "red": "Red",
+ "orange": "Orange",
+ "yellow": "Yellow",
+ "green": "Green",
+ "blue": "Blue",
+ "violet": "Violet",
+ "gray": "Gray"
},
"options": "Layer options",
"regionalGuidance": {
diff --git a/invokeai/frontend/webv2/src/platform/ui/Menu.tsx b/invokeai/frontend/webv2/src/platform/ui/Menu.tsx
index 42ff2b9088..f23eab9fc3 100644
--- a/invokeai/frontend/webv2/src/platform/ui/Menu.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/Menu.tsx
@@ -17,6 +17,8 @@ export interface MenuActionItemProps {
value: string;
label: string;
icon?: LucideIcon;
+ /** CSS color for the icon (e.g. a swatch); the theme tone otherwise. */
+ iconColor?: string;
tone?: 'danger';
disabled?: boolean;
/** Trailing keycap strings, already formatted for the platform. */
@@ -25,11 +27,26 @@ export interface MenuActionItemProps {
}
/** The shared icon+label menu item; `tone: 'danger'` colors the whole row, icon included. */
-export const MenuActionItem = ({ disabled, hintParts, icon, label, onSelect, tone, value }: MenuActionItemProps) => (
+export const MenuActionItem = ({
+ disabled,
+ hintParts,
+ icon,
+ iconColor,
+ label,
+ onSelect,
+ tone,
+ value,
+}: MenuActionItemProps) => (
<Menu.Item color={tone === 'danger' ? 'fg.error' : undefined} disabled={disabled} value={value} onSelect={onSelect}>
<HStack gap="2" minW="0" w="full">
{icon ? (
- <Icon as={icon} boxSize="3.5" color={tone === 'danger' ? 'fg.error' : 'fg.subtle'} flexShrink={0} />
+ <Icon
+ as={icon}
+ boxSize="3.5"
+ color={tone === 'danger' ? 'fg.error' : (iconColor ?? 'fg.subtle')}
+ fill={iconColor ?? 'none'}
+ flexShrink={0}
+ />
) : null}
<Text flex="1" fontSize="xs">
{label}
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/capabilities.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/capabilities.ts
index 60151d9b1d..cc7e808659 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/capabilities.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/capabilities.ts
@@ -575,7 +575,7 @@ export interface CanvasEngine {
// Public Canvas-owned value contracts. These remain serializable and contain
// no engine implementation, mutable store, controller, or construction type.
export type * from './contracts';
-export { CANVAS_MAX_NODE_COUNT, CANVAS_MAX_NODE_DEPTH } from './contracts';
+export { CANVAS_COLOR_LABELS, CANVAS_MAX_NODE_COUNT, CANVAS_MAX_NODE_DEPTH } from './contracts';
export type BooleanRasterOperation = 'intersect' | 'cutout' | 'cutaway' | 'exclude';
export interface StagedPreviewPlacement extends Rect {
opacity: number;
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
index 7daf424d54..76fcb8cdec 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/contracts.ts
@@ -151,6 +151,10 @@ export type CanvasLayerSourceContract =
height?: number;
};
+/** Photoshop's layer-color palette; also the PSD `layerColor` vocabulary. */
+export const CANVAS_COLOR_LABELS = ['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'gray'] as const;
+export type CanvasColorLabel = (typeof CANVAS_COLOR_LABELS)[number];
+
export interface CanvasLayerBaseContract {
id: string;
name: string;
@@ -158,6 +162,8 @@ export interface CanvasLayerBaseContract {
isLocked: boolean;
opacity: number;
blendMode: CanvasBlendMode;
+ /** Organizational color label; display-only, absent means none. */
+ colorLabel?: CanvasColorLabel;
transform: { x: number; y: number; scaleX: number; scaleY: number; rotation: number };
}
@@ -360,6 +366,8 @@ export interface CanvasGroupContract {
opacity?: number;
/** Raster-stack groups only; absent means 'normal'. Applies to the group's isolated composite. */
blendMode?: CanvasBlendMode;
+ /** Organizational color label; display-only, absent means none. */
+ colorLabel?: CanvasColorLabel;
adjustments?: CanvasAdjustmentsContract;
/** Index 0 is the top-most child. */
children: CanvasNodeContract[];
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/psdExportController.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/psdExportController.ts
index 70af53fbc2..8a643ad4ca 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/psdExportController.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/psdExportController.ts
@@ -121,6 +121,7 @@ export class PsdExportController {
{
blendMode: node.blendMode,
children: toInputs(node.children, stacks),
+ colorLabel: node.colorLabel,
id: node.id,
isEnabled: node.isEnabled,
name: node.name,
@@ -148,6 +149,7 @@ export class PsdExportController {
// Identity-aware: an emptied stack must not trigger the executor's bake writeback.
adjustments: isIdentityAdjustments(combined) ? undefined : combined,
blendMode: node.blendMode,
+ colorLabel: node.colorLabel,
contentRect: detached.rect,
id: node.id,
isEnabled: node.isEnabled,
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.fuzz.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.fuzz.test.ts
index ab6921b461..58d1bd59fd 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.fuzz.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.fuzz.test.ts
@@ -212,11 +212,14 @@ const randomCommand = (random: () => number, document: CanvasDocumentContractV3)
const id = pick(random, ids);
const roll = random();
const patch =
- roll < 0.4
+ roll < 0.3
? { name: `n${Math.floor(random() * 100)}` }
- : roll < 0.7
+ : roll < 0.55
? { opacity: random() }
- : { transform: { x: Math.round(random() * 50) } };
+ : roll < 0.8
+ ? { transform: { x: Math.round(random() * 50) } }
+ : // Clears exercise the explicit-undefined inverse path.
+ { colorLabel: random() < 0.3 ? undefined : random() < 0.5 ? ('red' as const) : ('blue' as const) };
return { id, patch, type: 'patch' };
}
case 'translate':
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 dd030397a3..5be8c6ea9e 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
@@ -643,6 +643,31 @@ describe('createDocumentModel', () => {
});
});
+ it('patches a color label on leaves and groups in any stack, locked included, and clears to absence', () => {
+ const project = projectWith(
+ [layer('r1', 'raster', { isLocked: true }), group('OG', [layer('c1', 'control')])],
+ null
+ );
+ // Organizational, so the lock does not gate it.
+ const { after, edit } = roundTrip(project, { id: 'r1', patch: { colorLabel: 'red' }, type: 'patch' });
+ expect(after.canvas.document.stacks.raster[0]).toMatchObject({ colorLabel: 'red' });
+ expect(edit.inverse).toEqual({ id: 'r1', patch: { colorLabel: undefined }, type: 'updateCanvasLayer' });
+
+ const overlayGroup = roundTrip(project, { id: 'OG', patch: { colorLabel: 'blue' }, type: 'patch' });
+ expect(overlayGroup.after.canvas.document.stacks.control[0]).toMatchObject({ colorLabel: 'blue' });
+
+ const cleared = applyCanvasProjectMutation(after, {
+ id: 'r1',
+ patch: { colorLabel: undefined },
+ type: 'updateCanvasLayer',
+ });
+ expect(
+ cleared.canvas.document.stacks.raster[0] && 'colorLabel' in cleared.canvas.document.stacks.raster[0]
+ ? cleared.canvas.document.stacks.raster[0].colorLabel
+ : undefined
+ ).toBeUndefined();
+ });
+
it('refuses opacity and blend on an overlay-stack group and on a locked group', () => {
const overlay = projectWith([group('OG', [layer('c1', 'control')])], null);
expect(modelOf(overlay).prepare({ id: 'OG', patch: { opacity: 0.5 }, type: 'patch' })).toEqual({
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 a3e1ec6bd8..599c5c5298 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
@@ -57,7 +57,7 @@ export const isPatchApplied = (node: CanvasNodeContract, patch: CanvasLayerBaseP
if (isGroupNode(node)) {
return (
GROUP_PATCH_KEYS.includes(key) &&
- node[key as 'name' | 'isEnabled' | 'isLocked' | 'opacity' | 'blendMode'] === patch[key]
+ node[key as 'name' | 'isEnabled' | 'isLocked' | 'opacity' | 'blendMode' | 'colorLabel'] === patch[key]
);
}
return key === 'transform'
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/export/psdExport.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/export/psdExport.test.ts
index 8b1d269cb4..835be340de 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/export/psdExport.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/export/psdExport.test.ts
@@ -287,6 +287,33 @@ describe('planPsdExport — folders', () => {
expect(folder.opacity).toBeCloseTo(0.5, 2);
});
+ it('round-trips color labels as native PSD layer colors on layers and folders', async () => {
+ const plan = planPsdExport([
+ { ...group('Tagged', [layer({ colorLabel: 'red', id: 'in', name: 'In' })]), colorLabel: 'violet' },
+ layer({ id: 'base', name: 'Base' }),
+ ]);
+ const backend = createTestStubRasterBackend();
+ const imageDataOf = (width: number, height: number): ImageData =>
+ ({ data: new Uint8ClampedArray(width * height * 4), height, width }) as ImageData;
+ let bytes: ArrayBuffer | null = null;
+ await executePsdExport(plan, 'labels.psd', {
+ backend,
+ download: (data) => {
+ bytes = data;
+ },
+ getLayerSurface: () =>
+ Promise.resolve({ rect: { height: 50, width: 100, x: 0, y: 0 }, surface: backend.createSurface(100, 50) }),
+ readImageData: (_surface, rect) => imageDataOf(rect.width, rect.height),
+ writeImageData: () => undefined,
+ writePsd: (psd) => Promise.resolve(writePsd(psd, { generateThumbnail: false })),
+ });
+ const parsed = readPsd(bytes!, { skipCompositeImageData: true, skipLayerImageData: true, skipThumbnail: true });
+ const folder = parsed.children!.find((child) => child.name === 'Tagged')!;
+ expect(folder.layerColor).toBe('violet');
+ expect(folder.children![0]!.layerColor).toBe('red');
+ expect(parsed.children!.find((child) => child.name === 'Base')!.layerColor ?? 'none').toBe('none');
+ });
+
it('round-trips a default folder as pass-through', async () => {
const plan = planPsdExport([
group('Plain', [layer({ id: 'in', name: 'In' })]),
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/export/psdExport.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/export/psdExport.ts
index ae5f62f283..4a5ebe0f52 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/export/psdExport.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/export/psdExport.ts
@@ -40,7 +40,7 @@
* user sees. Opacity/blend stay as PSD layer properties (not baked).
*/
-import type { CanvasAdjustmentsContract, CanvasBlendMode } from '@workbench/canvas-engine/contracts';
+import type { CanvasAdjustmentsContract, CanvasBlendMode, CanvasColorLabel } from '@workbench/canvas-engine/contracts';
import type { RasterSurface } from '@workbench/canvas-engine/render/raster';
import type { Mat2d, Rect } from '@workbench/canvas-engine/types';
import type { BlendMode, Layer as AgPsdLayer, Psd } from 'ag-psd';
@@ -107,6 +107,8 @@ export interface PsdExportLayerInput {
blendMode: CanvasBlendMode;
/** The layer's own flag; a disabled layer is exported with `hidden: true`, not dropped. */
isEnabled: boolean;
+ /** Organizational color label; PSD carries it natively as `layerColor`. */
+ colorLabel?: CanvasColorLabel;
/** Non-destructive adjustments to bake into the layer's pixels, if any. */
adjustments?: CanvasAdjustmentsContract;
}
@@ -122,6 +124,8 @@ export interface PsdExportGroupInput {
opacity?: number;
/** PSD folders carry a blend mode natively. Absent means 'normal'. */
blendMode?: CanvasBlendMode;
+ /** Organizational color label; PSD carries it natively as `layerColor`. */
+ colorLabel?: CanvasColorLabel;
children: readonly PsdExportNodeInput[];
}
@@ -154,6 +158,7 @@ export interface PsdPlanLayer {
hidden: boolean;
/** Enabled with every folder above it enabled: the leaves the merged preview flattens. */
contributes: boolean;
+ colorLabel?: CanvasColorLabel;
adjustments?: CanvasAdjustmentsContract;
}
@@ -168,6 +173,7 @@ export interface PsdPlanFolder {
blendMode: BlendMode;
/** Canvas `globalCompositeOperation` for the flattened composite preview. */
compositeBlend: GlobalCompositeOperation;
+ colorLabel?: CanvasColorLabel;
children: PsdPlanNode[];
}
@@ -272,6 +278,7 @@ export const planPsdExport = (
adjustments: input.adjustments,
blendMode: mapped ?? 'normal',
bottom: top + worldRect.height,
+ colorLabel: input.colorLabel,
compositeBlend: blendToComposite(input.blendMode),
contentRect: input.contentRect,
contributes,
@@ -312,6 +319,7 @@ export const planPsdExport = (
out.push({
blendMode: isolated ? (mapped ?? 'normal') : 'pass through',
children,
+ colorLabel: node.colorLabel,
compositeBlend: blendToComposite(blendMode),
hidden: !node.isEnabled,
id: node.id,
@@ -476,6 +484,7 @@ export const executePsdExport = async (
hidden: planLayer.hidden,
imageData,
left: planLayer.left,
+ ...(planLayer.colorLabel ? { layerColor: planLayer.colorLabel } : {}),
name: planLayer.name,
opacity: planLayer.opacity,
right: planLayer.right,
@@ -489,6 +498,7 @@ export const executePsdExport = async (
blendMode: node.blendMode,
children: toChildren(node.children),
hidden: node.hidden,
+ ...(node.colorLabel ? { layerColor: node.colorLabel } : {}),
name: node.name,
opacity: node.opacity,
opened: true,
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/mutationContracts.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/mutationContracts.ts
index 477f717b7d..921379d3f5 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/mutationContracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/mutationContracts.ts
@@ -25,9 +25,9 @@ import type {
import type { CanvasNodeInsertion, CanvasNodeInsertionAnchor, CanvasNodeMove } from './document/insertionAnchors';
import type { ReorderSiblingsCommand } from './document/layerStacks';
-/** Base fields a node accepts; a group takes `name`, `isEnabled`, `isLocked`, `opacity` and `blendMode`. */
+/** Base fields a node accepts; a group takes everything but `transform`. */
export type CanvasLayerBasePatch = Partial<
- Pick<CanvasLayerBaseContract, 'name' | 'isEnabled' | 'isLocked' | 'opacity' | 'blendMode'>
+ Pick<CanvasLayerBaseContract, 'name' | 'isEnabled' | 'isLocked' | 'opacity' | 'blendMode' | 'colorLabel'>
> & { transform?: Partial<CanvasLayerBaseContract['transform']> };
/** The base fields a group carries; anything else in a patch does not apply to it. */
@@ -37,10 +37,16 @@ export const GROUP_PATCH_KEYS: readonly (keyof CanvasLayerBasePatch)[] = [
'isLocked',
'opacity',
'blendMode',
+ 'colorLabel',
];
-/** Patch keys allowed on a locked node (renaming or unlocking never needs the lock lifted first). */
-export const LOCK_EXEMPT_PATCH_KEYS: readonly (keyof CanvasLayerBasePatch)[] = ['name', 'isEnabled', 'isLocked'];
+/** Patch keys allowed on a locked node (organizational edits never need the lock lifted first). */
+export const LOCK_EXEMPT_PATCH_KEYS: readonly (keyof CanvasLayerBasePatch)[] = [
+ 'name',
+ 'isEnabled',
+ 'isLocked',
+ 'colorLabel',
+];
export type CanvasLayerConfigPatch =
| {
diff --git a/invokeai/frontend/webv2/src/workbench/canvasMigration.test.ts b/invokeai/frontend/webv2/src/workbench/canvasMigration.test.ts
index 4e9056acb2..330a833550 100644
--- a/invokeai/frontend/webv2/src/workbench/canvasMigration.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvasMigration.test.ts
@@ -146,6 +146,29 @@ describe('loadCanvasState', () => {
expect(loadedMalformed?.type === 'group' ? loadedMalformed.children.length : 0).toBe(1);
});
+ it('round-trips color labels on leaves and groups in any stack, and drops malformed values', () => {
+ const labelled = load(withNodes([{ ...createEmptyPaintLayer('Tagged', 'tagged'), colorLabel: 'violet' }]));
+ const leaf = labelled.document.stacks.raster[0];
+ expect(leaf && 'colorLabel' in leaf ? leaf.colorLabel : null).toBe('violet');
+
+ const overlayGroup = {
+ children: [],
+ colorLabel: 'green',
+ id: 'og',
+ isEnabled: true,
+ isLocked: false,
+ name: 'Overlay',
+ type: 'group',
+ };
+ const overlayLoaded = load(withNodes([overlayGroup], 'control'));
+ const loadedOverlay = overlayLoaded.document.stacks.control[0];
+ expect(loadedOverlay?.type === 'group' ? loadedOverlay.colorLabel : null).toBe('green');
+
+ const malformed = load(withNodes([{ ...createEmptyPaintLayer('Bad', 'bad'), colorLabel: 'magenta' }]));
+ const badLeaf = malformed.document.stacks.raster[0];
+ expect(badLeaf && 'colorLabel' in badLeaf ? badLeaf.colorLabel : null).toBeUndefined();
+ });
+
it('round-trips group opacity and blend in the raster stack, strips them from overlay groups, and drops malformed values', () => {
const rasterGroup = {
blendMode: 'multiply',
diff --git a/invokeai/frontend/webv2/src/workbench/canvasMigration.ts b/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
index 9f08d7aca9..13e4cdd0b1 100644
--- a/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvasMigration.ts
@@ -196,8 +196,10 @@ const zBlendMode = z.enum([
'color',
'luminosity',
]);
+const zColorLabel = z.enum(['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'gray']);
const zLayerBase = z.object({
blendMode: zBlendMode,
+ colorLabel: zColorLabel.optional().catch(undefined),
id: z.string(),
isEnabled: z.boolean(),
isLocked: z.boolean(),
@@ -450,6 +452,7 @@ const zGroupShell = z.object({
// Like the raster arm: a malformed stack drops without failing the document.
adjustments: zAdjustments.optional().catch(undefined),
blendMode: zBlendMode.optional().catch(undefined),
+ colorLabel: zColorLabel.optional().catch(undefined),
id: z.string(),
isEnabled: z.boolean(),
isHidden: z.boolean().optional(),
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
index e159712b57..cf3d6b302b 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
@@ -1,5 +1,6 @@
import type {
CanvasAdjustmentEntry,
+ CanvasColorLabel,
CanvasDocumentContractV3,
CanvasLayerContract,
CanvasMaskContract,
@@ -49,6 +50,7 @@ import {
CopyIcon,
MergeIcon,
MoreVerticalIcon,
+ PaletteIcon,
SlidersHorizontalIcon,
} from 'lucide-react';
import { Fragment, useCallback, useMemo, useState } from 'react';
@@ -511,6 +513,15 @@ const LayerMenu = ({
patchBase(t('widgets.layers.actions.toggleLock'), { isLocked: !layer.isLocked });
}, [commitPrepared, document, layer, patchBase, selectedIds, t]);
+ const handleSetColorLabel = useCallback(
+ (label: CanvasColorLabel | null) => {
+ // `undefined` clears: the reducer writes the key as undefined and
+ // serialization drops it, so "no label" round-trips as absence.
+ patchBase(t('widgets.layers.menu.colorLabel'), { colorLabel: label ?? undefined });
+ },
+ [patchBase, t]
+ );
+
const openRename = useCallback(() => setDialogKind('rename'), [setDialogKind]);
const closeDialog = useCallback(() => setDialogKind(null), [setDialogKind]);
const openRunWorkflow = useCallback(() => setDialogKind('run-workflow'), [setDialogKind]);
@@ -827,6 +838,7 @@ const LayerMenu = ({
rasterize: handleRasterize,
reorder: (kind, actionId) => reorder(kind, getActionLabel(actionId)),
saveToAssets: handleSaveToAssets,
+ setColorLabel: handleSetColorLabel,
toggleLock: handleToggleLock,
toggleHidden: handleToggleHidden,
toggleVisibility: handleToggleVisibility,
@@ -854,6 +866,7 @@ const LayerMenu = ({
handleOpenProperties,
handleRasterize,
handleSaveToAssets,
+ handleSetColorLabel,
handleToggleLock,
handleToggleHidden,
handleToggleVisibility,
@@ -1074,6 +1087,7 @@ const SUBMENU_META: Record<LayerContextSubmenuId, { defaultLabel: string; icon:
},
arrange: { defaultLabel: 'Arrange', icon: ArrowUpDownIcon, labelKey: 'widgets.layers.menu.arrange' },
boolean: { defaultLabel: 'Boolean operations', icon: MergeIcon, labelKey: 'widgets.layers.menu.booleanOperations' },
+ 'color-label': { defaultLabel: 'Color label', icon: PaletteIcon, labelKey: 'widgets.layers.menu.colorLabel' },
'convert-to': { defaultLabel: 'Convert to', icon: ArrowRightLeftIcon, labelKey: 'widgets.layers.menu.convertTo' },
'copy-to': { defaultLabel: 'Copy to', icon: CopyIcon, labelKey: 'widgets.layers.menu.copyTo' },
};
@@ -1250,6 +1264,7 @@ const LayerMenuActionItem = ({
disabled={action.isDisabled}
hint={action.hint}
icon={action.icon}
+ iconColor={action.iconColor}
label={t(action.labelKey, { count: action.labelCount, defaultValue: action.defaultLabel })}
tone={action.tone}
value={action.id}
@@ -1262,6 +1277,7 @@ const LayerMenuItem = ({
disabled,
hint,
icon,
+ iconColor,
label,
onSelect,
tone,
@@ -1271,6 +1287,7 @@ const LayerMenuItem = ({
/** A raw hotkey string, formatted per platform and shown as trailing keycaps. */
hint?: string;
icon: LucideIcon;
+ iconColor?: string;
label: string;
onSelect: () => void;
tone?: 'danger';
@@ -1280,6 +1297,7 @@ const LayerMenuItem = ({
disabled={disabled}
hintParts={hint ? formatHotkeyForPlatform(hint) : undefined}
icon={icon}
+ iconColor={iconColor}
label={label}
tone={tone}
value={value}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerGroupContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerGroupContextMenu.tsx
index 63bfe371ce..1ca43c3863 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerGroupContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerGroupContextMenu.tsx
@@ -1,5 +1,6 @@
import type {
CanvasAdjustmentEntry,
+ CanvasColorLabel,
CanvasGroupContract,
LayerStackKind,
LayerStackMoveKind,
@@ -29,6 +30,7 @@ import {
FolderPlusIcon,
LockIcon,
LockOpenIcon,
+ PaletteIcon,
PencilIcon,
SlidersHorizontalIcon,
Trash2Icon,
@@ -37,6 +39,7 @@ import {
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { COLOR_LABEL_ITEMS } from './colorLabels';
import { ADJUSTMENT_ADD_ITEMS } from './layerContextActions';
import { canGroupSelection, groupLayers, ungroupLayers } from './layerGroupCommands';
import { createIdentityAdjustment } from './layerOps';
@@ -194,6 +197,14 @@ export const LayerGroupContextMenu = ({
[commitPrepared, group.adjustments, group.id, t]
);
+ const handleSetColorLabel = useCallback(
+ (label: CanvasColorLabel | null) => () =>
+ commitPrepared(t('widgets.layers.menu.colorLabel'), (model) =>
+ model.prepare({ id: group.id, patch: { colorLabel: label ?? undefined }, type: 'patch' })
+ ),
+ [commitPrepared, group.id, t]
+ );
+
const items = (
<MenuContent minW="13rem" py="1">
{ARRANGE.map((entry) => (
@@ -297,6 +308,50 @@ export const LayerGroupContextMenu = ({
value="lock"
onSelect={handleToggleLock}
/>
+ {!locked ? (
+ <Menu.Root positioning={SUBMENU_POSITIONING}>
+ <Menu.TriggerItem aria-label={t('widgets.layers.menu.colorLabel')}>
+ <HStack gap="2" minW="0" w="full">
+ <Icon as={PaletteIcon} boxSize="3.5" color="fg.subtle" flexShrink={0} />
+ <Text flex="1" fontSize="xs">
+ {t('widgets.layers.menu.colorLabel')}
+ </Text>
+ <Icon as={ChevronRightIcon} boxSize="3" color="fg.subtle" flexShrink={0} />
+ </HStack>
+ </Menu.TriggerItem>
+ <Portal>
+ <Menu.Positioner>
+ <MenuContent minW="10rem" py="1">
+ {COLOR_LABEL_ITEMS.map((item) => (
+ <MenuActionItem
+ key={item.value}
+ icon={CircleIcon}
+ iconColor={item.hex}
+ label={t(item.labelKey, { defaultValue: item.defaultLabel })}
+ value={`color-label-${item.value}`}
+ onSelect={handleSetColorLabel(item.value)}
+ />
+ ))}
+ <MenuActionItem
+ disabled={group.colorLabel === undefined}
+ icon={CircleOffIcon}
+ label={t('widgets.layers.labels.none', { defaultValue: 'None' })}
+ value="color-label-none"
+ onSelect={handleSetColorLabel(null)}
+ />
+ </MenuContent>
+ </Menu.Positioner>
+ </Portal>
+ </Menu.Root>
+ ) : (
+ <MenuActionItem
+ disabled
+ icon={PaletteIcon}
+ label={t('widgets.layers.menu.colorLabel')}
+ value="color-label"
+ onSelect={noop}
+ />
+ )}
<Menu.Separator borderColor="border.subtle" />
<MenuActionItem
disabled={locked || holdsLocked}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRow.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRow.tsx
index 629b559070..395df89d18 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRow.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRow.tsx
@@ -22,6 +22,7 @@ import { useTranslation } from 'react-i18next';
import type { LayerRowCommands } from './layerRowCommands';
import type { LayerTreeRow } from './layerTreeRows';
+import { colorLabelHex } from './colorLabels';
import { ControlLayerWarningIcon } from './ControlLayerWarningIcon';
import { LayerActiveDot, ROW_SELECTION_FOCUS } from './LayerActiveDot';
import { recordLayerRowCommit } from './layerPanelDiagnostics';
@@ -298,6 +299,7 @@ const LayerRowComponent = ({
h="full"
opacity={drag ? 0.4 : undefined}
pb="0.5"
+ position="relative"
role="treeitem"
rounded="sm"
tabIndex={focused ? 0 : -1}
@@ -308,6 +310,21 @@ const LayerRowComponent = ({
onFocus={handleFocus}
onKeyDown={handleKeyDown}
>
+ {node.colorLabel ? (
+ // A fixed gutter column regardless of nesting depth, like a desktop
+ // editor's label swatch; display-only, so it takes no pointer events.
+ <Box
+ bg={colorLabelHex(node.colorLabel)}
+ bottom="1.5"
+ data-color-label={node.colorLabel}
+ left="0"
+ pointerEvents="none"
+ position="absolute"
+ rounded="full"
+ top="1"
+ w="2px"
+ />
+ ) : null}
<LayerRowSurface active={tone} cursor={drag === 'source' ? 'grabbing' : 'default'} indentStyle={indentStyle}>
<LayerActiveDot
checked={node.isEnabled}
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 4e8375714d..08a621d43a 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
@@ -885,3 +885,16 @@ describe('LayersTree list changes', () => {
expect(document.activeElement).toBe(treeitem('Renamed'));
});
});
+
+describe('LayersTree color labels', () => {
+ it('shows a color-label strip on labelled rows only', async () => {
+ await renderTree([
+ layerContract('tagged', 'raster', { colorLabel: 'red', name: 'Tagged' }),
+ groupContract('folder', [paint('inside', 'Inside')], { colorLabel: 'blue' }),
+ paint('plain', 'Plain'),
+ ]);
+ expect(host!.querySelector('[data-layer-row-id="tagged"] [data-color-label="red"]')).not.toBeNull();
+ expect(host!.querySelector('[data-layer-row-id="folder"] [data-color-label="blue"]')).not.toBeNull();
+ expect(host!.querySelector('[data-layer-row-id="plain"] [data-color-label]')).toBeNull();
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/colorLabels.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/colorLabels.ts
new file mode 100644
index 0000000000..4d3a3ac824
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/colorLabels.ts
@@ -0,0 +1,27 @@
+import type { CanvasColorLabel } from '@workbench/canvas-engine/api';
+
+/** Swatch hexes tuned to read on both themes; keys are the PSD layer-color vocabulary. */
+const COLOR_LABEL_HEX: Record<CanvasColorLabel, string> = {
+ blue: '#3e82f7',
+ gray: '#8d8d8d',
+ green: '#46a758',
+ orange: '#ee7d2c',
+ red: '#e5484d',
+ violet: '#8e6cef',
+ yellow: '#d9b40e',
+};
+
+export const colorLabelHex = (label: CanvasColorLabel): string => COLOR_LABEL_HEX[label];
+
+/** The one label catalog; the leaf action registry and the group menu both render from it. */
+export const COLOR_LABEL_ITEMS: readonly {
+ readonly value: CanvasColorLabel;
+ readonly hex: string;
+ readonly labelKey: string;
+ readonly defaultLabel: string;
+}[] = (['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'gray'] as const).map((value) => ({
+ defaultLabel: value[0]!.toUpperCase() + value.slice(1),
+ hex: COLOR_LABEL_HEX[value],
+ labelKey: `widgets.layers.labels.${value}`,
+ value,
+}));
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 57061df84f..253d01bce9 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts
@@ -113,6 +113,7 @@ const makeEffects = (): LayerContextActionEffects => ({
patchConfig: vi.fn(),
rasterize: vi.fn(),
reorder: vi.fn(),
+ setColorLabel: vi.fn(),
saveToAssets: vi.fn(() => Promise.resolve()),
toggleLock: vi.fn(),
toggleVisibility: vi.fn(),
@@ -494,6 +495,14 @@ describe('getLayerContextActions', () => {
'toggle-visibility',
'toggle-hidden',
'toggle-lock',
+ 'color-label-red',
+ 'color-label-orange',
+ 'color-label-yellow',
+ 'color-label-green',
+ 'color-label-blue',
+ 'color-label-violet',
+ 'color-label-gray',
+ 'color-label-none',
'delete',
];
@@ -502,6 +511,25 @@ describe('getLayerContextActions', () => {
expect([...new Set(actions.filter((action) => !action.isDisabled).map((action) => action.id))]).toEqual([]);
});
+ it('offers color labels on every layer type, locked layers included, and routes to the effect', () => {
+ const locked = { ...makeLayer('raster'), isLocked: true };
+ const actions = getLayerContextActions(makeState(locked));
+ const red = byId(actions, 'color-label-red');
+ expect(red.isDisabled).toBe(false);
+ expect(red.submenu).toBe('color-label');
+ expect(red.iconColor).toBeDefined();
+ // None only clears an existing label.
+ expect(byId(actions, 'color-label-none').isDisabled).toBe(true);
+ const labelled = getLayerContextActions(makeState({ ...makeLayer('raster'), colorLabel: 'red' }));
+ expect(byId(labelled, 'color-label-none').isDisabled).toBe(false);
+
+ const effects = makeEffects();
+ red.handler({ ...makeState(locked), effects });
+ expect(effects.setColorLabel).toHaveBeenCalledWith('red');
+ byId(labelled, 'color-label-none').handler({ ...makeState(locked), effects });
+ expect(effects.setColorLabel).toHaveBeenLastCalledWith(null);
+ });
+
it('offers add-reference-image on regional layers unless the model base is flux2', () => {
const regional = makeLayer('regional_guidance');
expect(byId(getLayerContextActions(makeState(regional)), 'add-reference-image').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 5e673446cf..6b83728c28 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
@@ -1,6 +1,7 @@
import type {
BooleanRasterOperation,
CanvasAdjustmentEntry,
+ CanvasColorLabel,
CanvasDocumentContractV3,
CanvasLayerContract,
LayerStackMoveKind,
@@ -50,6 +51,7 @@ import {
WorkflowIcon,
} from 'lucide-react';
+import { COLOR_LABEL_ITEMS } from './colorLabels';
import { canConvertRasterControl, canMergeLayerDown } from './layerOps';
export type LayerContextActionId =
@@ -100,11 +102,13 @@ export type LayerContextActionId =
| 'toggle-visibility'
| 'toggle-hidden'
| 'toggle-lock'
+ | 'color-label-none'
+ | `color-label-${CanvasColorLabel}`
| 'delete';
export type LayerType = CanvasLayerContract['type'];
export type LayerContextMenuSectionId = 'quick' | 'primary' | 'operations' | 'output' | 'state' | 'danger';
-export type LayerContextSubmenuId = 'arrange' | 'boolean' | 'copy-to' | 'convert-to' | 'add-adjustment';
+export type LayerContextSubmenuId = 'arrange' | 'boolean' | 'copy-to' | 'convert-to' | 'add-adjustment' | 'color-label';
export interface LayerContextActionState {
canRunWorkflow: boolean;
@@ -153,6 +157,7 @@ export interface LayerContextActionEffects {
addMaskModifier(field: 'noise' | 'denoise'): void;
addAdjustment(type: CanvasAdjustmentEntry['type']): void;
addLayerRegion(): void;
+ setColorLabel(label: CanvasColorLabel | null): void;
mergeDown(): void;
toggleVisibility(): void;
toggleHidden(): void;
@@ -170,6 +175,8 @@ export interface LayerContextActionDefinition {
defaultLabel: string;
icon: LucideIcon;
getIcon?(context: LayerContextActionState): LucideIcon;
+ /** CSS color for the item's icon (label swatches); the theme tone otherwise. */
+ iconColor?: string;
section: LayerContextMenuSectionId;
submenu?: LayerContextSubmenuId;
order: number;
@@ -192,6 +199,7 @@ export interface LayerContextAction {
defaultLabel: string;
labelCount?: number;
icon: LucideIcon;
+ iconColor?: string;
section: LayerContextMenuSectionId;
submenu?: LayerContextSubmenuId;
order: number;
@@ -900,6 +908,34 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini
section: 'state',
supportedLayerTypes: ALL_LAYER_TYPES,
},
+ // Color labels are organizational, so a locked layer still takes one.
+ ...COLOR_LABEL_ITEMS.map((item, index): LayerContextActionDefinition => ({
+ defaultLabel: item.defaultLabel,
+ handler: ({ effects }) => effects.setColorLabel(item.value),
+ icon: CircleIcon,
+ iconColor: item.hex,
+ id: `color-label-${item.value}`,
+ isEnabled: isInteractionFree,
+ isVisible: alwaysVisible,
+ labelKey: item.labelKey,
+ order: 15 + index,
+ section: 'state',
+ submenu: 'color-label',
+ supportedLayerTypes: ALL_LAYER_TYPES,
+ })),
+ {
+ defaultLabel: 'None',
+ handler: ({ effects }) => effects.setColorLabel(null),
+ icon: CircleOffIcon,
+ id: 'color-label-none',
+ isEnabled: (context) => isInteractionFree(context) && context.layer.colorLabel !== undefined,
+ isVisible: alwaysVisible,
+ labelKey: 'widgets.layers.labels.none',
+ order: 15 + COLOR_LABEL_ITEMS.length,
+ section: 'state',
+ submenu: 'color-label',
+ supportedLayerTypes: ALL_LAYER_TYPES,
+ },
{
defaultLabel: 'Delete',
getDefaultLabel: (context) => (isMultiTarget(context) ? `Delete ${targetCount(context)} layers` : 'Delete'),
@@ -935,6 +971,7 @@ export const getLayerContextActions = (context: LayerContextActionState): LayerC
handler: definition.handler,
hint: definition.hint,
icon: definition.getIcon?.(context) ?? definition.icon,
+ iconColor: definition.iconColor,
id: definition.id,
isDisabled: !definition.isEnabled(context),
labelCount: definition.getLabelCount?.(context),
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 8a0cc7f316..af03fcb123 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts
@@ -106,7 +106,15 @@ describe('getLayerContextMenuLayout', () => {
presentation: 'list',
},
{ id: 'output', items: ['crop-to-bbox', 'save-to-assets'], presentation: 'list' },
- { id: 'state', items: ['toggle-visibility', 'toggle-lock'], presentation: 'list' },
+ {
+ id: 'state',
+ items: [
+ 'toggle-visibility',
+ 'toggle-lock',
+ 'color-label(color-label-red,color-label-orange,color-label-yellow,color-label-green,color-label-blue,color-label-violet,color-label-gray,color-label-none)',
+ ],
+ presentation: 'list',
+ },
{ id: 'danger', items: ['delete'], presentation: 'list' },
]);
});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.test.ts
index 9a024677e4..68da3d3c32 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.test.ts
@@ -462,9 +462,10 @@ describe('convertRasterControlLayer', () => {
it('converts raster→control preserving source/id/name/transform and applying the default adapter', () => {
const source = { image: { height: 48, imageName: 'pic', width: 64 }, type: 'image' } as const;
const transform = { rotation: 10, scaleX: 2, scaleY: 2, x: 5, y: 6 };
- const raster = paintLayer('r', { name: 'My Layer', opacity: 0.5, source, transform });
+ const raster = paintLayer('r', { colorLabel: 'red', name: 'My Layer', opacity: 0.5, source, transform });
const converted = convertRasterControlLayer(raster, 'control');
expect(converted).toMatchObject({
+ colorLabel: 'red',
id: 'r',
name: 'My Layer',
opacity: 0.5,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.ts
index bace519070..9882796356 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.ts
@@ -475,6 +475,7 @@ const cloneMask = (mask: CanvasMaskContract): CanvasMaskContract => ({
const destinationBase = (layer: CanvasLayerContract, id: string, isCopy: boolean): CanvasLayerBaseContract => ({
blendMode: layer.blendMode,
+ ...(layer.colorLabel ? { colorLabel: layer.colorLabel } : {}),
id,
isEnabled: layer.isEnabled,
isLocked: layer.isLocked,