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): put gallery upload beside the grid and make empty boards a drop target
joshistoaste8da83c87c90
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 8a33e59c05..2a7cb1090f 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -2758,6 +2758,7 @@"downloadReady": "Download ready","downloadSelection": "Download selection","dropMediaToUploadToBoard": "Drop images or videos to upload to {{name}}",+ "emptyBoardUploadHint": "Drop media here or click to upload","exportProjectFromBoard": "Export project (.invk)","expandStarredItems": "Expand starred items","generationProgress": "Generation progress",diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsxindex 36f02326fe..bc404b21b1 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.browser.test.tsx@@ -118,6 +118,7 @@ void i18n.use(initReactI18next).init({noImagesMatch: 'No items',collapseStarredItems: 'Collapse starred items',dropMediaToUploadToBoard: 'Drop media to {{name}}',+ emptyBoardUploadHint: 'Drop media here or click to upload',expandStarredItems: 'Expand starred items',selectImageForPreview: 'Select {{name}} for preview',selectVideoForPreview: 'Select video {{name}}, duration {{duration}}, for preview',@@ -886,6 +887,53 @@ describe('GalleryImageGrid upload drop zone', () => {expect(host?.textContent).toContain('Drop media to Uncategorized');});++ it('turns a true-empty, non-searching, non-virtual board into a click/drop upload target', async () => {+ await renderGallery(createGallery({ items: [], pendingPlaceholders: [] }));++ const target = host?.querySelector<HTMLElement>('[role="button"]');+ const input = host?.querySelector<HTMLInputElement>('input[type="file"]');++ expect(target).not.toBeNull();+ expect(target?.getAttribute('tabIndex')).toBe('0');+ expect(target?.textContent).toContain('Drop media here or click to upload');+ expect(input).not.toBeNull();+ expect(host?.textContent).not.toContain('No items');++ const clickSpy = vi.spyOn(input!, 'click');++ await interact(() => target?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true })));++ expect(clickSpy).toHaveBeenCalledOnce();+ });++ it('keeps the no-match message for a search with no results instead of the upload target', async () => {+ await renderGallery(createGallery({ items: [], pendingPlaceholders: [], searchTerm: 'nope' }));++ expect(host?.textContent).toContain('No items');+ expect(host?.querySelector('[role="button"]')).toBeNull();+ });++ it('keeps the no-match message for an empty virtual (date) board instead of the upload target', async () => {+ await renderGallery(+ createGallery({+ boards: [{ ...board, id: 'by_date:2026-07-30', kind: 'date' }],+ items: [],+ pendingPlaceholders: [],+ selectedBoardId: 'by_date:2026-07-30',+ })+ );++ expect(host?.textContent).toContain('No items');+ expect(host?.querySelector('[role="button"]')).toBeNull();+ });++ it('keeps the loading message while an empty board is still loading', async () => {+ await renderGallery(createGallery({ isLoading: true, items: [], pendingPlaceholders: [] }));++ expect(host?.textContent).toContain('Loading gallery');+ expect(host?.querySelector('[role="button"]')).toBeNull();+ });});describe('GalleryImageGrid virtualization', () => {diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsxindex e519b12dd4..ef6805500d 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx@@ -1,6 +1,7 @@-import { Box, chakra, Flex, HStack, Icon, ScrollArea, Spinner, Text } from '@chakra-ui/react';+import { Box, chakra, Flex, HStack, Icon, ScrollArea, Spinner, Stack, Text } from '@chakra-ui/react';import { getGalleryBoardLabel } from '@features/gallery/core/boardLabels';import { toGalleryItemKey, type GalleryItem } from '@features/gallery/core/items';+import { isDateBoardId } from '@features/gallery/data/backend';import { DropZone } from '@platform/ui';import { ChevronRightIcon, StarIcon, UploadIcon } from 'lucide-react';import {@@ -11,7 +12,9 @@ import {useMemo,useRef,useState,+ type ChangeEvent,type DragEvent,+ type KeyboardEvent,} from 'react';import { useVirtualizer } from 'react-hook-tanstack-virtual';import { useTranslation } from 'react-i18next';@@ -28,6 +31,7 @@ import {import { GalleryQueuePlaceholderCell } from './GalleryQueuePlaceholderCell';import { GalleryThumbnailCell } from './GalleryThumbnail';import { useGalleryUi } from './GalleryUiContext';+import { ACCEPTED_UPLOAD_EXTENSIONS, UPLOAD_INPUT_STYLE } from './GalleryUploadButton';import { useGalleryWidget } from './GalleryWidgetContext';import { useGalleryGridHotkeys } from './useGalleryGridHotkeys';import { useGalleryGridSelection } from './useGalleryGridSelection';@@ -124,6 +128,7 @@ export const GalleryImageGrid = () => {const [viewportWidth, setViewportWidth] = useState(() => viewportWidthCache.get(region) ?? 0);const dragDepthRef = useRef(0);const viewportRef = useRef<HTMLDivElement | null>(null);+ const uploadInputRef = useRef<HTMLInputElement | null>(null);const { imageDensityPercent, imageOrderDir, paginationMode, showImageDimensions, thumbnailFit } = gallery.settings;const {@@ -149,6 +154,8 @@ export const GalleryImageGrid = () => {? getGalleryBoardLabel(selectedBoard, t): t('widgets.gallery.selectedBoardFallback');const isEmpty = gallery.items.length === 0 && gallery.pendingPlaceholders.length === 0;+ const hasActiveSearch = gallery.searchTerm.trim() !== '';+ const isVirtualBoard = isDateBoardId(gallery.selectedBoardId);const rows = useMemo(() =>@@ -295,6 +302,31 @@ export const GalleryImageGrid = () => {[actions]);+ const handleUploadFileChange = useCallback(+ (event: ChangeEvent<HTMLInputElement>) => {+ const files = Array.from(event.currentTarget.files ?? []);++ event.currentTarget.value = '';++ if (files.length > 0) {+ void actions.uploadFiles(files);+ }+ },+ [actions]+ );++ const openUploadPicker = useCallback(() => uploadInputRef.current?.click(), []);++ const handleUploadKeyDown = useCallback(+ (event: KeyboardEvent) => {+ if (event.key === 'Enter' || event.key === ' ') {+ event.preventDefault();+ openUploadPicker();+ }+ },+ [openUploadPicker]+ );+const handleShowProgressImages = useCallback(() => {account.enableLiveFollow();}, [account]);@@ -324,11 +356,39 @@ export const GalleryImageGrid = () => {onDrop={handleDrop}>{isEmpty ? (- <Flex align="center" color="fg.muted" h="full" justify="center" minH="8rem">- <Text fontSize="xs">- {gallery.isLoading ? t('widgets.gallery.loadingBackendGallery') : t('widgets.gallery.noImagesMatch')}- </Text>- </Flex>+ gallery.isLoading || hasActiveSearch || isVirtualBoard ? (+ <Flex align="center" color="fg.muted" h="full" justify="center" minH="8rem">+ <Text fontSize="xs">+ {gallery.isLoading ? t('widgets.gallery.loadingBackendGallery') : t('widgets.gallery.noImagesMatch')}+ </Text>+ </Flex>+ ) : (+ <Flex align="stretch" h="full" minH="8rem" p="2">+ <input+ accept={ACCEPTED_UPLOAD_EXTENSIONS}+ multiple+ ref={uploadInputRef}+ style={UPLOAD_INPUT_STYLE}+ type="file"+ onChange={handleUploadFileChange}+ />+ <DropZone+ cursor="pointer"+ flex="1"+ fontSize="xs"+ isOver={isDropActive}+ role="button"+ tabIndex={0}+ onClick={openUploadPicker}+ onKeyDown={handleUploadKeyDown}+ >+ <Stack align="center" gap="1">+ <Icon as={UploadIcon} boxSize="4" color="fg.subtle" />+ <Text color="fg.muted">{t('widgets.gallery.emptyBoardUploadHint')}</Text>+ </Stack>+ </DropZone>+ </Flex>+ )) : (<ScrollArea.Root h="full" minH="0" size="xs" variant="hover" w="full"><ScrollArea.Viewport ref={viewportRef} h="full" outline="none" w="full">diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryLayout.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryLayout.browser.test.tsxindex 9c613e9270..f1f86149e2 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryLayout.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryLayout.browser.test.tsx@@ -252,6 +252,25 @@ describe('gallery layout shells', () => {expect(contextBase.actions.updateSettings).toHaveBeenLastCalledWith({ boardPanelHeightPx: measuredMaximum });});+ it('puts the upload control in the toolbar row for both shells, disabled for date boards', async () => {+ for (const Layout of [GalleryStackedLayout, GalleryWideLayout]) {+ setGallery(gallery);+ await renderLayout(Layout);++ const upload = host?.querySelector<HTMLButtonElement>('button[aria-label^="widgets.gallery.upload"]');++ expect(upload, 'upload control did not render in the toolbar').not.toBeNull();+ expect(upload?.disabled).toBe(false);++ setGallery(createGallery({ selectedBoardId: 'by_date:2026-07-30' }));+ await renderLayout(Layout);++ const uploadForDateBoard = host?.querySelector<HTMLButtonElement>('button[aria-label^="widgets.gallery.upload"]');++ expect(uploadForDateBoard?.disabled).toBe(true);+ }+ });+it('hides the board column and its handle in both shells when collapsed', async () => {setGallery(createGallery({ settings: { ...DEFAULT_GALLERY_SETTINGS, boardPanelCollapsed: true } }));diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryStackedLayout.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryStackedLayout.tsxindex c61aa06f76..ebf90e83a5 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryStackedLayout.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryStackedLayout.tsx@@ -13,6 +13,7 @@ import { GalleryItemSearch } from './GalleryItemSearch';import { GalleryItemSortMenu } from './GalleryItemSortMenu';import { GallerySelectionBar } from './GallerySelectionBar';import { GALLERY_SPLIT_HANDLE_SIZE_PX, GallerySplitHandle } from './GallerySplitHandle';+import { GalleryUploadButton } from './GalleryUploadButton';import { GalleryViewTabs } from './GalleryViewTabs';import { useGalleryWidget } from './GalleryWidgetContext';@@ -123,6 +124,11 @@ export const GalleryStackedLayout = () => {<GalleryViewTabs /><Spacer /><GalleryItemSortMenu />+ <GalleryUploadButton+ boards={gallery.boards}+ selectedBoardId={gallery.selectedBoardId}+ onUploadFiles={actions.uploadFiles}+ /></HStack><GalleryItemSearch /></Stack>diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUploadButton.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUploadButton.tsxnew file mode 100644index 0000000000..7fdbfde981--- /dev/null+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUploadButton.tsx@@ -0,0 +1,73 @@+import type { GalleryBoard } from '@features/gallery/core/types';++import { Icon } from '@chakra-ui/react';+import { getGalleryBoardLabel } from '@features/gallery/core/boardLabels';+import { isDateBoardId } from '@features/gallery/data/backend';+import { IconButton } from '@platform/ui/Button';+import { Tooltip } from '@platform/ui/Tooltip';+import { UploadIcon } from 'lucide-react';+import { useCallback, useRef } from 'react';+import { useTranslation } from 'react-i18next';++export const ACCEPTED_UPLOAD_EXTENSIONS = 'image/png,image/jpeg,image/webp,video/mp4,.png,.jpg,.jpeg,.webp,.mp4';+export const UPLOAD_INPUT_STYLE = { display: 'none' } as const;++export const GalleryUploadButton = ({+ boards,+ selectedBoardId,+ onUploadFiles,+}: {+ boards: GalleryBoard[];+ selectedBoardId: string;+ onUploadFiles: (files: File[]) => Promise<void>;+}) => {+ const { t } = useTranslation();+ const fileInputRef = useRef<HTMLInputElement>(null);+ const selectedBoard = boards.find((board) => board.id === selectedBoardId);+ const isVirtualTarget = isDateBoardId(selectedBoardId);+ const label = isVirtualTarget+ ? t('widgets.gallery.uploadsUnavailableForDateBoards')+ : t('widgets.gallery.uploadMediaToBoard', {+ name: selectedBoard ? getGalleryBoardLabel(selectedBoard, t) : t('widgets.gallery.selectedBoardFallback'),+ });++ const handleFileChange = useCallback(+ (event: React.ChangeEvent<HTMLInputElement>) => {+ const files = Array.from(event.currentTarget.files ?? []);++ event.currentTarget.value = '';++ if (files.length > 0) {+ void onUploadFiles(files);+ }+ },+ [onUploadFiles]+ );++ const handleUploadClick = useCallback(() => fileInputRef.current?.click(), []);++ return (+ <>+ <input+ accept={ACCEPTED_UPLOAD_EXTENSIONS}+ multiple+ ref={fileInputRef}+ style={UPLOAD_INPUT_STYLE}+ type="file"+ onChange={handleFileChange}+ />+ <Tooltip content={label}>+ <IconButton+ aria-label={label}+ color="fg.muted"+ disabled={isVirtualTarget}+ size="2xs"+ variant="ghost"+ onClick={handleUploadClick}+ >+ <Icon as={UploadIcon} boxSize="3.5" />+ </IconButton>+ </Tooltip>+ </>+ );+};diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWideLayout.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWideLayout.tsxindex 0c139b2d01..7c31c70cb6 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWideLayout.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWideLayout.tsx@@ -9,6 +9,7 @@ import { GalleryItemSearch } from './GalleryItemSearch';import { GalleryItemSortMenu } from './GalleryItemSortMenu';import { GallerySelectionBar } from './GallerySelectionBar';import { GallerySplitHandle } from './GallerySplitHandle';+import { GalleryUploadButton } from './GalleryUploadButton';import { GalleryViewTabs } from './GalleryViewTabs';import { useGalleryWidget } from './GalleryWidgetContext';@@ -69,6 +70,11 @@ export const GalleryWideLayout = () => {<GalleryItemSearch /></Box><GalleryItemSortMenu />+ <GalleryUploadButton+ boards={gallery.boards}+ selectedBoardId={gallery.selectedBoardId}+ onUploadFiles={actions.uploadFiles}+ /></HStack><Box flex="1" minH="0" minW="0" pb="2" pe="3" ps="3"><GalleryImageGrid />diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.browser.test.tsxindex cc54ee899b..c1ebf8630c 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.browser.test.tsx@@ -139,20 +139,12 @@ describe('GalleryWidgetLabel', () => {});describe('GalleryWidgetHeaderActions', () => {- it('offers upload and settings in every region, since the body renders neither', async () => {+ it('offers settings in every region, since the body renders neither (upload now lives in the toolbar)', async () => {for (const region of ['center', 'right'] as const) {await renderChrome(GalleryWidgetHeaderActions, { selectedBoardId: 'dogs' }, region);- expect(host?.querySelector('button[aria-label^="widgets.gallery.upload"]'), region).not.toBeNull();expect(host?.querySelector('button[aria-label="widgets.gallery.settings"]'), region).not.toBeNull();+ expect(host?.querySelector('button[aria-label^="widgets.gallery.upload"]'), region).toBeNull();}});-- it('disables upload for a date board, which cannot receive one', async () => {- await renderChrome(GalleryWidgetHeaderActions, { selectedBoardId: 'by_date:2026-07-30' });-- const upload = host?.querySelector<HTMLButtonElement>('button[aria-label^="widgets.gallery.upload"]');-- expect(upload?.disabled).toBe(true);- });});diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.tsxindex c49433c913..dc05feee92 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetChrome.tsx@@ -1,29 +1,22 @@-import type { GalleryBoard } from '@features/gallery/core/types';-import { HStack, Icon, Text } from '@chakra-ui/react';import { getGalleryBoardLabel } from '@features/gallery/core/boardLabels';import { getGallerySettings } from '@features/gallery/core/settings';-import { isDateBoardId } from '@features/gallery/data/backend';import { galleryBoardsOptions } from '@features/gallery/data/queries';-import { Button, IconButton } from '@platform/ui/Button';+import { Button } from '@platform/ui/Button';import { MiddleTruncate } from '@platform/ui/MiddleTruncate';-import { Tooltip } from '@platform/ui/Tooltip';import { useQuery } from '@tanstack/react-query';-import { ChevronsDownUpIcon, ChevronsUpDownIcon, UploadIcon } from 'lucide-react';-import { useCallback, useMemo, useRef } from 'react';+import { ChevronsDownUpIcon, ChevronsUpDownIcon } from 'lucide-react';+import { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import type { GalleryWidgetProps } from './GalleryUiContext';import { GallerySettingsMenu } from './GallerySettingsMenu';-import { getGallerySelectedBoardId, getGalleryView } from './galleryStateView';+import { getGallerySelectedBoardId } from './galleryStateView';import { useGalleryUi } from './GalleryUiContext';-import { useGalleryUploadAction } from './useGalleryUploadAction';type GalleryChromeProps = { region: GalleryWidgetProps['region'] };-const ACCEPTED_UPLOAD_EXTENSIONS = 'image/png,image/jpeg,image/webp,video/mp4,.png,.jpg,.jpeg,.webp,.mp4';-const UPLOAD_INPUT_STYLE = { display: 'none' } as const;const LABEL_EXPANDED_PROPS = { bg: 'transparent' } as const;const useGalleryChromeBoards = () => {@@ -48,19 +41,6 @@ const useGalleryChromeBoards = () => {};};-const useGalleryChromeActions = () => {- const { boards, galleryValues, selectedBoardId, ...rest } = useGalleryChromeBoards();- const galleryView = getGalleryView(galleryValues);- const currentGalleryLocationRef = useRef({ galleryView, selectedBoardId });-- // eslint-disable-next-line react/react-compiler- currentGalleryLocationRef.current = { galleryView, selectedBoardId };- const getCurrentGalleryLocation = useCallback(() => currentGalleryLocationRef.current, []);- const uploadFiles = useGalleryUploadAction({ boards, getCurrentGalleryLocation, selectedBoardId });-- return { ...rest, boards, galleryValues, selectedBoardId, uploadFiles };-};-export const GalleryWidgetLabel = ({ region }: GalleryChromeProps) => {const { t } = useTranslation();const { boards, gallery, selectedBoardId, settings } = useGalleryChromeBoards();@@ -102,72 +82,11 @@ export const GalleryWidgetLabel = ({ region }: GalleryChromeProps) => {};export const GalleryWidgetHeaderActions = (_props: GalleryChromeProps) => {- const { boards, gallery, selectedBoardId, settings, uploadFiles } = useGalleryChromeActions();+ const { gallery, settings } = useGalleryChromeBoards();return (<HStack gap="0.5">- <GalleryUploadButton boards={boards} selectedBoardId={selectedBoardId} onUploadFiles={uploadFiles} /><GallerySettingsMenu settings={settings} onUpdateSettings={gallery.updateSettings} /></HStack>);};--const GalleryUploadButton = ({- boards,- selectedBoardId,- onUploadFiles,-}: {- boards: GalleryBoard[];- selectedBoardId: string;- onUploadFiles: (files: File[]) => Promise<void>;-}) => {- const { t } = useTranslation();- const fileInputRef = useRef<HTMLInputElement>(null);- const selectedBoard = boards.find((board) => board.id === selectedBoardId);- const isVirtualTarget = isDateBoardId(selectedBoardId);- const label = isVirtualTarget- ? t('widgets.gallery.uploadsUnavailableForDateBoards')- : t('widgets.gallery.uploadMediaToBoard', {- name: selectedBoard ? getGalleryBoardLabel(selectedBoard, t) : t('widgets.gallery.selectedBoardFallback'),- });-- const handleFileChange = useCallback(- (event: React.ChangeEvent<HTMLInputElement>) => {- const files = Array.from(event.currentTarget.files ?? []);-- event.currentTarget.value = '';-- if (files.length > 0) {- void onUploadFiles(files);- }- },- [onUploadFiles]- );-- const handleUploadClick = useCallback(() => fileInputRef.current?.click(), []);-- return (- <>- <input- accept={ACCEPTED_UPLOAD_EXTENSIONS}- multiple- ref={fileInputRef}- style={UPLOAD_INPUT_STYLE}- type="file"- onChange={handleFileChange}- />- <Tooltip content={label}>- <IconButton- aria-label={label}- color="fg.muted"- disabled={isVirtualTarget}- size="2xs"- variant="ghost"- onClick={handleUploadClick}- >- <Icon as={UploadIcon} boxSize="3.5" />- </IconButton>- </Tooltip>- </>- );-};