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(gallery): keep the board name in step with a project rename
Josh Corbettd0b88307ca6d
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsxindex 02fc85dc89..5f4a933264 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.browser.test.tsx@@ -183,9 +183,10 @@ describe('GalleryBoardsPanel', () => {await renderPanel({ ...createGallery(), boards: ownedBoards, projectBoardId: 'cats' } as GalleryStateView);- const catsRow = getBoardRows().find((row) => row.textContent?.includes('Cats'));+ // The hoisted row shows the live project name, not the stored board name.+ const projectRow = getBoardRows().find((row) => row.textContent?.includes('Project'));- expect(catsRow?.textContent).toContain('common.project');+ expect(projectRow?.textContent).toContain('common.project');});it('shows media and asset counts together, so the row does not change meaning with the tab', async () => {diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.test.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.test.tsindex 2c1f5bb010..17380ef4ab 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.test.ts@@ -70,6 +70,21 @@ describe('getGalleryBoardGroups', () => {expect(groups.yourBoards.map((board) => board.id)).toEqual(['none', 'mine', 'dogs', 'cats']);});+ /** The fetched list can lag a rename; the live project name wins for the open project's row. */+ it('shows the open project board under the live project name, and searches by it', () => {+ const groups = groupsOf({ projectBoardId: 'mine', projectName: 'Renamed' });++ expect(groups.yourBoards.find((board) => board.id === 'mine')?.name).toBe('Renamed');+ expect(+ groupsOf({ projectBoardId: 'mine', projectName: 'Renamed', searchTerm: 'renamed' }).yourBoards+ ).toContainEqual(expect.objectContaining({ id: 'mine' }));+ expect(+ groupsOf({ projectBoardId: 'mine', projectName: 'Renamed', searchTerm: 'My project' }).yourBoards.map(+ (board) => board.id+ )+ ).not.toContain('mine');+ });+it('filters every section by a case-insensitive substring match', () => {const groups = groupsOf({ searchTerm: 'DOG' });diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.tsindex 6d05717c04..fdcb920fbc 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.ts@@ -46,8 +46,10 @@ export const getGalleryBoardGroups = ({const matchesSearch = (name: string) => !normalizedSearchTerm || name.toLowerCase().includes(normalizedSearchTerm);const uncategorizedBoard = boards.find((board) => board.kind === 'uncategorized') ?? null;- const projectBoard = projectBoardId ? (boards.find((board) => board.id === projectBoardId) ?? null) : null;- const projectRowName = projectBoard?.name ?? projectName;+ const fetchedProjectBoard = projectBoardId ? (boards.find((board) => board.id === projectBoardId) ?? null) : null;+ // The board renames with its project server-side, but the fetched list can lag+ // a rename — the live project name is authoritative for the open project's row.+ const projectBoard = fetchedProjectBoard ? { ...fetchedProjectBoard, name: projectName } : null;const matchesBoardSearch = (board: GalleryBoard) => matchesSearch(getGalleryBoardLabel(board, t));// The open project's own board is never "another project's", whatever the@@ -75,7 +77,7 @@ export const getGalleryBoardGroups = ({const hasAnyMatch = yourBoards.length > 0 || dateBoards.length > 0 || archivedBoards.length > 0;const hasExactMatch =boards.some((board) => getGalleryBoardLabel(board, t).toLowerCase() === normalizedSearchTerm) ||- projectRowName.toLowerCase() === normalizedSearchTerm;+ projectName.toLowerCase() === normalizedSearchTerm;return {archivedBoards,diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.browser.test.tsxindex 4ec9e26e19..2c981917f6 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.browser.test.tsx@@ -92,6 +92,7 @@ vi.mock('@workbench/launchpad/formatRelativeTime', () => ({ formatRelativeTime:vi.mock('@workbench/projects/components', () => ({ OpenProjectDialog: () => null }));vi.mock('@workbench/projects/library', () => ({refreshProjectLibrary: vi.fn(() => Promise.resolve()),+ renameLibraryProject: vi.fn(() => Promise.resolve()),useProjectLibrarySelector: (selector: (snapshot: { summaries: [] }) => unknown) => selector({ summaries: [] }),}));vi.mock('@workbench/projects/useProjectActions', () => ({diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsxindex 5173c7ac54..35701a915e 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx@@ -11,10 +11,11 @@ import { ConfirmDialog } from '@platform/ui/ConfirmDialog';import { MenuContent } from '@platform/ui/Menu';import { MiddleTruncate } from '@platform/ui/MiddleTruncate';import { RenameDialog } from '@platform/ui/RenameDialog';+import { toaster } from '@platform/ui/toaster';import { QueueCircularProgress } from '@workbench/components/QueueProgressIndicator';import { formatRelativeTime } from '@workbench/launchpad/formatRelativeTime';import { OpenProjectDialog } from '@workbench/projects/components';-import { refreshProjectLibrary, useProjectLibrarySelector } from '@workbench/projects/library';+import { refreshProjectLibrary, renameLibraryProject, useProjectLibrarySelector } from '@workbench/projects/library';import { useProjectActions } from '@workbench/projects/useProjectActions';import { useExportOpenProject } from '@workbench/projects/useProjectFileActions';import { useOpenWorkbenchWidget } from '@workbench/useOpenWorkbenchWidget';@@ -81,13 +82,27 @@ export const ProjectSwitcher = () => {const hideOpenDialog = useCallback(() => setIsOpenDialogVisible(false), []);const closeRenameDialog = useCallback(() => setRenameTarget(null), []);const closeDeleteDialog = useCallback(() => setDeleteTarget(null), []);+ // Through the library, not the bare store command: the library path flushes+ // an open project immediately, which is what renames its board on the server.const renameProject = useCallback(- (name: string) => {- if (renameTarget) {- projects.rename(renameTarget.id, name);+ async (name: string) => {+ if (!renameTarget) {+ return;+ }++ try {+ await renameLibraryProject(renameTarget.id, name);+ } catch (error) {+ toaster.create({+ description: error instanceof Error ? error.message : undefined,+ title: t('projects.renameFailed'),+ type: 'error',+ });+ // The rename dialog stays open on a rejection, so the user keeps their input.+ throw error;}},- [projects, renameTarget]+ [renameTarget, t]);const confirmDeleteProject = useCallback(async () => {const project = deleteTarget ? getProject(deleteTarget.id) : null;