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(ui): compact top bar
joshistoastda50ce257c06
diff --git a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjsindex c8fe486e34..9a0bd9926d 100644--- a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs+++ b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs@@ -395,6 +395,14 @@ const runTopbarMenuJourney = async (browser) => {assert.ok(activeLeftWidgetName);const routingTrigger = page.getByRole('button', { name: /^Invoke from/ });+ const routingLockIndicator = routingTrigger.locator('[data-routing-lock-indicator]');+ const routingTriggerBoundsBeforeHover = await routingTrigger.boundingBox();+ assert.ok(routingTriggerBoundsBeforeHover);+ assert.ok(+ routingTriggerBoundsBeforeHover.width <= 36 && routingTriggerBoundsBeforeHover.height <= 38,+ 'The routing trigger should remain narrow and align with its attached controls.'+ );+ assert.equal(await routingLockIndicator.count(), 0);await routingTrigger.hover();const routingTooltip = page.getByRole('tooltip', { exact: true, name: 'Change routing' });await routingTooltip.waitFor({ timeout: 2_000 });@@ -427,6 +435,7 @@ const runTopbarMenuJourney = async (browser) => {name: 'Invoke from workflow, output to gallery, source locked, destination locked',});await lockedRoutingTrigger.waitFor();+ assert.equal(await lockedRoutingTrigger.locator('[data-routing-lock-indicator]').count(), 1);await lockedRoutingTrigger.click();const unlockRouting = page.getByRole('menu').getByRole('menuitem', { exact: true, name: 'Unlock routing' });await unlockRouting.click();@@ -436,6 +445,7 @@ const runTopbarMenuJourney = async (browser) => {name: 'Invoke from workflow, output to gallery, following edits',}).waitFor();+ assert.equal(await routingTrigger.locator('[data-routing-lock-indicator]').count(), 0);await routingTrigger.click();diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/AppMenu.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/AppMenu.tsxindex 10963c74b2..11d3c7962a 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/AppMenu.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/AppMenu.tsx@@ -54,7 +54,7 @@ export const AppMenu = () => {return (<Menu.Root positioning={MENU_POSITIONING}><Menu.Trigger asChild>- <IconButton aria-label={t('topbar.appMenu.open')} className="group" size="sm" variant="ghost">+ <IconButton aria-label={t('topbar.appMenu.open')} className="group" size="xs" variant="ghost"><AppMenuGlyph /></IconButton></Menu.Trigger>diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.tsxindex 45a9efe19d..79c67e6231 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.tsx@@ -55,7 +55,7 @@ export const InvokeButton = ({ state }: { state: InvocationState }) => {cursor={isValid ? undefined : 'not-allowed'}flexShrink={0}opacity={isValid ? undefined : 0.55}- size="sm"+ size="xs"onClick={isValid ? handleClick : undefined}zIndex="2">diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/IterationsField.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/IterationsField.tsxindex ab6e2b1b5f..656863fc0c 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/IterationsField.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/IterationsField.tsx@@ -49,7 +49,7 @@ export const IterationsField = () => {flexShrink={0}min={MIN_BATCH_COUNT}rounded="l2"- size="sm"+ size="xs"value={String(batchCount)}w="14"onValueChange={handleValueChange}diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsxindex d5d130a776..a6df7a605a 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx@@ -151,7 +151,7 @@ export const ProjectSwitcher = () => {<Menu.Trigger asChild><Buttonaria-label={t('topbar.projectSwitcher.trigger', { name: activeProjectName })}- size="sm"+ size="xs"variant="ghost"><Text css={HIDE_BELOW_PROJECT_NAME_WIDTH} fontWeight="500" minW="0" truncate>@@ -171,6 +171,7 @@ export const ProjectSwitcher = () => {{activeProjectName}</Text></Stack>+ <Menu.Separator /><Menu.Item value="rename-project" onClick={renameActiveProject}><Icon as={PencilIcon} boxSize="3.5" /><Menu.ItemText>{t('projects.renameWithEllipsis')}</Menu.ItemText>diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsxindex 7ff9e4ffae..fc377a771e 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx@@ -74,7 +74,8 @@ export const QueueCluster = () => {fontVariantNumeric="tabular-nums"overflow="hidden"position="relative"- size="sm"+ size="xs"+ px={2}variant={tone === 'idle' ? 'outline' : 'subtle'}onClick={handleOpenQueue}>@@ -116,7 +117,7 @@ export const QueueCluster = () => {<IconButtonaria-label={t('topbar.queue.actions')}color="fg.subtle"- size="sm"+ size="xs"minW="0"w="6"variant="outline"diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.browser.test.tsxnew file mode 100644index 0000000000..646e49f901--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.browser.test.tsx@@ -0,0 +1,136 @@+import { ChakraProvider } from '@chakra-ui/react';+import { Button } from '@platform/ui/Button';+import { Group } from '@platform/ui/Group';+import { system } from '@theme/system';+import { graphWidgetSources } from '@workbench/graphWidgets';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, describe, expect, it, vi } from 'vitest';++import type { InvocationState } from './useInvocationState';++vi.mock('@workbench/WorkbenchContext', () => ({+ useWorkbenchCommands: () => ({+ generation: {+ setDestination: vi.fn(),+ setSource: vi.fn(),+ toggleRoutingLock: vi.fn(),+ },+ }),+}));++vi.mock('react-i18next', () => ({+ useTranslation: () => ({+ t: (key: string) =>+ ({+ 'topbar.routing.change': 'Change routing',+ 'topbar.routing.destination': 'Destination',+ 'topbar.routing.lockRouting': 'Lock routing',+ 'topbar.routing.source': 'Source',+ 'topbar.routing.unlockRouting': 'Unlock routing',+ })[key] ?? key,+ }),+}));++import { RoutingControl } from './RoutingControl';++const NOOP_INVOKE = () => Promise.resolve();+const BASE_STATE = {+ batchCount: 1,+ blockingReasons: [],+ invocation: {+ destination: 'gallery',+ destinationLocked: false,+ sourceId: 'generate',+ sourceLocked: false,+ },+ invoke: NOOP_INVOKE,+ isValid: true,+ placedTypeIds: new Set(['generate']),+ promptExpansion: {},+ sourceValues: {},+ sources: graphWidgetSources,+ visibleTypeIds: new Set(['generate']),+} as unknown as InvocationState;+const LOCKED_STATE = {+ ...BASE_STATE,+ invocation: { ...BASE_STATE.invocation, destinationLocked: true, sourceLocked: true },+} satisfies InvocationState;++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 renderControl = async (state: InvocationState) => {+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);++ await act(async () => {+ root?.render(+ <ChakraProvider value={system}>+ <Group attached>+ <Button data-routing-height-reference="" size="xs">+ Invoke+ </Button>+ <RoutingControl state={state} />+ </Group>+ </ChakraProvider>+ );+ await new Promise<void>((resolve) => {+ globalThis.setTimeout(resolve, 50);+ });+ });+};++afterEach(async () => {+ await act(() => root?.unmount());+ host?.remove();+ host = null;+ root = null;+});++describe('RoutingControl', () => {+ it('uses narrow diagonal route geometry without an arrow and adds only a top-right dot when locked', async () => {+ await renderControl(BASE_STATE);++ const button = document.querySelector<HTMLButtonElement>('[data-routing-control]');+ const sourceIcon = button?.querySelector<SVGElement>('[data-routing-source-icon]');+ const destinationIcon = button?.querySelector<SVGElement>('[data-routing-destination-icon]');+ const heightReference = document.querySelector<HTMLButtonElement>('[data-routing-height-reference]');+ expect(button).not.toBeNull();+ expect(heightReference).not.toBeNull();+ expect(sourceIcon).not.toBeNull();+ expect(destinationIcon).not.toBeNull();++ const buttonBounds = button!.getBoundingClientRect();+ const sourceBounds = sourceIcon!.getBoundingClientRect();+ const destinationBounds = destinationIcon!.getBoundingClientRect();+ expect(buttonBounds.width).toBe(36);+ expect(buttonBounds.height).toBe(32);+ expect(buttonBounds.height).toBe(heightReference!.getBoundingClientRect().height);+ expect(destinationBounds.left - sourceBounds.left).toBeGreaterThanOrEqual(8);+ expect(destinationBounds.top - sourceBounds.top).toBeGreaterThanOrEqual(8);+ expect(button?.querySelectorAll('svg')).toHaveLength(2);+ expect(button?.querySelector('[data-routing-lock-indicator]')).toBeNull();++ await act(() => {+ root?.render(+ <ChakraProvider value={system}>+ <Group attached>+ <Button data-routing-height-reference="" size="xs">+ Invoke+ </Button>+ <RoutingControl state={LOCKED_STATE} />+ </Group>+ </ChakraProvider>+ );+ });++ const lockIndicator = button?.querySelector<HTMLElement>('[data-routing-lock-indicator]');+ expect(lockIndicator).not.toBeNull();+ const dotBounds = lockIndicator!.getBoundingClientRect();+ expect(dotBounds.left).toBeGreaterThan(sourceBounds.right);+ expect(dotBounds.top).toBeLessThan(destinationBounds.top);+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsxindex 5cb5e877b1..7ce20b1c01 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx@@ -1,7 +1,7 @@import type { GraphWidgetSource } from '@workbench/graphWidgets';import type { InvocationSourceId, ResultDestination } from '@workbench/invocationContracts';-import { Box, Icon, Menu, Portal, SegmentGroup, Stack, Text } from '@chakra-ui/react';+import { Box, Icon, Menu, Portal, SegmentGroup, Stack, Status, Text } from '@chakra-ui/react';import { Button } from '@platform/ui/Button';import { MenuContent } from '@platform/ui/Menu';import { Tooltip } from '@platform/ui/Tooltip';@@ -10,7 +10,7 @@ import { WidgetIcon } from '@workbench/iconResolver';import { getDestinationLabel, resultDestinations } from '@workbench/invocation';import { getWidgetById } from '@workbench/widgetRegistry';import { useWorkbenchCommands } from '@workbench/WorkbenchContext';-import { ArrowRightIcon, Link2Icon, LockKeyholeIcon, UnlockKeyholeIcon } from 'lucide-react';+import { LockKeyholeIcon, UnlockKeyholeIcon } from 'lucide-react';import { useCallback, useId, useMemo } from 'react';import { useTranslation } from 'react-i18next';@@ -30,7 +30,6 @@ export const RoutingControl = ({ state }: { state: InvocationState }) => {const triggerIds = useMemo(() => ({ trigger: triggerId }), [triggerId]);const { invocation, placedTypeIds, sources } = state;const isLocked = invocation.sourceLocked || invocation.destinationLocked;- const relationship = isLocked ? 'link' : 'arrow';const hasSource = placedTypeIds.has(getWidgetTypeIdForSourceId(invocation.sourceId));const sourceTypeId = getWidgetTypeIdForSourceId(invocation.sourceId);const destinationTypeId = destinationWidgetTypeIds[invocation.destination];@@ -41,33 +40,68 @@ export const RoutingControl = ({ state }: { state: InvocationState }) => {sourceId: invocation.sourceId,sourceLocked: invocation.sourceLocked,});- const glyphColor = isLocked ? 'accent.fg' : 'fg.muted';const lockActionLabel = t(isLocked ? 'topbar.routing.unlockRouting' : 'topbar.routing.lockRouting');+ const getWidgetIconProps = (type: 'source' | 'destination') => ({+ boxSize: '3.5',+ color: 'fg.muted',+ [`data-routing-${type}-icon`]: '',+ icon: getWidgetById(type === 'source' ? sourceTypeId : destinationTypeId)?.manifest.icon,+ position: 'absolute',+ top: type === 'source' ? '4px' : undefined,+ left: type === 'source' ? '4px' : undefined,+ bottom: type === 'destination' ? '4px' : undefined,+ right: type === 'destination' ? '4px' : undefined,+ });+return (<Menu.Root ids={triggerIds} positioning={MENU_POSITIONING}><Tooltip content={t('topbar.routing.change')} ids={triggerIds}><Menu.Trigger asChild><Buttonaria-label={accessibleName}- colorPalette={isLocked ? 'accent' : undefined}+ data-routing-control=""flexShrink={0}- px="2"- size="sm"- gap="1.5"- variant={isLocked ? 'subtle' : 'outline'}+ maxW="36px"+ minW="36px"+ overflow="visible"+ p="0"+ position="relative"+ size="xs"+ variant="outline"+ w="34px"+ display="grid">{hasSource ? (- <WidgetIcon boxSize="3.5" color={glyphColor} icon={getWidgetById(sourceTypeId)?.manifest.icon} />+ <WidgetIcon {...getWidgetIconProps('source')} />) : (- <Box borderColor="border.emphasized" borderStyle="dashed" borderWidth="1px" boxSize="3.5" rounded="xs" />+ <Box+ borderColor="border.emphasized"+ borderStyle="dashed"+ borderWidth="1px"+ boxSize="3.5"+ data-routing-source-icon=""+ left="4px"+ position="absolute"+ rounded="xs"+ top="4px"+ />)}- <Icon- as={relationship === 'link' ? Link2Icon : ArrowRightIcon}- boxSize="3"- color={isLocked ? 'accent.fg' : 'fg.subtle'}- />- <WidgetIcon boxSize="3.5" color={glyphColor} icon={getWidgetById(destinationTypeId)?.manifest.icon} />+ <WidgetIcon {...getWidgetIconProps('destination')} />+ {isLocked ? (+ <Status.Root+ colorPalette="accent"+ data-routing-lock-indicator=""+ pointerEvents="none"+ position="absolute"+ right="-1px"+ size="sm"+ top="-1px"+ zIndex="1"+ >+ <Status.Indicator />+ </Status.Root>+ ) : null}</Button></Menu.Trigger></Tooltip>diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/TopBar.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/TopBar.tsxindex fac5013be2..b7e61800b6 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/TopBar.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/TopBar.tsx@@ -35,7 +35,7 @@ export const TopBar = () => (flexShrink={0}gap="2"gridTemplateColumns={TOPBAR_COLUMNS}- h="46px"+ h="44px"px="1.5"w="full">