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(preview): float/dock the preview widget, with an Invoke control while floated
Lincoln Steinba0122aa6320
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex a282f40d7d..157925522d 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -2015,6 +2015,7 @@"hideInProgressDiffusion": "Hide in-progress diffusion","imageCount_one": "{{count}} image","imageCount_other": "{{count}} images",+ "invoke": "Invoke","itemCount_one": "{{count}} item","itemCount_other": "{{count}} items","loadingBoard": "Loading board",diff --git a/invokeai/frontend/webv2/src/platform/ui/InvokeMark.tsx b/invokeai/frontend/webv2/src/platform/ui/InvokeMark.tsxindex d77971e5ac..c4c6eb09f3 100644--- a/invokeai/frontend/webv2/src/platform/ui/InvokeMark.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/InvokeMark.tsx@@ -1,14 +1,37 @@+import type { SVGProps } from 'react';+import { Box } from '@chakra-ui/react';+/** The stylized Invoke "I" logomark path, on a 44×44 viewBox. */+const INVOKE_MARK_PATH = 'M29.1951 10.6667H42V2H2V10.6667H14.8049L29.1951 33.3333H42V42H2V33.3333H14.8049';++/**+ * The Invoke logomark as a bare `1em`/`currentColor` glyph, shaped like a+ * Lucide icon so it drops into `<Icon as={InvokeMarkIcon} />` and inherits the+ * surrounding color. Decorative by default; the button around it carries the+ * accessible name.+ */+export const InvokeMarkIcon = (props: SVGProps<SVGSVGElement>) => (+ <svg+ aria-hidden="true"+ fill="none"+ height="1em"+ stroke="currentColor"+ strokeWidth="4"+ viewBox="0 0 44 44"+ width="1em"+ xmlns="http://www.w3.org/2000/svg"+ {...props}+ >+ <path d={INVOKE_MARK_PATH} />+ </svg>+);+/** The Invoke logomark, drawn in the theme brand color. */export const InvokeMark = ({ size = 36 }: { size?: number }) => (<Box color="brand.fg"><svg aria-hidden="true" fill="none" height={size} viewBox="0 0 44 44" width={size}>- <path- d="M29.1951 10.6667H42V2H2V10.6667H14.8049L29.1951 33.3333H42V42H2V33.3333H14.8049"- stroke="currentColor"- strokeWidth="2.8"- />+ <path d={INVOKE_MARK_PATH} stroke="currentColor" strokeWidth="2.8" /></svg></Box>);diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.tsindex 51d172c157..6827e9d6a1 100644--- a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts@@ -79,9 +79,10 @@ const implemented = new Set([/*** Hotkeys that must fire with the caret inside a text field or numeric input.*- * There is no second Invoke button anywhere in the application, so `app.invoke`- * and its variants are load-bearing: a prompt textarea that swallows ⌘↵ leaves- * the user with no way to submit at all.+ * The topbar's Invoke button is the only one that is always on screen (the+ * floating preview window carries a second one, but only while it floats), so+ * `app.invoke` and its variants are load-bearing: a prompt textarea that+ * swallows ⌘↵ leaves the user with no way to submit at all.*/const editableAppHotkeys = new Set(['app.focusPrompt',diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.browser.test.tsxindex 47661e67c8..b32c05062a 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.browser.test.tsx@@ -18,10 +18,12 @@ void i18n.use(initReactI18next).init({resources: {en: {translation: {+ topbar: { invoke: { unavailable: 'Invoke unavailable: {{reason}}', unrunnable: 'Unrunnable' } },widgets: {preview: {hideFilmstrip: 'Hide filmstrip',hideInProgressDiffusion: 'Hide in-progress diffusion',+ invoke: 'Invoke',showFilmstrip: 'Show filmstrip',showInProgressDiffusion: 'Show in-progress diffusion',},@@ -34,6 +36,12 @@ void i18n.use(initReactI18next).init({const state = vi.hoisted(() => ({ filmstripVisible: true, showProgressImagesInViewer: true }));const patchValues = vi.hoisted(() => vi.fn());const updateProjectPreferences = vi.hoisted(() => vi.fn());+const executeCommand = vi.hoisted(() => vi.fn(() => Promise.resolve()));+const invocationState = vi.hoisted(() => ({ blockingReasons: [] as string[], isPreparing: false, isValid: true }));++vi.mock('@workbench/shell/topbar/useInvocationState', () => ({+ useInvocationState: () => invocationState,+}));vi.mock('@features/queue/react', () => ({ useProgressImage: () => null }));@@ -73,7 +81,7 @@ const settle = (action: () => void): Promise<void> =>});});-const render = async () => {+const render = async (region: WidgetViewProps['region'] = 'center') => {host = document.createElement('div');document.body.append(host);root = createRoot(host);@@ -82,7 +90,9 @@ const render = async () => {root?.render(<I18nextProvider i18n={i18n}><ChakraProvider value={system}>- <PreviewHeaderActions {...({ region: 'center' } as unknown as WidgetViewProps)} />+ <PreviewHeaderActions+ {...({ region, runtime: { commands: { execute: executeCommand } } } as unknown as WidgetViewProps)}+ /></ChakraProvider></I18nextProvider>);@@ -97,6 +107,10 @@ beforeEach(() => {state.showProgressImagesInViewer = true;patchValues.mockClear();updateProjectPreferences.mockClear();+ executeCommand.mockClear();+ invocationState.blockingReasons = [];+ invocationState.isPreparing = false;+ invocationState.isValid = true;});afterEach(async () => {@@ -135,3 +149,43 @@ describe('preview header toggles', () => {expect(updateProjectPreferences).toHaveBeenCalledWith({ showProgressImagesInViewer: false });});});++describe('preview floating Invoke control', () => {+ it('is offered only while the widget floats', async () => {+ await render('center');+ expect(host?.querySelector('button[aria-label="Invoke"]')).toBeNull();++ await settle(() => root?.unmount());+ host?.remove();++ await render('right');+ expect(host?.querySelector('button[aria-label="Invoke"]')).toBeNull();++ await settle(() => root?.unmount());+ host?.remove();++ await render('floating');+ expect(host?.querySelector('button[aria-label="Invoke"]')).not.toBeNull();+ });++ it('runs the app-level Invoke command, the same path as the topbar button', async () => {+ await render('floating');++ await settle(() => button('Invoke').click());++ expect(executeCommand).toHaveBeenCalledWith('app.invoke');+ });++ it('dims, names the blocking reason, and refuses the click when Invoke cannot run', async () => {+ invocationState.isValid = false;+ invocationState.blockingReasons = ['The backend is disconnected.'];+ await render('floating');++ const control = button('Invoke unavailable: The backend is disconnected.');+ expect(control.getAttribute('aria-disabled')).toBe('true');++ await settle(() => control.click());++ expect(executeCommand).not.toHaveBeenCalled();+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.tsxindex 46ce2f5c25..31303f8eda 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewHeaderActions.tsx@@ -1,8 +1,10 @@import type { WidgetViewProps } from '@workbench/widgetContracts';-import { Box, HStack } from '@chakra-ui/react';+import { Box, HStack, Icon } from '@chakra-ui/react';import { useProgressImage } from '@features/queue/react';-import { ToggleIconButton } from '@platform/ui';+import { IconButton, ToggleIconButton, Tooltip } from '@platform/ui';+import { InvokeMarkIcon } from '@platform/ui/InvokeMark';+import { useInvocationState } from '@workbench/shell/topbar/useInvocationState';import { getProjectWidgetValues } from '@workbench/widgetState';import { useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';import { GalleryThumbnailsIcon, HourglassIcon } from 'lucide-react';@@ -18,8 +20,14 @@ import { getPreviewFilmstripVisible } from './previewSettings';* selection (published by the view via `previewHeaderStore`) plus the* in-progress diffusion toggle. Actions live here — in the frame's standard* header slot — like every other widget, not in the widget body.+ *+ * Floated, the widget also carries an Invoke control: a floating preview is+ * typically parked over a maximized work surface, or on a second display, with+ * the topbar's Invoke button out of easy reach — so the window that shows the+ * result offers the one action that produces the next one. Docked, the topbar+ * is right there and a second Invoke button would only compete with it.*/-export const PreviewHeaderActions = ({ region }: WidgetViewProps) => {+export const PreviewHeaderActions = ({ region, runtime }: WidgetViewProps) => {const { t } = useTranslation();const showProgressImagesInViewer = useActiveProjectSelector((project) => project.settings.showProgressImagesInViewer);const hasProgressImage = useProgressImage() !== null;@@ -61,6 +69,7 @@ export const PreviewHeaderActions = ({ region }: WidgetViewProps) => {{/* Both toggles go through `ToggleIconButton` so they read as one controltype: the filled variant carries "on", `aria-pressed` carries it forassistive tech, and the label doubles as the tooltip. */}+ {region === 'floating' ? <FloatingInvokeButton runtime={runtime} /> : null}<ToggleIconButtonchecked={isFilmstripVisible}icon={GalleryThumbnailsIcon}@@ -79,3 +88,43 @@ export const PreviewHeaderActions = ({ region }: WidgetViewProps) => {</HStack>);};++/**+ * The floating window's Invoke control. It reads the same invocation state as+ * the topbar button, so it dims and names the blocking reason under exactly+ * the conditions the topbar does, instead of silently doing nothing when the+ * route is invalid or the backend is disconnected. Submission goes through the+ * registered `app.invoke` command — the topbar button's and the hotkey's path+ * — so the validation and disconnect guards are not duplicated here.+ *+ * Split out so the hook's subscriptions (models, dynamic prompt expansion)+ * only run while the widget floats.+ */+const FloatingInvokeButton = ({ runtime }: Pick<WidgetViewProps, 'runtime'>) => {+ const { t } = useTranslation();+ const { blockingReasons, isPreparing, isValid } = useInvocationState();+ const canInvoke = isValid && !isPreparing;+ const label = canInvoke+ ? t('widgets.preview.invoke')+ : isPreparing+ ? t('topbar.invoke.preparing')+ : t('topbar.invoke.unavailable', { reason: blockingReasons[0] ?? t('topbar.invoke.unrunnable') });+ const invoke = useCallback(() => void runtime.commands.execute('app.invoke'), [runtime]);++ return (+ <Tooltip content={label}>+ <IconButton+ aria-disabled={!canInvoke}+ aria-label={label}+ color="brand.fg"+ cursor={canInvoke ? undefined : 'not-allowed'}+ opacity={canInvoke ? undefined : 0.55}+ size="2xs"+ variant="ghost"+ onClick={canInvoke ? invoke : undefined}+ >+ <Icon as={InvokeMarkIcon} boxSize="3.5" />+ </IconButton>+ </Tooltip>+ );+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/manifest.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/manifest.tsindex 55a26a5a52..f2fed99dd7 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/manifest.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/manifest.ts@@ -3,6 +3,7 @@ import type { WidgetManifest } from '@workbench/widgetContracts';import { EyeIcon } from 'lucide-react';export const previewWidgetManifest: WidgetManifest = {+ allowFloating: true,allowMultiple: false,allowedRegions: ['center', 'right'],failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },