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(workbench): per-cluster drop zones in the status bar, one shared drop chrome
Josh Corbetta59816ba8439
diff --git a/invokeai/frontend/webv2/src/platform/ui/DropZone.tsx b/invokeai/frontend/webv2/src/platform/ui/DropZone.tsxindex 18b7e4312a..bb8dc45dd2 100644--- a/invokeai/frontend/webv2/src/platform/ui/DropZone.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/DropZone.tsx@@ -39,14 +39,14 @@ export const DropZone = ({ children, isDisabled, isOver, variant = 'inline', _ho() => ({...(variant === 'inline' && !isDisabled ? { borderColor: 'accent.solid' } : null),..._hover,- ...(isOver ? { bg: 'accent.muted', borderColor: 'accent.solid' } : null),+ ...(isOver ? { bg: 'accent.solid/15', borderColor: 'accent.solid' } : null),}),[_hover, isDisabled, isOver, variant]);return (<Box- bg={isOver ? 'accent.muted' : variant === 'overlay' ? 'bg.muted/80' : undefined}+ bg={isOver ? 'accent.solid/15' : variant === 'overlay' ? 'bg.muted/60' : undefined}borderColor={isOver ? 'accent.solid' : 'border.emphasized'}borderStyle="dashed"borderWidth={variant === 'overlay' ? '2px' : '1px'}diff --git a/invokeai/frontend/webv2/src/workbench/layoutPresets.ts b/invokeai/frontend/webv2/src/workbench/layoutPresets.tsindex e7fcf628e1..b5826cb7d7 100644--- a/invokeai/frontend/webv2/src/workbench/layoutPresets.ts+++ b/invokeai/frontend/webv2/src/workbench/layoutPresets.ts@@ -13,6 +13,8 @@ import type { WidgetInstanceId, WidgetTypeId } from '@workbench/widgetContracts'import { BUILT_IN_LAYOUT_PRESET_LABELS } from '@workbench/launchpad/intents';+// Notifications read as ambient status, not a tool: they live on the right.+const defaultBottomAlignEndInstanceIds: WidgetInstanceId[] = ['notifications'];const defaultBottomInstanceIds: WidgetInstanceId[] = ['server-status','queue-status',@@ -47,15 +49,23 @@ const defaultInstanceTypes: Record<WidgetInstanceId, WidgetTypeId> = {const createRegion = ({activeInstanceId,+ alignEndInstanceIds,instanceIds,isCollapsed = false,sizePx,}: {activeInstanceId: WidgetInstanceId;+ alignEndInstanceIds?: WidgetInstanceId[];instanceIds: WidgetInstanceId[];isCollapsed?: boolean;sizePx: number;-}): WidgetRegionState => ({ activeInstanceId, instanceIds, isCollapsed, sizePx });+}): WidgetRegionState => ({+ activeInstanceId,+ ...(alignEndInstanceIds ? { alignEndInstanceIds } : {}),+ instanceIds,+ isCollapsed,+ sizePx,+});const createWidgetInstances = (widgetRegions: Record<WidgetRegion, WidgetRegionState>@@ -156,6 +166,7 @@ export const builtInLayoutPresetDescriptors: BuiltInLayoutPresetDescriptor[] = [widgetRegions: {bottom: createRegion({activeInstanceId: 'gallery:bottom',+ alignEndInstanceIds: defaultBottomAlignEndInstanceIds,instanceIds: defaultBottomInstanceIds,isCollapsed: true,sizePx: 180,@@ -195,6 +206,7 @@ export const builtInLayoutPresetDescriptors: BuiltInLayoutPresetDescriptor[] = [widgetRegions: {bottom: createRegion({activeInstanceId: 'gallery:bottom',+ alignEndInstanceIds: defaultBottomAlignEndInstanceIds,instanceIds: defaultBottomInstanceIds,isCollapsed: true,sizePx: 180,@@ -228,6 +240,7 @@ export const builtInLayoutPresetDescriptors: BuiltInLayoutPresetDescriptor[] = [widgetRegions: {bottom: createRegion({activeInstanceId: 'gallery:bottom',+ alignEndInstanceIds: defaultBottomAlignEndInstanceIds,instanceIds: defaultBottomInstanceIds,isCollapsed: true,sizePx: 180,@@ -263,6 +276,7 @@ export const builtInLayoutPresetDescriptors: BuiltInLayoutPresetDescriptor[] = [widgetRegions: {bottom: createRegion({activeInstanceId: 'gallery:bottom',+ alignEndInstanceIds: defaultBottomAlignEndInstanceIds,instanceIds: defaultBottomInstanceIds,isCollapsed: true,sizePx: 180,diff --git a/invokeai/frontend/webv2/src/workbench/shell/StatusBar.tsx b/invokeai/frontend/webv2/src/workbench/shell/StatusBar.tsxindex 18234cd5a8..7443ce8bbc 100644--- a/invokeai/frontend/webv2/src/workbench/shell/StatusBar.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/StatusBar.tsx@@ -2,20 +2,26 @@ import type { WidgetInstanceId } from '@workbench/widgetContracts';import type { WidgetRegionDropState } from '@workbench/widgetDnd';import type { PlacedWidgetRegionItem, WidgetPlacementInstanceMeta } from '@workbench/widgetRegionViewModel';-import { Box, Popover, Portal } from '@chakra-ui/react';-import { useDroppable } from '@dnd-kit/core';+import { Box, Flex, Icon, Popover, Portal } from '@chakra-ui/react';+import { useDndContext, useDroppable } from '@dnd-kit/core';import { horizontalListSortingStrategy } from '@dnd-kit/sortable';import { PopoverContent, Row, Tooltip } from '@platform/ui';import {WidgetEnableMenu,WidgetInstanceContextMenu,+ WidgetRegionDropOverlay,WidgetRendererById,WidgetStrip,useWidgetSortable,type WidgetEnableMenuItem,type WidgetInstanceContextMenuTarget,} from '@workbench/widget-frame';-import { getWidgetRegionEndDropData, getWidgetRegionEndDropId } from '@workbench/widgetDnd';+import {+ getWidgetRegionDropId,+ getWidgetRegionEndDropData,+ getWidgetRegionEndDropId,+ isWidgetInstanceDragData,+} from '@workbench/widgetDnd';import { resolveWidgetLabel } from '@workbench/widgetLabels';import { closeWidgetPlacement, openWidgetPlacement, revealWidgetPlacement } from '@workbench/widgetPlacementCommands';import { areWidgetPlacementProjectsEqual, getWidgetPlacementProject } from '@workbench/widgetPlacementMeta';@@ -28,7 +34,8 @@ import {} from '@workbench/widgetRegionViewModel';import { getWidgetById, getWidgetsForRegion } from '@workbench/widgetRegistry';import { useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';-import { type KeyboardEvent, type MouseEvent, useCallback, useMemo, useState } from 'react';+import { ArrowRightToLineIcon } from 'lucide-react';+import { type KeyboardEvent, type MouseEvent, type ReactNode, useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';interface BottomWidgetItem extends PlacedWidgetRegionItem<WidgetPlacementInstanceMeta> {@@ -47,14 +54,43 @@ const BOTTOM_MENU_TRIGGER = { kind: 'bottom' } as const;*/const COMPACT_ROW_HOVER_PROPS = { bg: 'bg.emphasized', color: 'fg' };-/** The stretch between the clusters doubles as the "move to the right side" drop target. */-const BottomEndDropZone = () => {- const { setNodeRef } = useDroppable({+/**+ * The per-cluster drop chrome: the rail overlay itself, sized to its+ * cluster. Two of these replace the strip-wide curtain, which hid the+ * right-side target behind itself.+ */+const ClusterDropRing = ({ dropState, isOver }: { dropState: WidgetRegionDropState; isOver: boolean }) => (+ <WidgetRegionDropOverlay dropState={dropState} isOver={isOver} left="-4px" right="-4px" zIndex={3} />+);++/** The trailing cluster and its "move to the right side" drop target. */+const BottomEndCluster = ({+ children,+ dropState,+ showDropChrome,+}: {+ children: ReactNode;+ dropState: WidgetRegionDropState;+ showDropChrome: boolean;+}) => {+ const { isOver, setNodeRef } = useDroppable({data: getWidgetRegionEndDropData('bottom'),id: getWidgetRegionEndDropId('bottom'),});- return <Box ref={setNodeRef} alignSelf="stretch" flex="1" />;+ return (+ <Flex ref={setNodeRef} align="center" alignSelf="stretch" flexShrink={0} position="relative">+ {children}+ {showDropChrome ? (+ <>+ <Flex align="center" justify="center" minW="10">+ <Icon as={ArrowRightToLineIcon} boxSize="3" color={isOver ? 'fg' : 'fg.muted'} zIndex={4} />+ </Flex>+ <ClusterDropRing dropState={dropState} isOver={isOver} />+ </>+ ) : null}+ </Flex>+ );};const COMPACT_ROW_ACTIVE_PROPS = { bg: 'bg.emphasized', color: 'brand.fg' };const COMPACT_ROW_ACTIVE_HOVER_PROPS = { bg: 'bg.emphasized', color: 'brand.fg' };@@ -138,6 +174,15 @@ export const StatusBar = ({ dropState }: { dropState: WidgetRegionDropState }) =[widgets]);const isItemAlignedEnd = useCallback((item: WidgetEnableMenuItem) => alignEndIds.has(item.id), [alignEndIds]);+ // The two-cluster drop chrome only lights for widget drags the region+ // accepts; the shell's dropState already encodes allowedRegions.+ const dnd = useDndContext();+ const showDropChrome =+ dropState.isActive && dropState.isAllowed && isWidgetInstanceDragData(dnd.active?.data.current);+ // Highlight rules mirror the rails exactly: the accent treatment fires+ // only when the pointer is over the zone's own background, never over+ // chips — a chip hover previews a reorder, not a zone drop.+ const isOverStart = showDropChrome && String(dnd.over?.id ?? '') === getWidgetRegionDropId('bottom');const handleContextClose = useCallback(() => setEnableMenuTarget(null), []);const handleInstanceClose = useCallback(() => setInstanceMenuTarget(null), []);@@ -152,6 +197,7 @@ export const StatusBar = ({ dropState }: { dropState: WidgetRegionDropState }) =dropState={dropState}flexShrink={0}h="6"+ overlay="none"px="2"region="bottom"sortableInstanceIds={sortableInstanceIds}@@ -159,37 +205,42 @@ export const StatusBar = ({ dropState }: { dropState: WidgetRegionDropState }) =w="full"onContextMenu={openEnableMenu}>- {startItems.map((item) => (- <CompactBottomWidget- key={item.id}- item={item}- isActive={item.isExpandable && item.id === bottomRegion.activeInstanceId && !bottomRegion.isCollapsed}- onContextMenu={openInstanceMenu}- onSelect={handleSelect}- />- ))}+ <Flex align="center" alignSelf="stretch" flexShrink={0} position="relative">+ {startItems.map((item) => (+ <CompactBottomWidget+ key={item.id}+ item={item}+ isActive={item.isExpandable && item.id === bottomRegion.activeInstanceId && !bottomRegion.isCollapsed}+ onContextMenu={openInstanceMenu}+ onSelect={handleSelect}+ />+ ))}- <WidgetEnableMenu- contextTarget={enableMenuTarget}- groupLabel="Bottom Widgets"- items={items}- positioning={BOTTOM_MENU_POSITIONING}- trigger={BOTTOM_MENU_TRIGGER}- triggerLabel="Bottom widget visibility"- onContextClose={handleContextClose}- onToggle={toggleBottomWidget}- />-- <BottomEndDropZone />- {endItems.map((item) => (- <CompactBottomWidget- key={item.id}- item={item}- isActive={item.isExpandable && item.id === bottomRegion.activeInstanceId && !bottomRegion.isCollapsed}- onContextMenu={openInstanceMenu}- onSelect={handleSelect}+ <WidgetEnableMenu+ contextTarget={enableMenuTarget}+ groupLabel="Bottom Widgets"+ items={items}+ positioning={BOTTOM_MENU_POSITIONING}+ trigger={BOTTOM_MENU_TRIGGER}+ triggerLabel="Bottom widget visibility"+ onContextClose={handleContextClose}+ onToggle={toggleBottomWidget}/>- ))}+ {showDropChrome ? <ClusterDropRing dropState={dropState} isOver={isOverStart} /> : null}+ </Flex>++ <Box flex="1" />+ <BottomEndCluster dropState={dropState} showDropChrome={showDropChrome}>+ {endItems.map((item) => (+ <CompactBottomWidget+ key={item.id}+ item={item}+ isActive={item.isExpandable && item.id === bottomRegion.activeInstanceId && !bottomRegion.isCollapsed}+ onContextMenu={openInstanceMenu}+ onSelect={handleSelect}+ />+ ))}+ </BottomEndCluster><WidgetInstanceContextMenuisAlignedEnd={isItemAlignedEnd}target={instanceMenuTarget}diff --git a/invokeai/frontend/webv2/src/workbench/shell/StatusBarEndDrop.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/StatusBarEndDrop.browser.test.tsxnew file mode 100644index 0000000000..e43c20690d--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/shell/StatusBarEndDrop.browser.test.tsx@@ -0,0 +1,157 @@+/* oxlint-disable react-perf/jsx-no-new-function-as-prop */+import type { DragEndEvent, DragOverEvent } from '@dnd-kit/core';++import { Box, ChakraProvider } from '@chakra-ui/react';+import { DndContext, useDroppable, useSensor, useSensors } from '@dnd-kit/core';+import { restrictToWindowEdges } from '@dnd-kit/modifiers';+import { horizontalListSortingStrategy } from '@dnd-kit/sortable';+import { system } from '@theme/system';+import { WidgetStrip, useWidgetSortable } from '@workbench/widget-frame';+import { getWidgetRegionEndDropData, getWidgetRegionEndDropId, widgetCollisionDetection } from '@workbench/widgetDnd';+import { act, useCallback } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, describe, expect, it } from 'vitest';+import { userEvent } from 'vitest/browser';++import { PrimaryMouseSensor } from './holdToDragSensor';++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++// Active, as during a real drag — the drop overlay renders over the strip.+const DROP_STATE = { helperText: 'Drop here', isActive: true, isAllowed: true };+const MODIFIERS = [restrictToWindowEdges];+const SORTABLE_IDS = ['alpha', 'beta'];++const Chip = ({ id }: { id: string }) => {+ const { dragHandleProps, setNodeRef, style } = useWidgetSortable({ instanceId: id, region: 'bottom', typeId: id });++ return (+ <Box ref={setNodeRef} data-chip={id} h="6" px="2" style={style} {...dragHandleProps}>+ {id}+ </Box>+ );+};++const EndZone = () => {+ const { setNodeRef } = useDroppable({+ data: getWidgetRegionEndDropData('bottom'),+ id: getWidgetRegionEndDropId('bottom'),+ });++ return <Box ref={setNodeRef} alignSelf="stretch" data-endzone flex="1" />;+};++const Harness = ({+ onDragCancel,+ onDragEnd,+ onDragOver,+ onDragStart,+}: {+ onDragCancel: () => void;+ onDragEnd: (event: DragEndEvent) => void;+ onDragOver: (id: string) => void;+ onDragStart: () => void;+}) => {+ // The shell's mouse sensor (holdToDragSensor.ts), same activation.+ const sensors = useSensors(useSensor(PrimaryMouseSensor, { activationConstraint: { distance: 6 } }));+ const handleDragOver = useCallback(+ (event: DragOverEvent) => onDragOver(String(event.over?.id ?? 'none')),+ [onDragOver]+ );++ return (+ <ChakraProvider value={system}>+ <DndContext+ collisionDetection={widgetCollisionDetection}+ modifiers={MODIFIERS}+ sensors={sensors}+ onDragEnd={onDragEnd}+ onDragCancel={onDragCancel}+ onDragOver={handleDragOver}+ onDragStart={onDragStart}+ >+ <WidgetStrip+ align="center"+ dropState={DROP_STATE}+ h="6"+ px="2"+ region="bottom"+ sortableInstanceIds={SORTABLE_IDS}+ strategy={horizontalListSortingStrategy}+ w="600px"+ >+ <Chip id="alpha" />+ <Chip id="beta" />+ <EndZone />+ </WidgetStrip>+ </DndContext>+ </ChakraProvider>+ );+};++let host: HTMLDivElement | null = null;+let root: Root | null = null;++afterEach(async () => {+ await act(() => root?.unmount());+ host?.remove();+ host = null;+ root = null;+});++describe('status bar end-zone drop (real dnd pipeline)', () => {+ it('reports the end zone as the drop target for a pointer over the spacer', async () => {+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);++ const events: DragEndEvent[] = [];+ let started = 0;+ let cancelled = 0;+ const overs: string[] = [];++ await act(async () => {+ const handleCancel = () => {+ cancelled += 1;+ };+ const handleEnd = (event: DragEndEvent) => {+ events.push(event);+ };+ const handleOver = (id: string) => {+ overs.push(id);+ };+ const handleStart = () => {+ started += 1;+ };++ root?.render(+ <Harness onDragCancel={handleCancel} onDragEnd={handleEnd} onDragOver={handleOver} onDragStart={handleStart} />+ );+ await new Promise<void>((resolve) => {+ globalThis.setTimeout(resolve, 50);+ });+ });++ const chip = host.querySelector<HTMLElement>('[data-chip="alpha"]')!;+ const zone = host.querySelector<HTMLElement>('[data-endzone]')!;++ // Deliberately OUTSIDE act(): wrapping the gesture starves dnd-kit's+ // effect-driven onDragOver/onDragEnd and reproduces the exact silent+ // failure this test exists to catch.+ await userEvent.dragAndDrop(chip, zone);++ const startedAt = Date.now();++ while (events.length === 0 && Date.now() - startedAt < 2000) {+ await new Promise<void>((resolve) => {+ globalThis.setTimeout(resolve, 25);+ });+ }++ expect(started).toBe(1);+ expect(cancelled).toBe(0);+ expect(overs).toContain(getWidgetRegionEndDropId('bottom'));+ expect(events).toHaveLength(1);+ expect(String(events[0]!.over?.id ?? 'none')).toBe(getWidgetRegionEndDropId('bottom'));+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRegionDropOverlay.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRegionDropOverlay.tsxindex e1f278e5f6..03fe1cceee 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRegionDropOverlay.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRegionDropOverlay.tsx@@ -4,13 +4,20 @@ import { DropZone, type DropZoneProps } from '@platform/ui/DropZone';const DISALLOWED_STYLES: DropZoneProps = { bg: 'bg.muted', borderColor: 'border.subtle' };+/**+ * The one drag-time chrome for widget drop targets: rails render it across+ * their whole strip, the status bar renders one per cluster with inset+ * overrides. Styling lives in `DropZone`; keep consumers prop-thin so the+ * look cannot fork.+ */export const WidgetRegionDropOverlay = ({dropState,isOver,+ ...boxProps}: {dropState: WidgetRegionDropState;isOver: boolean;-}) => (+} & DropZoneProps) => (<DropZonebottom="0"isOver={dropState.isAllowed && isOver}@@ -23,5 +30,6 @@ export const WidgetRegionDropOverlay = ({variant="overlay"zIndex="2"{...(dropState.isAllowed ? undefined : DISALLOWED_STYLES)}+ {...boxProps}/>);diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetStrip.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetStrip.tsxindex b8b9aee266..5d33de4184 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetStrip.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetStrip.tsx@@ -13,6 +13,8 @@ import { WidgetRegionDropOverlay } from './WidgetRegionDropOverlay';interface WidgetStripProps extends FlexProps {children: ReactNode;dropState: WidgetRegionDropState;+ /** 'none' for strips that draw their own per-cluster drop chrome (the status bar). */+ overlay?: 'region' | 'none';region: WidgetRegion;sortableInstanceIds: WidgetInstanceId[];strategy: SortingStrategy;@@ -21,6 +23,7 @@ interface WidgetStripProps extends FlexProps {export const WidgetStrip = ({children,dropState,+ overlay = 'region',region,sortableInstanceIds,strategy,@@ -41,7 +44,9 @@ export const WidgetStrip = ({<SortableContext items={sortableItems} strategy={strategy}>{children}</SortableContext>- {dropState.isActive ? <WidgetRegionDropOverlay dropState={dropState} isOver={isOver} /> : null}+ {overlay === 'region' && dropState.isActive ? (+ <WidgetRegionDropOverlay dropState={dropState} isOver={isOver} />+ ) : null}</Flex>);};diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex c4283b1e89..64bd056ee8 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -994,7 +994,10 @@ describe('workbench widget alignment', () => {type: 'setWidgetInstanceAlignment',});- expect(getActiveProject(alignedEnd).widgetRegions.bottom.alignEndInstanceIds).toEqual([instanceId]);+ expect(getActiveProject(alignedEnd).widgetRegions.bottom.alignEndInstanceIds).toEqual([+ ...(getActiveProject(initial).widgetRegions.bottom.alignEndInstanceIds ?? []),+ instanceId,+ ]);// Placement itself is untouched: alignment is a render split, not a move.expect(getActiveProject(alignedEnd).widgetRegions.bottom.instanceIds).toEqual(getActiveProject(initial).widgetRegions.bottom.instanceIds@@ -1007,7 +1010,9 @@ describe('workbench widget alignment', () => {type: 'setWidgetInstanceAlignment',});- expect(getActiveProject(alignedStart).widgetRegions.bottom.alignEndInstanceIds).toEqual([]);+ expect(getActiveProject(alignedStart).widgetRegions.bottom.alignEndInstanceIds).toEqual(+ getActiveProject(initial).widgetRegions.bottom.alignEndInstanceIds ?? []+ );});it('aligning an already-aligned widget is a no-op', () => {