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(canvas): layers panel polish
Josh Corbett224a1941a56a
diff --git a/invokeai/frontend/webv2/.gitignore b/invokeai/frontend/webv2/.gitignoreindex c864b969a2..3dbc790499 100644--- a/invokeai/frontend/webv2/.gitignore+++ b/invokeai/frontend/webv2/.gitignore@@ -10,3 +10,5 @@ __screenshots__/# planning scratch, never committeddocs/superpowers/*.tsbuildinfo+vite.config.mjs+vite.config.d.mtsdiff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 300fccde30..4969369dd3 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -2501,13 +2501,8 @@"layers": {"actions": {"addControlLayer": "Control layer",- "addDenoiseLimit": "Add denoise limit",- "addImageNoise": "Add image noise","addInpaintMask": "Inpaint mask",- "addNegativePrompt": "Add negative prompt",- "addPositivePrompt": "Add positive prompt","addRasterLayer": "Raster layer",- "addReferenceImage": "Add reference image","addRegionalGuidance": "Regional guidance","addRegionalReferenceImage": "Regional reference image","actionFailed": "Layer action failed",@@ -2583,7 +2578,6 @@"newGroup": "New group","expandGroup": "Expand group","collapseGroup": "Collapse group",- "selectFirstChild": "Select first layer in group","indent": "Move into the group above","outdent": "Move out of the group","groupLocked": "Locked by a group",@@ -2912,8 +2906,6 @@"regional": "Regional"},"menu": {- "add": "Add",- "addModifiers": "Add modifiers","arrange": "Arrange","booleanOperations": "Boolean operations","convertTo": "Convert to",diff --git a/invokeai/frontend/webv2/src/platform/ui/Select.tsx b/invokeai/frontend/webv2/src/platform/ui/Select.tsxindex 5c470cfb67..d24c0fffea 100644--- a/invokeai/frontend/webv2/src/platform/ui/Select.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/Select.tsx@@ -10,6 +10,9 @@ import type {import type { Key, ReactNode } from 'react';import { Portal, Select as ChakraSelect, useFieldContext } from '@chakra-ui/react';+import { useCallback, useRef } from 'react';++import { Scrollable } from './Scrollable';const getDefaultItemKey = <T extends CollectionItem>(item: T, index: number): Key => {const keyedItem = item as { id?: Key; value?: Key };@@ -26,8 +29,10 @@ const renderDefaultItem = <T extends CollectionItem>(item: T): ReactNode => {export interface SelectProps<T extends CollectionItem> extends Omit<SelectRootProps<T>, 'children'> {contentProps?: SelectContentProps;/**- * Caps the open menu's height; the content element itself scrolls, which is- * the element the select machine scrolls the highlighted item within.+ * Caps the open menu's height and scrolls the items inside a Scrollable.+ * The machine's own content-element scrolling is replaced by a+ * `scrollToIndexFn` targeting the Scrollable viewport, so keyboard+ * highlight, typeahead, and the open-reveal keep working.*/itemsMaxH?: string;getItemKey?: (item: T, index: number) => Key;@@ -62,8 +67,13 @@ export const Select = <T extends CollectionItem>({// own Label part there would duplicate that id; the field's visible label// already names the trigger.const field = useFieldContext();+ const itemsRef = useRef<HTMLDivElement>(null);+ const scrollToIndexFn = useCallback(({ index }: { index: number }) => {+ const options = itemsRef.current?.querySelectorAll('[role="option"]');+ options?.[index]?.scrollIntoView({ block: 'nearest' });+ }, []);return (- <ChakraSelect.Root collection={collection} {...rootProps}>+ <ChakraSelect.Root collection={collection} scrollToIndexFn={itemsMaxH ? scrollToIndexFn : undefined} {...rootProps}>{/* A real (visually hidden) Label part: the machine's trigger always pointsits aria-labelledby at this id, so a bare aria-label must materialize it —left on the Root it lands on a div, which ARIA prohibits. */}@@ -79,16 +89,36 @@ export const Select = <T extends CollectionItem>({</ChakraSelect.Control><Portal disabled={!portalled}><ChakraSelect.Positioner {...positionerProps}>- <ChakraSelect.Content maxH={itemsMaxH} overflowY={itemsMaxH ? 'auto' : undefined} {...contentProps}>- {collection.items.map((item, index) => (- <ChakraSelect.Item key={getItemKey(item, index)} item={item}>- <ChakraSelect.ItemText>{renderItem(item)}</ChakraSelect.ItemText>- {itemIndicator ? <ChakraSelect.ItemIndicator /> : null}- </ChakraSelect.Item>- ))}+ <ChakraSelect.Content {...contentProps}>+ <SelectItems ref={itemsRef} maxH={itemsMaxH}>+ {collection.items.map((item, index) => (+ <ChakraSelect.Item key={getItemKey(item, index)} item={item}>+ <ChakraSelect.ItemText>{renderItem(item)}</ChakraSelect.ItemText>+ {itemIndicator ? <ChakraSelect.ItemIndicator /> : null}+ </ChakraSelect.Item>+ ))}+ </SelectItems></ChakraSelect.Content></ChakraSelect.Positioner></Portal></ChakraSelect.Root>);};++/** Items pass through untouched unless a max height asks for a scroll viewport. */+const SelectItems = ({+ children,+ maxH,+ ref,+}: {+ children: ReactNode;+ maxH?: string;+ ref: React.RefObject<HTMLDivElement | null>;+}) =>+ maxH ? (+ <Scrollable ref={ref} maxH={maxH}>+ {children}+ </Scrollable>+ ) : (+ children+ );diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.tsxindex 886efbde22..469a7d2103 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerBlendRow.tsx@@ -3,7 +3,7 @@ import type { CanvasBlendMode, CanvasDocumentContractV3, CanvasLayerContract } fimport type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';import { createListCollection, Flex, HStack, NumberInput } from '@chakra-ui/react';-import { Field, Select } from '@platform/ui';+import { Select } from '@platform/ui';import { getDocumentLayer } from '@workbench/canvas-engine/api';import { useCanvasDocumentEditingLocked } from '@workbench/widgets/canvas/engineStoreHooks';import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';@@ -15,6 +15,8 @@ import { useTranslation } from 'react-i18next';type LayerBlendRowEngine = Pick<CanvasEngineHandle, 'document' | 'exports' | 'interaction' | 'layers' | 'projectId'>;const SELECT_POSITIONING = { placement: 'bottom-start', sameWidth: true } as const;+const BLEND_TRIGGER_PROPS = { fontSize: '2xs', h: '6', minH: '6' } as const;+const OPACITY_INPUT_PROPS = { fontSize: '2xs', h: '6' } as const;const clamp01 = (value: number): number => Math.min(1, Math.max(0, value));@@ -37,7 +39,7 @@ export const LayerBlendRow = ({ engine }: { engine: LayerBlendRowEngine | null }const editingLocked = useCanvasDocumentEditingLocked(engine);return (- <Flex align="center" flexShrink={0} gap="2" px="2" py="1">+ <Flex align="center" flexShrink={0} gap="1.5" mx="1.5" pb="1" pt="0.5"><BlendModeControl editingLocked={editingLocked} engine={engine} layer={layer} /><OpacityRow editingLocked={editingLocked} engine={engine} layer={layer} /></Flex>@@ -85,21 +87,20 @@ const BlendModeControl = ({);return (- <Field disabled={disabled} flex="1.5" label={t('widgets.layers.actions.blendMode')} orientation="horizontal">- <Select- aria-label={t('widgets.layers.actions.blendMode')}- collection={blendCollection}- disabled={disabled}- itemsMaxH="16rem"- minW="7rem"- positioning={SELECT_POSITIONING}- size="xs"- value={blendValue}- valueText={t(`widgets.layers.blendModes.${blendMode}`)}- w="full"- onValueChange={handleBlendChange}- />- </Field>+ <Select+ aria-label={t('widgets.layers.actions.blendMode')}+ collection={blendCollection}+ disabled={disabled}+ flex="1"+ itemsMaxH="16rem"+ minW="0"+ positioning={SELECT_POSITIONING}+ size="xs"+ triggerProps={BLEND_TRIGGER_PROPS}+ value={blendValue}+ valueText={t(`widgets.layers.blendModes.${blendMode}`)}+ onValueChange={handleBlendChange}+ />);};@@ -195,26 +196,25 @@ const OpacityRow = ({);return (- <Field disabled={disabled} label={t('widgets.layers.actions.opacity')} orientation="horizontal">- <HStack ref={flushOnUnmountRef} gap="2">- <NumberInput.Root- disabled={disabled}- max={100}- min={0}- size="xs"- step={1}- value={opacityPercent}- w="20"- onValueChange={handleOpacityChange}- >- <NumberInput.Control onClick={commitPending} />- <NumberInput.Input- aria-label={t('widgets.layers.actions.opacity')}- onBlur={commitPending}- onKeyUp={handleInputKeyUp}- />- </NumberInput.Root>- </HStack>- </Field>+ <HStack ref={flushOnUnmountRef} flexShrink={0} gap="2">+ <NumberInput.Root+ disabled={disabled}+ max={100}+ min={0}+ size="xs"+ step={1}+ value={opacityPercent}+ w="16"+ onValueChange={handleOpacityChange}+ >+ <NumberInput.Control onClick={commitPending} />+ <NumberInput.Input+ aria-label={t('widgets.layers.actions.opacity')}+ css={OPACITY_INPUT_PROPS}+ onBlur={commitPending}+ onKeyUp={handleInputKeyUp}+ />+ </NumberInput.Root>+ </HStack>);};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsxindex 85582fb496..c3e0e1748e 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx@@ -46,7 +46,6 @@ import {CopyIcon,MergeIcon,MoreVerticalIcon,- PlusIcon,} from 'lucide-react';import { Fragment, useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -100,12 +99,7 @@ import {createLayerId,fitLayerTransformToBbox,getControlTransparencyEffectPatch,- getInpaintDenoiseLimitPatch,- getInpaintNoisePatch,getRegionalGuidanceAutoNegativePatch,- getRegionalGuidanceNegativePromptPatch,- getRegionalGuidancePositivePromptPatch,- getRegionalGuidanceReferenceImagePatch,} from './layerOps';import { requestLayerProperties } from './layerPropertiesRequestStore';import { RunLayerWorkflowDialog, useLayerWorkflowAvailability } from './RunLayerWorkflowDialog';@@ -698,21 +692,11 @@ const LayerMenu = ({(id: LayerConfigPatchKind) => {if (id === 'control-transparency-effect' && layer.type === 'control') {patchConfig(getActionLabel(id), getControlTransparencyEffectPatch(layer));- } else if (id === 'regional-positive-prompt' && layer.type === 'regional_guidance') {- patchConfig(getActionLabel(id), getRegionalGuidancePositivePromptPatch(layer));- } else if (id === 'regional-negative-prompt' && layer.type === 'regional_guidance') {- patchConfig(getActionLabel(id), getRegionalGuidanceNegativePromptPatch(layer));- } else if (id === 'regional-reference-image' && layer.type === 'regional_guidance') {- patchConfig(getActionLabel(id), getRegionalGuidanceReferenceImagePatch(layer, base));} else if (id === 'regional-auto-negative' && layer.type === 'regional_guidance') {patchConfig(getActionLabel(id), getRegionalGuidanceAutoNegativePatch(layer));- } else if (id === 'inpaint-noise' && layer.type === 'inpaint_mask') {- patchConfig(getActionLabel(id), getInpaintNoisePatch(layer));- } else if (id === 'inpaint-denoise-limit' && layer.type === 'inpaint_mask') {- patchConfig(getActionLabel(id), getInpaintDenoiseLimitPatch(layer));}},- [base, getActionLabel, layer, patchConfig]+ [getActionLabel, layer, patchConfig]);const effects = useMemo<LayerContextActionEffects>(@@ -984,12 +968,6 @@ export const CanvasLayerContextMenu = ({const stopPropagation = (event: { stopPropagation: () => void }): void => event.stopPropagation();const SUBMENU_META: Record<LayerContextSubmenuId, { defaultLabel: string; icon: LucideIcon; labelKey: string }> = {- 'add-modifiers': {- defaultLabel: 'Add modifiers',- icon: PlusIcon,- labelKey: 'widgets.layers.menu.addModifiers',- },- 'add-regional': { defaultLabel: 'Add', icon: PlusIcon, labelKey: 'widgets.layers.menu.add' },arrange: { defaultLabel: 'Arrange', icon: ArrowUpDownIcon, labelKey: 'widgets.layers.menu.arrange' },boolean: { defaultLabel: 'Boolean operations', icon: MergeIcon, labelKey: 'widgets.layers.menu.booleanOperations' },'convert-to': { defaultLabel: 'Convert to', icon: ArrowRightLeftIcon, labelKey: 'widgets.layers.menu.convertTo' },diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.tsxindex afd02e5d90..47b91aac71 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.tsx@@ -105,7 +105,7 @@ const LayerStackHeaderComponent = ({onFocus={pinned ? undefined : handleFocus}onKeyDown={pinned ? undefined : handleKeyDown}>- <HStack gap="1" h="full" px="1.5">+ <HStack gap="1" h="full" pe="1.5" ps="0"><IconButtonaria-label={t(collapsed ? 'widgets.layers.groupActions.expand' : 'widgets.layers.groupActions.collapse')}color="fg.muted"diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsxindex c9161068db..47921cb65e 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx@@ -129,7 +129,7 @@ export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {const closeAddMenu = useCallback(() => setAddMenuAnchor(null), []);return (- <Stack gap="1" h="full" minH="0">+ <Stack gap="0.5" h="full" minH="0"><LayerColorPane layout={colorPaneLayout} onLayoutChange={handleColorPaneLayout} /><SegmentTabsactiveId={treeTab}@@ -144,8 +144,8 @@ export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {direction="column"flex="1"id={segmentTabsPanelId(TREE_TABS_ID_BASE)}- // The blend row (32px control + 8px padding) + tree floor (128px) +- // footer (40px); anything less lets the unshrinkable rows paint under+ // The blend row (~30px) + tree floor (128px) + footer (40px), with a+ // little slack; anything less lets the unshrinkable rows paint under// the editor panes.minH="13rem"overflow="hidden"diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.tsindex 953e9978d7..553f2d43a6 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts@@ -473,12 +473,7 @@ describe('getLayerContextActions', () => {'convert-to-inpaint-mask','convert-to-regional-guidance','control-transparency-effect',- 'regional-positive-prompt',- 'regional-negative-prompt',- 'regional-reference-image','regional-auto-negative',- 'inpaint-noise',- 'inpaint-denoise-limit','merge-down','merge-selected','toggle-visibility',@@ -748,22 +743,15 @@ describe('getLayerContextActions', () => {expect(idsFor(rasterLayer)).not.toContain('copy-to-raster');});- it('exposes regional guidance add actions only for missing prompts', () => {- const layer = { ...createRegionalGuidanceLayer('Region', 0, 'region-prompts'), positivePrompt: 'already' };+ it('keeps the surviving regional and inpaint verbs without the retired add actions', () => {+ const region = createRegionalGuidanceLayer('Region', 0, 'region-prompts');+ expect(idsFor(region)).toContain('regional-auto-negative');+ expect(idsFor(region)).not.toContain('regional-positive-prompt' as never);- expect(idsFor(layer)).toContain('regional-negative-prompt');- expect(idsFor(layer)).toContain('regional-reference-image');- expect(idsFor(layer)).toContain('regional-auto-negative');- expect(idsFor(layer)).not.toContain('regional-positive-prompt');- });-- it('exposes inpaint modifier add actions only for missing modifiers', () => {- const layer = { ...createInpaintMaskLayer('Mask', 'mask-modifiers'), noiseLevel: 0.25 };-- expect(idsFor(layer)).toContain('inpaint-denoise-limit');- expect(idsFor(layer)).toContain('copy-to-regional-guidance');- expect(idsFor(layer)).toContain('extract-masked-area');- expect(idsFor(layer)).not.toContain('inpaint-noise');+ const mask = createInpaintMaskLayer('Mask', 'mask-modifiers');+ expect(idsFor(mask)).toContain('copy-to-regional-guidance');+ expect(idsFor(mask)).toContain('extract-masked-area');+ expect(idsFor(mask)).not.toContain('inpaint-noise' as never);});it('copies regional guidance to an inpaint mask without unsupported conversions', () => {diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.tsindex 879d153644..3c491509d6 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts@@ -71,12 +71,7 @@ export type LayerContextActionId =| 'convert-to-inpaint-mask'| 'convert-to-regional-guidance'| 'control-transparency-effect'- | 'regional-positive-prompt'- | 'regional-negative-prompt'- | 'regional-reference-image'| 'regional-auto-negative'- | 'inpaint-noise'- | 'inpaint-denoise-limit'| 'merge-down'| 'toggle-visibility'| 'toggle-hidden'@@ -85,7 +80,7 @@ export type LayerContextActionId =export type LayerType = CanvasLayerContract['type'];export type LayerContextMenuSectionId = 'quick' | 'primary' | 'operations' | 'output' | 'state' | 'danger';-export type LayerContextSubmenuId = 'arrange' | 'add-modifiers' | 'add-regional' | 'boolean' | 'copy-to' | 'convert-to';+export type LayerContextSubmenuId = 'arrange' | 'boolean' | 'copy-to' | 'convert-to';export interface LayerContextActionState {canRunWorkflow: boolean;@@ -176,14 +171,7 @@ export interface LayerContextAction {handler(context: LayerContextActionRuntimeContext): void | Promise<void>;}-export type LayerConfigPatchKind =- | 'control-transparency-effect'- | 'regional-positive-prompt'- | 'regional-negative-prompt'- | 'regional-reference-image'- | 'regional-auto-negative'- | 'inpaint-noise'- | 'inpaint-denoise-limit';+export type LayerConfigPatchKind = 'control-transparency-effect' | 'regional-auto-negative';const ALL_LAYER_TYPES = ['raster', 'control', 'inpaint_mask', 'regional_guidance'] as const;const RASTER_ONLY = ['raster'] as const;@@ -372,71 +360,6 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefinisection: 'quick',supportedLayerTypes: ALL_LAYER_TYPES,},- {- defaultLabel: 'Add image noise',- handler: ({ effects }) => effects.patchConfig('inpaint-noise'),- icon: SlidersHorizontalIcon,- id: 'inpaint-noise',- isEnabled: isLayerMutable,- isVisible: (context) => context.layer.type === 'inpaint_mask' && context.layer.noiseLevel === undefined,- labelKey: 'widgets.layers.actions.addImageNoise',- order: 0,- section: 'primary',- submenu: 'add-modifiers',- supportedLayerTypes: INPAINT_ONLY,- },- {- defaultLabel: 'Add denoise limit',- handler: ({ effects }) => effects.patchConfig('inpaint-denoise-limit'),- icon: SlidersHorizontalIcon,- id: 'inpaint-denoise-limit',- isEnabled: isLayerMutable,- isVisible: (context) => context.layer.type === 'inpaint_mask' && context.layer.denoiseLimit === undefined,- labelKey: 'widgets.layers.actions.addDenoiseLimit',- order: 1,- section: 'primary',- submenu: 'add-modifiers',- supportedLayerTypes: INPAINT_ONLY,- },- {- defaultLabel: 'Add positive prompt',- handler: ({ effects }) => effects.patchConfig('regional-positive-prompt'),- icon: PencilIcon,- id: 'regional-positive-prompt',- isEnabled: isLayerMutable,- isVisible: (context) => context.layer.type === 'regional_guidance' && context.layer.positivePrompt === null,- labelKey: 'widgets.layers.actions.addPositivePrompt',- order: 0,- section: 'primary',- submenu: 'add-regional',- supportedLayerTypes: REGIONAL_ONLY,- },- {- defaultLabel: 'Add negative prompt',- handler: ({ effects }) => effects.patchConfig('regional-negative-prompt'),- icon: PencilIcon,- id: 'regional-negative-prompt',- isEnabled: isLayerMutable,- isVisible: (context) => context.layer.type === 'regional_guidance' && context.layer.negativePrompt === null,- labelKey: 'widgets.layers.actions.addNegativePrompt',- order: 1,- section: 'primary',- submenu: 'add-regional',- supportedLayerTypes: REGIONAL_ONLY,- },- {- defaultLabel: 'Add reference image',- handler: ({ effects }) => effects.patchConfig('regional-reference-image'),- icon: ImageIcon,- id: 'regional-reference-image',- isEnabled: isLayerMutable,- isVisible: alwaysVisible,- labelKey: 'widgets.layers.actions.addReferenceImage',- order: 2,- section: 'primary',- submenu: 'add-regional',- supportedLayerTypes: REGIONAL_ONLY,- },{defaultLabel: 'Transform',handler: ({ effects }) => effects.transform(),diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.tsindex b6db059f5b..a43bdb57be 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts@@ -101,23 +101,18 @@ describe('getLayerContextMenuLayout', () => {]);});- it('groups inpaint modifiers and regional additions into type-specific submenus', () => {+ it('keeps the primary section lean now the panes own the per-type additions', () => {const inpaint = createInpaintMaskLayer('Mask', 'mask');const regional = createRegionalGuidanceLayer('Region', 0, 'region');expect(summarize(inpaint)[1]).toEqual({id: 'primary',- items: ['add-modifiers(inpaint-noise,inpaint-denoise-limit)', 'rename', 'fit-to-bbox', 'extract-masked-area'],+ items: ['rename', 'fit-to-bbox', 'extract-masked-area'],presentation: 'list',});expect(summarize(regional)[1]).toEqual({id: 'primary',- items: [- 'add-regional(regional-positive-prompt,regional-negative-prompt,regional-reference-image)',- 'rename',- 'fit-to-bbox',- 'regional-auto-negative',- ],+ items: ['rename', 'fit-to-bbox', 'regional-auto-negative'],presentation: 'list',});});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.test.tsindex cd9ca32563..9a024677e4 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.test.ts@@ -38,12 +38,7 @@ import {DEFAULT_INPAINT_MASK_FILL,fitLayerTransformToBbox,getControlTransparencyEffectPatch,- getInpaintDenoiseLimitPatch,- getInpaintNoisePatch,getRegionalGuidanceAutoNegativePatch,- getRegionalGuidanceNegativePromptPatch,- getRegionalGuidancePositivePromptPatch,- getRegionalGuidanceReferenceImagePatch,isMergeableRasterLayer,nextControlLayerName,nextInpaintMaskName,@@ -457,26 +452,9 @@ describe('menu patch helpers', () => {expect(getControlTransparencyEffectPatch(layer)).toEqual({ layerType: 'control', withTransparencyEffect: false });});- it('builds regional prompt and reference image patches', () => {+ it('builds the auto-negative toggle patch', () => {const layer = createRegionalGuidanceLayer('region', 0, 'r1');-- expect(getRegionalGuidancePositivePromptPatch(layer)).toEqual({- layerType: 'regional_guidance',- positivePrompt: '',- });- expect(getRegionalGuidanceNegativePromptPatch(layer)).toEqual({- layerType: 'regional_guidance',- negativePrompt: '',- });expect(getRegionalGuidanceAutoNegativePatch(layer)).toEqual({ autoNegative: true, layerType: 'regional_guidance' });- expect(getRegionalGuidanceReferenceImagePatch(layer, 'sdxl').referenceImages).toHaveLength(1);- });-- it('builds inpaint modifier patches', () => {- const layer = createInpaintMaskLayer('mask', 'm1');-- expect(getInpaintNoisePatch(layer)).toEqual({ layerType: 'inpaint_mask', noiseLevel: 0.25 });- expect(getInpaintDenoiseLimitPatch(layer)).toEqual({ denoiseLimit: 0.8, layerType: 'inpaint_mask' });});});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.tsindex 92b4c236d2..64e14591d1 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerOps.ts@@ -37,7 +37,6 @@ type RegionalGuidanceConfigPatch = {autoNegative?: boolean;referenceImages?: CanvasRegionalGuidanceLayerContract['referenceImages'];};-type InpaintMaskConfigPatch = { layerType: 'inpaint_mask'; noiseLevel?: number; denoiseLimit?: number };/*** Re-exported so existing imports of `isMergeableRasterLayer` from this module* keep working; the canonical definition lives in the engine's `document/sources`@@ -391,36 +390,10 @@ export const getControlTransparencyEffectPatch = (layer: CanvasControlLayerContrwithTransparencyEffect: !layer.withTransparencyEffect,});-export const getRegionalGuidancePositivePromptPatch = (- layer: CanvasRegionalGuidanceLayerContract-): RegionalGuidanceConfigPatch => ({ layerType: 'regional_guidance', positivePrompt: layer.positivePrompt ?? '' });--export const getRegionalGuidanceNegativePromptPatch = (- layer: CanvasRegionalGuidanceLayerContract-): RegionalGuidanceConfigPatch => ({ layerType: 'regional_guidance', negativePrompt: layer.negativePrompt ?? '' });-export const getRegionalGuidanceAutoNegativePatch = (layer: CanvasRegionalGuidanceLayerContract): RegionalGuidanceConfigPatch => ({ autoNegative: !layer.autoNegative, layerType: 'regional_guidance' });-export const getRegionalGuidanceReferenceImagePatch = (- layer: CanvasRegionalGuidanceLayerContract,- base: string | null-): RegionalGuidanceConfigPatch => ({- layerType: 'regional_guidance',- referenceImages: [...layer.referenceImages, createRegionalReferenceImage(base)],-});--export const getInpaintNoisePatch = (layer: CanvasInpaintMaskLayerContract): InpaintMaskConfigPatch => ({- layerType: 'inpaint_mask',- noiseLevel: layer.noiseLevel === undefined ? 0.25 : undefined,-});--export const getInpaintDenoiseLimitPatch = (layer: CanvasInpaintMaskLayerContract): InpaintMaskConfigPatch => ({- denoiseLimit: layer.denoiseLimit === undefined ? 0.8 : undefined,- layerType: 'inpaint_mask',-});-/*** True when `layer` can be converted to a control layer (and vice-versa): only a* raster layer with a rasterizable image/paint source, or a control layer,diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/GroupSelectedNotice.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/GroupSelectedNotice.tsxindex 5d601103a0..30f8506be2 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/GroupSelectedNotice.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/GroupSelectedNotice.tsx@@ -1,42 +1,25 @@-import { Flex, Text } from '@chakra-ui/react';-import { Button } from '@platform/ui/Button';-import { collectSubtreeLeaves, getDocumentNode } from '@workbench/canvas-engine/api';-import { useCanvasProjectMutationDispatch } from '@workbench/useCanvasProjectMutationDispatch';+import { Text } from '@chakra-ui/react';+import { getDocumentNode } from '@workbench/canvas-engine/api';import { useActiveProjectSelector } from '@workbench/WorkbenchContext';-import { useCallback } from 'react';import { useTranslation } from 'react-i18next';-/** Leaf tools and editors cannot act on a group: name the way out instead of silently refusing. */+/**+ * Leaf tools and editors cannot act on a group: name the state instead of+ * silently refusing. Renders nothing unless a group really is selected, so+ * ungated callers stay honest for leaves and for no selection at all.+ */export const GroupSelectedNotice = ({ hint }: { hint?: string }) => {const { t } = useTranslation();- const dispatch = useCanvasProjectMutationDispatch();- const group = useActiveProjectSelector(- (project) => {- const { document } = project.canvas;- const node = getDocumentNode(document, document.selectedLayerId);- return node?.type === 'group' ? { firstLeafId: collectSubtreeLeaves(node)[0]?.id ?? null, id: node.id } : null;- },- (a, b) => a?.id === b?.id && a?.firstLeafId === b?.firstLeafId- );- const selectFirstLeaf = useCallback(() => {- if (group?.firstLeafId) {- dispatch({ id: group.firstLeafId, type: 'setCanvasSelectedLayer' });- }- }, [dispatch, group]);-- if (!group) {+ const isGroupSelected = useActiveProjectSelector((project) => {+ const { document } = project.canvas;+ return getDocumentNode(document, document.selectedLayerId)?.type === 'group';+ });+ if (!isGroupSelected) {return null;}return (- <Flex align="center" gap="2">- <Text color="fg.muted" fontSize="xs" minW="0">- {hint ?? t('widgets.layers.groupSelectedHint')}- </Text>- {group.firstLeafId ? (- <Button flexShrink={0} size="2xs" variant="subtle" onClick={selectFirstLeaf}>- {t('widgets.layers.actions.selectFirstChild')}- </Button>- ) : null}- </Flex>+ <Text color="fg.muted" fontSize="xs" minW="0">+ {hint ?? t('widgets.layers.groupSelectedHint')}+ </Text>);};