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.

refactor(platform): promote the pane tab strips to SegmentTabs

Josh Corbett5d49fa8309c7
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.json
index e3ae8648a0..4b2e6664f2 100644
--- a/invokeai/frontend/webv2/performance/architecture-baseline.json
+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json
@@ -2,12 +2,12 @@
"build": {
"launchpad": {
"baseline": {
- "brotliBytes": 839937,
+ "brotliBytes": 840774,
"cssRawBytes": 2159,
"fontRawBytes": 219480,
- "gzipBytes": 838725,
+ "gzipBytes": 839534,
"imageRawBytes": 156376,
- "initialRawBytes": 1954479,
+ "initialRawBytes": 1956734,
"largestAssetRawBytes": 746376,
"otherAssetRawBytes": 0,
"ownedRawBytes": 70891,
@@ -213,6 +213,7 @@
"source:src/platform/ui/ResizableTextarea.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
+ "source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/Select.tsx",
"source:src/platform/ui/Slider.tsx",
"source:src/platform/ui/StatusWidgetChip.tsx",
@@ -290,12 +291,12 @@
]
},
"limits": {
- "brotliBytes": 848337,
+ "brotliBytes": 849182,
"cssRawBytes": 2181,
"fontRawBytes": 221675,
- "gzipBytes": 847113,
+ "gzipBytes": 847930,
"imageRawBytes": 157940,
- "initialRawBytes": 1974024,
+ "initialRawBytes": 1976302,
"largestAssetRawBytes": 753840,
"otherAssetRawBytes": 0,
"ownedRawBytes": 70891,
@@ -308,12 +309,12 @@
},
"editor": {
"baseline": {
- "brotliBytes": 1098809,
+ "brotliBytes": 1099653,
"cssRawBytes": 2159,
"fontRawBytes": 219480,
- "gzipBytes": 1094053,
+ "gzipBytes": 1094899,
"imageRawBytes": 156376,
- "initialRawBytes": 2740036,
+ "initialRawBytes": 2742452,
"largestAssetRawBytes": 746376,
"otherAssetRawBytes": 0,
"ownedRawBytes": 114602,
@@ -677,6 +678,7 @@
"source:src/platform/ui/ResizableTextarea.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
+ "source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/Select.tsx",
"source:src/platform/ui/Slider.tsx",
"source:src/platform/ui/StatusWidgetChip.tsx",
@@ -931,12 +933,12 @@
]
},
"limits": {
- "brotliBytes": 1109798,
+ "brotliBytes": 1110650,
"cssRawBytes": 2181,
"fontRawBytes": 221675,
- "gzipBytes": 1104994,
+ "gzipBytes": 1105848,
"imageRawBytes": 157940,
- "initialRawBytes": 2767437,
+ "initialRawBytes": 2769877,
"largestAssetRawBytes": 753840,
"otherAssetRawBytes": 0,
"ownedRawBytes": 114602,
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.json
index e3f6ff3c17..4a200d7cc7 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.80000000074506,
+ "domContentLoadedMedianMs": 115.19999999925494,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 122,
- "longestTaskMaxMs": 71,
+ "loadMedianMs": 115.30000000074506,
+ "longestTaskMaxMs": 67,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -43,9 +43,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 38,
- "scriptRawBytes": 1630506,
+ "scriptRawBytes": 1632761,
"scriptRequestCount": 34,
- "totalRawBytes": 1814453
+ "totalRawBytes": 1816708
},
"resourceLimits": {
"cssRawBytes": 2181,
@@ -54,11 +54,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 38,
- "scriptRawBytes": 1646812,
+ "scriptRawBytes": 1649089,
"scriptRequestCount": 34,
- "totalRawBytes": 1832598
+ "totalRawBytes": 1834876
},
- "routeReadyMedianMs": 270.5999999977648,
+ "routeReadyMedianMs": 250.70000000298023,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@ -85,13 +85,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 120.5,
+ "domContentLoadedMedianMs": 113.19999999925494,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 120.60000000149012,
- "longestTaskMaxMs": 73,
+ "loadMedianMs": 113.40000000223517,
+ "longestTaskMaxMs": 67,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@ -103,9 +103,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 38,
- "scriptRawBytes": 1630506,
+ "scriptRawBytes": 1632761,
"scriptRequestCount": 34,
- "totalRawBytes": 1814453
+ "totalRawBytes": 1816708
},
"resourceLimits": {
"cssRawBytes": 2181,
@@ -114,11 +114,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 38,
- "scriptRawBytes": 1646812,
+ "scriptRawBytes": 1649089,
"scriptRequestCount": 34,
- "totalRawBytes": 1832598
+ "totalRawBytes": 1834876
},
- "routeReadyMedianMs": 288.80000000074506,
+ "routeReadyMedianMs": 268.69999999925494,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@ -145,15 +145,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 120.39999999850988,
+ "domContentLoadedMedianMs": 111.90000000223517,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 120.5,
- "longestTaskMaxMs": 103,
+ "loadMedianMs": 112.10000000149012,
+ "longestTaskMaxMs": 95,
"owner": "workbench",
- "projectSwitchMedianMs": 40.30000000074506,
+ "projectSwitchMedianMs": 35.19999999925494,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -163,9 +163,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 115,
- "scriptRawBytes": 3262124,
+ "scriptRawBytes": 3264378,
"scriptRequestCount": 110,
- "totalRawBytes": 3602447
+ "totalRawBytes": 3604701
},
"resourceLimits": {
"cssRawBytes": 2181,
@@ -174,11 +174,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 115,
- "scriptRawBytes": 3294746,
+ "scriptRawBytes": 3297022,
"scriptRequestCount": 110,
- "totalRawBytes": 3638472
+ "totalRawBytes": 3640749
},
- "routeReadyMedianMs": 679.1999999992549,
+ "routeReadyMedianMs": 650.8999999985099,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -205,15 +205,15 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 120.59999999776483,
+ "domContentLoadedMedianMs": 111,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 120.69999999925494,
- "longestTaskMaxMs": 190,
+ "loadMedianMs": 111.09999999776483,
+ "longestTaskMaxMs": 181,
"owner": "workbench",
- "projectSwitchMedianMs": 77.19999999925494,
+ "projectSwitchMedianMs": 70.20000000298023,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@ -223,9 +223,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 115,
- "scriptRawBytes": 3262124,
+ "scriptRawBytes": 3264378,
"scriptRequestCount": 110,
- "totalRawBytes": 3602447
+ "totalRawBytes": 3604701
},
"resourceLimits": {
"cssRawBytes": 2181,
@@ -234,11 +234,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 115,
- "scriptRawBytes": 3294746,
+ "scriptRawBytes": 3297022,
"scriptRequestCount": 110,
- "totalRawBytes": 3638472
+ "totalRawBytes": 3640749
},
- "routeReadyMedianMs": 465.6000000014901,
+ "routeReadyMedianMs": 420.19999999925494,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@ -247,31 +247,31 @@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 257353,
+ "largestAssetRawBytes": 254236,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 414001,
+ "scriptRawBytes": 410885,
"scriptRequestCount": 7,
- "totalRawBytes": 414001
+ "totalRawBytes": 410885
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 259927,
+ "largestAssetRawBytes": 256779,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 418142,
+ "scriptRawBytes": 414994,
"scriptRequestCount": 7,
- "totalRawBytes": 418142
+ "totalRawBytes": 414994
},
- "domContentLoadedMedianMs": 118.60000000149012,
+ "domContentLoadedMedianMs": 112.69999999925494,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.300000000745058,
- "layoutReturnSwitchMedianMs": 58.600000001490116,
- "layoutSwitchMedianMs": 96.5,
- "loadMedianMs": 118.70000000298023,
- "longestTaskMaxMs": 130,
+ "layoutAckMedianMs": 2.199999999254942,
+ "layoutReturnSwitchMedianMs": 53,
+ "layoutSwitchMedianMs": 89.19999999925494,
+ "loadMedianMs": 112.79999999701977,
+ "longestTaskMaxMs": 125,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -283,9 +283,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 122,
- "scriptRawBytes": 3676125,
+ "scriptRawBytes": 3675263,
"scriptRequestCount": 117,
- "totalRawBytes": 4016448
+ "totalRawBytes": 4015586
},
"resourceLimits": {
"cssRawBytes": 2181,
@@ -294,11 +294,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 122,
- "scriptRawBytes": 3712887,
+ "scriptRawBytes": 3712016,
"scriptRequestCount": 117,
- "totalRawBytes": 4056613
+ "totalRawBytes": 4055742
},
- "routeReadyMedianMs": 1067,
+ "routeReadyMedianMs": 1011.8999999985099,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@ -307,31 +307,31 @@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 257353,
+ "largestAssetRawBytes": 254236,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 414001,
+ "scriptRawBytes": 410885,
"scriptRequestCount": 7,
- "totalRawBytes": 414001
+ "totalRawBytes": 410885
},
"activatedResourceLimits": {
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
- "largestAssetRawBytes": 259927,
+ "largestAssetRawBytes": 256779,
"otherRawBytes": 0,
"requestCount": 7,
- "scriptRawBytes": 418142,
+ "scriptRawBytes": 414994,
"scriptRequestCount": 7,
- "totalRawBytes": 418142
+ "totalRawBytes": 414994
},
- "domContentLoadedMedianMs": 120.30000000074506,
+ "domContentLoadedMedianMs": 115.60000000149012,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.699999999254942,
- "layoutReturnSwitchMedianMs": 49.30000000074506,
- "layoutSwitchMedianMs": 84.80000000074506,
- "loadMedianMs": 120.5,
- "longestTaskMaxMs": 200,
+ "layoutAckMedianMs": 2.5,
+ "layoutReturnSwitchMedianMs": 43.30000000074506,
+ "layoutSwitchMedianMs": 82.80000000074506,
+ "loadMedianMs": 115.69999999925494,
+ "longestTaskMaxMs": 177,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@ -343,9 +343,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 122,
- "scriptRawBytes": 3676125,
+ "scriptRawBytes": 3675263,
"scriptRequestCount": 117,
- "totalRawBytes": 4016448
+ "totalRawBytes": 4015586
},
"resourceLimits": {
"cssRawBytes": 2181,
@@ -354,11 +354,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 122,
- "scriptRawBytes": 3712887,
+ "scriptRawBytes": 3712016,
"scriptRequestCount": 117,
- "totalRawBytes": 4056613
+ "totalRawBytes": 4055742
},
- "routeReadyMedianMs": 1168.5,
+ "routeReadyMedianMs": 1098.199999999255,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@ -385,13 +385,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383457
},
- "domContentLoadedMedianMs": 118.59999999776483,
+ "domContentLoadedMedianMs": 110.59999999776483,
"id": "editor-workflow",
- "layoutAckMedianMs": 2.300000000745058,
- "layoutReturnSwitchMedianMs": 34.599999997764826,
- "layoutSwitchMedianMs": 93.39999999850988,
- "loadMedianMs": 118.69999999925494,
- "longestTaskMaxMs": 102,
+ "layoutAckMedianMs": 2.199999999254942,
+ "layoutReturnSwitchMedianMs": 31.399999998509884,
+ "layoutSwitchMedianMs": 89.09999999776483,
+ "loadMedianMs": 110.69999999925494,
+ "longestTaskMaxMs": 96,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -403,9 +403,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 122,
- "scriptRawBytes": 3626371,
+ "scriptRawBytes": 3628625,
"scriptRequestCount": 116,
- "totalRawBytes": 3982107
+ "totalRawBytes": 3984361
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -414,11 +414,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 122,
- "scriptRawBytes": 3662635,
+ "scriptRawBytes": 3664912,
"scriptRequestCount": 116,
- "totalRawBytes": 4021929
+ "totalRawBytes": 4024205
},
- "routeReadyMedianMs": 1060.800000000745,
+ "routeReadyMedianMs": 1026.5,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "empty"
},
@@ -445,13 +445,13 @@
"scriptRequestCount": 6,
"totalRawBytes": 383457
},
- "domContentLoadedMedianMs": 122.40000000223517,
+ "domContentLoadedMedianMs": 112.30000000074506,
"id": "editor-workflow",
- "layoutAckMedianMs": 3.100000001490116,
- "layoutReturnSwitchMedianMs": 42.399999998509884,
- "layoutSwitchMedianMs": 129.5,
- "loadMedianMs": 122.60000000149012,
- "longestTaskMaxMs": 365,
+ "layoutAckMedianMs": 2.5,
+ "layoutReturnSwitchMedianMs": 39.5,
+ "layoutSwitchMedianMs": 118.19999999925494,
+ "loadMedianMs": 112.5,
+ "longestTaskMaxMs": 329,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@ -463,9 +463,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 122,
- "scriptRawBytes": 3626371,
+ "scriptRawBytes": 3628625,
"scriptRequestCount": 116,
- "totalRawBytes": 3982107
+ "totalRawBytes": 3984361
},
"resourceLimits": {
"cssRawBytes": 17748,
@@ -474,11 +474,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 122,
- "scriptRawBytes": 3662635,
+ "scriptRawBytes": 3664912,
"scriptRequestCount": 116,
- "totalRawBytes": 4021929
+ "totalRawBytes": 4024205
},
- "routeReadyMedianMs": 1210.3999999985099,
+ "routeReadyMedianMs": 1134.300000000745,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "representative"
},
@@ -505,13 +505,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 119,
+ "domContentLoadedMedianMs": 112.69999999925494,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 27,
- "loadMedianMs": 119.19999999925494,
- "longestTaskMaxMs": 101,
+ "layoutSwitchMedianMs": 23.5,
+ "loadMedianMs": 112.80000000074506,
+ "longestTaskMaxMs": 92,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -523,9 +523,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 115,
- "scriptRawBytes": 3262124,
+ "scriptRawBytes": 3264378,
"scriptRequestCount": 110,
- "totalRawBytes": 3602447
+ "totalRawBytes": 3604701
},
"resourceLimits": {
"cssRawBytes": 2181,
@@ -534,11 +534,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 115,
- "scriptRawBytes": 3294746,
+ "scriptRawBytes": 3297022,
"scriptRequestCount": 110,
- "totalRawBytes": 3638472
+ "totalRawBytes": 3640749
},
- "routeReadyMedianMs": 1284.1000000014901,
+ "routeReadyMedianMs": 1248.300000000745,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@ -565,13 +565,13 @@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 127.39999999850988,
+ "domContentLoadedMedianMs": 111.80000000074506,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 101.40000000223517,
- "loadMedianMs": 127.5,
- "longestTaskMaxMs": 211,
+ "layoutSwitchMedianMs": 82.29999999701977,
+ "loadMedianMs": 111.80000000074506,
+ "longestTaskMaxMs": 162,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@ -583,9 +583,9 @@
"largestAssetRawBytes": 746376,
"otherRawBytes": 158124,
"requestCount": 115,
- "scriptRawBytes": 3262124,
+ "scriptRawBytes": 3264378,
"scriptRequestCount": 110,
- "totalRawBytes": 3602447
+ "totalRawBytes": 3604701
},
"resourceLimits": {
"cssRawBytes": 2181,
@@ -594,11 +594,11 @@
"largestAssetRawBytes": 753840,
"otherRawBytes": 159706,
"requestCount": 115,
- "scriptRawBytes": 3294746,
+ "scriptRawBytes": 3297022,
"scriptRequestCount": 110,
- "totalRawBytes": 3638472
+ "totalRawBytes": 3640749
},
- "routeReadyMedianMs": 1555.699999999255,
+ "routeReadyMedianMs": 1401.7999999970198,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
}
@@ -843,6 +843,7 @@
"source:src/platform/ui/ResizableTextarea.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
+ "source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/Select.tsx",
"source:src/platform/ui/Slider.tsx",
"source:src/platform/ui/StatusWidgetChip.tsx",
@@ -1423,6 +1424,7 @@
"source:src/platform/ui/ResizableTextarea.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
+ "source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/Select.tsx",
"source:src/platform/ui/Slider.tsx",
"source:src/platform/ui/SliderNumberField.tsx",
@@ -2379,6 +2381,7 @@
"source:src/platform/ui/ResizableTextarea.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
+ "source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/Select.tsx",
"source:src/platform/ui/Slider.tsx",
"source:src/platform/ui/SliderNumberField.tsx",
@@ -3528,6 +3531,7 @@
"source:src/platform/ui/ResizableTextarea.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
+ "source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/Select.tsx",
"source:src/platform/ui/Slider.tsx",
"source:src/platform/ui/SliderNumberField.tsx",
diff --git a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx
new file mode 100644
index 0000000000..84d215ba07
--- /dev/null
+++ b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx
@@ -0,0 +1,138 @@
+import type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';
+
+import { chakra, HStack, Text } from '@chakra-ui/react';
+import { useCallback } from 'react';
+
+const TAB_HOVER_PROPS = { bg: 'bg.muted', color: 'fg' };
+
+/** The strip's fixed height; collapsed blocks and drag snaps size against it. */
+export const SEGMENT_TABS_HEIGHT_PX = 40;
+
+export interface SegmentTab<T extends string = string> {
+ id: T;
+ label: string;
+}
+
+/** Roving focus for a horizontal tablist: arrows cycle, Home/End jump. */
+const focusSibling = (event: ReactKeyboardEvent<HTMLElement>) => {
+ if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight' && event.key !== 'Home' && event.key !== 'End') {
+ return;
+ }
+ const tabs = [...event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]')];
+ const current = tabs.indexOf(document.activeElement as HTMLElement);
+ if (current === -1) {
+ return;
+ }
+ event.preventDefault();
+ const next =
+ event.key === 'Home'
+ ? 0
+ : event.key === 'End'
+ ? tabs.length - 1
+ : (current + (event.key === 'ArrowRight' ? 1 : tabs.length - 1)) % tabs.length;
+ tabs[next]?.focus();
+};
+
+/**
+ * The workbench's segment-style tab strip: a row of pill tabs over a panel the
+ * caller owns. Ids follow one convention — tab `${idBase}-tab-${id}`, panel
+ * `${idBase}-panel` — so the caller's `role="tabpanel"` region wires itself
+ * with `id={segmentTabsPanelId(idBase)}` and
+ * `aria-labelledby={segmentTabsTabId(idBase, activeId)}`. Clicking the active
+ * tab calls `onSelect` again, which lets a collapsible block treat it as a
+ * toggle; `showActivePanel={false}` keeps the active tab selected and focusable
+ * while dropping the shown look (a collapsed block). `trailing` renders after
+ * the tablist, outside it, for chevrons and action buttons.
+ */
+export const SegmentTabs = <T extends string>({
+ activeId,
+ ariaLabel,
+ idBase,
+ onSelect,
+ showActivePanel = true,
+ tabs,
+ trailing,
+}: {
+ activeId: T;
+ ariaLabel: string;
+ idBase: string;
+ onSelect: (id: T) => void;
+ showActivePanel?: boolean;
+ tabs: readonly SegmentTab<T>[];
+ trailing?: ReactNode;
+}) => (
+ <HStack align="center" flexShrink={0} gap="0.5" h={`${SEGMENT_TABS_HEIGHT_PX}px`} minW="0" px="1.5">
+ <HStack
+ aria-label={ariaLabel}
+ aria-orientation="horizontal"
+ flex="1"
+ gap="0.5"
+ minW="0"
+ overflow="hidden"
+ role="tablist"
+ onKeyDown={focusSibling}
+ >
+ {tabs.map((tab) => (
+ <SegmentTabButton
+ key={tab.id}
+ id={tab.id}
+ idBase={idBase}
+ isSelected={tab.id === activeId}
+ isShown={tab.id === activeId && showActivePanel}
+ label={tab.label}
+ onSelect={onSelect}
+ />
+ ))}
+ </HStack>
+ {trailing}
+ </HStack>
+);
+
+export const segmentTabsPanelId = (idBase: string): string => `${idBase}-panel`;
+export const segmentTabsTabId = (idBase: string, tabId: string): string => `${idBase}-tab-${tabId}`;
+
+const SegmentTabButton = <T extends string>({
+ id,
+ idBase,
+ isSelected,
+ isShown,
+ label,
+ onSelect,
+}: {
+ id: T;
+ idBase: string;
+ isSelected: boolean;
+ /** Selected AND its panel is visible; a collapsed block keeps selection without the shown look. */
+ isShown: boolean;
+ label: string;
+ onSelect: (id: T) => void;
+}) => {
+ const select = useCallback(() => onSelect(id), [id, onSelect]);
+
+ return (
+ <chakra.button
+ aria-controls={isShown ? segmentTabsPanelId(idBase) : undefined}
+ aria-selected={isSelected}
+ bg={isShown ? 'bg.emphasized' : 'transparent'}
+ color={isShown ? 'fg' : 'fg.muted'}
+ cursor="pointer"
+ fontSize="xs"
+ fontWeight="600"
+ h="7"
+ id={segmentTabsTabId(idBase, id)}
+ minW="10"
+ overflow="hidden"
+ px="2.5"
+ role="tab"
+ rounded="md"
+ tabIndex={isSelected ? 0 : -1}
+ type="button"
+ _hover={isShown ? undefined : TAB_HOVER_PROPS}
+ onClick={select}
+ >
+ <Text as="span" truncate>
+ {label}
+ </Text>
+ </chakra.button>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/platform/ui/index.ts b/invokeai/frontend/webv2/src/platform/ui/index.ts
index 5695c907f4..760646ea80 100644
--- a/invokeai/frontend/webv2/src/platform/ui/index.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/index.ts
@@ -14,6 +14,7 @@ export * from './RenameDialog';
export * from './ResizableTextarea';
export * from './Row';
export * from './Scrollable';
+export * from './SegmentTabs';
export * from './Select';
export * from './Slider';
export * from './StatusWidgetChip';
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx
index 5c5d3a2a3c..c9161068db 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx
@@ -1,6 +1,7 @@
import type { WidgetViewProps } from '@workbench/widgetContracts';
import { Flex, Icon, Stack, Text } from '@chakra-ui/react';
+import { SegmentTabs, segmentTabsPanelId, segmentTabsTabId } from '@platform/ui/SegmentTabs';
import { getDocumentIndex } from '@workbench/canvas-engine/api';
import { setLayerPanelFilter, useLayerPanelState } from '@workbench/layerPanelState';
import { useCanvasProjectMutationDispatch } from '@workbench/useCanvasProjectMutationDispatch';
@@ -30,7 +31,7 @@ import {
readLayerTreeTab,
} from './panes/editorPaneLayout';
import { HistoryPane } from './panes/HistoryPane';
-import { LAYER_TREE_PANEL_ID, LayerColorPane, LayerEditorPanes, LayerTreeStrip } from './panes/LayerEditorPanes';
+import { LayerColorPane, LayerEditorPanes } from './panes/LayerEditorPanes';
import { useLayerSelectionCommands } from './useLayerSelectionCommands';
/**
@@ -40,6 +41,12 @@ import { useLayerSelectionCommands } from './useLayerSelectionCommands';
* at the bottom — the selected layer's other editors live in the Properties pane. Regions keep
* their geometry; their controls disable instead of appearing and disappearing.
*/
+const TREE_TABS_ID_BASE = 'layer-tree';
+const TREE_TABS: ReadonlyArray<{ id: LayerTreeTabId; labelKey: string }> = [
+ { id: 'layers', labelKey: 'widgets.labels.layers' },
+ { id: 'history', labelKey: 'widgets.labels.history' },
+];
+
export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {
const { t } = useTranslation();
const engine = useCanvasEngine();
@@ -92,6 +99,8 @@ export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {
readLayerTreeTab(project.widgetInstances[runtime.instanceId]?.state.values ?? {})
);
const handleTreeTab = useCallback((tab: LayerTreeTabId) => runtime.state.patch({ treeTab: tab }), [runtime.state]);
+ const treeTabs = useMemo(() => TREE_TABS.map(({ id, labelKey }) => ({ id, label: t(labelKey) })), [t]);
+ const addLayerButton = useMemo(() => <LayersHeaderActions />, []);
// A properties request (canvas context menu) must reach the tree, which only
// mounts on the Layers tab — switch back so the reveal actually happens.
const propertiesRequest = useCurrentLayerPropertiesRequest();
@@ -122,14 +131,19 @@ export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {
return (
<Stack gap="1" h="full" minH="0">
<LayerColorPane layout={colorPaneLayout} onLayoutChange={handleColorPaneLayout} />
- <LayerTreeStrip activeTab={treeTab} onSelectTab={handleTreeTab}>
- <LayersHeaderActions />
- </LayerTreeStrip>
+ <SegmentTabs
+ activeId={treeTab}
+ ariaLabel={t('widgets.layers.treeTabs')}
+ idBase={TREE_TABS_ID_BASE}
+ tabs={treeTabs}
+ trailing={addLayerButton}
+ onSelect={handleTreeTab}
+ />
<Flex
- aria-labelledby={`layer-tree-tab-${treeTab}`}
+ aria-labelledby={segmentTabsTabId(TREE_TABS_ID_BASE, treeTab)}
direction="column"
flex="1"
- id={LAYER_TREE_PANEL_ID}
+ id={segmentTabsPanelId(TREE_TABS_ID_BASE)}
// The blend row (32px control + 8px padding) + tree floor (128px) +
// footer (40px); anything less lets the unshrinkable rows paint under
// the editor panes.
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
index 0190e2cad4..750acb5a24 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
@@ -75,14 +75,15 @@ vi.mock('@workbench/useCanvasProjectMutationDispatch', () => ({
}));
vi.mock('@workbench/widgets/canvas/useCanvasEngine', () => ({ useCanvasEngine: () => harness.engine }));
+import { SegmentTabs, segmentTabsPanelId, segmentTabsTabId } from '@platform/ui/SegmentTabs';
import { clearMaskTintTarget } from '@workbench/widgets/canvas/color-system/maskTintTarget';
-import type { LayerEditorPaneLayout, LayerTreeTabId } from './editorPaneLayout';
+import type { LayerEditorPaneLayout } from './editorPaneLayout';
import { ColorPane } from './ColorPane';
import { LAYER_EDITOR_PANE_DEFAULTS } from './editorPaneLayout';
import { HistoryPane } from './HistoryPane';
-import { LAYER_TREE_PANEL_ID, LayerEditorPanes, LayerTreeStrip } from './LayerEditorPanes';
+import { LayerEditorPanes } from './LayerEditorPanes';
import { OverviewPane } from './OverviewPane';
import { PropertiesPane } from './PropertiesPane';
import { SwatchesPane } from './SwatchesPane';
@@ -458,21 +459,32 @@ const OverviewHarness = () => (
</Box>
);
+const TREE_STRIP_TABS = [
+ { id: 'layers', label: 'Layers' },
+ { id: 'history', label: 'History' },
+];
+const TREE_STRIP_TRAILING = <span>trailing-slot</span>;
+
const TreeStripHarness = () => {
- const [tab, setTab] = useState<LayerTreeTabId>('layers');
+ const [tab, setTab] = useState('layers');
return (
<>
- <LayerTreeStrip activeTab={tab} onSelectTab={setTab}>
- <span>trailing-slot</span>
- </LayerTreeStrip>
- <Box id={LAYER_TREE_PANEL_ID} role="tabpanel">
+ <SegmentTabs
+ activeId={tab}
+ ariaLabel="Layer panel views"
+ idBase="layer-tree"
+ tabs={TREE_STRIP_TABS}
+ trailing={TREE_STRIP_TRAILING}
+ onSelect={setTab}
+ />
+ <Box aria-labelledby={segmentTabsTabId('layer-tree', tab)} id={segmentTabsPanelId('layer-tree')} role="tabpanel">
{tab === 'history' ? 'history-panel' : 'layers-panel'}
</Box>
</>
);
};
-describe('Layer tree strip', () => {
+describe('Segment tab strip', () => {
it('switches the middle region between the tree and history', async () => {
await mount(TreeStripHarness);
const layersTab = page.getByRole('tab', { exact: true, name: 'Layers' });
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.tsx
index 7b00cb95b7..e7c4ab9b62 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.tsx
@@ -1,8 +1,9 @@
import type { KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent, ReactNode } from 'react';
-import { Box, chakra, Flex, HStack, Icon, Text } from '@chakra-ui/react';
+import { Box, Flex, Icon } from '@chakra-ui/react';
import { useMountEffect } from '@platform/react/useMountEffect';
import { IconButton } from '@platform/ui/Button';
+import { SEGMENT_TABS_HEIGHT_PX, SegmentTabs, segmentTabsPanelId, segmentTabsTabId } from '@platform/ui/SegmentTabs';
import { Tooltip } from '@platform/ui/Tooltip';
import { ChevronDownIcon, ChevronUpIcon } from 'lucide-react';
import { useCallback, useMemo, useRef, useState } from 'react';
@@ -13,7 +14,6 @@ import type {
LayerColorPaneLayout,
LayerEditorPaneId,
LayerEditorPaneLayout,
- LayerTreeTabId,
PaneBlockLayout,
} from './editorPaneLayout';
@@ -31,12 +31,9 @@ import { PropertiesPane } from './PropertiesPane';
import { SwatchesPane } from './SwatchesPane';
import { TransformPane } from './TransformPane';
-/** The tab strip's height; a collapsed pane block is exactly this tall. */
-const STRIP_HEIGHT_PX = 40;
const RESIZE_STEP_PX = 16;
/** Parity with the shell panels: releasing at the floor stops there; collapse asks for a real push past it. */
const COLLAPSE_OVERSHOOT_PX = 80;
-const TAB_HOVER_PROPS = { bg: 'bg.muted', color: 'fg' };
const HANDLE_HOVER_PROPS = { bg: 'accent.solid', opacity: 0.45 };
const HANDLE_FOCUS_PROPS = { bg: 'accent.solid', opacity: 0.65, outline: '2px solid {colors.accent.solid}' };
@@ -47,26 +44,6 @@ interface PaneBlockLabels {
tabs: string;
}
-/** Roving focus for a horizontal tablist: arrows cycle, Home/End jump. */
-const focusSibling = (event: ReactKeyboardEvent<HTMLElement>) => {
- if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight' && event.key !== 'Home' && event.key !== 'End') {
- return;
- }
- const tabs = [...event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]')];
- const current = tabs.indexOf(document.activeElement as HTMLElement);
- if (current === -1) {
- return;
- }
- event.preventDefault();
- const next =
- event.key === 'Home'
- ? 0
- : event.key === 'End'
- ? tabs.length - 1
- : (current + (event.key === 'ArrowRight' ? 1 : tabs.length - 1)) % tabs.length;
- tabs[next]?.focus();
-};
-
/**
* One fixed pane block of the Layers panel: a tab strip over a panel, with a
* preferred height, a resize separator on its inner edge, and collapse down to
@@ -108,7 +85,7 @@ const LayerPaneBlock = ({
const toggleRef = useRef<HTMLButtonElement>(null);
// Toward the panel's middle: the direction a drag or grow-key moves the handle.
const growSign = edge === 'top' ? 1 : -1;
- const panelId = `${blockId}-panel`;
+ const panelId = segmentTabsPanelId(blockId);
useMountEffect(() => () => drag.current?.abort());
@@ -142,7 +119,7 @@ const LayerPaneBlock = ({
const move = (moveEvent: PointerEvent) => {
latest = sizePx + (moveEvent.clientY - startY) * growSign;
// Past the overshoot the preview snaps to the strip, so the release's collapse is never a surprise.
- setPreviewSizePx(latest <= minSizePx - COLLAPSE_OVERSHOOT_PX ? STRIP_HEIGHT_PX : clampSize(latest));
+ setPreviewSizePx(latest <= minSizePx - COLLAPSE_OVERSHOOT_PX ? SEGMENT_TABS_HEIGHT_PX : clampSize(latest));
};
const finish = (apply: boolean) => () => {
controller.abort();
@@ -219,30 +196,8 @@ const LayerPaneBlock = ({
/>
</Box>
) : null;
- const strip = (
- <HStack align="center" flexShrink={0} gap="0.5" h={`${STRIP_HEIGHT_PX}px`} minW="0" px="1.5">
- <HStack
- aria-label={labels.tabs}
- aria-orientation="horizontal"
- flex="1"
- gap="0.5"
- minW="0"
- overflow="hidden"
- role="tablist"
- onKeyDown={focusSibling}
- >
- {panes.map((pane) => (
- <PaneTab
- key={pane.id}
- blockId={blockId}
- id={pane.id}
- isExpanded={!isCollapsed}
- isSelected={pane.id === activePane}
- label={pane.label}
- onSelect={onSelectPane}
- />
- ))}
- </HStack>
+ const collapseButton = useMemo(
+ () => (
<Tooltip content={collapseLabel}>
<IconButton
ref={toggleRef}
@@ -256,11 +211,23 @@ const LayerPaneBlock = ({
<Icon as={collapseIcon} boxSize="3.5" />
</IconButton>
</Tooltip>
- </HStack>
+ ),
+ [collapseIcon, collapseLabel, isCollapsed, toggle]
+ );
+ const strip = (
+ <SegmentTabs
+ activeId={activePane}
+ ariaLabel={labels.tabs}
+ idBase={blockId}
+ showActivePanel={!isCollapsed}
+ tabs={panes}
+ trailing={collapseButton}
+ onSelect={onSelectPane}
+ />
);
const panel = !isCollapsed ? (
<Box
- aria-labelledby={`${blockId}-tab-${activePane}`}
+ aria-labelledby={segmentTabsTabId(blockId, activePane)}
flex="1"
id={panelId}
minH="0"
@@ -278,7 +245,7 @@ const LayerPaneBlock = ({
data-pane-collapsed={isCollapsed ? '' : undefined}
direction="column"
flex={isCollapsed ? '0 0 auto' : `0 1 ${previewSizePx ?? sizePx}px`}
- minH={`${STRIP_HEIGHT_PX}px`}
+ minH={`${SEGMENT_TABS_HEIGHT_PX}px`}
overflow="hidden"
{...(edge === 'top' ? { borderBottomWidth: '1px' } : { borderTopWidth: '1px' })}
>
@@ -429,105 +396,3 @@ export const LayerColorPane = ({
</LayerPaneBlock>
);
};
-
-const TREE_TABS: ReadonlyArray<{ id: LayerTreeTabId; labelKey: string }> = [
- { id: 'layers', labelKey: 'widgets.labels.layers' },
- { id: 'history', labelKey: 'widgets.labels.history' },
-];
-
-/** The middle region announces itself as this strip's tabpanel. */
-export const LAYER_TREE_PANEL_ID = 'layer-tree-panel';
-
-/**
- * The strip over the flexible middle region: the layer tree and the edit
- * history as sibling tabs, with the add-layer menu at the trailing edge. The
- * middle region is the tabpanel — it has no preferred size and no collapse.
- */
-export const LayerTreeStrip = ({
- activeTab,
- children,
- onSelectTab,
-}: {
- activeTab: LayerTreeTabId;
- children?: ReactNode;
- onSelectTab: (tab: LayerTreeTabId) => void;
-}) => {
- const { t } = useTranslation();
- const tabs = useMemo(() => TREE_TABS.map(({ id, labelKey }) => ({ id, label: t(labelKey) })), [t]);
- const onSelect = useCallback((tab: string) => onSelectTab(tab as LayerTreeTabId), [onSelectTab]);
-
- return (
- <HStack align="center" flexShrink={0} gap="0.5" h={`${STRIP_HEIGHT_PX}px`} minW="0" px="1.5">
- <HStack
- aria-label={t('widgets.layers.treeTabs')}
- aria-orientation="horizontal"
- flex="1"
- gap="0.5"
- minW="0"
- overflow="hidden"
- role="tablist"
- onKeyDown={focusSibling}
- >
- {tabs.map((tab) => (
- <PaneTab
- key={tab.id}
- blockId="layer-tree"
- id={tab.id}
- isExpanded
- isSelected={tab.id === activeTab}
- label={tab.label}
- onSelect={onSelect}
- />
- ))}
- </HStack>
- {children}
- </HStack>
- );
-};
-
-const PaneTab = ({
- blockId,
- id,
- isExpanded,
- isSelected,
- label,
- onSelect,
-}: {
- blockId: string;
- id: string;
- /** Collapsed keeps the selected tab focusable and selected; only the shown look changes. */
- isExpanded: boolean;
- isSelected: boolean;
- label: string;
- onSelect: (pane: string) => void;
-}) => {
- const select = useCallback(() => onSelect(id), [id, onSelect]);
- const isShown = isSelected && isExpanded;
-
- return (
- <chakra.button
- aria-controls={isShown ? `${blockId}-panel` : undefined}
- aria-selected={isSelected}
- bg={isShown ? 'bg.emphasized' : 'transparent'}
- color={isShown ? 'fg' : 'fg.muted'}
- cursor="pointer"
- fontSize="xs"
- fontWeight="600"
- h="7"
- id={`${blockId}-tab-${id}`}
- minW="10"
- overflow="hidden"
- px="2.5"
- role="tab"
- rounded="md"
- tabIndex={isSelected ? 0 : -1}
- type="button"
- _hover={isShown ? undefined : TAB_HOVER_PROPS}
- onClick={select}
- >
- <Text as="span" truncate>
- {label}
- </Text>
- </chakra.button>
- );
-};