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(gallery): rule off the starred section from the regular grid
Josh Corbett165187018f18
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 27992e8678..272c2d5bb9 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@@ -17,6 +17,7 @@ import { sortableKeyboardCoordinates } from '@dnd-kit/sortable';import { requestGalleryItemReveal } from '@features/gallery/core/selection';import { getGallerySettings } from '@features/gallery/core/settings';import { GalleryUiProvider, type GalleryUiAdapter } from '@features/gallery/react';+import { GALLERY_STARRED_SEPARATOR_HEIGHT_PX } from '@features/gallery/ui/galleryGridLayout';import { isGalleryImageDragData } from '@features/gallery/utility';import { parseDateTokens } from '@platform/search/dateTokens';import { accountLifecycle } from '@platform/state/accountLifecycle';@@ -573,7 +574,9 @@ describe('GalleryImageGrid mixed item cells', () => {expect((headerRect?.top ?? 0) - (listRect?.top ?? 0)).toBeCloseTo(0, 0);expect(starredRect.top - (headerRect?.bottom ?? 0)).toBeLessThan(4);- expect(regularRect.top - starredRect.bottom).toBeCloseTo(12, 0);+ // The trailing gap holds a hairline separator while the section is open.+ expect(regularRect.top - starredRect.bottom).toBeCloseTo(8 + GALLERY_STARRED_SEPARATOR_HEIGHT_PX, 0);+ expect(host?.querySelector('[data-gallery-starred-separator]')).not.toBeNull();await click(getButton('Collapse starred items'));@@ -584,6 +587,7 @@ describe('GalleryImageGrid mixed item cells', () => {expect((collapsedHeaderRect?.top ?? 0) - (listRect?.top ?? 0)).toBeCloseTo(0, 0);expect(collapsedSectionGap).toBeGreaterThanOrEqual(4);expect(collapsedSectionGap).toBeLessThan(8);+ expect(host?.querySelector('[data-gallery-starred-separator]')).toBeNull();});it('collapses only the starred items and omits the disclosure when no stars are loaded', async () => {diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsxindex 9a639c6b3c..8a369b870b 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryImageGrid.tsx@@ -29,6 +29,7 @@ import {buildGalleryGridRows,GALLERY_GRID_GAP_PX,GALLERY_STARRED_HEADER_HEIGHT_PX,+ GALLERY_STARRED_SEPARATOR_HEIGHT_PX,getGalleryCellSizePx,getGalleryColumnCount,getGalleryGridRowHeightPx,@@ -473,14 +474,33 @@ export const GalleryImageGrid = () => {{virtualRows.map((virtualRow) => {const row = rows[virtualRow.index];- return row?.kind === 'starred-header' ? (- <GalleryStarredSectionHeader+ if (row?.kind === 'starred-header') {+ return (+ <GalleryStarredSectionHeader+ key={virtualRow.key}+ isOpen={isStarredOpen}+ itemCount={row.itemCount}+ offsetPx={virtualRow.start}+ onToggle={handleToggleStarredSection}+ />+ );+ }++ return row?.kind === 'starred-gap' && row.withSeparator ? (+ <Flexkey={virtualRow.key}- isOpen={isStarredOpen}- itemCount={row.itemCount}- offsetPx={virtualRow.start}- onToggle={handleToggleStarredSection}- />+ aria-hidden="true"+ data-gallery-starred-separator+ align="center"+ h={`${GALLERY_STARRED_SEPARATOR_HEIGHT_PX}px`}+ left="0"+ position="absolute"+ top="0"+ transform={`translateY(${virtualRow.start}px)`}+ w="full"+ >+ <Box bg="border.subtle" h="1px" w="full" />+ </Flex>) : null;})}<Boxdiff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryGridLayout.test.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryGridLayout.test.tsindex 9570a73c6d..0644ac1b37 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryGridLayout.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryGridLayout.test.ts@@ -8,6 +8,7 @@ import {buildGalleryGridRows,GALLERY_GRID_GAP_PX,GALLERY_STARRED_HEADER_HEIGHT_PX,+ GALLERY_STARRED_SEPARATOR_HEIGHT_PX,getGalleryCellSizePx,getGalleryColumnCount,getGalleryGridRowHeightPx,@@ -124,14 +125,16 @@ describe('buildGalleryGridRows', () => {expect(rows.map((row) => row.kind)).toEqual(['starred-header', 'cells', 'starred-gap', 'cells']);expect(rows[0]?.kind === 'starred-header' && rows[0].itemCount).toBe(1);expect(rows[1]?.kind === 'cells' && rows[1].section).toBe('starred');+ expect(rows[2]?.kind === 'starred-gap' && rows[2].withSeparator).toBe(true);expect(rows[3]?.kind === 'cells' && rows[3].section).toBe('regular');});- it('keeps the header but drops the starred rows while collapsed', () => {+ it('keeps the header but drops the starred rows and the separator while collapsed', () => {const items = [createImageItem('starred-1', true), createImageItem('regular-1')];const rows = buildRows({ isStarredOpen: false, items });expect(rows.map((row) => row.kind)).toEqual(['starred-header', 'starred-gap', 'cells']);+ expect(rows[1]?.kind === 'starred-gap' && rows[1].withSeparator).toBe(false);});it('keeps regular row keys stable across a starred collapse so their cells are not recreated', () => {@@ -198,11 +201,16 @@ describe('buildGalleryGridRows', () => {describe('getGalleryGridRowHeightPx', () => {it('sizes chrome rows by their own constants and cell rows by the shared row height', () => {- const rows = buildRows({ items: [createImageItem('starred-1', true), createImageItem('regular-1')] });+ const items = [createImageItem('starred-1', true), createImageItem('regular-1')];- expect(rows.map((row) => getGalleryGridRowHeightPx(row, 100))).toEqual([+ expect(buildRows({ items }).map((row) => getGalleryGridRowHeightPx(row, 100))).toEqual([GALLERY_STARRED_HEADER_HEIGHT_PX,100,+ GALLERY_STARRED_SEPARATOR_HEIGHT_PX,+ 100,+ ]);+ expect(buildRows({ isStarredOpen: false, items }).map((row) => getGalleryGridRowHeightPx(row, 100))).toEqual([+ GALLERY_STARRED_HEADER_HEIGHT_PX,GALLERY_GRID_GAP_PX,100,]);diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryGridLayout.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryGridLayout.tsindex cda6bc9f62..c1938850ef 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryGridLayout.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryGridLayout.ts@@ -9,6 +9,8 @@ import { getGalleryPlaceholderInsertionIndex } from './galleryStateView';export const GALLERY_GRID_GAP_PX = 4;export const GALLERY_STARRED_HEADER_HEIGHT_PX = 24;+/** The gap row grows to hold a hairline rule while the starred section is open. */+export const GALLERY_STARRED_SEPARATOR_HEIGHT_PX = 13;const GALLERY_MIN_COLUMN_COUNT = 2;const GALLERY_MAX_COLUMN_COUNT = 12;@@ -61,7 +63,7 @@ export type GalleryGridSection = 'regular' | 'starred';export type GalleryGridRow =| { cells: GalleryGridCell[]; key: string; kind: 'cells'; section: GalleryGridSection }- | { key: string; kind: 'starred-gap' }+ | { key: string; kind: 'starred-gap'; withSeparator: boolean }| { itemCount: number; key: string; kind: 'starred-header' };const getGalleryGridCellKey = (cell: GalleryGridCell): string =>@@ -149,7 +151,9 @@ export const buildGalleryGridRows = ({}if (regularCells.length > 0) {- rows.push({ key: 'starred-gap', kind: 'starred-gap' });+ // A visible rule only while the starred cells are showing; collapsed, the+ // header already separates the sections.+ rows.push({ key: 'starred-gap', kind: 'starred-gap', withSeparator: isStarredOpen });}}@@ -165,7 +169,7 @@ export const getGalleryGridRowHeightPx = (row: GalleryGridRow, cellRowHeightPx:}if (row.kind === 'starred-gap') {- return GALLERY_GRID_GAP_PX;+ return row.withSeparator ? GALLERY_STARRED_SEPARATOR_HEIGHT_PX : GALLERY_GRID_GAP_PX;}return cellRowHeightPx;