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): remove the project-board dead ends left by the server owning boards
Josh Corbett0b5bb8d32db5
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.jsonindex 6d6d5962a0..194847cf6b 100644--- a/invokeai/frontend/webv2/performance/architecture-baseline.json+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json@@ -2,15 +2,15 @@"build": {"launchpad": {"baseline": {- "brotliBytes": 826351,+ "brotliBytes": 826868,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 825960,+ "gzipBytes": 826468,"imageRawBytes": 156376,- "initialRawBytes": 1919126,+ "initialRawBytes": 1920562,"largestAssetRawBytes": 746170,"otherAssetRawBytes": 0,- "ownedRawBytes": 66207,+ "ownedRawBytes": 66295,"requestCount": 35,"scriptRequestCount": 19,"sourceOwners": [@@ -273,15 +273,15 @@]},"limits": {- "brotliBytes": 834615,+ "brotliBytes": 835137,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 834220,+ "gzipBytes": 834733,"imageRawBytes": 157940,- "initialRawBytes": 1938318,+ "initialRawBytes": 1939768,"largestAssetRawBytes": 753632,"otherAssetRawBytes": 0,- "ownedRawBytes": 66207,+ "ownedRawBytes": 66295,"requestCount": 35,"scriptRequestCount": 19},@@ -291,12 +291,12 @@},"editor": {"baseline": {- "brotliBytes": 1009372,+ "brotliBytes": 1009800,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 1006745,+ "gzipBytes": 1007220,"imageRawBytes": 156376,- "initialRawBytes": 2471744,+ "initialRawBytes": 2473503,"largestAssetRawBytes": 746170,"otherAssetRawBytes": 0,"ownedRawBytes": 113633,@@ -796,12 +796,12 @@]},"limits": {- "brotliBytes": 1019466,+ "brotliBytes": 1019898,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 1016813,+ "gzipBytes": 1017293,"imageRawBytes": 157940,- "initialRawBytes": 2496462,+ "initialRawBytes": 2498239,"largestAssetRawBytes": 753632,"otherAssetRawBytes": 0,"ownedRawBytes": 113633,diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 3eb0b8b89e..bc2f72b3dd 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -464,6 +464,8 @@"projectDuplicated": "Project duplicated","projectDuplicatedDescription": "\"{{name}}\" was created.","renameFailed": "Rename failed",+ "renameProject": "Rename project",+ "renameProjectNameLabel": "Project name","renameWithEllipsis": "Rename…","searchLabel": "Search projects","searchPlaceholder": "Search projects…",@@ -2665,7 +2667,6 @@"oldest": "Oldest","pagination": "Pagination","preparingDownload": "Preparing download",- "projectBoardCreated": "Created project board \"{{name}}\"","renameBoard": "Rename board","resizeBoardPanel": "Resize board panel","searchHelpDate": "A single day.",diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.tsxindex 02005ea126..5bf8d4d346 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardMenu.tsx@@ -4,7 +4,7 @@ import type { GalleryBoard } from '@features/gallery/core/types';import { Dialog, HStack, Icon, Input, Menu, Portal, Stack, Text } from '@chakra-ui/react';import { Button } from '@platform/ui/Button';import { MenuContent } from '@platform/ui/Menu';-import { ArchiveIcon, DownloadIcon, PencilIcon, Trash2Icon, type LucideIcon } from 'lucide-react';+import { ArchiveIcon, DownloadIcon, FileDownIcon, PencilIcon, Trash2Icon, type LucideIcon } from 'lucide-react';import { useCallback, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -30,7 +30,7 @@ export const GalleryBoardMenu = ({onClose: () => void;}) => {const { t } = useTranslation();- const { actions } = useGalleryWidget();+ const { actions, gallery } = useGalleryWidget();const [renameTarget, setRenameTarget] = useState<GalleryBoard | null>(null);const [deleteTarget, setDeleteTarget] = useState<GalleryBoard | null>(null);const [renameValue, setRenameValue] = useState('');@@ -42,7 +42,12 @@ export const GalleryBoardMenu = ({// A project's board can be downloaded but never renamed, archived, or deleted: those follow// the project. This covers every project's board, not just the open one — the server refuses// all of them, so offering the action anywhere would only produce a 409.- const isManagedBoard = board !== null && board.kind === 'board' && board.projectId === null;+ //+ // The open project's own board is checked locally as well. `project_id` is omitted rather than+ // nulled by the backend's DTO, so a response that has lost it would make the project's board+ // look ordinary — offering a rename that 409s and dropping the badge that explains why.+ const isManagedBoard =+ board !== null && board.kind === 'board' && board.projectId === null && board.id !== gallery.projectBoardId;const positioning = useMemo(() => ({getAnchorRect: () => {@@ -133,7 +138,12 @@ export const GalleryBoardMenu = ({<Menu.Positioner>{board && (<MenuContent minW="12rem">- {board.projectId !== null && <BoardExportProjectMenuItem board={board} />}+ {board.projectId !== null && (+ <>+ <BoardExportProjectMenuItem board={board} />+ <Menu.Separator />+ </>+ )}<BoardDownloadMenuItem board={board} />{isManagedBoard && (<>@@ -243,7 +253,7 @@ const BoardExportProjectMenuItem = ({ board }: { board: GalleryBoard }) => {return (<BoardMenuItem- icon={DownloadIcon}+ icon={FileDownIcon}label={t('widgets.gallery.exportProjectFromBoard')}value="export-project"onClick={handleClick}diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.tsxindex 409e59398c..6c93635dfc 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryBoardsPanel.tsx@@ -2,11 +2,11 @@ import type { GalleryItemKey } from '@features/gallery/core/items';import type { GalleryBoardSectionId } from '@features/gallery/core/settings';import type { GalleryBoard } from '@features/gallery/core/types';-import { Badge, HStack, Icon, ScrollArea, Stack, Text } from '@chakra-ui/react';+import { HStack, Icon, ScrollArea, Stack, Text } from '@chakra-ui/react';import { toGalleryItemKey } from '@features/gallery/core/items';import { IconButton } from '@platform/ui/Button';import { Tooltip } from '@platform/ui/Tooltip';-import { PinIcon, PlusIcon } from 'lucide-react';+import { PlusIcon } from 'lucide-react';import { useCallback, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -20,7 +20,6 @@ import { GalleryBoardSection } from './GalleryBoardSection';import { useGalleryWidget } from './GalleryWidgetContext';const SCROLL_CONTENT_PROPS = { py: '1' } as const;-const PROJECT_ROW_COVER = <BoardCoverIcon icon={PinIcon} />;const CREATE_ROW_COVER = <BoardCoverIcon icon={PlusIcon} />;/**@@ -94,11 +93,6 @@ export const GalleryBoardsPanel = () => {[actions]);- const handleSelectProjectBoard = useCallback(() => {- setSearchTerm('');- void actions.selectProjectBoard();- }, [actions]);-const openBoardMenu = useCallback((board: GalleryBoard, x: number, y: number) => {setBoardMenuTarget({ board, x, y });}, []);@@ -153,13 +147,6 @@ export const GalleryBoardsPanel = () => {sectionId="boards"onToggle={handleToggleSection}>- {groups.hasProjectBoardPlaceholder ? (- <GalleryBoardRowShell cover={PROJECT_ROW_COVER} label={projectName} onSelect={handleSelectProjectBoard}>- <Badge colorPalette="accent" flexShrink={0} size="xs" variant="subtle">- {t('common.project')}- </Badge>- </GalleryBoardRowShell>- ) : null}{groups.yourBoards.map((board) => (<GalleryBoardRowkey={board.id}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 7f12832262..c37e90e9a2 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@@ -309,7 +309,6 @@ const createAdapter = (): GalleryUiAdapter =>setItemMultiSelection: noop,setPage: noop,setPageInfo: noop,- setProjectBoard: noop,setSearchTerm: noop,setView: noop,toggleItemSelection: noop,diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsxindex 17d0685d1d..08ab418907 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx@@ -54,7 +54,6 @@ export interface GalleryCommandsPort {setItemMultiSelection(itemKeys: GalleryItemKey[], primaryItem: GalleryItem): void;setPage(page: number): void;setPageInfo(totalImages: number): void;- setProjectBoard(boardId: string): void;setSearchTerm(searchTerm: string): void;setView(view: GalleryView): void;toggleItemSelection(item: GalleryItem, nextPrimaryItem: GalleryItem | null): void;diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsxindex 358f8e4061..64b9513e4a 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetContext.tsx@@ -27,8 +27,6 @@ export interface GalleryActions {selectBoard: (boardId: string) => void;selectItem: (item: GalleryItem) => void;selectItemRange: (items: GalleryItemRef[], primaryItem: GalleryItem) => void;- /** Select the project's own board. It always exists, so this never creates one. */- selectProjectBoard: () => void;setCompareItem: (image: GalleryImageItem | null) => void;setSearchTerm: (searchTerm: string) => void;setView: (galleryView: GalleryView) => void;diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsxindex 721f569c2f..33f065f6fc 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryWidgetView.tsx@@ -15,7 +15,6 @@ import { GalleryBoardDragMonitor } from './GalleryBoardDragMonitor';import { GalleryLayout } from './GalleryLayout';import {getGalleryPage,- getGalleryProjectBoardId,getGallerySearchTerm,getGallerySelectedBoardId,getGalleryStateView,@@ -133,7 +132,6 @@ export const GalleryWidgetView = ({ presentation, region, runtime }: GalleryWidgboards: data.boards,getCurrentGalleryLocation,loadMore,- projectBoardId: getGalleryProjectBoardId(galleryValues),selectedBoardId,});diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.test.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.test.tsindex 22f4dba423..d0e53301bf 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.test.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.test.ts@@ -79,16 +79,12 @@ describe('getGalleryBoardGroups', () => {expect(groupsOf({ searchTerm: 'Uncategorized' }).canCreateFromSearch).toBe(false);});- it('treats the yet-to-exist project board as an exact match so it is never duplicated', () => {- const groups = groupsOf({ searchTerm: 'Project' });-- expect(groups.hasProjectBoardPlaceholder).toBe(true);- expect(groups.canCreateFromSearch).toBe(false);- expect(groups.hasAnyMatch).toBe(true);- });-- it('drops the project placeholder once the project board exists', () => {- expect(groupsOf({ projectBoardId: 'cats' }).hasProjectBoardPlaceholder).toBe(false);+ /**+ * The board is not in the list yet — it is still loading — but it exists, and offering to create+ * one under its own name would be offering to make a second.+ */+ it('treats the project board name as an exact match even before the board arrives', () => {+ expect(groupsOf({ searchTerm: 'Project' }).canCreateFromSearch).toBe(false);});it('reports no match when the search excludes every row', () => {diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.tsindex 3258d9112f..593abb37b6 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryBoardGroups.ts@@ -10,11 +10,6 @@ export interface GalleryBoardGroups {dateBoards: GalleryBoard[];/** Any row at all survived the search — drives the "no matches" copy. */hasAnyMatch: boolean;- /**- * True when the project has no board yet and the search does not hide the- * row, so the panel can offer to create one on demand.- */- hasProjectBoardPlaceholder: boolean;/** Project board (if any), then other boards, then Uncategorized last. */yourBoards: GalleryBoard[];}@@ -63,9 +58,7 @@ export const getGalleryBoardGroups = ({...(uncategorizedBoard && matchesBoardSearch(uncategorizedBoard) ? [uncategorizedBoard] : []),];- const hasProjectBoardPlaceholder = projectBoard === null && matchesSearch(projectRowName);- const hasAnyMatch =- yourBoards.length > 0 || dateBoards.length > 0 || archivedBoards.length > 0 || hasProjectBoardPlaceholder;+ const hasAnyMatch = yourBoards.length > 0 || dateBoards.length > 0 || archivedBoards.length > 0;const hasExactMatch =boards.some((board) => getGalleryBoardLabel(board, t).toLowerCase() === normalizedSearchTerm) ||projectRowName.toLowerCase() === normalizedSearchTerm;@@ -75,7 +68,6 @@ export const getGalleryBoardGroups = ({canCreateFromSearch: normalizedSearchTerm.length > 0 && !hasExactMatch,dateBoards,hasAnyMatch,- hasProjectBoardPlaceholder,yourBoards,};};diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsxindex 737cc32881..dfe02b5bc6 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.browser.test.tsx@@ -135,7 +135,6 @@ const Probe = ({},],loadMore: vi.fn(),- projectBoardId: null,selectedBoardId,getCurrentGalleryLocation,});@@ -164,7 +163,6 @@ const adapter: GalleryUiAdapter = {setItemMultiSelection,setPage: noop,setPageInfo: noop,- setProjectBoard: noop,setSearchTerm: noop,setView: noop,toggleItemSelection: noop,diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.tsindex 56fcbea6c0..48f361ff52 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryActions.ts@@ -30,13 +30,11 @@ export const useGalleryActions = ({boards,getCurrentGalleryLocation,loadMore,- projectBoardId,selectedBoardId,}: {boards: GalleryBoard[];getCurrentGalleryLocation: () => { galleryView: GalleryView; selectedBoardId: string };loadMore: () => void;- projectBoardId: string | null;selectedBoardId: string;}): GalleryActions => {const { exportProject, gallery, notifications } = useGalleryUi();@@ -192,17 +190,6 @@ export const useGalleryActions = ({selectBoard: gallery.selectBoard,selectItem: gallery.selectItem,selectItemRange: (items, primaryItem) => gallery.setItemMultiSelection(items.map(toGalleryItemKey), primaryItem),- /**- * The project's board always exists — the server creates it with the project and- * hydration writes its id into the document — so selecting it is just a selection.- * There is deliberately no create-on-demand branch: a board this client made would- * not be the project's, and the server would refuse to let a project adopt it later.- */- selectProjectBoard: () => {- if (projectBoardId) {- gallery.selectBoard(projectBoardId);- }- },setCompareItem: gallery.setCompareItem,setSearchTerm: gallery.setSearchTerm,setView: gallery.setView,@@ -210,16 +197,5 @@ export const useGalleryActions = ({updateSettings: gallery.updateSettings,uploadFiles,};- }, [- boards,- exportProject,- gallery,- loadMore,- notifications,- projectBoardId,- queryClient,- selectedBoardId,- t,- uploadFiles,- ]);+ }, [boards, exportProject, gallery, loadMore, notifications, queryClient, selectedBoardId, t, uploadFiles]);};diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.browser.test.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.browser.test.tsxindex 04d8a803b0..5adb0cff09 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryUploadAction.browser.test.tsx@@ -88,7 +88,6 @@ const adapter: GalleryUiAdapter = {setItemMultiSelection: noop,setPage: noop,setPageInfo: noop,- setProjectBoard: noop,setSearchTerm: noop,setView: noop,toggleItemSelection: noop,diff --git a/invokeai/frontend/webv2/src/platform/ui/EmptyState.tsx b/invokeai/frontend/webv2/src/platform/ui/EmptyState.tsxindex 03d0d36062..fca6b5c7c1 100644--- a/invokeai/frontend/webv2/src/platform/ui/EmptyState.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/EmptyState.tsx@@ -28,7 +28,9 @@ export const EmptyState = React.forwardRef<HTMLDivElement, EmptyStateProps>(funcconst fgColor = danger ? 'fg.error' : undefined;const isStart = align === 'start';return (- <ChakraEmptyState.Root ref={ref} {...rest} {...(isStart ? { px: '0' } : {})} size={props.size ?? 'sm'}>+ // `px` before the spread, not after: dropping the recipe's inset is this prop's job, but a+ // caller that asked for its own padding still outranks it.+ <ChakraEmptyState.Root ref={ref} px={isStart ? '0' : undefined} {...rest} size={props.size ?? 'sm'}><ChakraEmptyState.Content alignItems={isStart ? 'flex-start' : undefined}>{icon && <ChakraEmptyState.Indicator color={fgColor}>{icon}</ChakraEmptyState.Indicator>}{description ? (@@ -37,7 +39,10 @@ export const EmptyState = React.forwardRef<HTMLDivElement, EmptyStateProps>(func<ChakraEmptyState.Description>{description}</ChakraEmptyState.Description></VStack>) : (- <ChakraEmptyState.Title color={fgColor}>{title}</ChakraEmptyState.Title>+ // A title long enough to wrap aligns with the rest of the block, not against it.+ <ChakraEmptyState.Title color={fgColor} textAlign={isStart ? 'start' : undefined}>+ {title}+ </ChakraEmptyState.Title>)}{children}</ChakraEmptyState.Content>diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectActionsMenu.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectActionsMenu.tsxindex b8ebd89c5e..6645feb583 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectActionsMenu.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectActionsMenu.tsx@@ -89,6 +89,9 @@ export const ProjectActionsMenu = ({<RenameDialoginitialName={projectName}isOpen={isRenameOpen}+ label={t('projects.renameProjectNameLabel')}+ submitLabel={t('common.rename')}+ title={t('projects.renameProject')}onClose={closeRenameDialog}onSubmit={actions.rename}/>diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/projects/useProjectCardActions.ts b/invokeai/frontend/webv2/src/workbench/launchpad/projects/useProjectCardActions.tsindex a66863c65f..35d2f27b59 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/projects/useProjectCardActions.ts+++ b/invokeai/frontend/webv2/src/workbench/launchpad/projects/useProjectCardActions.ts@@ -1,7 +1,7 @@import { toaster } from '@platform/ui';import { deleteLibraryProject, renameLibraryProject, type ProjectSummary } from '@workbench/projects/library';import { useDuplicateProject, useExportLibraryProject } from '@workbench/projects/useProjectFileActions';-import { useCallback } from 'react';+import { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { dropProjectPin } from './projectPins';@@ -68,5 +68,11 @@ export const useProjectCardActions = (summary: ProjectSummary): ProjectCardActio}}, [summary.id, t]);- return { delete: deleteProject, duplicate, export: exportProject, rename };+ // Memoized because `ProjectActionsMenu` derives callbacks from this object, and the browser+ // renders one of these per row in a virtualized list: a fresh literal each render invalidates+ // every one of them on every render.+ return useMemo(+ () => ({ delete: deleteProject, duplicate, export: exportProject, rename }),+ [deleteProject, duplicate, exportProject, rename]+ );};diff --git a/invokeai/frontend/webv2/src/workbench/projects/openProjectBroker.test.ts b/invokeai/frontend/webv2/src/workbench/projects/openProjectBroker.test.tsindex cf068d7dd6..c01cf17e10 100644--- a/invokeai/frontend/webv2/src/workbench/projects/openProjectBroker.test.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/openProjectBroker.test.ts@@ -1,4 +1,4 @@-import { beforeEach, describe, expect, it, vi } from 'vitest';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { createOpenProjectBroker } from './openProjectBroker';import { getOpenProject } from './syncStore';@@ -39,17 +39,35 @@ const createHarness = () => {};describe('createOpenProjectBroker', () => {+ const brokers: { dispose: () => void }[] = [];++ const startBroker = (deps: Parameters<typeof createOpenProjectBroker>[0]) => {+ const broker = createOpenProjectBroker(deps);++ brokers.push(broker);++ return broker;+ };+beforeEach(async () => {const account = await import('@platform/state/accountLifecycle');account.accountLifecycle.activate('broker-user');});+ // The registry is module state. A test that leaves a handle in it is a test the next one+ // inherits, and these only pass in isolation by using different ids.+ afterEach(() => {+ for (const broker of brokers.splice(0)) {+ broker.dispose();+ }+ });+it('publishes a handle for every project the editor already holds', () => {const harness = createHarness();harness.setOpenIds(['a', 'b']);- createOpenProjectBroker(harness.deps);+ startBroker(harness.deps);expect(getOpenProject('a')).not.toBeNull();expect(getOpenProject('b')).not.toBeNull();@@ -58,7 +76,7 @@ describe('createOpenProjectBroker', () => {it('follows the open set as tabs come and go', () => {const harness = createHarness();- const broker = createOpenProjectBroker(harness.deps);+ const broker = startBroker(harness.deps);harness.setOpenIds(['a']);expect(getOpenProject('a')).not.toBeNull();@@ -73,7 +91,7 @@ describe('createOpenProjectBroker', () => {/** The handle is the mounted editor's. When the editor goes, every mutation must fall back to HTTP. */it('withdraws every handle when the editor unmounts', () => {const harness = createHarness();- const broker = createOpenProjectBroker(harness.deps);+ const broker = startBroker(harness.deps);harness.setOpenIds(['a', 'b']);broker.dispose();@@ -96,7 +114,7 @@ describe('createOpenProjectBroker', () => {return Promise.resolve();});- createOpenProjectBroker(harness.deps);+ startBroker(harness.deps);harness.setOpenIds(['a']);await getOpenProject('a')!.rename('New name');@@ -108,7 +126,7 @@ describe('createOpenProjectBroker', () => {it('routes deletion and closing at the project it was published for', () => {const harness = createHarness();- createOpenProjectBroker(harness.deps);+ startBroker(harness.deps);harness.setOpenIds(['a']);const handle = getOpenProject('a')!;@@ -119,4 +137,25 @@ describe('createOpenProjectBroker', () => {expect(harness.deps.markProjectDeleted).toHaveBeenCalledWith('a');expect(harness.deps.closeProject).toHaveBeenCalledWith('a');});++ /**+ * The registry is cleared when the account changes. A broker that trusted its own record of what+ * it had published would never register those projects again, and every library mutation would+ * silently take the HTTP path for the rest of the mount — the exact thing this exists to stop.+ */+ it('republishes its handles after the registry is cleared underneath it', async () => {+ const harness = createHarness();+ const account = await import('@platform/state/accountLifecycle');++ startBroker(harness.deps);+ harness.setOpenIds(['a']);+ expect(getOpenProject('a')).not.toBeNull();++ account.accountLifecycle.activate('someone-else');+ expect(getOpenProject('a')).toBeNull();++ harness.setOpenIds(['a', 'b']);+ expect(getOpenProject('a')).not.toBeNull();+ expect(getOpenProject('b')).not.toBeNull();+ });});diff --git a/invokeai/frontend/webv2/src/workbench/projects/openProjectBroker.ts b/invokeai/frontend/webv2/src/workbench/projects/openProjectBroker.tsindex dc7ff0884b..761851076d 100644--- a/invokeai/frontend/webv2/src/workbench/projects/openProjectBroker.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/openProjectBroker.ts@@ -48,6 +48,15 @@ export const createOpenProjectBroker = (deps: OpenProjectBrokerDeps): OpenProjecunmarkDeleted: () => deps.unmarkProjectDeleted(projectId),});+ /**+ * Publish the current open set, unregistering whatever is no longer in it.+ *+ * Registration is unconditional rather than skipped for ids already published. The registry is+ * cleared when the account changes, and a `published` set that believed it was still there would+ * never re-register — silently sending every library mutation back over HTTP for the rest of the+ * mount, which is the one thing this module exists to prevent. `published` therefore records only+ * what to *retract*, and the registry stays the single source of what is currently published.+ */const sync = (): void => {const openIds = new Set(deps.getOpenProjectIds());@@ -59,10 +68,8 @@ export const createOpenProjectBroker = (deps: OpenProjectBrokerDeps): OpenProjec}for (const projectId of openIds) {- if (!published.has(projectId)) {- registerOpenProject(projectId, buildHandle(projectId));- published.add(projectId);- }+ registerOpenProject(projectId, buildHandle(projectId));+ published.add(projectId);}};diff --git a/invokeai/frontend/webv2/src/workbench/projects/useProjectActions.ts b/invokeai/frontend/webv2/src/workbench/projects/useProjectActions.tsindex e972e4a514..cebd4ecd9b 100644--- a/invokeai/frontend/webv2/src/workbench/projects/useProjectActions.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/useProjectActions.ts@@ -99,9 +99,15 @@ export const useProjectActions = (): {const projectToFlush = queries.getProject(project.id) ?? project;- void persistenceService.flushProjectToServer(projectToFlush).finally(() => {- persistenceService.releaseProjectSync(project.id);- });+ // `.finally()` forwards the rejection it was chained onto, so `void` alone left an unhandled+ // one behind — reachable by closing a tab while the account is going away, which is when the+ // flush rejects. The tab is closing either way; the flush was best-effort.+ void persistenceService+ .flushProjectToServer(projectToFlush)+ .finally(() => {+ persistenceService.releaseProjectSync(project.id);+ })+ .catch(() => undefined);if (leaveEditorIfLast(project.id)) {return;diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsxindex b60d9fae7a..d5d130a776 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx@@ -241,7 +241,15 @@ export const ProjectSwitcher = () => {</Menu.Root>{renameTarget ? (- <RenameDialog initialName={renameTarget.name} isOpen onClose={closeRenameDialog} onSubmit={renameProject} />+ <RenameDialog+ initialName={renameTarget.name}+ isOpen+ label={t('projects.renameProjectNameLabel')}+ submitLabel={t('common.rename')}+ title={t('projects.renameProject')}+ onClose={closeRenameDialog}+ onSubmit={renameProject}+ />) : null}<ConfirmDialogbody={`${t('projects.deleteProjectTabBody', { name: deleteTarget?.name ?? '' })} ${t('projects.deleteProjectBoardNote')}`}@@ -251,7 +259,10 @@ export const ProjectSwitcher = () => {onClose={closeDeleteDialog}onConfirm={confirmDeleteProject}/>- {isOpenDialogVisible ? <OpenProjectDialog isOpen onClose={hideOpenDialog} /> : null}+ {/* Rendered unconditionally and driven by `open`: the dialog already declares `lazyMount`+ and `unmountOnExit`, so it costs nothing while closed — and unmounting it here instead+ skipped its exit transition, closing by cutting rather than fading. */}+ <OpenProjectDialog isOpen={isOpenDialogVisible} onClose={hideOpenDialog} /></>);};diff --git a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts b/invokeai/frontend/webv2/src/workbench/workbenchStore.tsindex a42a7fac71..a470efe459 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchStore.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchStore.ts@@ -412,13 +412,18 @@ const createPersistenceAdapter = (dispatch: WorkbenchDispatch, getState: () => Wreturn {/**- * A project created by persistence learns its board from the create response. Both writes- * belong together: the id records which board is the project's, and selecting it is what- * makes the project's own output land there rather than in Uncategorized.+ * A project created by persistence learns its board from the create response.+ *+ * Recording the id is the whole write. It does *not* also select the board: the create response+ * arrives a round trip after the draft appears, and forcing a selection then would overwrite+ * whatever the person picked in the meantime. Nothing is lost by leaving it —+ * `getGallerySelectedBoardId` already falls back to the project's board when the saved+ * selection does not resolve, which is exactly this case. It matches hydration, which passes+ * `selectBoard: false` for the same reason, and makes this idempotent, which matters because+ * an assignment can be applied from a save whose snapshot has already moved on.*/assignProjectBoard: ({ boardId, projectId }: { boardId: string; projectId: string }) => {dispatch({ boardId, projectId, type: 'setGalleryProjectBoardId' });- dispatch({ boardId, projectId, type: 'selectGalleryBoard' });},getState,hydrate: command('hydrateWorkbench', (state: WorkbenchState) => ({ state })),