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
fix(canvas): preserve compact panel behavior
joshistoast0cc9923f58ac
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 2af132bc0a..99b9d899e1 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1342,9 +1342,9 @@"errorUnknown": "Select Object could not finish.","errorUpload": "The canvas composite could not be uploaded for Select Object.","exclude": "Exclude",- "excludeCount": "Exclude · {{count}}",+ "excludeCount": "Exclude {{count}}","include": "Include",- "includeCount": "Include · {{count}}",+ "includeCount": "Include {{count}}","invert": "Invert","isolatedPreview": "Isolated Preview","isolatedPreviewCompact": "Isolate",diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.test.tsxindex 90b8d59291..5fd4061bc6 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.test.tsx@@ -8,8 +8,8 @@ import {CANVAS_OPERATION_FIXED_SECTION_LAYOUT,CANVAS_OPERATION_FOOTER_LAYOUT,CANVAS_OPERATION_PANEL_LAYOUT,+ CANVAS_OPERATION_SLOT_LAYOUT,CANVAS_SELECT_OBJECT_PANEL_LAYOUT,- CANVAS_SELECT_OBJECT_SLOT_LAYOUT,CanvasOperationPanel,} from './CanvasOperationPanel';@@ -68,7 +68,7 @@ describe('CanvasOperationPanel', () => {w: '26.25rem',});expect(CANVAS_OPERATION_PANEL_LAYOUT.w).toBe('30rem');- expect(CANVAS_SELECT_OBJECT_SLOT_LAYOUT).toMatchObject({ px: '3', py: '2' });+ expect(CANVAS_OPERATION_SLOT_LAYOUT).toEqual({ px: '4', py: '3' });});it('keeps vertical overflow on the body while fixed sections retain their order', () => {diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.tsxindex 3188a1d8d2..0e9f1fde57 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/CanvasOperationPanel.tsx@@ -26,9 +26,9 @@ export const CANVAS_SELECT_OBJECT_PANEL_LAYOUT = {w: '26.25rem',} satisfies BoxProps;-export const CANVAS_SELECT_OBJECT_SLOT_LAYOUT = {- px: '3',- py: '2',+export const CANVAS_OPERATION_SLOT_LAYOUT = {+ px: '4',+ py: '3',} satisfies BoxProps;export const CANVAS_OPERATION_FOOTER_LAYOUT = {@@ -77,7 +77,7 @@ const Header = (props: BoxProps) => {as="header"borderBottomWidth={operation === 'select-object' ? undefined : '1px'}data-slot="header"- {...CANVAS_SELECT_OBJECT_SLOT_LAYOUT}+ {...CANVAS_OPERATION_SLOT_LAYOUT}{...CANVAS_OPERATION_FIXED_SECTION_LAYOUT}{...props}/>@@ -90,7 +90,7 @@ const Body = (props: BoxProps) => {<Boxdata-scroll-container="body"data-slot="body"- {...CANVAS_SELECT_OBJECT_SLOT_LAYOUT}+ {...CANVAS_OPERATION_SLOT_LAYOUT}{...CANVAS_OPERATION_BODY_LAYOUT}flex={operation === 'select-object' ? '0 1 auto' : CANVAS_OPERATION_BODY_LAYOUT.flex}{...props}@@ -119,7 +119,7 @@ const Footer = (props: FlexProps) => (borderTopWidth="1px"data-slot="footer"gap="2"- {...CANVAS_SELECT_OBJECT_SLOT_LAYOUT}+ {...CANVAS_OPERATION_SLOT_LAYOUT}{...CANVAS_OPERATION_FOOTER_LAYOUT}{...CANVAS_OPERATION_FIXED_SECTION_LAYOUT}{...props}diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.test.tsindex def0579e8e..cac536a639 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.test.ts@@ -19,7 +19,10 @@ import {SAM_COMPACT_CONTROL_LAYOUT,SAM_COMPACT_FOOTER_LAYOUT,SAM_COMPACT_GROUP_LAYOUT,+ SAM_COMPACT_SLOT_LAYOUT,+ SAM_COMPACT_SWITCH_LAYOUT,SAM_MODEL_SELECT_LAYOUT,+ SAM_VISUAL_BUTTON_LAYOUT,SamPromptBody,SamModeToggle,SamOptionsPanel,@@ -181,6 +184,9 @@ describe('SamModeToggle', () => {expect(SAM_COMPACT_BUTTON_LAYOUT).toEqual({ h: '8', minH: '8', px: '2', size: 'xs' });expect(SAM_COMPACT_FOOTER_LAYOUT).toMatchObject({ flexWrap: 'wrap', gap: '1' });expect(SAM_COMPACT_GROUP_LAYOUT).toEqual({ maxW: 'full', minW: '0' });+ expect(SAM_COMPACT_SLOT_LAYOUT).toEqual({ px: '3', py: '2' });+ expect(SAM_COMPACT_SWITCH_LAYOUT).toEqual({ flex: '0 1 auto', maxW: 'full', minW: '0' });+ expect(SAM_VISUAL_BUTTON_LAYOUT).toMatchObject({ fontSize: '2xs', px: '1' });expect(SAM_MODEL_SELECT_LAYOUT).toEqual({ flex: '0 1 11rem', maxW: 'full', minW: '0', w: '11rem' });});@@ -374,6 +380,8 @@ describe('compact SAM inputs', () => {expect(en.widgets.layers.selectObject.technicalDetails).toBe('Technical details');expect(en.widgets.layers.selectObject.sourceDimensions).toBe('{{width}} × {{height}}');expect(en.widgets.layers.selectObject.sourceDimensionsLabel).toContain('{{width}}');+ expect(en.widgets.layers.selectObject.includeCount).toBe('Include {{count}}');+ expect(en.widgets.layers.selectObject.excludeCount).toBe('Exclude {{count}}');expect(en.widgets.layers.selectObject).not.toHaveProperty('modelAndRefinement');expect(en.widgets.layers.selectObject).not.toHaveProperty('sourceSummary');});@@ -445,14 +453,20 @@ describe('getSamActionHandlers', () => {const actions = getSamActionHandlers(engine as never);actions.process();- actions.apply();actions.reset();+ actions.apply();actions.save('control');actions.cancel();expect(engine.processSelectObjectSession).toHaveBeenCalledOnce();- expect(engine.applySelectObjectSession).toHaveBeenCalledOnce();expect(engine.resetSelectObjectSession).toHaveBeenCalledOnce();+ expect(engine.applySelectObjectSession).toHaveBeenCalledOnce();+ expect(engine.processSelectObjectSession.mock.invocationCallOrder[0]).toBeLessThan(+ engine.resetSelectObjectSession.mock.invocationCallOrder[0] as number+ );+ expect(engine.resetSelectObjectSession.mock.invocationCallOrder[0]).toBeLessThan(+ engine.applySelectObjectSession.mock.invocationCallOrder[0] as number+ );expect(engine.saveSelectObjectSession).toHaveBeenCalledWith('control', expect.any(Function));expect(engine.cancelSelectObjectSession).toHaveBeenCalledOnce();});@@ -493,9 +507,9 @@ describe('SamOptionsPanel', () => {expect(markup).toContain('>Auto<');expect(markup).toContain('>Isolate<');expect(markup).toContain('aria-label="Generation area: 1024 × 768"');- expect(markup.indexOf('>Process<')).toBeLessThan(markup.indexOf('>Apply<'));- expect(markup.indexOf('>Apply<')).toBeLessThan(markup.indexOf('>Reset<'));- expect(markup.indexOf('>Reset<')).toBeLessThan(markup.indexOf('Save As'));+ expect(markup.indexOf('>Process<')).toBeLessThan(markup.indexOf('>Reset<'));+ expect(markup.indexOf('>Reset<')).toBeLessThan(markup.indexOf('>Apply<'));+ expect(markup.indexOf('>Apply<')).toBeLessThan(markup.indexOf('Save As'));expect(markup.indexOf('Save As')).toBeLessThan(markup.indexOf('>Cancel<'));});});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.tsxindex e7d63c30f2..48d78caa36 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SamOptions.tsx@@ -52,6 +52,8 @@ export const SAM_COMPACT_CONTROL_LAYOUT = { h: '8', minH: '8', size: 'xs' } as cexport const SAM_COMPACT_BUTTON_LAYOUT = { ...SAM_COMPACT_CONTROL_LAYOUT, px: '2' } as const;export const SAM_COMPACT_FOOTER_LAYOUT = { flexWrap: 'wrap', gap: '1' } satisfies FlexProps;export const SAM_COMPACT_GROUP_LAYOUT = { maxW: 'full', minW: '0' } as const;+export const SAM_COMPACT_SLOT_LAYOUT = { px: '3', py: '2' } as const;+export const SAM_COMPACT_SWITCH_LAYOUT = { flex: '0 1 auto', maxW: 'full', minW: '0' } as const;export const SAM_MODEL_SELECT_LAYOUT = { flex: '0 1 11rem', maxW: 'full', minW: '0', w: '11rem' } as const;const SAM_SEGMENT_BUTTON_LAYOUT = {@@ -61,6 +63,8 @@ const SAM_SEGMENT_BUTTON_LAYOUT = {overflow: 'hidden',} as const;+export const SAM_VISUAL_BUTTON_LAYOUT = { ...SAM_SEGMENT_BUTTON_LAYOUT, fontSize: '2xs', px: '1' } as const;+const SAM_PROMPT_GUIDANCE_ID = 'sam-prompt-guidance';const SAM_VISUAL_GUIDANCE_ID = 'sam-visual-guidance';@@ -199,15 +203,15 @@ export const SamSwitch = ({<Switch.Rootchecked={checked}disabled={disabled}- minW="0"{...SAM_COMPACT_CONTROL_LAYOUT}+ {...SAM_COMPACT_SWITCH_LAYOUT}onCheckedChange={({ checked: next }) => onChange(next)}><Switch.HiddenInput aria-label={accessibleLabel} /><Switch.Control flexShrink="0"><Switch.Thumb /></Switch.Control>- <Switch.Label fontSize="xs" whiteSpace="nowrap">+ <Switch.Label fontSize="xs" minW="0" overflow="hidden" textOverflow="ellipsis" whiteSpace="nowrap">{label}</Switch.Label></Switch.Root>@@ -281,7 +285,7 @@ export const SamVisualBody = ({<Buttonaria-pressed={session.pointLabel === 'include'}disabled={disabled}- {...SAM_SEGMENT_BUTTON_LAYOUT}+ {...SAM_VISUAL_BUTTON_LAYOUT}variant={session.pointLabel === 'include' ? 'solid' : 'outline'}onClick={onInclude}>@@ -292,7 +296,7 @@ export const SamVisualBody = ({<Buttonaria-pressed={session.pointLabel === 'exclude'}disabled={disabled}- {...SAM_SEGMENT_BUTTON_LAYOUT}+ {...SAM_VISUAL_BUTTON_LAYOUT}variant={session.pointLabel === 'exclude' ? 'solid' : 'outline'}onClick={onExclude}>@@ -301,7 +305,15 @@ export const SamVisualBody = ({</Text></Button></Group>- <Text color={viewModel.bboxActive ? 'fg' : 'fg.muted'} flex="0 1 auto" fontSize="xs" fontWeight="medium" minW="0">+ <Text+ color={viewModel.bboxActive ? 'fg' : 'fg.muted'}+ flex="0 1 auto"+ fontSize="xs"+ fontWeight="medium"+ maxW="full"+ minW="0"+ overflowWrap="anywhere"+ >{viewModel.bboxActive? t('widgets.layers.selectObject.bboxActive'): t('widgets.layers.selectObject.bboxInactive')}@@ -381,10 +393,10 @@ export const SamOptionsPanel = ({return (<CanvasOperationPanel.Root aria-labelledby="sam-operation-title" operation="select-object">- <CanvasOperationPanel.Header>- <Flex align="center" flexWrap="wrap" gap="2" justify="space-between">- <Flex align="baseline" gap="1" minW="0">- <Heading fontSize="sm" id="sam-operation-title" whiteSpace="nowrap">+ <CanvasOperationPanel.Header {...SAM_COMPACT_SLOT_LAYOUT}>+ <Flex align="center" flexWrap="wrap" gap="2" justify="space-between" maxW="full" minW="0">+ <Flex align="baseline" flex="0 1 auto" flexWrap="wrap" gap="1" maxW="full" minW="0">+ <Heading fontSize="sm" id="sam-operation-title" maxW="full" whiteSpace="nowrap">{t('widgets.layers.selectObject.title')}</Heading><Text@@ -392,12 +404,14 @@ export const SamOptionsPanel = ({color="fg.muted"fontSize="xs"fontVariantNumeric="tabular-nums"+ maxW="full"+ minW="0"whiteSpace="nowrap">{viewModel.sourceSummary}</Text></Flex>- <Flex align="center" flexWrap="wrap" gap="2" minW="0">+ <Flex align="center" flex="0 1 auto" flexWrap="wrap" gap="2" maxW="full" minW="0"><SamSwitchaccessibleLabel={t('widgets.layers.selectObject.autoProcess')}checked={session.autoProcess}@@ -415,7 +429,7 @@ export const SamOptionsPanel = ({</Flex></Flex></CanvasOperationPanel.Header>- <CanvasOperationPanel.Body>+ <CanvasOperationPanel.Body {...SAM_COMPACT_SLOT_LAYOUT}><Stack gap="2"><Flex align="center" flexWrap="wrap" gap="1" justify="space-between" minW="0"><SamModeToggle@@ -487,7 +501,11 @@ export const SamOptionsPanel = ({</Stack></CanvasOperationPanel.Body>{session.error || isProcessing || session.status === 'scheduled' || session.status === 'committing' ? (- <CanvasOperationPanel.Feedback color={session.error ? 'fg.error' : 'fg.muted'} fontSize="xs">+ <CanvasOperationPanel.Feedback+ {...SAM_COMPACT_SLOT_LAYOUT}+ color={session.error ? 'fg.error' : 'fg.muted'}+ fontSize="xs"+ ><SamProcessFeedbackerror={session.error}errorText={session.error ? t(getSamErrorTranslationKey(session.error.code)) : null}@@ -497,7 +515,7 @@ export const SamOptionsPanel = ({/></CanvasOperationPanel.Feedback>) : null}- <CanvasOperationPanel.Footer {...SAM_COMPACT_FOOTER_LAYOUT}>+ <CanvasOperationPanel.Footer {...SAM_COMPACT_FOOTER_LAYOUT} {...SAM_COMPACT_SLOT_LAYOUT}><Buttondisabled={!eligibility.canProcess}loading={isProcessing}@@ -506,6 +524,9 @@ export const SamOptionsPanel = ({>{t('widgets.layers.selectObject.process')}</Button>+ <Button disabled={!eligibility.canReset} variant="ghost" {...SAM_COMPACT_BUTTON_LAYOUT} onClick={actions.reset}>+ {t('widgets.layers.selectObject.reset')}+ </Button><ButtoncolorPalette="accent"disabled={!eligibility.canApply}@@ -514,9 +535,6 @@ export const SamOptionsPanel = ({>{t('common.apply')}</Button>- <Button disabled={!eligibility.canReset} variant="ghost" {...SAM_COMPACT_BUTTON_LAYOUT} onClick={actions.reset}>- {t('widgets.layers.selectObject.reset')}- </Button><Menu.Root><Menu.Trigger asChild><Button disabled={!eligibility.canSave} variant="outline" {...SAM_COMPACT_BUTTON_LAYOUT}>