Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

Merge branch 'main' into feat/scrubber-input

Josh Corbett67ff1029448f
diff --cc invokeai/frontend/webv2/performance/browser-baseline.json
index 5c730178ec,f27044175c..1a0bf1ae9e
--- a/invokeai/frontend/webv2/performance/browser-baseline.json
+++ b/invokeai/frontend/webv2/performance/browser-baseline.json
@@@ -1,6 -1,6 +1,6 @@@
{
-- "browserExecutable": "/home/lstein/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome",
- "capturedAt": "2026-09-13",
- "capturedAt": "2026-09-14",
++ "browserExecutable": "/home/toast/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome",
++ "capturedAt": "2026-09-15",
"routes": [
{
"activatedResourceBaseline": {
@@@ -14,13 -14,13 +14,13 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 104,
- "domContentLoadedMedianMs": 98.29999995231628,
++ "domContentLoadedMedianMs": 121.60000000149012,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 104.19999992847443,
- "longestTaskMaxMs": 75,
- "loadMedianMs": 98.39999997615814,
- "longestTaskMaxMs": 58,
++ "loadMedianMs": 121.69999999552965,
++ "longestTaskMaxMs": 73,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@@ -30,13 -30,13 +30,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 39,
- "scriptRawBytes": 1692314,
- "scriptRawBytes": 1692362,
++ "scriptRawBytes": 1694394,
"scriptRequestCount": 35,
- "totalRawBytes": 1871108
- "totalRawBytes": 1871238
++ "totalRawBytes": 1874638
},
- "routeReadyMedianMs": 237.29999995231628,
- "routeReadyMedianMs": 222.29999995231628,
++ "routeReadyMedianMs": 271.8999999985099,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "empty"
},
@@@ -52,13 -52,13 +52,13 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 98.60000002384186,
- "domContentLoadedMedianMs": 96.79999995231628,
++ "domContentLoadedMedianMs": 119.30000000447035,
"id": "launchpad",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 98.69999992847443,
- "longestTaskMaxMs": 66,
- "loadMedianMs": 97,
- "longestTaskMaxMs": 60,
++ "loadMedianMs": 119.40000000596046,
++ "longestTaskMaxMs": 73,
"owner": "app",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:launchpad",
@@@ -68,13 -68,13 +68,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 0,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 39,
- "scriptRawBytes": 1692314,
- "scriptRawBytes": 1692362,
++ "scriptRawBytes": 1694394,
"scriptRequestCount": 35,
- "totalRawBytes": 1871108
- "totalRawBytes": 1871238
++ "totalRawBytes": 1874638
},
- "routeReadyMedianMs": 244.69999992847443,
- "routeReadyMedianMs": 226.5,
++ "routeReadyMedianMs": 276.1000000014901,
"scriptSourceOwnerSet": "launchpad-static",
"stateProfile": "representative"
},
@@@ -90,15 -90,15 +90,15 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 98.5,
- "domContentLoadedMedianMs": 97.10000002384186,
++ "domContentLoadedMedianMs": 120,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 98.70000004768372,
- "longestTaskMaxMs": 111,
- "loadMedianMs": 97.29999995231628,
- "longestTaskMaxMs": 108,
++ "loadMedianMs": 120.20000000298023,
++ "longestTaskMaxMs": 138,
"owner": "workbench",
- "projectSwitchMedianMs": 32.699999928474426,
- "projectSwitchMedianMs": 31.699999928474426,
++ "projectSwitchMedianMs": 39.29999999701977,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@@ -106,13 -106,13 +106,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 122,
- "scriptRawBytes": 3549693,
- "scriptRawBytes": 3552481,
++ "scriptRawBytes": 3578744,
"scriptRequestCount": 117,
- "totalRawBytes": 3884863
- "totalRawBytes": 3887733
++ "totalRawBytes": 3915364
},
- "routeReadyMedianMs": 372.8000000715256,
- "routeReadyMedianMs": 361.6999999284744,
++ "routeReadyMedianMs": 453.20000000298023,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@@ -128,15 -128,15 +128,15 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 97.80000007152557,
- "domContentLoadedMedianMs": 94.59999990463257,
++ "domContentLoadedMedianMs": 121.89999999850988,
"id": "editor-minimal",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
"layoutSwitchMedianMs": 0,
- "loadMedianMs": 97.80000007152557,
- "longestTaskMaxMs": 112,
- "loadMedianMs": 94.69999992847443,
- "longestTaskMaxMs": 117,
++ "loadMedianMs": 122,
++ "longestTaskMaxMs": 135,
"owner": "workbench",
- "projectSwitchMedianMs": 38.5,
- "projectSwitchMedianMs": 36.60000002384186,
++ "projectSwitchMedianMs": 45.70000000298023,
"readyMark": "invokeai:ready:widget:center:preview",
"remediationTicket": "deepen-widget-registry-loading",
"resourceBaseline": {
@@@ -144,13 -144,13 +144,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 122,
- "scriptRawBytes": 3549693,
- "scriptRawBytes": 3552481,
++ "scriptRawBytes": 3578744,
"scriptRequestCount": 117,
- "totalRawBytes": 3884863
- "totalRawBytes": 3887733
++ "totalRawBytes": 3915364
},
- "routeReadyMedianMs": 379.7999999523163,
- "routeReadyMedianMs": 361.89999997615814,
++ "routeReadyMedianMs": 442.29999999701977,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
},
@@@ -159,20 -159,20 +159,20 @@@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
-- "largestAssetRawBytes": 307179,
++ "largestAssetRawBytes": 310171,
"otherRawBytes": 0,
"requestCount": 10,
-- "scriptRawBytes": 501646,
++ "scriptRawBytes": 504532,
"scriptRequestCount": 10,
-- "totalRawBytes": 501646
++ "totalRawBytes": 504532
},
- "domContentLoadedMedianMs": 96.39999997615814,
- "domContentLoadedMedianMs": 96.5,
++ "domContentLoadedMedianMs": 119.89999999850988,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.700000047683716,
- "layoutReturnSwitchMedianMs": 52.60000002384186,
- "layoutSwitchMedianMs": 86.10000002384186,
- "layoutAckMedianMs": 2.399999976158142,
- "layoutReturnSwitchMedianMs": 50.799999952316284,
- "layoutSwitchMedianMs": 79.79999995231628,
-- "loadMedianMs": 96.5,
- "longestTaskMaxMs": 133,
- "longestTaskMaxMs": 122,
++ "layoutAckMedianMs": 2.5,
++ "layoutReturnSwitchMedianMs": 47.899999998509884,
++ "layoutSwitchMedianMs": 91.39999999850988,
++ "loadMedianMs": 120,
++ "longestTaskMaxMs": 144,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@@ -182,13 -182,13 +182,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 132,
- "scriptRawBytes": 4051339,
- "scriptRawBytes": 4054127,
++ "scriptRawBytes": 4083276,
"scriptRequestCount": 127,
- "totalRawBytes": 4386509
- "totalRawBytes": 4389379
++ "totalRawBytes": 4419896
},
- "routeReadyMedianMs": 1051.5,
- "routeReadyMedianMs": 1037.5,
++ "routeReadyMedianMs": 1147.7999999970198,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "empty"
},
@@@ -197,20 -197,20 +197,20 @@@
"cssRawBytes": 0,
"fontRawBytes": 0,
"imageRawBytes": 0,
-- "largestAssetRawBytes": 307179,
++ "largestAssetRawBytes": 310171,
"otherRawBytes": 0,
"requestCount": 10,
-- "scriptRawBytes": 501646,
++ "scriptRawBytes": 504532,
"scriptRequestCount": 10,
-- "totalRawBytes": 501646
++ "totalRawBytes": 504532
},
- "domContentLoadedMedianMs": 101.60000002384186,
- "domContentLoadedMedianMs": 95.70000004768372,
++ "domContentLoadedMedianMs": 117.30000000447035,
"id": "editor-canvas",
- "layoutAckMedianMs": 2.899999976158142,
- "layoutReturnSwitchMedianMs": 47.299999952316284,
- "layoutSwitchMedianMs": 81.19999992847443,
- "loadMedianMs": 101.70000004768372,
- "longestTaskMaxMs": 159,
- "layoutAckMedianMs": 2.600000023841858,
- "layoutReturnSwitchMedianMs": 47.800000071525574,
- "layoutSwitchMedianMs": 77.89999997615814,
- "loadMedianMs": 95.89999997615814,
- "longestTaskMaxMs": 149,
++ "layoutAckMedianMs": 2.5,
++ "layoutReturnSwitchMedianMs": 44.399999998509884,
++ "layoutSwitchMedianMs": 85.89999999850988,
++ "loadMedianMs": 117.30000000447035,
++ "longestTaskMaxMs": 199,
"owner": "canvas",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:canvas",
@@@ -220,13 -220,13 +220,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 132,
- "scriptRawBytes": 4051339,
- "scriptRawBytes": 4054127,
++ "scriptRawBytes": 4083276,
"scriptRequestCount": 127,
- "totalRawBytes": 4386509
- "totalRawBytes": 4389379
++ "totalRawBytes": 4419896
},
- "routeReadyMedianMs": 1060.3000000715256,
- "routeReadyMedianMs": 1045.6999999284744,
++ "routeReadyMedianMs": 1148.3999999985099,
"scriptSourceOwnerSet": "editor-canvas-static",
"stateProfile": "representative"
},
@@@ -238,17 -238,17 +238,17 @@@
"largestAssetRawBytes": 174131,
"otherRawBytes": 0,
"requestCount": 7,
-- "scriptRawBytes": 368285,
++ "scriptRawBytes": 370147,
"scriptRequestCount": 6,
-- "totalRawBytes": 383698
++ "totalRawBytes": 385560
},
- "domContentLoadedMedianMs": 103.29999995231628,
- "domContentLoadedMedianMs": 94.40000009536743,
++ "domContentLoadedMedianMs": 116.89999999850988,
"id": "editor-workflow",
- "layoutAckMedianMs": 1.9000000953674316,
- "layoutReturnSwitchMedianMs": 30.399999976158142,
- "layoutSwitchMedianMs": 78.59999990463257,
- "loadMedianMs": 103.39999997615814,
- "longestTaskMaxMs": 112,
- "layoutAckMedianMs": 1.8000000715255737,
- "layoutReturnSwitchMedianMs": 29.5,
- "layoutSwitchMedianMs": 76.19999992847443,
- "loadMedianMs": 94.5,
- "longestTaskMaxMs": 109,
++ "layoutAckMedianMs": 2.399999998509884,
++ "layoutReturnSwitchMedianMs": 33.70000000298023,
++ "layoutSwitchMedianMs": 93.29999999701977,
++ "loadMedianMs": 117.19999999552965,
++ "longestTaskMaxMs": 138,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@@ -258,13 -258,13 +258,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 129,
- "scriptRawBytes": 3917978,
- "scriptRawBytes": 3920766,
++ "scriptRawBytes": 3948891,
"scriptRequestCount": 123,
- "totalRawBytes": 4268561
- "totalRawBytes": 4271431
++ "totalRawBytes": 4300924
},
- "routeReadyMedianMs": 1048.3999999761581,
- "routeReadyMedianMs": 1030,
++ "routeReadyMedianMs": 1140.2999999970198,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "empty"
},
@@@ -276,17 -276,17 +276,17 @@@
"largestAssetRawBytes": 174131,
"otherRawBytes": 0,
"requestCount": 7,
-- "scriptRawBytes": 368285,
++ "scriptRawBytes": 370147,
"scriptRequestCount": 6,
-- "totalRawBytes": 383698
++ "totalRawBytes": 385560
},
- "domContentLoadedMedianMs": 100.60000002384186,
- "domContentLoadedMedianMs": 95.5,
++ "domContentLoadedMedianMs": 120.69999999552965,
"id": "editor-workflow",
- "layoutAckMedianMs": 3.6999999284744263,
- "layoutReturnSwitchMedianMs": 36.89999997615814,
- "layoutSwitchMedianMs": 108.5,
- "loadMedianMs": 100.69999992847443,
- "longestTaskMaxMs": 294,
- "layoutAckMedianMs": 3.100000023841858,
- "layoutReturnSwitchMedianMs": 35.299999952316284,
- "layoutSwitchMedianMs": 109.20000004768372,
- "loadMedianMs": 95.5,
- "longestTaskMaxMs": 290,
++ "layoutAckMedianMs": 2.399999998509884,
++ "layoutReturnSwitchMedianMs": 40,
++ "layoutSwitchMedianMs": 132.60000000149012,
++ "loadMedianMs": 120.79999999701977,
++ "longestTaskMaxMs": 364,
"owner": "workflow",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:workflow",
@@@ -296,13 -296,13 +296,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 129,
- "scriptRawBytes": 3917978,
- "scriptRawBytes": 3920766,
++ "scriptRawBytes": 3948891,
"scriptRequestCount": 123,
- "totalRawBytes": 4268561
- "totalRawBytes": 4271431
++ "totalRawBytes": 4300924
},
- "routeReadyMedianMs": 1107.3000000715256,
- "routeReadyMedianMs": 1068.7000000476837,
++ "routeReadyMedianMs": 1173.7000000029802,
"scriptSourceOwnerSet": "editor-workflow-static",
"stateProfile": "representative"
},
@@@ -318,13 -318,13 +318,13 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 103.30000007152557,
- "domContentLoadedMedianMs": 98.39999997615814,
++ "domContentLoadedMedianMs": 118.60000000149012,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 23.899999976158142,
- "loadMedianMs": 103.40000009536743,
- "longestTaskMaxMs": 112,
- "layoutSwitchMedianMs": 20.899999976158142,
- "loadMedianMs": 98.60000002384186,
- "longestTaskMaxMs": 105,
++ "layoutSwitchMedianMs": 27.100000001490116,
++ "loadMedianMs": 118.60000000149012,
++ "longestTaskMaxMs": 141,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@@ -334,13 -334,13 +334,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 122,
- "scriptRawBytes": 3549693,
- "scriptRawBytes": 3552481,
++ "scriptRawBytes": 3578744,
"scriptRequestCount": 117,
- "totalRawBytes": 3884863
- "totalRawBytes": 3887733
++ "totalRawBytes": 3915364
},
- "routeReadyMedianMs": 1259.5,
- "routeReadyMedianMs": 1246.6999999284744,
++ "routeReadyMedianMs": 1347,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "empty"
},
@@@ -356,13 -356,13 +356,13 @@@
"scriptRequestCount": 0,
"totalRawBytes": 0
},
- "domContentLoadedMedianMs": 101.69999992847443,
- "domContentLoadedMedianMs": 98.60000002384186,
++ "domContentLoadedMedianMs": 122.70000000298023,
"id": "editor-gallery",
"layoutAckMedianMs": 0,
"layoutReturnSwitchMedianMs": 0,
- "layoutSwitchMedianMs": 33,
- "loadMedianMs": 101.79999995231628,
- "longestTaskMaxMs": 102,
- "layoutSwitchMedianMs": 27.799999952316284,
- "loadMedianMs": 98.70000004768372,
- "longestTaskMaxMs": 101,
++ "layoutSwitchMedianMs": 39.19999999552965,
++ "loadMedianMs": 122.80000000447035,
++ "longestTaskMaxMs": 128,
"owner": "gallery",
"projectSwitchMedianMs": 0,
"readyMark": "invokeai:ready:widget:center:gallery",
@@@ -372,13 -372,13 +372,13 @@@
"fontRawBytes": 23664,
"imageRawBytes": 156376,
"largestAssetRawBytes": 747218,
- "otherRawBytes": 152971,
- "otherRawBytes": 153053,
++ "otherRawBytes": 154421,
"requestCount": 122,
- "scriptRawBytes": 3549693,
- "scriptRawBytes": 3552481,
++ "scriptRawBytes": 3578744,
"scriptRequestCount": 117,
- "totalRawBytes": 3884863
- "totalRawBytes": 3887733
++ "totalRawBytes": 3915364
},
- "routeReadyMedianMs": 1278.0999999046326,
- "routeReadyMedianMs": 1261.5999999046326,
++ "routeReadyMedianMs": 1370.7999999970198,
"scriptSourceOwnerSet": "editor-minimal-static",
"stateProfile": "representative"
}
@@@ -1248,6 -1257,7 +1257,8 @@@
"source:src/platform/ui/RetryBoundary.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
++ "source:src/platform/ui/ScrubberField.tsx",
+ "source:src/platform/ui/SeedInput.tsx",
"source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/SegmentedControl.tsx",
"source:src/platform/ui/Select.tsx",
@@@ -2277,6 -2296,7 +2297,8 @@@
"source:src/platform/ui/RetryBoundary.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
++ "source:src/platform/ui/ScrubberField.tsx",
+ "source:src/platform/ui/SeedInput.tsx",
"source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/SegmentedControl.tsx",
"source:src/platform/ui/Select.tsx",
@@@ -3521,6 -3550,7 +3552,8 @@@
"source:src/platform/ui/RetryBoundary.tsx",
"source:src/platform/ui/Row.tsx",
"source:src/platform/ui/Scrollable.tsx",
++ "source:src/platform/ui/ScrubberField.tsx",
+ "source:src/platform/ui/SeedInput.tsx",
"source:src/platform/ui/SegmentTabs.tsx",
"source:src/platform/ui/SegmentedControl.tsx",
"source:src/platform/ui/Select.tsx",
diff --cc invokeai/frontend/webv2/public/locales/en.json
index 4ac234c86c,32a6118a9d..ef6de715b1
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@@ -2190,8 -2217,7 +2213,9 @@@
"renamePresetNamed": "Rename preset {{name}}",
"renamePresetTitle": "Rename preset",
"resetToModelDefault": "Reset to model default",
+ "resetToConceptDefault": "Reset to concept default",
+ "resetToDefault": "Reset to default",
+ "retry": "Retry",
"savePresetAction": "Save",
"savePresetTitle": "Save preset",
"scaleBeforeProcessing": "Scale before processing",
diff --cc invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.browser.test.tsx
index 0000000000,1c515a222a..139768dcd2
mode 000000,100644..100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.browser.test.tsx
@@@ -1,0 -1,396 +1,417 @@@
+ /* oxlint-disable react-perf/jsx-no-new-object-as-prop */
+ import type { GenerateSettings, MainModelConfig } from '@features/generation/core/types';
+
+ import { ChakraProvider } from '@chakra-ui/react';
+ import { seedArchitectureCapabilities } from '@features/generation/core/architectureCapabilities.testing';
+ import { getDefaultGenerateSettings } from '@features/generation/core/baseGenerationPolicies';
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+ import { system } from '@theme/system';
+ import { createInstance } from 'i18next';
+ import { act } from 'react';
+ import { createRoot, type Root } from 'react-dom/client';
+ import { I18nextProvider, initReactI18next } from 'react-i18next';
+ import { afterEach, describe, expect, it, vi } from 'vitest';
+
+ import { GenerateRenderSection } from './GenerateRenderSection';
+
+ const seedHistory = [
+ { seed: 777, thumbnailUrl: null },
+ { seed: 888, thumbnailUrl: null },
+ ];
+
+ vi.mock('./GenerationUiContext', () => ({
+ useGenerationUi: () => ({
+ queueInsights: { secondsPerRun: null, seedHistory },
+ sectionPreferences: { sectionsOpen: { render: true }, setSectionOpen: vi.fn() },
+ }),
+ }));
+
+ const i18n = createInstance();
+ void i18n.use(initReactI18next).init({
+ fallbackLng: 'en',
+ initAsync: false,
+ lng: 'en',
+ resources: {
+ en: {
+ translation: {
+ common: {
+ newSeed: 'New seed',
++ scrubber: { editValue: 'Edit {{label}}' },
+ seed: 'Seed',
+ seedMode: {
+ decrement: 'Decrement',
+ decrementDescription: 'Use successive seeds, decreasing by 1.',
+ fixed: 'Fixed',
+ fixedDescription: 'Reuse the entered seed.',
+ increment: 'Increment',
+ incrementDescription: 'Use successive seeds, increasing by 1.',
+ label: 'Seed mode',
+ random: 'Random',
+ randomDescription: 'Choose a fresh starting seed for each submission.',
+ },
+ seedNextBatch: 'Next batch: {{seed}}',
+ seedNextBatchRange: 'Next batch: {{first}} → {{last}}',
+ },
+ widgets: {
+ generate: {
+ // Verbatim from `public/locales/en.json`: Ideogram 4's overrides really are labelled
+ // "Steps" and "Guidance", the same as the shared controls beside them. Inventing
+ // distinct names here would hide that from the one test that renders both at once.
+ ideogram4ColorHelp: 'Comma-separated color terms folded into the caption.',
+ ideogram4ColorPalette: 'Color palette',
+ ideogram4GuidanceScale: 'Guidance',
+ ideogram4Mu: 'Mu',
+ ideogram4MuHelp: 'Timestep shift. Higher values spend more of the schedule at high noise.',
+ ideogram4PresetDerived: 'Set by the sampler preset unless overridden.',
+ ideogram4SamplerPreset: 'Sampler preset',
+ ideogram4Steps: 'Steps',
+ override: 'Override',
+ recentSeeds: 'Recent seeds',
+ render: 'Render',
+ scheduler: 'Scheduler',
+ seedSummary: '{{mode}} · {{seed}}',
+ steps: 'Steps',
+ useSeed: 'Use seed {{seed}}',
- useModelDefaultField: 'Use model default {{field}}',
+ useModelDefaultScheduler: 'Use model default scheduler',
- useModelDefaultSteps: 'Use model default steps',
+ },
+ },
+ },
+ },
+ },
+ });
+
+ /**
+ * FLUX Fill's own recommendation is `guidance=30`, well past the guidance slider's practical top of
- * 10. That is the case the number input's looser `numberInputMax` exists for: without it the field
++ * 10. That is the case the scrubber's looser `inputMax` exists for: without it the field
+ * clamps to the slider's bound the first time it loses focus, and the model's own default is gone
+ * before the user has touched anything.
+ */
+ const fluxFillModel: MainModelConfig = {
+ base: 'flux',
+ default_settings: { cfg_scale: 1, guidance: 30 },
+ format: 'diffusers',
+ key: 'flux-fill',
+ name: 'FLUX Fill',
+ type: 'main',
+ };
+
+ /** `flux2_denoise.guidance` is `le=20`, which the capability table serves as `guidance_max`. */
+ const flux2Model: MainModelConfig = {
+ base: 'flux2',
+ format: 'diffusers',
+ key: 'flux2',
+ name: 'FLUX.2 dev',
+ type: 'main',
+ variant: 'dev',
+ };
+
+ /** `ernie_image_denoise.guidance_scale` is `ge=1.0`, served as `guidance_min`. */
+ const ernieModel: MainModelConfig = {
+ base: 'ernie-image',
+ format: 'diffusers',
+ key: 'ernie',
+ name: 'ERNIE Image',
+ type: 'main',
+ };
+
+ const ideogram4Model: MainModelConfig = {
+ base: 'ideogram-4',
+ format: 'diffusers',
+ key: 'ideogram-4',
+ name: 'Ideogram 4',
+ type: 'main',
+ };
+
+ const sd1Model: MainModelConfig = { base: 'sd-1', key: 'sd1', name: 'SD 1.5', type: 'main' };
+
+ let host: HTMLDivElement | null = null;
+ let root: Root | null = null;
+ (globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+ const settle = (action: () => void): Promise<void> =>
+ act(async () => {
+ action();
+ await new Promise<void>((resolve) => {
+ globalThis.setTimeout(resolve, 50);
+ });
+ });
+
+ const render = async (model: MainModelConfig, settings: Partial<GenerateSettings> = {}) => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ const onCommit = vi.fn();
+
+ await settle(() => {
+ root?.render(
+ // The seed field observes the dynamic prompts expansion query.
+ <QueryClientProvider client={new QueryClient()}>
+ <ChakraProvider value={system}>
+ <I18nextProvider i18n={i18n}>
+ <GenerateRenderSection
+ selectedModel={model}
+ settings={{ ...getDefaultGenerateSettings(model), ...settings }}
+ onCommit={onCommit}
+ onCommitImmediate={vi.fn()}
+ />
+ </I18nextProvider>
+ </ChakraProvider>
+ </QueryClientProvider>
+ );
+ });
+
+ return onCommit;
+ };
+
+ const renderSeed = (overrides: Partial<GenerateSettings>) => render(sd1Model, { seed: 42, ...overrides });
+ const seedInput = () => host?.querySelector<HTMLInputElement>('input[aria-label="Seed"]') ?? null;
+ const modeTrigger = () => host?.querySelector<HTMLButtonElement>('button[aria-label^="Seed mode:"]') ?? null;
+ const menuItem = (label: string) =>
+ [...document.querySelectorAll<HTMLElement>('[role="menuitemradio"]')].find((item) =>
+ item.textContent?.startsWith(label)
+ ) ?? null;
+ const preview = () => host?.querySelector('[data-testid="seed-sequence-preview"]')?.textContent ?? null;
+
+ afterEach(async () => {
+ await settle(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+ });
+
+ describe('GenerateRenderSection seed field', () => {
+ it('quiets the input in random mode but keeps the entered seed on show', async () => {
+ await renderSeed({ seedMode: 'random' });
+
+ expect(seedInput()?.disabled).toBe(true);
+ expect(seedInput()?.value).toBe('42');
+ expect(host?.querySelector<HTMLButtonElement>('button[aria-label="New seed"]')?.disabled).toBe(true);
+ expect(modeTrigger()?.getAttribute('aria-label')).toBe('Seed mode: Random');
+ expect(preview()).toBeNull();
+ });
+
+ it('commits a mode chosen from the menu without touching the seed', async () => {
+ const onCommit = await renderSeed({ seedMode: 'random' });
+
+ await settle(() => modeTrigger()?.click());
+ const increment = menuItem('Increment');
+
+ expect(increment?.getAttribute('aria-checked')).toBe('false');
+ expect(menuItem('Random')?.getAttribute('aria-checked')).toBe('true');
+ expect(increment?.textContent).toContain('Use successive seeds, increasing by 1.');
+
+ await settle(() => increment?.click());
+
+ expect(onCommit).toHaveBeenCalledWith({ seedMode: 'increment' });
+ });
+
+ it('is operable from the keyboard and returns focus to the trigger', async () => {
+ const onCommit = await renderSeed({ seedMode: 'random' });
+ const trigger = modeTrigger();
+
+ await settle(() => trigger?.focus());
+ await settle(() => trigger?.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'Enter' })));
+ // The menu itself takes focus and tracks the highlighted item by attribute.
+ const menu = document.activeElement;
+
+ expect(menu?.getAttribute('role')).toBe('menu');
+
+ // Enter opens on the first mode; one step down lands on the second.
+ await settle(() => menu?.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'ArrowDown' })));
+
+ expect(document.querySelector('[role="menuitemradio"][data-highlighted]')?.getAttribute('data-value')).toBe(
+ 'fixed'
+ );
+
+ await settle(() => menu?.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'Enter' })));
+
+ expect(onCommit).toHaveBeenCalledWith({ seedMode: 'fixed' });
+ expect(document.activeElement).toBe(trigger);
+ });
+
+ it('previews the seeds the next batch will run in a stepping mode', async () => {
+ await renderSeed({ batchCount: 3, seedMode: 'increment' });
+
+ expect(seedInput()?.disabled).toBe(false);
+ expect(preview()).toBe('Next batch: 42 → 44');
+ expect(document.getElementById(seedInput()?.getAttribute('aria-describedby') ?? '')?.textContent).toBe(
+ 'Next batch: 42 → 44'
+ );
+ });
+
+ it('previews a single-seed batch without a range', async () => {
+ await renderSeed({ batchCount: 1, seedMode: 'decrement' });
+
+ expect(preview()).toBe('Next batch: 42');
+ });
+
+ it('pins a recent seed by switching to fixed', async () => {
+ const onCommit = await renderSeed({ seedMode: 'increment' });
+
+ await settle(() => host?.querySelector<HTMLButtonElement>('button[aria-label="Use seed 888"]')?.click());
+
+ expect(onCommit).toHaveBeenCalledWith({ seed: 888, seedMode: 'fixed' });
+ });
+
+ it('names the active mode in the collapsed summary', async () => {
+ await renderSeed({ seedMode: 'decrement' });
+
+ expect(host?.textContent).toContain('Decrement · 42');
+ });
+ });
+
+ /**
- * The thumb is the tooltip trigger, so `role="slider"` is the stable selector rather than
- * `[data-part="thumb"]`. Guidance is the second slider in the section; steps is the first.
++ * The shared steps and guidance controls are scrubbers, whose slider is named by `aria-labelledby`;
++ * Ideogram 4's overrides are still sliders named by `aria-label`. One resolver reads both.
+ */
-const guidanceThumb = (label = 'Guidance'): Element | undefined =>
- [...(host?.querySelectorAll('[role="slider"]') ?? [])].find(
- (candidate) => candidate.getAttribute('aria-label') === label
++const sliderName = (slider: Element): string | null => {
++ const labelId = slider.getAttribute('aria-labelledby');
++
++ return (
++ slider.getAttribute('aria-label') ??
++ (labelId === null ? null : (host?.querySelector(`#${CSS.escape(labelId)}`)?.textContent ?? null))
+ );
++};
++const slidersNamed = (label: string): Element[] =>
++ [...(host?.querySelectorAll('[role="slider"]') ?? [])].filter((slider) => sliderName(slider) === label);
++const guidanceSlider = (label = 'Guidance'): Element | undefined => slidersNamed(label)[0];
++const guidanceFrame = (label = 'Guidance'): Element | null =>
++ guidanceSlider(label)?.closest('[data-scope="scrubber"]') ?? null;
++const guidanceValue = (label = 'Guidance'): string | undefined =>
++ guidanceFrame(label)?.querySelector('button[data-part="value"]')?.textContent ?? undefined;
++
++/** Opens the scrubber's editor on the shown value and closes it without a change, as a focus-out does. */
++const openAndBlurEditor = async (label = 'Guidance') => {
++ await settle(() => guidanceFrame(label)?.querySelector<HTMLButtonElement>('button[data-part="value"]')?.click());
++ const editor = guidanceFrame(label)?.querySelector<HTMLInputElement>('input[data-part="value"]');
++
++ if (!editor) {
++ throw new Error(`The ${label} scrubber did not open its editor`);
++ }
++
++ await settle(() => editor.blur());
++};
++
++const pressOnSlider = (label: string, key: string) =>
++ settle(() => guidanceSlider(label)?.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key })));
+
+ describe('GenerateRenderSection guidance field', () => {
+ // The guidance label and the model's stored guidance both come from the served table now,
+ // and the resolver returns nothing without it -- the field would render empty.
+ seedArchitectureCapabilities();
+
- it('does not clamp a model default above the slider track when the field loses focus', async () => {
++ it('does not clamp a model default above the slider track when the editor closes', async () => {
+ const onCommit = await render(fluxFillModel);
- const input = host?.querySelector<HTMLInputElement>('input[aria-label="Guidance"]');
+
- expect(input?.value).toBe('30');
++ expect(guidanceValue()).toBe('30');
+
- await settle(() => input?.focus());
- await settle(() => input?.blur());
++ await openAndBlurEditor();
+
- // The commit is the observable, not the input's value: the field is controlled, so the value
- // prop puts 30 back either way and only the caller sees the clamp. Dropping numberInputMax
- // makes this a commit of 10, which is then the value every subsequent graph is compiled with.
++ // The commit is the observable, not the shown value: the field is controlled, so the value
++ // prop puts 30 back either way and only the caller sees the clamp. Dropping inputMax makes
++ // this a commit of 10, which is then the value every subsequent graph is compiled with.
+ expect(onCommit).not.toHaveBeenCalled();
+ });
+
- it('still holds the guidance slider itself to its practical range', async () => {
- await render(fluxFillModel);
++ it('still holds the guidance track itself to its practical range', async () => {
++ const onCommit = await render(fluxFillModel);
++
++ // The track ends at 10 even while the value sits past it: End lands on the track's end, not
++ // on the input ceiling the model default needed.
++ await pressOnSlider('Guidance', 'End');
+
- expect(guidanceThumb()?.getAttribute('aria-valuenow')).toBe('10');
- expect(guidanceThumb()?.getAttribute('aria-valuemax')).toBe('10');
++ expect(onCommit).toHaveBeenCalledWith({ cfgScale: 10 });
+ });
+
+ it('clamps a typed guidance to the ceiling the architecture declares', async () => {
+ // The reported failure, from the other side: a project that stored FLUX Fill's 30 and then
+ // selected a FLUX.2 model. With a fixed input maximum of 100 the 30 persisted and was submitted
+ // to `flux2_denoise.guidance` (le=20), which rejects it at enqueue with nothing said in the UI.
+ const onCommit = await render(flux2Model, { cfgScale: 30 });
- const input = host?.querySelector<HTMLInputElement>('input[aria-label="Guidance"]');
+
- await settle(() => input?.focus());
- await settle(() => input?.blur());
++ await openAndBlurEditor();
+
+ expect(onCommit).toHaveBeenCalledWith({ cfgScale: 20 });
+ });
+
+ it('starts the guidance track at the floor the architecture declares', async () => {
- // `ernie_image_denoise.guidance_scale` is ge=1: dragging the slider to 0, or typing 0.5, used
- // to persist and be forwarded unchanged by graph.ts.
++ // `ernie_image_denoise.guidance_scale` is ge=1: scrubbing to 0, or typing 0.5, used to persist
++ // and be forwarded unchanged by graph.ts.
+ const onCommit = await render(ernieModel, { cfgScale: 0.5 });
- const input = host?.querySelector<HTMLInputElement>('input[aria-label="CFG"]');
-
- expect(guidanceThumb('CFG')?.getAttribute('aria-valuemin')).toBe('1');
+
- await settle(() => input?.focus());
- await settle(() => input?.blur());
++ await openAndBlurEditor('CFG');
+
++ expect(onCommit).toHaveBeenCalledTimes(1);
+ expect(onCommit).toHaveBeenCalledWith({ cfgScale: 1 });
++
++ await pressOnSlider('CFG', 'Home');
++
++ expect(onCommit).toHaveBeenCalledTimes(2);
++ expect(onCommit).toHaveBeenLastCalledWith({ cfgScale: 1 });
+ });
+
+ it('holds the Ideogram 4 overrides to their own node bounds', async () => {
- // Not the shared slider: `ideogram4_denoise` takes preset-derived optional overrides whose
++ // Not the shared control: `ideogram4_denoise` takes preset-derived optional overrides whose
+ // constraints sit on the numeric branch of an `anyOf` -- guidance ge=1/le=20, steps ge=2, mu
+ // ge=-4/le=4. The guidance control offered 0 and the mu control 0..10, both forwarded verbatim.
+ await render(ideogram4Model, { ideogram4GuidanceScale: 5, ideogram4Mu: 1, ideogram4Steps: 48 });
+ const ranges = (label: string) =>
- [...(host?.querySelectorAll('[role="slider"]') ?? [])]
- .filter((thumb) => thumb.getAttribute('aria-label') === label)
- .map((thumb) => [thumb.getAttribute('aria-valuemin'), thumb.getAttribute('aria-valuemax')]);
++ slidersNamed(label).map((slider) => [slider.getAttribute('aria-valuemin'), slider.getAttribute('aria-valuemax')]);
+
+ // Two per name: the shared control first, then Ideogram's override. They carry the same
+ // accessible name in the product, which is its own (pre-existing) problem — asserting both
+ // ranges at once is what keeps this test honest about which is which.
+ expect(ranges('Guidance')).toEqual([
+ ['0', '10'],
+ ['1', '20'],
+ ]);
+ expect(ranges('Steps')).toEqual([
+ ['1', '100'],
+ ['2', '100'],
+ ]);
+ expect(ranges('Mu')).toEqual([['-4', '4']]);
+ });
+
+ it('names the broken bound on the field, not only in the Invoke button tooltip', async () => {
+ // Model selection clamps, so this is what a recalled or previously persisted value looks like:
+ // the field shows 30, Invoke is disabled elsewhere, and without this the only explanation is a
+ // tooltip on a button in another panel.
+ await render(flux2Model, { cfgScale: 30 });
+
+ expect(host?.querySelector('[role="alert"]')?.textContent).toBe('Guidance must be at most 20 for FLUX.2 dev.');
- expect(host?.querySelector<HTMLInputElement>('input[aria-label="Guidance"]')?.value).toBe('30');
++ expect(guidanceValue()).toBe('30');
++ expect(guidanceFrame()?.hasAttribute('data-invalid')).toBe(true);
+ });
+
+ it('says nothing on the field while the value is inside the architecture bound', async () => {
+ await render(flux2Model, { cfgScale: 7 });
+
+ expect(host?.querySelector('[role="alert"]')).toBeNull();
+ });
+
+ it('drops the model-default mark the guidance track cannot place', async () => {
+ // FLUX Fill's default of 30 has no position on a track that stops at 10. Steps keeps its own
+ // mark (30 of 100), so this is the out-of-range mark going, not marks in general.
+ await render(fluxFillModel);
- const [stepsSlider, guidanceSlider] = [
- ...(host?.querySelectorAll('[data-scope="slider"][data-part="root"]') ?? []),
- ];
++ const [stepsFrame, guidanceFrameElement] = [...(host?.querySelectorAll('[data-scope="scrubber"]') ?? [])];
+
- expect(stepsSlider?.querySelectorAll('[data-part="marker"]')).toHaveLength(1);
- expect(guidanceSlider?.querySelectorAll('[data-part="marker"]')).toHaveLength(0);
++ expect(stepsFrame?.querySelectorAll('[data-part="mark"]')).toHaveLength(1);
++ expect(guidanceFrameElement?.querySelectorAll('[data-part="mark"]')).toHaveLength(0);
+ });
+ });
+
+ describe('GenerateRenderSection before the capability table arrives', () => {
+ // No `seedArchitectureCapabilities()` here on purpose. Generation is blocked outright without the
+ // table, so the fallback guidance range is deliberately the widest one: tightening it would clamp
+ // a stored value the user legitimately had while the capabilities are still in flight.
+ it('keeps the guidance field permissive rather than guessing a bound', async () => {
+ const onCommit = await render(fluxFillModel, { cfgScale: 30 });
- const input = host?.querySelector<HTMLInputElement>('input[aria-label="CFG"]');
+
- expect(input?.value).toBe('30');
++ expect(guidanceValue('CFG')).toBe('30');
+ expect(host?.querySelector('[role="alert"]')).toBeNull();
+
- await settle(() => input?.focus());
- await settle(() => input?.blur());
++ await openAndBlurEditor('CFG');
+
+ expect(onCommit).not.toHaveBeenCalled();
+ });
+ });
diff --cc invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.tsx
index f9e2acf946,e763545a26..4b0f80189f
--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateRenderSection.tsx
@@@ -35,11 -32,21 +33,22 @@@ import { useGenerationUi } from './Gene
import { GenerateCollapsibleSection } from './shared/GenerateCollapsibleSection';
import { GenerateFieldContextMenu } from './shared/GenerateFieldContextMenu';
import { GenerateToggleSwitch } from './shared/GenerateToggleSwitch';
+ import { SeedField as SharedSeedField } from './shared/SeedField';
+ import { useDynamicPrompts } from './useDynamicPrompts';
const STEPS_SLIDER_MAX = 100;
+const formatPercent = (value: number): string => `${value}%`;
- const SEED_END_ELEMENT_PROPS = { pointerEvents: 'auto', pr: '0.5' } as const;
+ /** The guidance/CFG slider's practical range — a UI choice about the track, not a rule. FLUX Fill
+ * recommends 30, which is off the track but a real value, so the number input keeps its own looser
+ * bound; without it the field clamps the model's own default away the first time it is focused.
+ *
+ * Where the architecture declares a ceiling (`policy.ui.guidanceMax`, e.g. `flux2_denoise.guidance`
+ * is `le=20`) that ceiling wins over this local cap, and where it declares none the local cap stays
+ * — `flux_denoise.guidance` genuinely has no upper bound. The floor comes from the architecture
+ * either way: 0 for most, 1 for the samplers whose node is `ge=1`. */
+ const GUIDANCE_SLIDER_MAX = 10;
+ const GUIDANCE_INPUT_MAX = 100;
interface GenerateRenderSectionProps {
settings: GenerateSettings;
@@@ -397,17 -389,20 +385,19 @@@ export const GenerateRenderSection = (
isAtDefault={modelDefaults !== null && settings.cfgScale === modelDefaults.cfgScale}
onReset={modelDefaults ? () => onCommit({ cfgScale: modelDefaults.cfgScale }) : undefined}
>
- <Field error={guidanceError} hint="guidance" label={policy.ui.guidanceLabel}>
- <SliderNumberField
- ariaLabel={policy.ui.guidanceLabel}
- defaultValue={modelDefaults?.cfgScale}
- marks={modelDefaults ? [modelDefaults.cfgScale] : undefined}
- max={guidanceSliderMax}
- min={policy.ui.guidanceMin}
- numberInputMax={guidanceInputMax}
- resetLabel={t('widgets.generate.useModelDefaultField', { field: policy.ui.guidanceLabel })}
- step={0.5}
- value={settings.cfgScale}
- onChange={(cfgScale) => commitNumber('cfgScale', cfgScale)}
- />
- </Field>
+ <ScrubberField
+ defaultValue={modelDefaults?.cfgScale}
++ error={guidanceError}
+ hint="guidance"
++ inputMax={guidanceInputMax}
+ label={policy.ui.guidanceLabel}
+ marks={modelDefaults ? [modelDefaults.cfgScale] : undefined}
- max={10}
- min={0}
++ max={guidanceSliderMax}
++ min={policy.ui.guidanceMin}
+ step={0.5}
+ value={settings.cfgScale}
+ onChange={(cfgScale) => commitNumber('cfgScale', cfgScale)}
+ />
</GenerateFieldContextMenu>
{familyBase === 'krea-2' ? (
<GenerateConditioningRebalanceField
diff --cc invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
index 5605da3dca,e7170e8eaf..ca6b53855a
--- a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
@@@ -3,21 -3,18 +3,9 @@@ import type { ProjectPromptDraftPatch
import type { ModelConfig, ModelTaxonomyType } from '@features/models';
import type { UpscaleWidgetValues } from '@features/upscale/core/types';
-import {
- Badge,
- createListCollection,
- DataList,
- NumberInput,
- SegmentGroup,
- SimpleGrid,
- Stack,
- Text,
-} from '@chakra-ui/react';
++import { Badge, createListCollection, DataList, SegmentGroup, SimpleGrid, Stack, Text } from '@chakra-ui/react';
+ import { GenerationSettingsSection, SeedField } from '@features/generation/components';
import {
- Badge,
- createListCollection,
- DataList,
- HStack,
- NumberInput,
- SegmentGroup,
- SimpleGrid,
- Stack,
- Switch,
- Text,
- } from '@chakra-ui/react';
- import { GenerationSettingsSection } from '@features/generation/components';
- import {
- SCHEDULER_OPTIONS,
getDefaultLoraWeight,
isLoraCompatibleWithModel,
isLoraModelConfig,
@@@ -47,12 -44,12 +35,12 @@@ import
UPSCALE_TILE_SIZE_MAX,
UPSCALE_TILE_SIZE_MIN,
} from '@features/upscale/core/settings';
+ import { SEED_MAX } from '@platform/core/seed';
import { useMountEffect } from '@platform/react/useMountEffect';
- import { Combobox, Field, IconButton, Select, Tooltip } from '@platform/ui';
+ import { Combobox, Field, Select, Tooltip } from '@platform/ui';
-import { SliderNumberField } from '@platform/ui/SliderNumberField';
+import { ScrubberField } from '@platform/ui/ScrubberField';
import { toaster } from '@platform/ui/toaster';
- import { DicesIcon } from 'lucide-react';
- import { memo, useCallback, useId, useMemo } from 'react';
+ import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { areInputImagesEquivalent, valuesAreEqual } from './upscaleComparators';
@@@ -92,11 -89,8 +80,10 @@@ const STRUCTURE_MARKS = [UPSCALE_STRUCT
const TILE_SIZE_MARKS = [UPSCALE_TILE_SIZE_MIN, 1024, UPSCALE_TILE_SIZE_MAX];
const TILE_OVERLAP_MARKS = [UPSCALE_TILE_OVERLAP_MIN, 128, 256, UPSCALE_TILE_OVERLAP_MAX];
-const GENERATION_GRID_COLUMNS = { base: 2, md: 3 };
+/** Scrub ranges cover everyday values; typing still reaches the validated bounds. */
+const STEPS_SLIDER_MAX = 100;
+const CFG_SLIDER_MAX = 20;
const ADVANCED_GRID_COLUMNS = { base: 1, md: 2 };
- const SWITCH_CHECKED_PROPS = { bg: 'accent.solid' };
const PRESET_ENTRIES = Object.entries(UPSCALE_PRESETS);
const isSelectableMainModel = (model: ModelConfig): boolean => isSupportedUpscaleMainModel(model);
@@@ -380,19 -367,20 +360,15 @@@ export const UpscaleWidgetView = () =>
// `onChange={(x) => patch({ x })}` props would defeat every `memo` below.
const set = useMemo(
() => ({
- batchCount: ({ valueAsNumber }: NumberInput.ValueChangeDetails) =>
- Number.isFinite(valueAsNumber) && patch({ batchCount: valueAsNumber }),
- cfgScale: ({ valueAsNumber }: NumberInput.ValueChangeDetails) =>
- Number.isFinite(valueAsNumber) && patch({ cfgScale: valueAsNumber }),
- clipSkip: ({ valueAsNumber }: NumberInput.ValueChangeDetails) =>
- Number.isFinite(valueAsNumber) && patch({ clipSkip: valueAsNumber }),
+ cfgScale: (cfgScale: number) => patch({ cfgScale }),
+ clipSkip: (clipSkip: number) => patch({ clipSkip }),
creativity: (creativity: number) => patch({ creativity }),
inputImage: (inputImage: UpscaleWidgetValues['inputImage']) => patch({ inputImage }),
- randomizeSeed: (details: { checked: boolean }) => patch({ shouldRandomizeSeed: details.checked }),
scale: (scale: number) => patch({ scale }),
scheduler: (scheduler: string) => patch({ scheduler }),
- seed: ({ valueAsNumber }: NumberInput.ValueChangeDetails) =>
- Number.isFinite(valueAsNumber) && patch({ seed: valueAsNumber }),
- shuffleSeed: () => patch({ seed: Math.floor(Math.random() * SEED_MAX) }),
spandrelModel: (model: ModelConfig | null) =>
patch({ upscaleModel: isSpandrelModelConfig(model) ? model : null }),
- steps: ({ valueAsNumber }: NumberInput.ValueChangeDetails) =>
- Number.isFinite(valueAsNumber) && patch({ steps: valueAsNumber }),
+ steps: (steps: number) => patch({ steps }),
structure: (structure: number) => patch({ structure }),
tileOverlap: (tileOverlap: number) => patch({ tileOverlap }),
tileSize: (tileSize: number) => patch({ tileSize }),
diff --cc invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
index ab7295a771,4e6120411e..be90455256
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
@@@ -135,7 -136,7 +136,7 @@@ const ReferenceCard = memo(function Ref
* object would be a fresh prop on every card on every edit to any reference. `updateReference`
* keeps the identity of the entries it did not touch, which is what lets the other cards bail
* out of a trim drag entirely; a per-card object would re-render all twelve — each one a zag
-- * Select and two SliderNumberFields — once per pointer step.
++ * Select and two ScrubberFields — once per pointer step.
*/
audioLabel: number | null;
collections: ReferenceCollections;
@@@ -360,17 -379,23 +379,19 @@@
fps={reference.clip.fps}
frame={reference.clip.startFrame}
label={t('widgets.video.trimStartShort')}
+ name={name}
src={galleryVideoUrls.full(name)}
+ onFindInGallery={findReferenceInGallery}
/>
- <Stack flex="1" gap="0.5" minW="0">
- <FieldLabel>{t('widgets.video.trimStart')}</FieldLabel>
- <SliderNumberField
- ariaLabel={t('widgets.video.trimStart')}
- disabled={disabled}
- max={Math.max(0, reference.clip.numFrames - 1)}
- min={0}
- showStepper
- step={1}
- value={reference.clip.startFrame}
- onChange={handleStartFrame}
- />
- </Stack>
+ <ScrubberField
+ disabled={disabled}
+ label={t('widgets.video.trimStart')}
+ max={Math.max(0, reference.clip.numFrames - 1)}
+ min={0}
+ step={1}
+ value={reference.clip.startFrame}
+ onChange={handleStartFrame}
+ />
</HStack>
<HStack gap="2">
<TrimBoundThumb
diff --cc invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx
index cf60e2fe9e,88414d4c09..34de095a17
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoSourceClipField.tsx
@@@ -321,17 -330,22 +330,19 @@@ export const VideoSourceClipField = mem
fps={sourceVideo.fps}
frame={sourceVideo.startFrame}
label={t('widgets.video.trimStartShort')}
+ name={sourceVideo.video_name}
src={previewSrc}
+ onFindInGallery={findClipInGallery}
/>
- <Box flex="1" minW="0">
- <SliderNumberField
- ariaLabel={t('widgets.video.trimStart')}
- disabled={disabled}
- max={maxFrameIndex}
- min={0}
- showStepper
- step={1}
- value={sourceVideo.startFrame}
- onChange={setStartFrame}
- />
- </Box>
+ <ScrubberField
+ disabled={disabled}
+ label={t('widgets.video.trimStart')}
+ max={maxFrameIndex}
+ min={0}
+ step={1}
+ value={sourceVideo.startFrame}
+ onChange={setStartFrame}
+ />
</HStack>
<HStack gap="2">
<TrimBoundThumb
diff --cc invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
index 772088cf49,c675003abe..f9592c15f1
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx
@@@ -29,10 -29,10 +29,10 @@@ import { createDefaultVideoWidgetValues
import { useMountEffect } from '@platform/react/useMountEffect';
import { Field, IconButton, Select } from '@platform/ui';
import { Button } from '@platform/ui/Button';
-import { SliderNumberField } from '@platform/ui/SliderNumberField';
+import { ScrubberField } from '@platform/ui/ScrubberField';
import { toaster } from '@platform/ui/toaster';
- import { ArrowLeftRightIcon, DicesIcon } from 'lucide-react';
- import { useCallback, useEffect, useId, useMemo, useRef } from 'react';
+ import { ArrowLeftRightIcon } from 'lucide-react';
+ import { useCallback, useEffect, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { areVideoValuesEqual } from './videoComparators';
@@@ -695,83 -688,50 +683,47 @@@ export const VideoWidgetView = () =>
</Switch.Root>
</Field>
) : null}
- <Field hint="steps" label={t('widgets.video.steps')}>
- <SliderNumberField
- ariaLabel={t('widgets.video.steps')}
- max={100}
- min={policy.minSteps}
- numberInputMax={500}
- step={1}
- value={values.steps}
- onChange={set.steps}
- />
- </Field>
+ <ScrubberField
+ hint="steps"
+ inputMax={500}
+ label={t('widgets.video.steps')}
+ max={100}
+ min={policy.minSteps}
+ step={1}
+ value={values.steps}
+ onChange={set.steps}
+ />
{policy.ui.cfgVisible ? (
- <Field hint="cfgScale" label={t('widgets.video.cfg')}>
- <SliderNumberField
- ariaLabel={t('widgets.video.cfg')}
- max={15}
- min={1}
- numberInputMax={100}
- step={0.1}
- value={values.cfgScale}
- onChange={set.cfgScale}
- />
- </Field>
+ <ScrubberField
+ hint="cfgScale"
+ inputMax={100}
+ label={t('widgets.video.cfg')}
+ max={15}
+ min={1}
+ step={0.1}
+ value={values.cfgScale}
+ onChange={set.cfgScale}
+ />
) : null}
{policy.ui.cfgLowNoiseVisible ? (
- <Field helpText={t('widgets.video.cfgLowNoiseHelp')} label={t('widgets.video.cfgLowNoise')}>
- <SliderNumberField
- ariaLabel={t('widgets.video.cfgLowNoise')}
- max={15}
- min={0}
- numberInputMax={100}
- step={0.1}
- value={values.cfgScaleLowNoise ?? values.cfgScale}
- onChange={set.cfgScaleLowNoise}
- />
- </Field>
+ <ScrubberField
+ helpText={t('widgets.video.cfgLowNoiseHelp')}
+ inputMax={100}
+ label={t('widgets.video.cfgLowNoise')}
+ max={15}
+ min={0}
+ step={0.1}
+ value={values.cfgScaleLowNoise ?? values.cfgScale}
+ onChange={set.cfgScaleLowNoise}
+ />
) : null}
- <Field hint="seed" label={t('widgets.video.seed')}>
- <HStack gap="2">
- <NumberInput.Root
- disabled={values.shouldRandomizeSeed}
- flex="1"
- max={SEED_MAX}
- min={0}
- size="xs"
- step={1}
- value={String(values.seed)}
- onValueChange={set.seed}
- >
- <NumberInput.Input aria-label={t('widgets.video.seed')} />
- </NumberInput.Root>
- <IconButton
- aria-label={t('widgets.video.shuffleSeed')}
- disabled={values.shouldRandomizeSeed}
- size="xs"
- variant="ghost"
- onClick={set.shuffleSeed}
- >
- <DicesIcon />
- </IconButton>
- <HStack gap="1">
- <Switch.Root
- checked={values.shouldRandomizeSeed}
- ids={seedSwitchIds}
- size="sm"
- onCheckedChange={set.randomizeSeed}
- >
- <Switch.HiddenInput />
- <Switch.Control _checked={SWITCH_CHECKED_PROPS}>
- <Switch.Thumb />
- </Switch.Control>
- {/* Inside Switch.Root, so the words are part of the control
- (they were an inert sibling <Text> before). */}
- <Switch.Label color="fg.muted" fontSize="2xs">
- {t('widgets.video.randomizeSeed')}
- </Switch.Label>
- </Switch.Root>
- </HStack>
- </HStack>
- </Field>
+ <SeedField
+ batchCount={values.batchCount}
+ label={t('widgets.video.seed')}
+ seed={values.seed}
+ seedMode={values.seedMode}
+ onCommit={patch}
+ />
</Stack>
</GenerationSettingsSection>
diff --cc invokeai/frontend/webv2/src/platform/ui/ScrubberField.browser.test.tsx
index c5c7145ad5,0000000000..9328c86b79
mode 100644,000000..100644
--- a/invokeai/frontend/webv2/src/platform/ui/ScrubberField.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/ScrubberField.browser.test.tsx
@@@ -1,380 -1,0 +1,391 @@@
+import { ChakraProvider } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import i18next from 'i18next';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { I18nextProvider, initReactI18next } from 'react-i18next';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { userEvent } from 'vitest/browser';
+
+import { ScrubberField, type ScrubberFieldProps } from './ScrubberField';
+
+const i18n = i18next.createInstance();
+await i18n.use(initReactI18next).init({
+ fallbackLng: 'en',
+ lng: 'en',
+ resources: { en: { translation: { common: { scrubber: { editValue: 'Edit {{label}}' } } } } },
+});
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+afterEach(async () => {
+ await act(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+const TRACK_INSET_PX = 10;
+const HOST_WIDTH_PX = 400;
+
+const mount = async (props: Partial<ScrubberFieldProps> = {}) => {
+ const onChange = vi.fn();
+
+ host = document.createElement('div');
+ host.style.width = `${HOST_WIDTH_PX}px`;
+ document.body.append(host);
+ root = createRoot(host);
+
+ await act(() => {
+ root?.render(
+ <I18nextProvider i18n={i18n}>
+ <ChakraProvider value={system}>
+ <ScrubberField label="Steps" max={100} min={0} step={1} value={30} onChange={onChange} {...props} />
+ </ChakraProvider>
+ </I18nextProvider>
+ );
+ });
+
+ const frame = host.querySelector<HTMLDivElement>('[data-scope="scrubber"]');
+ const slider = host.querySelector<HTMLDivElement>('[role="slider"]');
+
+ if (!frame || !slider) {
+ throw new Error('ScrubberField did not render');
+ }
+
+ return { frame, onChange, slider };
+};
+
+/** Client X for a fraction of the track, which is inset from the frame edges. */
+const trackX = (frame: HTMLElement, fraction: number): number => {
+ const rect = frame.getBoundingClientRect();
+
+ return rect.left + TRACK_INSET_PX + fraction * (rect.width - TRACK_INSET_PX * 2);
+};
+
+const pointer = (
+ target: EventTarget,
+ type: 'pointercancel' | 'pointerdown' | 'pointermove' | 'pointerup',
+ init: PointerEventInit
+) => act(() => target.dispatchEvent(new PointerEvent(type, { bubbles: true, button: 0, ...init })));
+
+const valueButton = () => host?.querySelector<HTMLButtonElement>('button[data-part="value"]') ?? null;
+const editor = () => host?.querySelector<HTMLInputElement>('input[data-part="value"]') ?? null;
+
+describe('ScrubberField', () => {
+ it('exposes a labelled slider with the formatted value as its text', async () => {
+ const { slider } = await mount({ formatValue: (value) => `${value}%` });
+ const label = host?.querySelector(`#${CSS.escape(slider.getAttribute('aria-labelledby') ?? '')}`);
+
+ expect(label?.textContent).toBe('Steps');
+ expect(slider.getAttribute('aria-valuenow')).toBe('30');
+ expect(slider.getAttribute('aria-valuetext')).toBe('30%');
+ expect(valueButton()?.textContent).toBe('30%');
+ expect(valueButton()?.getAttribute('aria-label')).toBe('Edit Steps');
+ });
+
+ it('jumps to the pressed position, then follows the drag snapped to the step', async () => {
+ const { frame, onChange } = await mount({ step: 5 });
+
+ await pointer(frame, 'pointerdown', { clientX: trackX(frame, 0.5) });
+
+ expect(onChange).toHaveBeenLastCalledWith(50);
+ expect(frame.hasAttribute('data-dragging')).toBe(true);
+
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0.73) });
+
+ expect(onChange).toHaveBeenLastCalledWith(75);
+
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 2) });
+
+ expect(onChange).toHaveBeenLastCalledWith(100);
+
+ await pointer(window, 'pointerup', { clientX: trackX(frame, 2) });
+
+ expect(frame.hasAttribute('data-dragging')).toBe(false);
+
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0) });
+
+ expect(onChange).toHaveBeenLastCalledWith(100);
+ });
+
+ it('scrubs relative to the current value at a tenth of the sensitivity while Shift is held', async () => {
+ const { frame, onChange } = await mount();
+
+ await pointer(frame, 'pointerdown', { clientX: trackX(frame, 0.9), shiftKey: true });
+
+ expect(onChange).not.toHaveBeenCalled();
+
+ // A full-track sweep in fine mode covers a tenth of the range.
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0.4), shiftKey: true });
+
+ expect(onChange).toHaveBeenLastCalledWith(25);
+ await pointer(window, 'pointerup', { clientX: trackX(frame, 0.4) });
+ });
+
+ it('snaps to the nearest stop while Alt is held', async () => {
+ const { frame, onChange } = await mount({ marks: [0, 20, 50, 100] });
+
+ await pointer(frame, 'pointerdown', { altKey: true, clientX: trackX(frame, 0.62) });
+
+ expect(onChange).toHaveBeenLastCalledWith(50);
+
+ await pointer(window, 'pointermove', { altKey: true, clientX: trackX(frame, 0.8) });
+
+ expect(onChange).toHaveBeenLastCalledWith(100);
+ await pointer(window, 'pointerup', { clientX: trackX(frame, 0.8) });
+ });
+
++ it('ignores stops beyond the track while Alt is held', async () => {
++ // A default past the track (FLUX Fill's guidance of 30 on a 0..10 track) is not a stop: an Alt
++ // gesture would otherwise snap straight off the track's end.
++ const { frame, onChange } = await mount({ defaultValue: 30, marks: [50], max: 10, value: 5 });
++
++ await pointer(frame, 'pointerdown', { altKey: true, clientX: trackX(frame, 0.9) });
++
++ expect(onChange).toHaveBeenLastCalledWith(9);
++ await pointer(window, 'pointerup', { clientX: trackX(frame, 0.9) });
++ });
++
+ it('ignores the value region and secondary buttons when scrubbing', async () => {
+ const { frame, onChange } = await mount();
+ const button = valueButton();
+
+ await pointer(frame, 'pointerdown', { button: 2, clientX: trackX(frame, 0.1) });
+
+ if (button) {
+ await pointer(button, 'pointerdown', { clientX: trackX(frame, 0.1) });
+ }
+
+ expect(onChange).not.toHaveBeenCalled();
+ expect(frame.hasAttribute('data-dragging')).toBe(false);
+ });
+
+ it('steps from the keyboard, ×10 with Shift or Page keys, and clamps typed-range bounds', async () => {
+ const { onChange, slider } = await mount({ inputMax: 1000, step: 0.5, value: 99.5 });
+
+ await act(async () => {
+ slider.focus();
+ await userEvent.keyboard('{ArrowRight}');
+ });
+
+ expect(onChange).toHaveBeenLastCalledWith(100);
+
+ await act(() => userEvent.keyboard('{Shift>}{ArrowUp}{/Shift}'));
+
+ expect(onChange).toHaveBeenLastCalledWith(104.5);
+
+ await act(() => userEvent.keyboard('{PageDown}'));
+
+ expect(onChange).toHaveBeenLastCalledWith(94.5);
+
+ await act(() => userEvent.keyboard('{Home}'));
+
+ expect(onChange).toHaveBeenLastCalledWith(0);
+
+ await act(() => userEvent.keyboard('{End}'));
+
+ expect(onChange).toHaveBeenLastCalledWith(100);
+ });
+
+ it('opens the editor from the value button, commits on Enter, and returns focus to the slider', async () => {
+ const { onChange, slider } = await mount({ inputMax: 500 });
+
+ await act(() => {
+ valueButton()?.click();
+ });
+
+ const input = editor();
+
+ expect(document.activeElement).toBe(input);
+ expect(input?.value).toBe('30');
+ expect(valueButton()).toBeNull();
+ expect(host?.querySelector('[data-part="label"]')?.checkVisibility()).toBe(true);
+
+ await act(() => userEvent.keyboard('250{Enter}'));
+
+ expect(onChange).toHaveBeenLastCalledWith(250);
+ expect(editor()).toBeNull();
+ expect(document.activeElement).toBe(slider);
+ });
+
+ it('discards the draft on Escape and ignores unparseable input', async () => {
+ const { onChange, slider } = await mount();
+
+ await act(async () => {
+ slider.focus();
+ await userEvent.keyboard('{Enter}');
+ });
+ await act(() => userEvent.keyboard('77{Escape}'));
+
+ expect(onChange).not.toHaveBeenCalled();
+ expect(editor()).toBeNull();
+ expect(document.activeElement).toBe(slider);
+
+ await act(() => userEvent.keyboard('{Enter}'));
+ await act(() => userEvent.keyboard('abc{Enter}'));
+
+ expect(onChange).not.toHaveBeenCalled();
+ });
+
+ it('starts typing from a digit key and commits on blur, clamped to the typed range', async () => {
+ const { onChange, slider } = await mount({ inputMax: 150 });
+
+ await act(async () => {
+ slider.focus();
+ await userEvent.keyboard('9');
+ });
+
+ expect(editor()?.value).toBe('9');
+
+ await act(() => userEvent.keyboard('99'));
+ await act(() => {
+ editor()?.blur();
+ });
+
+ expect(onChange).toHaveBeenLastCalledWith(150);
+ expect(editor()).toBeNull();
+ });
+
+ it('restores the default on double-click or Backspace, and only when one is given', async () => {
+ const { frame, onChange, slider } = await mount({ defaultValue: 20 });
+
+ await act(() => frame.dispatchEvent(new MouseEvent('dblclick', { bubbles: true, clientX: trackX(frame, 0.5) })));
+
+ expect(onChange).toHaveBeenLastCalledWith(20);
+
+ await act(async () => {
+ slider.focus();
+ await userEvent.keyboard('{Backspace}');
+ });
+
+ expect(onChange).toHaveBeenCalledTimes(2);
+ expect(onChange).toHaveBeenLastCalledWith(20);
+
+ await act(() => root?.unmount());
+ host?.remove();
+
+ const noDefault = await mount();
+
+ await act(() =>
+ noDefault.frame.dispatchEvent(
+ new MouseEvent('dblclick', { bubbles: true, clientX: trackX(noDefault.frame, 0.5) })
+ )
+ );
+
+ expect(noDefault.onChange).not.toHaveBeenCalled();
+ });
+
+ it('marks stops as under, over, or at the value, adds the default, and skips the implied end stops', async () => {
+ await mount({ defaultValue: 30, marks: [0, 10, 30, 60, 100], value: 30 });
+
+ const states = [...(host?.querySelectorAll('[data-part="mark"]') ?? [])].map((mark) =>
+ mark.getAttribute('data-state')
+ );
+
+ expect(states).toEqual(['over-value', 'at-value', 'under-value']);
+ });
+
+ it('keeps the slider range valid around a typed value beyond the track', async () => {
+ const { slider } = await mount({ inputMax: 1000, value: 150 });
+
+ expect(slider.getAttribute('aria-valuenow')).toBe('150');
+ expect(slider.getAttribute('aria-valuemax')).toBe('150');
+ const thumb = host?.querySelector<HTMLElement>('[data-part="thumb"]')?.getBoundingClientRect();
+ const frame = host?.querySelector('[data-scope="scrubber"]')?.getBoundingClientRect();
+
+ // Clamped to the track end rather than drawn past the frame (±1px for the frame border).
+ expect(
+ thumb && frame ? Math.abs(frame.right - (thumb.left + thumb.width / 2) - TRACK_INSET_PX) : NaN
+ ).toBeLessThanOrEqual(1);
+ });
+
+ it('stays relative once Shift has been pressed mid-drag, in both directions', async () => {
+ const { frame, onChange } = await mount();
+
+ await pointer(frame, 'pointerdown', { clientX: trackX(frame, 0.5) });
+
+ expect(onChange).toHaveBeenLastCalledWith(50);
+
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0.5), shiftKey: true });
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0.6), shiftKey: true });
+
+ expect(onChange).toHaveBeenLastCalledWith(51);
+
+ // Releasing Shift re-anchors at full sensitivity rather than jumping to the pointer.
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0.6) });
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0.7) });
+
+ expect(onChange).toHaveBeenLastCalledWith(61);
+ await pointer(window, 'pointercancel', {});
+
+ expect(frame.hasAttribute('data-dragging')).toBe(false);
+ });
+
+ it('lets a touch pan the panel until it moves sideways', async () => {
+ const { frame, onChange } = await mount();
+
+ await pointer(frame, 'pointerdown', { clientX: trackX(frame, 0.5), pointerType: 'touch' });
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0.5) + 4, pointerType: 'touch' });
+
+ expect(onChange).not.toHaveBeenCalled();
+
+ await pointer(window, 'pointermove', { clientX: trackX(frame, 0.7), pointerType: 'touch' });
+
+ expect(onChange).toHaveBeenLastCalledWith(70);
+ await pointer(window, 'pointerup', { pointerType: 'touch' });
+ });
+
+ it('keeps one tab stop per field', async () => {
+ await mount();
+
+ expect(valueButton()?.getAttribute('tabindex')).toBe('-1');
+ });
+
+ it('hides the stops that would sit under the label or the value', async () => {
+ // Label "Steps" spans roughly the first 15% of a 400px frame; the value the last ~10%.
+ await mount({ marks: [3, 50, 97], value: 50 });
+ await act(
+ () =>
+ new Promise<void>((resolve) => {
+ requestAnimationFrame(() => resolve());
+ })
+ );
+
+ const hidden = [...(host?.querySelectorAll('[data-part="mark"]') ?? [])].map((mark) =>
+ mark.hasAttribute('data-hidden')
+ );
+
+ expect(hidden).toEqual([true, false, true]);
+ });
+
+ it('does nothing while disabled', async () => {
+ const { frame, onChange, slider } = await mount({ defaultValue: 10, disabled: true });
+
+ await pointer(frame, 'pointerdown', { clientX: trackX(frame, 0.5) });
+ await act(() => frame.dispatchEvent(new MouseEvent('dblclick', { bubbles: true })));
+ await act(async () => {
+ slider.focus();
+ await userEvent.keyboard('{ArrowRight}');
+ });
+ await act(() => {
+ valueButton()?.click();
+ });
+
+ expect(onChange).not.toHaveBeenCalled();
+ expect(editor()).toBeNull();
+ expect(slider.getAttribute('tabindex')).toBe('-1');
+ expect(valueButton()?.disabled).toBe(true);
+ });
+
+ it('describes the slider with the error line and flags the frame invalid', async () => {
+ const { frame, slider } = await mount({ error: 'Too high', helpText: 'Ignored while erroring' });
+ const described = host?.querySelector(`#${CSS.escape(slider.getAttribute('aria-describedby') ?? '')}`);
+
+ expect(described?.textContent).toBe('Too high');
+ expect(described?.getAttribute('role')).toBe('alert');
+ expect(frame.hasAttribute('data-invalid')).toBe(true);
+ });
+});