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(webv2): widen the gallery picker to every project's boards
Josh Corbette93685f588de
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRowShell.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRowShell.tsxindex 726581e466..236a84e3a9 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRowShell.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardRowShell.tsx@@ -7,7 +7,8 @@ import { useMemo, type MouseEvent, type ReactNode, type Ref } from 'react';const ROW_CONTAINER_CSS = {'&:hover .board-row-actions, &:focus-within .board-row-actions': { opacity: 1 },'&:hover .board-row-hover, &:focus-within .board-row-hover': { opacity: 1 },- _hover: { bg: 'bg.muted' },+ // A tint rather than a surface token: the picker popover's own background is bg.muted, which hid the hover there.+ _hover: { bg: 'gray.hoverTint/10' },borderRadius: 'sm',transition: 'background var(--wb-motion-duration-fast) ease',} as const;diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryViewTabs.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryViewTabs.tsxindex 8f93d2fd35..0ec7cb526e 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryViewTabs.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryViewTabs.tsx@@ -1,7 +1,8 @@import type { GalleryBoard, GalleryView } from '@features/gallery/core/types';-import { Text } from '@chakra-ui/react';+import { Icon, Text } from '@chakra-ui/react';import { SegmentTabs } from '@platform/ui';+import { ImagesIcon, ImageUpIcon, type LucideIcon } from 'lucide-react';import { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';@@ -9,19 +10,22 @@ import { getGalleryCountForView } from './galleryBoardLabels';import { useGalleryWidget } from './GalleryWidgetContext';const GALLERY_VIEW_TABS = [- { labelKey: 'common.media', value: 'images' },- { labelKey: 'common.assets', value: 'assets' },-] satisfies { labelKey: string; value: GalleryView }[];+ { icon: ImagesIcon, labelKey: 'common.media', value: 'images' },+ { icon: ImageUpIcon, labelKey: 'common.assets', value: 'assets' },+] satisfies { icon: LucideIcon; labelKey: string; value: GalleryView }[];/** Wire the caller's grid to segmentTabsPanelId(idBase); tab counts distinguish Media and Assets before switching. */export const GalleryViewSegmentTabs = ({activeView,board,+ iconLabels = false,idBase,onSelect,}: {activeView: GalleryView;board: GalleryBoard | undefined;+ /** Icons in place of the view names, for headers too narrow to spare the words; the names become tooltips. */+ iconLabels?: boolean;idBase: string;onSelect: (view: GalleryView) => void;}) => {@@ -40,14 +44,16 @@ export const GalleryViewSegmentTabs = ({const tabs = useMemo(() =>- GALLERY_VIEW_TABS.map(({ labelKey, value }) => {+ GALLERY_VIEW_TABS.map(({ icon, labelKey, value }) => {const count = board ? getGalleryCountForView(board, value) : null;+ const name = t(labelKey);return {+ ariaLabel: iconLabels ? (count === null ? name : `${name} ${count}`) : undefined,id: value,label: (- <Text as="span" display="flex" gap="1.5">- {t(labelKey)}+ <Text alignItems="center" as="span" display="flex" gap="1.5">+ {iconLabels ? <Icon as={icon} aria-hidden boxSize="3.5" /> : name}{count === null ? null : (<Text as="span" color="currentColor" fontVariantNumeric="tabular-nums" opacity="0.8">{count}@@ -57,7 +63,7 @@ export const GalleryViewSegmentTabs = ({),};}),- [board, t]+ [board, iconLabels, t]);return (diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerGrid.tsxindex a5203c78c5..0120ba62dc 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerGrid.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerGrid.tsx@@ -36,12 +36,12 @@ const ACTIVE_TILE_CSS: SystemStyleObject = {outlineOffset: '-4px',};-const PICKABLE_TILE_CSS: SystemStyleObject = { cursor: 'pointer' };+// Tiles keep the default arrow like every other control; only full or unsupported ones say they won't pick.+const TILE_CSS: SystemStyleObject = { cursor: 'default' };const INERT_TILE_CSS: SystemStyleObject = { cursor: 'not-allowed', opacity: 0.35 };-const ADDED_TILE_CSS: SystemStyleObject = { cursor: 'default' };const getTileCss = (state: GalleryPickerTileState, isActive: boolean): SystemStyleObject => {- const base = state === 'pickable' ? PICKABLE_TILE_CSS : state === 'added' ? ADDED_TILE_CSS : INERT_TILE_CSS;+ const base = state === 'pickable' || state === 'added' ? TILE_CSS : INERT_TILE_CSS;return isActive ? { ...base, ...ACTIVE_TILE_CSS } : base;};diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerPopover.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerPopover.browser.test.tsxindex abff4a8c17..93eae1219c 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerPopover.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerPopover.browser.test.tsx@@ -81,7 +81,9 @@ const uncategorized: GalleryBoard = {kind: 'uncategorized',name: '',};-const boards = [board, uncategorized];+/** Another project's board: the Gallery widget hides these by default, the picker lists them. */+const otherProjectBoard: GalleryBoard = { ...board, id: 'cats', imageCount: 0, name: 'Cats', projectId: 'project-b' };+const boards = [board, uncategorized, otherProjectBoard];/** Newest first, matching the picker's DESC order. */const ORDER = ['a.png', 'b.png', 'c.mp4', 'cat.png', 'e.png', 'f.png', 'loose.png'];@@ -369,9 +371,11 @@ describe('GalleryPickerPopover', () => {it('switches to the Assets view from the tabs', async () => {const { dialog } = await openPicker();+ // Icons label the tabs in the picker's narrow header; the view names stay their accessible names.const assetsTab = [...dialog.querySelectorAll<HTMLButtonElement>('[role="tab"]')].find((tab) =>- tab.textContent?.includes('common.assets')+ tab.getAttribute('aria-label')?.startsWith('common.assets'));+ expect(assetsTab?.textContent).not.toContain('common.assets');await act(() => assetsTab?.click());await settle();@@ -424,6 +428,7 @@ describe('GalleryPickerPopover', () => {expect(input.value).toBe('');expect(getStatus(dialog)).toBe('widgets.gallery.picker.boardCount');expect(getBoardRow(dialog, 'Dogs')?.getAttribute('aria-current')).toBe('true');+ expect(getBoardRow(dialog, 'Cats')).toBeDefined();// Enter with an empty search must not silently switch boards.await pressKey(input, 'Enter');diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerPopover.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerPopover.tsxindex 905d7964de..7a248e402a 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerPopover.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerPopover.tsx@@ -69,7 +69,7 @@ export const GalleryPickerPopover = ({flexDirection="column"maxH="min(26rem, var(--available-height))"p="0"- w="clamp(18rem, var(--reference-width), 28rem)"+ w="clamp(20rem, var(--reference-width), 28rem)"><Suspense fallback={PICKER_FALLBACK}><GalleryPickerViewdiff --git a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerView.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerView.tsxindex 5dbe710301..6900376f3d 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerView.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryPickerView.tsx@@ -178,7 +178,8 @@ export const GalleryPickerView = ({searchTerm: scope.searchTerm,showArchived: settings.showArchivedBoards,showDates: settings.showDateBoards,- showOtherProjects: settings.showOtherProjectBoards,+ // A pick can come from any project's board, whatever the Gallery widget hides for browsing.+ showOtherProjects: true,t,});@@ -194,7 +195,6 @@ export const GalleryPickerView = ({scope.searchTerm,settings.showArchivedBoards,settings.showDateBoards,- settings.showOtherProjectBoards,t,]);const visibleBoardCount = boardGroups.reduce((count, group) => count + group.boards.length, 0);@@ -376,6 +376,7 @@ export const GalleryPickerView = ({<GalleryViewSegmentTabsactiveView={scope.galleryView}board={selectedBoard}+ iconLabelsidBase={idBase}onSelect={setView}/>diff --git a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsxindex a3de652959..a2e1f42039 100644--- a/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/SegmentTabs.tsx@@ -3,6 +3,8 @@ import type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';import { Box, chakra, HStack, Text } from '@chakra-ui/react';import { Fragment, useCallback } from 'react';+import { Tooltip } from './Tooltip';+const TAB_HOVER_PROPS = { bg: 'gray.hoverTint/8', color: 'fg' };const TAB_SHOWN_BG = 'gray.hoverTint/15';@@ -13,6 +15,8 @@ export interface SegmentTab<T extends string = string> {id: T;/** Usually a string; gallery tabs carry a dimmed count span. */label: ReactNode;+ /** The tab's name when its label is an icon; it is also shown as the tab's tooltip. */+ ariaLabel?: string;}/** Roving focus for a horizontal tablist: arrows cycle, Home/End jump. */@@ -92,6 +96,7 @@ export const SegmentTabs = <T extends string>({/>) : null}<SegmentTabButton+ ariaLabel={tab.ariaLabel}id={tab.id}idBase={idBase}isSelected={tab.id === activeId}@@ -110,6 +115,7 @@ export const segmentTabsPanelId = (idBase: string): string => `${idBase}-panel`;export const segmentTabsTabId = (idBase: string, tabId: string): string => `${idBase}-tab-${tabId}`;const SegmentTabButton = <T extends string>({+ ariaLabel,id,idBase,isSelected,@@ -117,6 +123,7 @@ const SegmentTabButton = <T extends string>({label,onSelect,}: {+ ariaLabel?: string;id: T;idBase: string;isSelected: boolean;@@ -127,9 +134,10 @@ const SegmentTabButton = <T extends string>({}) => {const select = useCallback(() => onSelect(id), [id, onSelect]);- return (+ const button = (<chakra.buttonaria-controls={isShown ? segmentTabsPanelId(idBase) : undefined}+ aria-label={ariaLabel}aria-selected={isSelected}bg={isShown ? TAB_SHOWN_BG : 'transparent'}color={isShown ? 'fg' : 'fg.muted'}@@ -153,4 +161,6 @@ const SegmentTabButton = <T extends string>({</Text></chakra.button>);++ return ariaLabel ? <Tooltip content={ariaLabel}>{button}</Tooltip> : button;};