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(webv2): integrate floating windows with workbench sizing
Josh Corbettb05ecdc67f76
diff --cc invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsxindex f522a90ae6,57fb312b38..a5bb797d7a--- a/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx@@@ -413,9 -430,56 +428,56 @@@ const KeptCenterViewSlot = ({ instanceIreturn <WidgetRendererById instanceId={instance.id} widget={widget} region="center" />;};+ /** The empty center while its last view is a floating window: where the view went, and the two ways back. */+ const FloatedCenterView = ({+ dockLabel,+ instanceId,+ label,+ typeId,+ }: {+ /** The Dock button's label, naming where the window returns to. */+ dockLabel: string;+ instanceId: string;+ label: string;+ typeId: string;+ }) => {+ 'use no memo';+ // A cold path that renders only while the center's last view floats: it needs no memo cache, and skipping one+ // keeps it small in the editor's startup chunk, whose size budget guards it.+ const { t } = useTranslation();+ const { widgets } = useWorkbenchCommands();+ const { focusFloating, focusRegion } = useWorkbenchFocus();+ const handleShow = useCallback(() => {+ widgets.revealFloating(instanceId);+ focusFloating(instanceId);+ }, [focusFloating, instanceId, widgets]);+ // Docking from here always gives the center its view back, so focus follows it.+ const handleDock = useCallback(() => {+ flushWorkbenchDrafts();+ widgets.dockFloating(instanceId);+ focusRegion('center', typeId);+ }, [focusRegion, instanceId, typeId, widgets]);++ return (+ <Flex align="center" direction="column" gap="3" h="full" justify="center" px="6" textAlign="center" w="full">- <Text color="fg.muted" fontSize="sm">++ <Text color="fg.muted" fontSize="lg">+ {t('widgets.floating.centerFloating', { label })}+ </Text>+ <HStack gap="2" wrap="wrap" justify="center">- <Button size="xs" variant="outline" onClick={handleShow}>++ <Button variant="outline" onClick={handleShow}>+ {t('widgets.floating.showWindow')}+ </Button>- <Button size="xs" variant="outline" onClick={handleDock}>++ <Button variant="outline" onClick={handleDock}>+ {dockLabel}+ </Button>+ </HStack>+ </Flex>+ );+ };+const FallbackCenterView = ({ label }: { label: string }) => (<Flex align="center" h="full" justify="center" w="full">- <Text color="fg.subtle" fontSize="sm" textTransform="capitalize">+ <Text color="fg.subtle" fontSize="lg" textTransform="capitalize">{label} view</Text></Flex>diff --cc invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.tsxindex 5991a0c3fa,ced2af8e0e..1b02e01bf5--- a/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.tsx@@@ -278,38 -680,61 +680,61 @@@ export const FloatingWidgetWindow = (data-hotkey-widget-instance-id={instanceId}data-hotkey-widget-region="floating"data-hotkey-widget-type-id={instance.typeId}- onPointerDownCapture={handleFocus}- {...positionProps}+ onFocusCapture={handleFocusCapture}+ onPointerDownCapture={handlePointerDownCapture}>- <HStack- aria-label={t('widgets.floating.move', { label })}- borderBottomWidth={isShaded ? 0 : '1px'}- cursor={isMaximized ? 'default' : 'move'}- flexShrink={0}- gap="1.5"- h={10}- justify="space-between"- pe="2"- ps="3"- tabIndex={isMaximized ? undefined : 0}- // `preventDefault` on pointerdown does not stop touch panning: without- // this the browser claims the gesture and cancels the drag.- touchAction="none"- userSelect="none"- onDoubleClick={handleTitleDoubleClick}- onKeyDown={handleTitleKeyDown}- onPointerDown={handleTitlePointerDown}+ <Flex+ bg="bg.subtle"+ // The active window carries the same accent outline, under the same preference, as a focused region.+ borderColor={isHighlighted ? 'accent.solid' : 'border.emphasized'}+ borderWidth="1px"+ direction="column"+ h="full"+ // Its own stacking context: nothing a widget stacks inside can rise above the resize handles.+ isolation="isolate"+ overflow="hidden"+ data-floating-frame=""+ rounded={isMaximized ? 'none' : 'md'}+ shadow="xl"+ transition="border-color var(--wb-motion-duration-fast) ease">- <HStack flex="1" gap="1.5" minW="0">- {widget ? <WidgetIcon boxSize="4" icon={widget.manifest.icon} /> : null}- <Text fontSize="md" fontWeight="700" truncate>- {label}- </Text>- </HStack>- <HStack flexShrink={0} gap="1">+ <HStack+ aria-label={t('widgets.floating.move', { label })}+ borderBottomWidth={isShaded ? 0 : '1px'}+ cursor={isMaximized ? 'default' : 'move'}+ flexShrink={0}+ gap="1.5"+ // Tighter than a docked panel's header: a window's chrome should take as little of it as it can. The+ // end padding keeps the Dock button clear of the top-right resize corner, which reaches 12px inside.+ h={8}+ pe="3"+ ps="3"+ tabIndex={isMaximized ? undefined : 0}+ // `preventDefault` on pointerdown does not stop touch panning: without+ // this the browser claims the gesture and cancels the drag.+ touchAction="none"+ userSelect="none"+ _focusVisible={FOCUS_RING}+ outline="none"+ onDoubleClick={handleTitleDoubleClick}+ onKeyDown={handleTitleKeyDown}+ onPointerDown={handleTitlePointerDown}+ >+ {/*+ * The label takes only the room the controls leave, so a narrow window truncates it first — down to its+ * icon, which keeps its place rather than sliding over the actions.+ */}+ <HStack flex="1 1 0" gap="1.5" minW="4" overflow="hidden">+ {widget ? <WidgetIcon boxSize="4" flexShrink={0} icon={widget.manifest.icon} /> : null}- <Text fontSize="xs" fontWeight="700" truncate>++ <Text fontSize="md" fontWeight="700" truncate>+ {label}+ </Text>+ </HStack>{/** Render widget actions and settings in a row because floating content has no frame header; window- * controls already own layout actions.+ * controls already own layout actions. Contributed actions give way before they can push the window's+ * own controls out of a narrow title bar: the ones that do not fit scroll, so focus brings each into+ * view and a sideways scroll or swipe reaches the rest.*/}{isEnabled && widget ? (<FloatingChromeBoundary>@@@ -320,65 -762,62 +762,62 @@@</Suspense></FloatingChromeBoundary>) : null}- {isEnabled && widget ? <Separator h="4" mx="0.5" orientation="vertical" /> : null}- <Tooltip content={isShaded ? t('widgets.floating.unshade') : t('widgets.floating.shade')}>- <IconButton- aria-label={isShaded ? t('widgets.floating.unshade') : t('widgets.floating.shade')}- color="fg.muted"- size="sm"- variant="ghost"- onClick={handleToggleShade}- >- <Icon as={isShaded ? ChevronsUpDownIcon : ChevronsDownUpIcon} boxSize="3.5" />- </IconButton>- </Tooltip>- <Tooltip content={isMaximized ? t('widgets.floating.restore') : t('widgets.floating.maximize')}>- <IconButton- aria-label={isMaximized ? t('widgets.floating.restore') : t('widgets.floating.maximize')}- color="fg.muted"- size="sm"- variant="ghost"- onClick={handleToggleMaximize}- >- <Icon as={isMaximized ? Minimize2Icon : Maximize2Icon} boxSize="3.5" />- </IconButton>- </Tooltip>- <Tooltip content={t('widgets.floating.dock')}>- <IconButton- aria-label={t('widgets.floating.dock')}- color="fg.muted"- size="sm"- variant="ghost"- onClick={handleDock}- >- <Icon as={PanelRightIcon} boxSize="3.5" />- </IconButton>- </Tooltip>+ <HStack flexShrink={0} gap="1" data-floating-controls="">+ {isEnabled && widget ? <Separator h="4" mx="0.5" orientation="vertical" /> : null}+ <Tooltip content={isShaded ? t('widgets.floating.unshade') : t('widgets.floating.shade')}>+ <IconButton+ aria-label={isShaded ? t('widgets.floating.unshade') : t('widgets.floating.shade')}+ color="fg.muted"- size="2xs"++ size="sm"+ variant="ghost"+ onClick={handleToggleShade}+ >+ <Icon as={isShaded ? ChevronsUpDownIcon : ChevronsDownUpIcon} boxSize="3.5" />+ </IconButton>+ </Tooltip>+ <Tooltip content={isMaximized ? t('widgets.floating.restore') : t('widgets.floating.maximize')}>+ <IconButton+ aria-label={isMaximized ? t('widgets.floating.restore') : t('widgets.floating.maximize')}+ color="fg.muted"- size="2xs"++ size="sm"+ variant="ghost"+ onClick={handleToggleMaximize}+ >+ <Icon as={isMaximized ? Minimize2Icon : Maximize2Icon} boxSize="3.5" />+ </IconButton>+ </Tooltip>+ <Tooltip content={dockLabel}>- <IconButton aria-label={dockLabel} color="fg.muted" size="2xs" variant="ghost" onClick={handleDock}>++ <IconButton aria-label={dockLabel} color="fg.muted" size="sm" variant="ghost" onClick={handleDock}>+ <Icon as={DOCK_DESTINATION_ICONS[state.returnRegion]} boxSize="3.5" />+ </IconButton>+ </Tooltip>+ </HStack></HStack>- </HStack>- {isShaded ? null : (- <Flex direction="column" flex="1" minH="0" overflow="hidden">- {isEnabled && widget ? (- <WidgetRendererById instanceId={instance.id} region="floating" widget={widget} />- ) : (- <HStack color="fg.error" gap="1.5" p="3">- <Icon as={TriangleAlertIcon} boxSize="3.5" />- <Text fontSize="md">{t('widgets.failure.title', { label })}</Text>- </HStack>- )}- </Flex>- )}+ {/* A shaded body is hidden, not unmounted: its local state survives, and no second copy mounts. */}+ <Activity mode={isShaded ? 'hidden' : 'visible'}>+ <Flex direction="column" flex="1" minH="0" overflow="hidden">+ {isEnabled && widget ? (+ <WidgetRendererById instanceId={instance.id} region="floating" widget={widget} />+ ) : (+ <HStack color="fg.error" gap="1.5" p="3">+ <Icon as={TriangleAlertIcon} boxSize="3.5" />- <Text fontSize="xs">{t('widgets.failure.title', { label })}</Text>++ <Text fontSize="md">{t('widgets.failure.title', { label })}</Text>+ </HStack>+ )}+ </Flex>+ </Activity>+ </Flex>{isShaded || isMaximized ? null : (- <ResizeCorner- label={t('widgets.floating.resize')}- valueMin={FLOATING_MIN_WIDTH_PX}- valueNow={state.widthPx}- onDragCancel={cancelGesture}- onDragEnd={endGesture}- onDragMove={handleResizeMove}- onKeyDown={handleResizeKeyDown}- />+ <>+ <FloatingResizeHandles onResizeStart={startWindowDrag} />+ <FloatingResizeCorner+ heightPx={heightPx}+ widthPx={widthPx}+ onKeyDown={handleResizeKeyDown}+ onPointerDown={handleCornerPointerDown}+ />+ </>)}- </Flex>+ </Box>);};diff --cc invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsxindex ffccdd26f0,96bb1daf5e..ca619fa72d--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx@@@ -446,13 -448,28 +448,28 @@@ const FooterSlot = memo(function Footer);}, areSlotPropsEqual);- export const MissingWidgetFrame = ({ label, region }: { label: string; region: Exclude<WidgetRegion, 'center'> }) => (- <WidgetPanelFrame region={region}>+ /**+ * Stands in for a widget whose view cannot render. It carries the instance's identity like any other frame, so focus+ * moves and hotkeys that look for the instance find it here.+ */+ export const MissingWidgetFrame = ({+ instanceId,+ label,+ region,+ typeId,+ }: {+ instanceId: WidgetInstanceId;+ label: string;+ region: Exclude<WidgetRegion, 'center'>;+ /** Unknown when the instance itself is gone. */+ typeId: WidgetTypeId | undefined;+ }) => (+ <WidgetPanelFrame instanceId={instanceId} region={region} typeId={typeId}><Box p="3">- <Text fontSize="xs" fontWeight="700">+ <Text fontSize="md" fontWeight="700">{label}</Text>- <Text color="fg.subtle" fontSize="2xs">+ <Text color="fg.subtle" fontSize="xs">Widget view unavailable.</Text></Box>