Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): aspect ratio select under the size scrubbers
Josh Corbettce5659e89253
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.jsonindex 1a0bf1ae9e..7fe8b20632 100644--- a/invokeai/frontend/webv2/performance/browser-baseline.json+++ b/invokeai/frontend/webv2/performance/browser-baseline.json@@ -14,13 +14,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 121.60000000149012,+ "domContentLoadedMedianMs": 124.29999999701977,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 121.69999999552965,- "longestTaskMaxMs": 73,+ "loadMedianMs": 124.29999999701977,+ "longestTaskMaxMs": 75,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -36,7 +36,7 @@"scriptRequestCount": 35,"totalRawBytes": 1874638},- "routeReadyMedianMs": 271.8999999985099,+ "routeReadyMedianMs": 278.6000000014901,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "empty"},@@ -52,13 +52,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 119.30000000447035,+ "domContentLoadedMedianMs": 122.5,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 119.40000000596046,- "longestTaskMaxMs": 73,+ "loadMedianMs": 122.60000000149012,+ "longestTaskMaxMs": 74,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -74,7 +74,7 @@"scriptRequestCount": 35,"totalRawBytes": 1874638},- "routeReadyMedianMs": 276.1000000014901,+ "routeReadyMedianMs": 285.8999999985099,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "representative"},@@ -90,15 +90,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 120,+ "domContentLoadedMedianMs": 123.89999999850988,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 120.20000000298023,- "longestTaskMaxMs": 138,+ "loadMedianMs": 124,+ "longestTaskMaxMs": 143,"owner": "workbench",- "projectSwitchMedianMs": 39.29999999701977,+ "projectSwitchMedianMs": 38.30000000447035,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -108,11 +108,11 @@"largestAssetRawBytes": 747218,"otherRawBytes": 154421,"requestCount": 122,- "scriptRawBytes": 3578744,+ "scriptRawBytes": 3578052,"scriptRequestCount": 117,- "totalRawBytes": 3915364+ "totalRawBytes": 3914672},- "routeReadyMedianMs": 453.20000000298023,+ "routeReadyMedianMs": 456.19999999552965,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -128,15 +128,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 121.89999999850988,+ "domContentLoadedMedianMs": 122.10000000149012,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 122,- "longestTaskMaxMs": 135,+ "loadMedianMs": 122.20000000298023,+ "longestTaskMaxMs": 136,"owner": "workbench",- "projectSwitchMedianMs": 45.70000000298023,+ "projectSwitchMedianMs": 46,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -146,11 +146,11 @@"largestAssetRawBytes": 747218,"otherRawBytes": 154421,"requestCount": 122,- "scriptRawBytes": 3578744,+ "scriptRawBytes": 3578052,"scriptRequestCount": 117,- "totalRawBytes": 3915364+ "totalRawBytes": 3914672},- "routeReadyMedianMs": 442.29999999701977,+ "routeReadyMedianMs": 460.5,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -166,13 +166,13 @@"scriptRequestCount": 10,"totalRawBytes": 504532},- "domContentLoadedMedianMs": 119.89999999850988,+ "domContentLoadedMedianMs": 120.5,"id": "editor-canvas",- "layoutAckMedianMs": 2.5,- "layoutReturnSwitchMedianMs": 47.899999998509884,- "layoutSwitchMedianMs": 91.39999999850988,- "loadMedianMs": 120,- "longestTaskMaxMs": 144,+ "layoutAckMedianMs": 2.399999998509884,+ "layoutReturnSwitchMedianMs": 48.899999998509884,+ "layoutSwitchMedianMs": 88.60000000149012,+ "loadMedianMs": 120.60000000149012,+ "longestTaskMaxMs": 145,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -184,11 +184,11 @@"largestAssetRawBytes": 747218,"otherRawBytes": 154421,"requestCount": 132,- "scriptRawBytes": 4083276,+ "scriptRawBytes": 4082584,"scriptRequestCount": 127,- "totalRawBytes": 4419896+ "totalRawBytes": 4419204},- "routeReadyMedianMs": 1147.7999999970198,+ "routeReadyMedianMs": 1153.1000000014901,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "empty"},@@ -204,13 +204,13 @@"scriptRequestCount": 10,"totalRawBytes": 504532},- "domContentLoadedMedianMs": 117.30000000447035,+ "domContentLoadedMedianMs": 123.5,"id": "editor-canvas",- "layoutAckMedianMs": 2.5,- "layoutReturnSwitchMedianMs": 44.399999998509884,- "layoutSwitchMedianMs": 85.89999999850988,- "loadMedianMs": 117.30000000447035,- "longestTaskMaxMs": 199,+ "layoutAckMedianMs": 2.600000001490116,+ "layoutReturnSwitchMedianMs": 47.20000000298023,+ "layoutSwitchMedianMs": 95,+ "loadMedianMs": 123.60000000149012,+ "longestTaskMaxMs": 209,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -222,11 +222,11 @@"largestAssetRawBytes": 747218,"otherRawBytes": 154421,"requestCount": 132,- "scriptRawBytes": 4083276,+ "scriptRawBytes": 4082584,"scriptRequestCount": 127,- "totalRawBytes": 4419896+ "totalRawBytes": 4419204},- "routeReadyMedianMs": 1148.3999999985099,+ "routeReadyMedianMs": 1151.5,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "representative"},@@ -242,13 +242,13 @@"scriptRequestCount": 6,"totalRawBytes": 385560},- "domContentLoadedMedianMs": 116.89999999850988,+ "domContentLoadedMedianMs": 124.10000000149012,"id": "editor-workflow",- "layoutAckMedianMs": 2.399999998509884,- "layoutReturnSwitchMedianMs": 33.70000000298023,- "layoutSwitchMedianMs": 93.29999999701977,- "loadMedianMs": 117.19999999552965,- "longestTaskMaxMs": 138,+ "layoutAckMedianMs": 2.600000001490116,+ "layoutReturnSwitchMedianMs": 33.899999998509884,+ "layoutSwitchMedianMs": 94,+ "loadMedianMs": 124.20000000298023,+ "longestTaskMaxMs": 142,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -260,11 +260,11 @@"largestAssetRawBytes": 747218,"otherRawBytes": 154421,"requestCount": 129,- "scriptRawBytes": 3948891,+ "scriptRawBytes": 3948199,"scriptRequestCount": 123,- "totalRawBytes": 4300924+ "totalRawBytes": 4300232},- "routeReadyMedianMs": 1140.2999999970198,+ "routeReadyMedianMs": 1160.6999999955297,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "empty"},@@ -280,13 +280,13 @@"scriptRequestCount": 6,"totalRawBytes": 385560},- "domContentLoadedMedianMs": 120.69999999552965,+ "domContentLoadedMedianMs": 120.09999999403954,"id": "editor-workflow",- "layoutAckMedianMs": 2.399999998509884,- "layoutReturnSwitchMedianMs": 40,- "layoutSwitchMedianMs": 132.60000000149012,- "loadMedianMs": 120.79999999701977,- "longestTaskMaxMs": 364,+ "layoutAckMedianMs": 2.899999998509884,+ "layoutReturnSwitchMedianMs": 40.100000001490116,+ "layoutSwitchMedianMs": 141.79999999701977,+ "loadMedianMs": 120.29999999701977,+ "longestTaskMaxMs": 391,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -298,11 +298,11 @@"largestAssetRawBytes": 747218,"otherRawBytes": 154421,"requestCount": 129,- "scriptRawBytes": 3948891,+ "scriptRawBytes": 3948199,"scriptRequestCount": 123,- "totalRawBytes": 4300924+ "totalRawBytes": 4300232},- "routeReadyMedianMs": 1173.7000000029802,+ "routeReadyMedianMs": 1222.7000000029802,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "representative"},@@ -318,13 +318,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 118.60000000149012,+ "domContentLoadedMedianMs": 121.29999999701977,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 27.100000001490116,- "loadMedianMs": 118.60000000149012,- "longestTaskMaxMs": 141,+ "layoutSwitchMedianMs": 29.700000002980232,+ "loadMedianMs": 121.39999999850988,+ "longestTaskMaxMs": 147,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -336,11 +336,11 @@"largestAssetRawBytes": 747218,"otherRawBytes": 154421,"requestCount": 122,- "scriptRawBytes": 3578744,+ "scriptRawBytes": 3578052,"scriptRequestCount": 117,- "totalRawBytes": 3915364+ "totalRawBytes": 3914672},- "routeReadyMedianMs": 1347,+ "routeReadyMedianMs": 1363.5,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -356,13 +356,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 122.70000000298023,+ "domContentLoadedMedianMs": 120.79999999701977,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 39.19999999552965,- "loadMedianMs": 122.80000000447035,- "longestTaskMaxMs": 128,+ "layoutSwitchMedianMs": 39.900000005960464,+ "loadMedianMs": 120.89999999850988,+ "longestTaskMaxMs": 138,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -374,11 +374,11 @@"largestAssetRawBytes": 747218,"otherRawBytes": 154421,"requestCount": 122,- "scriptRawBytes": 3578744,+ "scriptRawBytes": 3578052,"scriptRequestCount": 117,- "totalRawBytes": 3915364+ "totalRawBytes": 3914672},- "routeReadyMedianMs": 1370.7999999970198,+ "routeReadyMedianMs": 1387.8999999985099,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"}@@ -1032,7 +1032,6 @@"source:src/features/generation/ui/reference-images/ReferenceImageControls.tsx","source:src/features/generation/ui/reference-images/ReferenceImageCropDialog.tsx","source:src/features/generation/ui/reference-images/referenceImageConfig.ts",- "source:src/features/generation/ui/shared/AspectRatioChips.tsx","source:src/features/generation/ui/shared/AspectRatioPreview.tsx","source:src/features/generation/ui/shared/AspectRatioSelect.tsx","source:src/features/generation/ui/shared/ConditioningRebalanceBars.tsx",@@ -2067,7 +2066,6 @@"source:src/features/generation/ui/reference-images/ReferenceImageControls.tsx","source:src/features/generation/ui/reference-images/ReferenceImageCropDialog.tsx","source:src/features/generation/ui/reference-images/referenceImageConfig.ts",- "source:src/features/generation/ui/shared/AspectRatioChips.tsx","source:src/features/generation/ui/shared/AspectRatioPreview.tsx","source:src/features/generation/ui/shared/AspectRatioSelect.tsx","source:src/features/generation/ui/shared/ConditioningRebalanceBars.tsx",@@ -3260,7 +3258,6 @@"source:src/features/generation/ui/reference-images/ReferenceImageControls.tsx","source:src/features/generation/ui/reference-images/ReferenceImageCropDialog.tsx","source:src/features/generation/ui/reference-images/referenceImageConfig.ts",- "source:src/features/generation/ui/shared/AspectRatioChips.tsx","source:src/features/generation/ui/shared/AspectRatioPreview.tsx","source:src/features/generation/ui/shared/AspectRatioSelect.tsx","source:src/features/generation/ui/shared/ConditioningRebalanceBars.tsx",diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateDimensionFields.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateDimensionFields.browser.test.tsxnew file mode 100644index 0000000000..18ac9e79dd--- /dev/null+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateDimensionFields.browser.test.tsx@@ -0,0 +1,192 @@+/* 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 { getDefaultGenerateSettings } from '@features/generation/core/baseGenerationPolicies';+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 { GenerateDimensionFields } from './GenerateDimensionFields';++vi.mock('./GenerationUiContext', () => ({+ useGenerationUi: () => ({+ queueInsights: { secondsPerRun: null, seedHistory: [] },+ sectionPreferences: { sectionsOpen: { dimensions: true }, setSectionOpen: vi.fn() },+ }),+}));++const i18n = createInstance();+void i18n.use(initReactI18next).init({+ fallbackLng: 'en',+ initAsync: false,+ lng: 'en',+ resources: {+ en: {+ translation: {+ common: { scrubber: { editValue: 'Edit {{label}}' } },+ widgets: {+ generate: {+ aspectRatio: 'Aspect ratio',+ height: 'Height',+ lockAspectRatio: 'Lock aspect ratio',+ megapixelsValue: '{{value}} MP',+ size: 'Size',+ swapWidthAndHeight: 'Swap width and height',+ unlockAspectRatio: 'Unlock aspect ratio',+ width: 'Width',+ },+ },+ },+ },+ },+});++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 (settings: Partial<GenerateSettings>) => {+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);+ const onCommit = vi.fn();++ await settle(() => {+ root?.render(+ <ChakraProvider value={system}>+ <I18nextProvider i18n={i18n}>+ <GenerateDimensionFields+ projectId="project"+ selectedModel={sd1Model}+ settings={{ ...getDefaultGenerateSettings(sd1Model), ...settings }}+ onCommit={onCommit}+ />+ </I18nextProvider>+ </ChakraProvider>+ );+ });++ return onCommit;+};++const lockButton = () =>+ host?.querySelector<HTMLButtonElement>(+ 'button[aria-label="Lock aspect ratio"], button[aria-label="Unlock aspect ratio"]'+ ) ?? null;+const bracket = () => host?.querySelector('[data-part="bracket"]')?.parentElement ?? null;+const presetTrigger = () => host?.querySelector<HTMLButtonElement>('[role="combobox"]') ?? null;++afterEach(async () => {+ await settle(() => root?.unmount());+ host?.remove();+ host = null;+ root = null;+});++describe('GenerateDimensionFields aspect ratio', () => {+ it('reshapes the size to a chosen preset and locks it', async () => {+ const onCommit = await render({ aspectRatioId: 'Free', aspectRatioIsLocked: false, height: 1024, width: 1024 });++ expect(lockButton()?.getAttribute('aria-label')).toBe('Lock aspect ratio');+ expect(bracket()?.hasAttribute('data-locked')).toBe(false);++ await settle(() => presetTrigger()?.click());+ await settle(() => document.querySelector<HTMLElement>('[role="option"][data-value="16:9"]')?.click());++ expect(onCommit).toHaveBeenCalledWith({+ aspectRatioId: '16:9',+ aspectRatioIsLocked: true,+ aspectRatioValue: 16 / 9,+ height: 768,+ width: 1368,+ });+ });++ it('shows the lock engaged while a preset is selected and unlocking returns to Free', async () => {+ // A preset with the flag off is what a recalled image can leave behind; the ratio is still+ // enforced, so the lock must say so rather than contradict the preset beside it.+ const onCommit = await render({+ aspectRatioId: '16:9',+ aspectRatioIsLocked: false,+ aspectRatioValue: 16 / 9,+ height: 768,+ width: 1368,+ });++ expect(presetTrigger()?.textContent).toContain('16:9');+ expect(lockButton()?.getAttribute('aria-label')).toBe('Unlock aspect ratio');+ expect(bracket()?.hasAttribute('data-locked')).toBe(true);++ await settle(() => lockButton()?.click());++ expect(onCommit).toHaveBeenCalledWith({+ aspectRatioId: 'Free',+ aspectRatioIsLocked: false,+ aspectRatioValue: 1368 / 768,+ height: 768,+ width: 1368,+ });+ });++ it('locking in Free captures the current ratio', async () => {+ const onCommit = await render({ aspectRatioId: 'Free', aspectRatioIsLocked: false, height: 800, width: 1024 });++ await settle(() => lockButton()?.click());++ expect(onCommit).toHaveBeenCalledWith({+ aspectRatioId: 'Free',+ aspectRatioIsLocked: true,+ aspectRatioValue: 1.28,+ height: 800,+ width: 1024,+ });+ });++ it('locking names the preset the current size already matches', async () => {+ // The same gesture in the canvas geometry form shows "4:3" for these dimensions.+ const onCommit = await render({ aspectRatioId: 'Free', aspectRatioIsLocked: false, height: 768, width: 1024 });++ await settle(() => lockButton()?.click());++ expect(onCommit).toHaveBeenCalledWith({+ aspectRatioId: '4:3',+ aspectRatioIsLocked: true,+ aspectRatioValue: 4 / 3,+ height: 768,+ width: 1024,+ });+ });++ it('swaps width and height and mirrors the preset', async () => {+ const onCommit = await render({+ aspectRatioId: '16:9',+ aspectRatioIsLocked: true,+ aspectRatioValue: 16 / 9,+ height: 768,+ width: 1368,+ });++ await settle(() => host?.querySelector<HTMLButtonElement>('button[aria-label="Swap width and height"]')?.click());++ expect(onCommit).toHaveBeenCalledWith({+ aspectRatioId: '9:16',+ aspectRatioValue: expect.closeTo(9 / 16, 10),+ height: 1368,+ width: 768,+ });+ });+});diff --git a/invokeai/frontend/webv2/src/features/generation/ui/GenerateDimensionFields.tsx b/invokeai/frontend/webv2/src/features/generation/ui/GenerateDimensionFields.tsxindex 664cb2ad15..48a1e3b656 100644--- a/invokeai/frontend/webv2/src/features/generation/ui/GenerateDimensionFields.tsx+++ b/invokeai/frontend/webv2/src/features/generation/ui/GenerateDimensionFields.tsx@@ -7,6 +7,7 @@ import {ASPECT_RATIO_MAP,calculateNewSize,clampDimension,+ deriveAspectRatioId,MAX_DIMENSION,MIN_DIMENSION,} from '@features/generation/core/settings';@@ -17,8 +18,7 @@ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'reactimport { useTranslation } from 'react-i18next';import { useGenerationUi } from './GenerationUiContext';-import { AspectRatioChips } from './shared/AspectRatioChips';-import { AspectRatioLockButton } from './shared/AspectRatioSelect';+import { AspectRatioLockButton, AspectRatioSelect } from './shared/AspectRatioSelect';import { GenerateCollapsibleSection } from './shared/GenerateCollapsibleSection';import { GenerateFieldContextMenu } from './shared/GenerateFieldContextMenu';@@ -75,6 +75,8 @@ const LOCK_BRACKET_CSS = {},'&[data-locked] [data-part="bracket"]': { stroke: 'accent.solid' },};+/** Same width as the lock column so the swap lines up under the lock. */+const SWAP_COLUMN_CSS = { display: 'flex', flexShrink: 0, justifyContent: 'center', w: '6' };const PREVIEW_PAD_PX = 10;const clampToRange = (value: number): number => Math.min(MAX_DIMENSION, Math.max(MIN_DIMENSION, value));@@ -356,14 +358,26 @@ export const GenerateDimensionFields = ({});};+ // The lock shows whether the ratio is held at all, preset or captured, so a+ // chosen preset reads as locked and unlocking always returns to Free. Locking+ // captures the current ratio, named by its preset when it matches one.const toggleLock = () => {+ if (isRatioConstrained) {+ commitSettings({+ aspectRatioId: 'Free',+ aspectRatioIsLocked: false,+ aspectRatioValue: dimensionRatio,+ ...displayDimensions,+ });+ return;+ }++ const id = deriveAspectRatioId(displayDimensions.width, displayDimensions.height);+commitSettings({- aspectRatioIsLocked: !settings.aspectRatioIsLocked,- // Locking in Free mode captures the current ratio so further edits preserve it.- aspectRatioValue:- !settings.aspectRatioIsLocked && settings.aspectRatioId === 'Free' && displayDimensions.height > 0- ? displayDimensions.width / displayDimensions.height- : settings.aspectRatioValue,+ aspectRatioId: id,+ aspectRatioIsLocked: true,+ aspectRatioValue: id === 'Free' ? dimensionRatio : ASPECT_RATIO_MAP[id].ratio,...displayDimensions,});};@@ -408,7 +422,7 @@ export const GenerateDimensionFields = ({<Badge size="xs">{displayDimensions.width}x{displayDimensions.height}</Badge>- {settings.aspectRatioIsLocked && (+ {isRatioConstrained && (<Badge size="xs"><Icon as={LockIcon} boxSize="3" /></Badge>@@ -460,33 +474,34 @@ export const GenerateDimensionFields = ({{dimensionField('width')}{dimensionField('height')}</Stack>- <Box css={LOCK_BRACKET_CSS} data-locked={settings.aspectRatioIsLocked ? '' : undefined}>+ <Box css={LOCK_BRACKET_CSS} data-locked={isRatioConstrained ? '' : undefined}><svg aria-hidden="true" data-part="bracket" viewBox="0 0 28 64"><path d={LOCK_BRACKET_PATH} /></svg>- <AspectRatioLockButton isLocked={settings.aspectRatioIsLocked} size="2xs" onToggle={toggleLock} />+ <AspectRatioLockButton isLocked={isRatioConstrained} size="2xs" onToggle={toggleLock} /></Box></HStack></GenerateFieldContextMenu>- {/* Every preset stays visible in the run beneath the values it- reshapes — nothing hides behind an overflow menu. */}- <HStack alignItems="flex-start" gap="1">- <AspectRatioChips+ {/* The preset row mirrors the dimension rows: the select fills the value+ column and the swap sits in the lock's column beneath it. */}+ <HStack alignItems="center" gap="1">+ <AspectRatioSelectfallbackRatio={dimensionRatio}value={settings.aspectRatioId}onChange={setAspectRatioId}/>- <Tooltip content={t('widgets.generate.swapWidthAndHeight')}>- <IconButton- aria-label={t('widgets.generate.swapWidthAndHeight')}- flexShrink="0"- size="2xs"- variant="outline"- onClick={swapDimensions}- >- <ArrowLeftRightIcon />- </IconButton>- </Tooltip>+ <Box css={SWAP_COLUMN_CSS}>+ <Tooltip content={t('widgets.generate.swapWidthAndHeight')}>+ <IconButton+ aria-label={t('widgets.generate.swapWidthAndHeight')}+ size="2xs"+ variant="outline"+ onClick={swapDimensions}+ >+ <ArrowLeftRightIcon />+ </IconButton>+ </Tooltip>+ </Box></HStack><HStack gap="2" justify="space-between" minH="5" mt="auto"><Text color="fg.muted" fontSize="2xs">diff --git a/invokeai/frontend/webv2/src/features/generation/ui/shared/AspectRatioChips.tsx b/invokeai/frontend/webv2/src/features/generation/ui/shared/AspectRatioChips.tsxdeleted file mode 100644index efecbf1f2c..0000000000--- a/invokeai/frontend/webv2/src/features/generation/ui/shared/AspectRatioChips.tsx+++ /dev/null@@ -1,50 +0,0 @@-/* oxlint-disable react-perf/jsx-no-new-function-as-prop */-import type { AspectRatioId } from '@features/generation/core/types';--import { Flex, Text } from '@chakra-ui/react';-import { ASPECT_RATIO_MAP, ASPECT_RATIO_OPTIONS } from '@features/generation/core/settings';-import { Button } from '@platform/ui/Button';-import { useTranslation } from 'react-i18next';--import { AspectRatioPreview } from './AspectRatioPreview';--/** `Free` has no fixed ratio, so its glyph mirrors whatever the caller is currently showing. */-const getRatioGlyph = (id: AspectRatioId, fallbackRatio: number): number =>- id === 'Free' ? fallbackRatio : ASPECT_RATIO_MAP[id].ratio;--export interface AspectRatioChipsProps {- /** Ratio used to draw the `Free` glyph — normally the live width/height. */- fallbackRatio: number;- value: AspectRatioId;- onChange: (id: AspectRatioId) => void;-}--/**- * Shape-first aspect ratio picker: a wrapped run of chips whose glyphs *are*- * the ratios. Every preset is visible — nothing hides behind an overflow menu.- */-export const AspectRatioChips = ({ fallbackRatio, value, onChange }: AspectRatioChipsProps) => {- const { t } = useTranslation();-- return (- <Flex aria-label={t('widgets.generate.aspectRatio')} flexWrap="wrap" gap="1" role="group">- {ASPECT_RATIO_OPTIONS.map((id) => (- <Button- key={id}- aria-label={id}- aria-pressed={value === id}- gap="1"- px="1.5"- size="2xs"- variant={value === id ? 'solid' : 'outline'}- onClick={() => onChange(id)}- >- <AspectRatioPreview boxSize="3.5" ratio={getRatioGlyph(id, fallbackRatio)} />- <Text as="span" fontSize="2xs">- {id}- </Text>- </Button>- ))}- </Flex>- );-};