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
perf(webv2): restore route bundle boundaries
joshistoast842cfbdc652f
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.jsonindex 835088bfda..2fb011d007 100644--- a/invokeai/frontend/webv2/performance/architecture-baseline.json+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json@@ -599,6 +599,7 @@"source:src/workbench/WorkbenchRuntime.tsx","source:src/workbench/WorkbenchSessionController.tsx","source:src/workbench/WorkbenchWidgetRegistryContext.tsx",+ "source:src/workbench/activeInvocationSubmission.ts","source:src/workbench/autoRoutePolicy.ts","source:src/workbench/canvas-engine/api.ts","source:src/workbench/canvas-engine/capabilities.ts",@@ -642,6 +643,7 @@"source:src/workbench/invocation.ts","source:src/workbench/invocationSubmit.ts","source:src/workbench/launchpad/formatRelativeTime.ts",+ "source:src/workbench/layoutPresetActivation.ts","source:src/workbench/layoutPresetSnapshots.ts","source:src/workbench/layoutPresets.ts","source:src/workbench/palette/WorkbenchCommandPalette.tsx",@@ -678,6 +680,7 @@"source:src/workbench/shell/topbar/InvocationCluster.tsx","source:src/workbench/shell/topbar/InvokeButton.tsx","source:src/workbench/shell/topbar/IterationsField.tsx",+ "source:src/workbench/shell/topbar/LayoutPresetAdminDialogs.tsx","source:src/workbench/shell/topbar/LayoutPresetDialog.tsx","source:src/workbench/shell/topbar/LayoutPresetManagerDialog.tsx","source:src/workbench/shell/topbar/LayoutPresetStrip.tsx",@@ -696,7 +699,6 @@"source:src/workbench/shell/topbar/useTopbarShortcut.ts","source:src/workbench/useNotify.ts","source:src/workbench/useOpenWorkbenchWidget.ts",- "source:src/workbench/useWidgetSurfaceFocus.ts","source:src/workbench/widget-frame/WidgetActionsMenu.tsx","source:src/workbench/widget-frame/WidgetBar.tsx","source:src/workbench/widget-frame/WidgetEnableMenu.tsx",diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.tsindex e34c2726fc..9002c64b9a 100644--- a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts@@ -1,5 +1,3 @@-import { builtInLayoutPresetDescriptors } from '@workbench/layoutPresets';-import type { HotkeyCategory, HotkeyDefinition } from './types';const categoryScopes = {@@ -145,7 +143,9 @@ export const firstPartyHotkeyCatalog: HotkeyDefinition[] = [hotkey('app', 'invokeFront', ['mod+shift+enter']),hotkey('app', 'openProjectSwitcher', ['mod+p']),hotkey('app', 'saveLayoutPreset', []),- ...builtInLayoutPresetDescriptors.map(({ defaultKeys, hotkeyId }) => hotkey('app', hotkeyId, [...defaultKeys])),+ hotkey('app', 'selectComposePreset', ['alt+1']),+ hotkey('app', 'selectEditPreset', ['alt+2']),+ hotkey('app', 'selectAutomatePreset', ['alt+3']),hotkey('app', 'cancelQueueItem', ['shift+x']),hotkey('app', 'clearQueue', ['mod+shift+x']),hotkey('app', 'selectGenerateTab', ['1']),diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectFile.ts b/invokeai/frontend/webv2/src/workbench/projects/projectFile.tsindex 5d16715ad8..04d49eabd4 100644--- a/invokeai/frontend/webv2/src/workbench/projects/projectFile.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/projectFile.ts@@ -11,7 +11,6 @@ import {import { createProject as apiCreateProject, getProject as apiGetProject, type ProjectRecordDTO } from './api';import { createProjectId } from './ids';import { upsertProjectSummary } from './library';-import { serializeProjectDocument } from './projectDocument';/*** The portable project file: a versioned envelope around the same document@@ -82,7 +81,9 @@ export const exportLibraryProject = async (};/** Export an open project from its live in-memory document. */-export const exportOpenProject = (project: Project): void => {+export const exportOpenProject = async (project: Project): Promise<void> => {+ const { serializeProjectDocument } = await import('./projectDocument');+downloadProjectFile(project.name, serializeProjectDocument(project));};diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetDialog.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetDialog.tsxindex 95bc6bb229..9ab4d842d2 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetDialog.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetDialog.tsx@@ -7,11 +7,28 @@ import { Tooltip } from '@platform/ui/Tooltip';import { useCallback, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';-import { getNextIconId } from './layoutPresetDialogModel';import { DEFAULT_LAYOUT_PRESET_ICON_ID, layoutPresetIconGroups } from './layoutPresetIcons';const layoutPresetIconIds = layoutPresetIconGroups.flatMap((group) => group.options.map((option) => option.id));+const getNextIconId = (currentIconId: string, key: string): string | null => {+ if (key === 'Home') {+ return layoutPresetIconIds[0] ?? null;+ }+ if (key === 'End') {+ return layoutPresetIconIds.at(-1) ?? null;+ }++ const direction = key === 'ArrowRight' || key === 'ArrowDown' ? 1 : key === 'ArrowLeft' || key === 'ArrowUp' ? -1 : 0;+ if (direction === 0) {+ return null;+ }++ const currentIndex = layoutPresetIconIds.indexOf(currentIconId);+ const nextIndex = (Math.max(currentIndex, 0) + direction + layoutPresetIconIds.length) % layoutPresetIconIds.length;+ return layoutPresetIconIds[nextIndex] ?? null;+};+/*** Name and icon for a custom layout preset.*@@ -78,7 +95,7 @@ export const LayoutPresetDialog = ({);const handleIconKeyDown = useCallback((event: KeyboardEvent<HTMLDivElement>) => {- const nextIconId = getNextIconId(layoutPresetIconIds, iconId, event.key);+ const nextIconId = getNextIconId(iconId, event.key);if (!nextIconId) {return;diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsxindex 8b10bc4626..527cd2ecf9 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/LayoutPresetStrip.tsx@@ -29,30 +29,16 @@ import { useTranslation } from 'react-i18next';import { LayoutPresetDialog } from './LayoutPresetDialog';import { openLayoutPresetDelete, openLayoutPresetEdit, openLayoutPresetManager } from './layoutPresetManagerStore';import { getLayoutPresetPresentation } from './layoutPresetPresentation';-import { getPresetAccessibleName, getTopbarPresetTabs } from './layoutPresetStripModel';import { HIDE_BELOW_PRESET_LABEL_WIDTH } from './topbarBreakpoints';import { useLayoutDrift } from './useLayoutDrift';import { useTopbarShortcut } from './useTopbarShortcut';-/** Marks the chevron inside a tab, so the tab's own click handler can tell them apart. */const PRESET_MENU_ATTRIBUTE = 'data-preset-menu';const PRESET_SCROLL_CSS = { '&::-webkit-scrollbar': { display: 'none' }, scrollbarWidth: 'none' } as const;const createCustomPresetId = (): string =>`custom-layout-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;-/**- * The centre of the top bar: the layout presets as a tab strip.- *- * Tabs rather than a segmented control because the active preset carries its own- * menu, and a tab is a container we can put that chevron inside — so the menu- * belongs to the preset visually as well as conceptually, instead of floating- * beside the group.- *- * A preset is an arrangement, never a widget, which is why the strip carries no- * source or routing marker, and why a customised layout is not a separate entry- * but the active entry with unsaved changes.- */export const LayoutPresetStrip = () => {const { t } = useTranslation();const { activePreset, hasDrifted } = useLayoutDrift();@@ -61,7 +47,7 @@ export const LayoutPresetStrip = () => {const [menuTarget, setMenuTarget] = useState<{ anchor: DOMRect; preset: LayoutPreset } | null>(null);const customPresets = useWorkbenchSelector((snapshot) => snapshot.account.customLayoutPresets ?? []);- const presets = useMemo(() => getTopbarPresetTabs(customPresets), [customPresets]);+ const presets = useMemo(() => [...layoutPresets, ...customPresets], [customPresets]);const activatePreset = useMemo(() => createLayoutPresetActivator({ apply: layout.applyPreset, load: loadLayoutPresetWidgets }),[layout.applyPreset]@@ -131,8 +117,6 @@ export const LayoutPresetStrip = () => {</Tabs.Root></Box>- {/* Saving the live arrangement as a new preset is the one preset action- frequent enough to earn a place in the bar itself. */}<Tooltip content={t('topbar.presets.saveAsTooltip')} showArrow><IconButtonaria-label={t('topbar.presets.saveAsTooltip')}@@ -200,9 +184,6 @@ const PresetTab = ({[onOpenMenu, preset]);- // Right-click opens the same menu, on whichever preset was under the pointer —- // including inactive ones, so a custom preset can be renamed or deleted- // without first switching into it.const handleContextMenu = useCallback((event: MouseEvent<HTMLButtonElement>) => {event.preventDefault();@@ -214,8 +195,6 @@ const PresetTab = ({[onOpenMenu, preset]);- // Keyboard parity for the chevron. Left/Right already move between tabs, so- // Down is free and is the usual "open this control's menu" key.const handleKeyDown = useCallback((event: KeyboardEvent<HTMLButtonElement>) => {if (!isActive || event.key !== 'ArrowDown') {@@ -231,7 +210,7 @@ const PresetTab = ({return (<Tooltip content={`${preset.label} — ${tooltip}`} showArrow><Tabs.Trigger- aria-label={getPresetAccessibleName(preset, showDrift, t('topbar.presets.unsaved'))}+ aria-label={showDrift ? `${preset.label}, ${t('topbar.presets.unsaved')}` : preset.label}aria-keyshortcuts={isActive ? 'ArrowDown' : undefined}gap="1.5"value={preset.id}@@ -242,13 +221,9 @@ const PresetTab = ({onPointerEnter={handlePreload}><Icon as={icon} boxSize="3.5" flexShrink={0} />- {/* The explicit aria-label above keeps the tab named when this visible- text is removed from the accessibility tree below 1280px. */}<Text as="span" css={HIDE_BELOW_PRESET_LABEL_WIDTH}>{preset.label}</Text>- {/* The dot is the whole signal that a layout has diverged, so it has to- reach screen readers too — as part of the tab's name. */}{showDrift ? <DriftDot /> : null}{isActive ? (<Box@@ -273,7 +248,6 @@ const PresetTab = ({const MENU_AFFORDANCE_HOVER_PROPS = { bg: 'bg.emphasized', color: 'fg' } as const;-/** Filled accent dot: this preset is loaded, but the live layout has moved on. */const DriftDot = () => <Box aria-hidden="true" bg="accent.solid" boxSize="1.5" flexShrink={0} rounded="full" />;const PresetMenu = ({@@ -360,8 +334,6 @@ const PresetMenu = ({</HStack><Menu.Separator />- {/* Right-clicking a preset you are not in should still offer the- thing left-clicking it does, the way any list does. */}{isActive ? null : (<Menu.Item value="apply-preset" onClick={apply}><Icon as={ArrowRightIcon} boxSize="3.5" />@@ -369,8 +341,6 @@ const PresetMenu = ({</Menu.Item>)}- {/* Revert and Save act on the *live* layout, so they only make- sense for the preset you are currently in. */}{isActive ? (<>{showDrift ? (@@ -391,8 +361,6 @@ const PresetMenu = ({</>) : null}- {/* Renaming, re-iconing, and deleting belong to the preset itself,- so they work on any custom preset without switching into it. */}{isCustom ? (<><Menu.Item value="edit-preset" onClick={edit}>diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsxindex 124c63f84e..8e4c385931 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/ProjectSwitcher.tsx@@ -37,7 +37,6 @@ import {import { useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';-import { getProjectSwitcherSections } from './projectSwitcherModel';import { projectSwitcherStore, setProjectSwitcherOpen } from './projectSwitcherStore';import { HIDE_BELOW_PROJECT_NAME_WIDTH } from './topbarBreakpoints';@@ -45,18 +44,6 @@ const MENU_POSITIONING = { placement: 'bottom-start' } as const;const DELETE_HOVER_PROPS = { bg: 'bg.error', color: 'fg.error' } as const;const RECENT_PROJECT_LIMIT = 5;-/**- * The project you are in, and the ones you would plausibly go to next.- *- * The old tab strip put a variable-width run of tabs in the middle of the bar,- * so everything beside it moved whenever a project opened or closed. A single- * fixed-shape trigger does not, which is what lets the preset strip stay- * optically centred.- *- * Open session projects come first, followed by saved recents that are not- * already open. This preserves document/session visibility without putting a- * variable-width tab strip back into the topbar.- */export const ProjectSwitcher = () => {const { t } = useTranslation();const activeProjectId = useActiveProjectSelector((project) => project.id);@@ -78,7 +65,6 @@ export const ProjectSwitcher = () => {setProjectSwitcherOpen(event.open);if (event.open) {- // The recents list is only worth a request when someone opens the menu.void refreshProjectLibrary();}}, []);@@ -121,7 +107,7 @@ export const ProjectSwitcher = () => {const project = getProject(activeProjectId);if (project) {- exportOpenProject(project);+ void exportOpenProject(project);}}, [activeProjectId, getProject]);const closeActiveProject = useCallback(() => {@@ -142,11 +128,11 @@ export const ProjectSwitcher = () => {[getProject, openProject]);- const { open: openProjectSummaries, recent: recentSummaries } = getProjectSwitcherSections(- openProjects,- librarySummaries,- RECENT_PROJECT_LIMIT- );+ const openProjectIds = new Set(openProjects.map((project) => project.id));+ const openProjectSummaries = openProjects;+ const recentSummaries = librarySummaries+ .filter((project) => !openProjectIds.has(project.id))+ .slice(0, RECENT_PROJECT_LIMIT);return (<>@@ -160,9 +146,6 @@ export const ProjectSwitcher = () => {size="sm"variant="ghost">- {/* Only the name truncates. The selector glyph is what makes this- legible as a switcher, so it holds its width all the way down- to the narrowest breakpoint. */}<Text css={HIDE_BELOW_PROJECT_NAME_WIDTH} fontWeight="500" minW="0" truncate>{activeProjectName}</Text>@@ -236,8 +219,6 @@ export const ProjectSwitcher = () => {) : null}<Menu.Separator />- {/* The `+` and folder glyphs that used to sit loose in the top- right; they belong with the projects they act on. */}<Menu.Item value="new-project" onClick={createProject}><Icon as={PlusIcon} boxSize="3.5" /><Menu.ItemText>{t('projects.newProject')}</Menu.ItemText>@@ -302,7 +283,6 @@ const OpenProjectRow = ({);};-/** One recent project. Loaded or not, selecting it lands you in it. */const RecentProjectRow = ({onOpen,summary,diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsxindex 042ceaa287..5cb5e877b1 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx@@ -16,8 +16,6 @@ import { useTranslation } from 'react-i18next';import type { InvocationState } from './useInvocationState';-import { getRoutingRelationship } from './routingPresentation';-const MENU_POSITIONING = { placement: 'bottom-end' } as const;const destinationWidgetTypeIds: Record<ResultDestination, 'canvas' | 'gallery'> = {@@ -25,20 +23,6 @@ const destinationWidgetTypeIds: Record<ResultDestination, 'canvas' | 'gallery'>gallery: 'gallery',};-/**- * Where the next Invoke reads from and writes to — always visible, never- * collapsed, at any width.- *- * It is the only thing standing between a user pressing ⌘↵ and generating from- * a widget they were not thinking about (contract §9.5), so it cannot be the- * control that gives way when the bar gets tight. In the common auto case it is- * two muted glyphs on the plain button surface: a permanently accented pill on- * a bar people stare at for hours becomes noise, and noise is not information.- *- * The whole control is one target that opens the menu. Splitting it so that the- * source glyph focused its widget made a small, ambiguous hit area out of what- * should read as a single indicator.- */export const RoutingControl = ({ state }: { state: InvocationState }) => {const { t } = useTranslation();const { generation } = useWorkbenchCommands();@@ -46,7 +30,7 @@ export const RoutingControl = ({ state }: { state: InvocationState }) => {const triggerIds = useMemo(() => ({ trigger: triggerId }), [triggerId]);const { invocation, placedTypeIds, sources } = state;const isLocked = invocation.sourceLocked || invocation.destinationLocked;- const relationship = getRoutingRelationship(invocation);+ const relationship = isLocked ? 'link' : 'arrow';const hasSource = placedTypeIds.has(getWidgetTypeIdForSourceId(invocation.sourceId));const sourceTypeId = getWidgetTypeIdForSourceId(invocation.sourceId);const destinationTypeId = destinationWidgetTypeIds[invocation.destination];@@ -76,8 +60,6 @@ export const RoutingControl = ({ state }: { state: InvocationState }) => {{hasSource ? (<WidgetIcon boxSize="3.5" color={glyphColor} icon={getWidgetById(sourceTypeId)?.manifest.icon} />) : (- // Empty source slot rather than a hidden control: the shape of the- // indicator must not change when nothing is open.<Box borderColor="border.emphasized" borderStyle="dashed" borderWidth="1px" boxSize="3.5" rounded="xs" />)}<Icon@@ -139,7 +121,6 @@ const SourceRadioGroup = ({);};-/** One graph source. Choosing it changes routing without changing the layout. */const SourceRow = ({ source }: { source: GraphWidgetSource }) => (<Menu.RadioItem value={source.sourceId}><Menu.ItemIndicator />diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetDialogModel.test.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetDialogModel.test.tsdeleted file mode 100644index f6133bd210..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetDialogModel.test.ts+++ /dev/null@@ -1,22 +0,0 @@-import { describe, expect, it } from 'vitest';--import { getNextIconId } from './layoutPresetDialogModel';--describe('layout preset icon keyboard navigation', () => {- const iconIds = ['grid', 'text', 'image'];-- it.each([- ['grid', 'ArrowRight', 'text'],- ['text', 'ArrowDown', 'image'],- ['image', 'ArrowRight', 'grid'],- ['grid', 'ArrowLeft', 'image'],- ['text', 'Home', 'grid'],- ['text', 'End', 'image'],- ])('moves from %s with %s to %s', (current, key, expected) => {- expect(getNextIconId(iconIds, current, key)).toBe(expected);- });-- it('ignores unrelated keys', () => {- expect(getNextIconId(iconIds, 'text', 'Enter')).toBeNull();- });-});diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetDialogModel.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetDialogModel.tsdeleted file mode 100644index 7cdf1ece13..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetDialogModel.ts+++ /dev/null@@ -1,22 +0,0 @@-export const getNextIconId = (iconIds: readonly string[], currentIconId: string, key: string): string | null => {- if (iconIds.length === 0) {- return null;- }- if (key === 'Home') {- return iconIds[0] ?? null;- }- if (key === 'End') {- return iconIds.at(-1) ?? null;- }-- const direction = key === 'ArrowRight' || key === 'ArrowDown' ? 1 : key === 'ArrowLeft' || key === 'ArrowUp' ? -1 : 0;-- if (direction === 0) {- return null;- }-- const currentIndex = iconIds.indexOf(currentIconId);- const nextIndex = (Math.max(currentIndex, 0) + direction + iconIds.length) % iconIds.length;-- return iconIds[nextIndex] ?? null;-};diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetStripModel.test.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetStripModel.test.tsdeleted file mode 100644index 4c93b8e110..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetStripModel.test.ts+++ /dev/null@@ -1,32 +0,0 @@-import type { LayoutPreset } from '@workbench/layoutContracts';--import { layoutPresets } from '@workbench/layoutPresets';-import { describe, expect, it } from 'vitest';--import { getPresetAccessibleName, getTopbarPresetTabs } from './layoutPresetStripModel';--const customPreset = (id: string, label: string): LayoutPreset => ({- ...layoutPresets[0],- id,- isBuiltIn: false,- label,-});--describe('topbar preset strip model', () => {- it('keeps every custom preset in the tab strip', () => {- const customPresets = [customPreset('custom-1', 'One'), customPreset('custom-2', 'Two')];-- expect(getTopbarPresetTabs(customPresets)).toMatchObject([- { id: 'compose' },- { id: 'edit' },- { id: 'automate' },- { id: 'custom-1' },- { id: 'custom-2' },- ]);- });-- it('keeps the visible label in the accessible name when visual text is hidden', () => {- expect(getPresetAccessibleName(layoutPresets[0], false)).toBe('Compose');- expect(getPresetAccessibleName(layoutPresets[0], true)).toBe('Compose, unsaved changes');- });-});diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetStripModel.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetStripModel.tsdeleted file mode 100644index 4d99f761b5..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/layoutPresetStripModel.ts+++ /dev/null@@ -1,14 +0,0 @@-import type { LayoutPreset } from '@workbench/layoutContracts';--import { layoutPresets } from '@workbench/layoutPresets';--export const getTopbarPresetTabs = (customPresets: LayoutPreset[]): LayoutPreset[] => [- ...layoutPresets,- ...customPresets,-];--export const getPresetAccessibleName = (- preset: LayoutPreset,- hasUnsavedChanges: boolean,- unsavedChangesLabel = 'unsaved changes'-): string => (hasUnsavedChanges ? `${preset.label}, ${unsavedChangesLabel}` : preset.label);diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/projectSwitcherModel.test.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/projectSwitcherModel.test.tsdeleted file mode 100644index 6118320ef3..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/projectSwitcherModel.test.ts+++ /dev/null@@ -1,35 +0,0 @@-import { describe, expect, it } from 'vitest';--import { getProjectSwitcherSections } from './projectSwitcherModel';--describe('project switcher sections', () => {- it('lists every open project and excludes them from recents', () => {- const openProjects = [- { id: 'open-1', name: 'First' },- { id: 'open-2', name: 'Second' },- ];- const libraryProjects = [- { id: 'open-2', name: 'Second', updatedAt: 2 },- { id: 'saved-1', name: 'Saved', updatedAt: 1 },- ];-- expect(getProjectSwitcherSections(openProjects, libraryProjects, 5)).toEqual({- open: openProjects,- recent: [{ id: 'saved-1', name: 'Saved', updatedAt: 1 }],- });- });-- it('limits only the recent library section', () => {- const openProjects = Array.from({ length: 7 }, (_, index) => ({ id: `open-${index}`, name: `${index}` }));- const libraryProjects = Array.from({ length: 7 }, (_, index) => ({- id: `saved-${index}`,- name: `${index}`,- updatedAt: index,- }));-- const sections = getProjectSwitcherSections(openProjects, libraryProjects, 5);-- expect(sections.open).toHaveLength(7);- expect(sections.recent).toHaveLength(5);- });-});diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/projectSwitcherModel.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/projectSwitcherModel.tsdeleted file mode 100644index 12e3fa4675..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/projectSwitcherModel.ts+++ /dev/null@@ -1,17 +0,0 @@-interface OpenProjectSummary {- id: string;- name: string;-}--export const getProjectSwitcherSections = <TOpen extends OpenProjectSummary, TRecent extends OpenProjectSummary>(- openProjects: TOpen[],- libraryProjects: TRecent[],- recentLimit: number-) => {- const openProjectIds = new Set(openProjects.map((project) => project.id));-- return {- open: openProjects,- recent: libraryProjects.filter((project) => !openProjectIds.has(project.id)).slice(0, recentLimit),- };-};diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/routingPresentation.test.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/routingPresentation.test.tsdeleted file mode 100644index 1b9a979fd8..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/routingPresentation.test.ts+++ /dev/null@@ -1,14 +0,0 @@-import { describe, expect, it } from 'vitest';--import { getRoutingRelationship } from './routingPresentation';--describe('routing preview relationship', () => {- it.each([- [{ destinationLocked: false, sourceLocked: false }, 'arrow'],- [{ destinationLocked: false, sourceLocked: true }, 'link'],- [{ destinationLocked: true, sourceLocked: false }, 'link'],- [{ destinationLocked: true, sourceLocked: true }, 'link'],- ] as const)('maps route locks to the preview relationship', (locks, expected) => {- expect(getRoutingRelationship(locks)).toBe(expected);- });-});diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/routingPresentation.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/routingPresentation.tsdeleted file mode 100644index d4bf4cbd27..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/routingPresentation.ts+++ /dev/null@@ -1,6 +0,0 @@-export type RoutingRelationship = 'arrow' | 'link';--export const getRoutingRelationship = (locks: {- destinationLocked: boolean;- sourceLocked: boolean;-}): RoutingRelationship => (locks.destinationLocked || locks.sourceLocked ? 'link' : 'arrow');diff --git a/invokeai/frontend/webv2/vite.config.mts b/invokeai/frontend/webv2/vite.config.mtsindex 0fd20ba3b1..17c46de42b 100644--- a/invokeai/frontend/webv2/vite.config.mts+++ b/invokeai/frontend/webv2/vite.config.mts@@ -11,99 +11,127 @@ const BACKEND_URL = process.env.INVOKEAI_DEV_BACKEND ?? 'http://127.0.0.1:9090';const BACKEND_WS_URL = BACKEND_URL.replace(/^http/, 'ws');const PROJECT_ROOT = fileURLToPath(new URL('.', import.meta.url));+const ROUTE_SHARED_MODULES = [+ '/features/models/data/modelLoadStore.ts',+ '/features/models/index.ts',+ '/features/models/ui/ModelsPage.tsx',+ '/features/nodes/data/nodeExecutionStore.ts',+ '/features/nodes/index.ts',+ '/features/nodes/ui/NodesPage.tsx',+ '/platform/browser/downloadBlob.ts',+ '/platform/query/client.ts',+ '/platform/time/serverTimestamp.ts',+ '/platform/transport/connectionStore.ts',+ '/platform/transport/socketHub.ts',+ '/platform/ui/theme/applyTheme.ts',+ '/workbench/components/WorkbenchSplashScreen.tsx',+ '/workbench/hotkeys/catalog.ts',+ '/workbench/launchpad/formatRelativeTime.ts',+ '/workbench/palette/settingsEntryDeps.ts',+ '/workbench/projects/ids.ts',+ '/workbench/projects/library.ts',+ '/workbench/projects/projectFile.ts',+ '/workbench/settings/SettingsDialogHost.tsx',+] as const;++const WORKBENCH_TOPBAR_MODULES = [+ '/workbench/shell/topbar/LayoutPresetAdminDialogs.tsx',+ '/workbench/shell/topbar/LayoutPresetStrip.tsx',+ '/workbench/shell/topbar/ProjectSwitcher.tsx',+] as const;++const matchesAnySuffix = (id: string, suffixes: readonly string[]) => suffixes.some((suffix) => id.endsWith(suffix));++const getLegacyChunkName = (id: string): string | null => {+ if (+ matchesAnySuffix(id, [+ '/platform/state/selectors.ts',+ '/workbench/palette/paletteStore.ts',+ '/platform/search/dateTokens.ts',+ '/platform/performance/semanticReady.ts',+ ])+ ) {+ return 'shared';+ }++ if (+ matchesAnySuffix(id, [+ '/platform/i18n/client.ts',+ '/platform/react/useMountEffect.ts',+ '/platform/ui/theme/system.ts',+ '/workbench/hotkeys/resolve.ts',+ '/workbench/settings/settingsDialogStore.ts',+ ])+ ) {+ return 'shell-shared';+ }++ if (matchesAnySuffix(id, ['/features/gallery/core/items.ts', '/features/gallery/ui/galleryStateView.ts'])) {+ return 'gallery-state';+ }++ if (!id.includes('/node_modules/')) {+ return null;+ }++ if (+ id.includes('/node_modules/ag-psd/') ||+ id.includes('/node_modules/pako/') ||+ id.includes('/node_modules/base64-js/')+ ) {+ return 'ag-psd';+ }++ if (id.includes('/node_modules/yaml/')) {+ return 'yaml';+ }++ if (id.includes('/node_modules/react-icons/')) {+ return 'react-icons';+ }++ if (id.includes('/node_modules/@xyflow/') || /\/node_modules\/d3-[^/]+\//.test(id)) {+ return 'workflow-vendor';+ }++ if (id.includes('/node_modules/perfect-freehand/') || id.includes('/node_modules/@dnd-kit/')) {+ return 'editor-interactions';+ }++ if (id.includes('/node_modules/@chakra-ui/') || id.includes('/node_modules/@emotion/')) {+ return 'chakra';+ }++ return 'vendor';+};+export default defineConfig({base: './',build: {manifest: true,rollupOptions: {output: {- manualChunks(id) {- // Tiny first-party modules imported by both the eager shell and lazy- // feature chunks (store selectors, the palette's open state, the- // date-token parser); one shared chunk instead of a file per module.- if (- id.endsWith('/platform/state/selectors.ts') ||- id.endsWith('/workbench/palette/paletteStore.ts') ||- id.endsWith('/platform/search/dateTokens.ts') ||- id.endsWith('/platform/performance/semanticReady.ts')- ) {- return 'shared';- }-- // Shell modules that both route shells reach but no longer reach- // *through each other*. The two top bars used to share their whole- // control set, so these rode along inside one chunk; now that the- // workbench bar owns its own controls, each would otherwise be- // emitted as a separate request on both routes for no byte saving.- if (- id.endsWith('/platform/i18n/client.ts') ||- id.endsWith('/platform/react/useMountEffect.ts') ||- id.endsWith('/platform/ui/theme/system.ts') ||- id.endsWith('/workbench/hotkeys/resolve.ts') ||- id.endsWith('/workbench/settings/settingsDialogStore.ts')- ) {- return 'shell-shared';- }-- // Mixed-gallery item helpers cross the eager editor shell and its- // lazy Gallery/Preview chunks. Keep them with the already-eager- // gallery state projection instead of emitting one extra request.- if (- id.endsWith('/features/gallery/core/items.ts') ||- id.endsWith('/features/gallery/ui/galleryStateView.ts')- ) {- return 'gallery-state';- }-- if (!id.includes('/node_modules/')) {- return undefined;- }-- // ag-psd (+ its only dependents pako/base64-js) is loaded LAZILY via a- // dynamic `import('ag-psd')` at PSD-export time. Keep it in its own chunk- // so it never lands in the eagerly-preloaded `vendor` bundle — otherwise- // the manualChunks catch-all below would pull it into the initial load.- if (- id.includes('/node_modules/ag-psd/') ||- id.includes('/node_modules/pako/') ||- id.includes('/node_modules/base64-js/')- ) {- return 'ag-psd';- }-- // Same story as ag-psd: `yaml` is reached only through a dynamic- // `import('yaml')` in wildcard import/export, and the catch-all below- // would otherwise make a parser nobody has asked for part of the- // initial load.- if (id.includes('/node_modules/yaml/')) {- return 'yaml';- }-- if (id.includes('/node_modules/react-icons/')) {- return 'react-icons';- }-- // The Workflow editor's graph canvas. XYFlow and the d3 modules it- // pulls in are reachable only from the Workflow widget, which is- // lazy — but the `vendor` catch-all below made them launchpad-eager.- if (id.includes('/node_modules/@xyflow/') || /\/node_modules\/d3-[^/]+\//.test(id)) {- return 'workflow-vendor';- }-- // Editor-only pointer and drag interaction libraries: perfect-freehand- // belongs to Canvas stroke geometry, dnd-kit to widget and tab- // reordering. Neither is reachable from the launchpad.- if (id.includes('/node_modules/perfect-freehand/') || id.includes('/node_modules/@dnd-kit/')) {- return 'editor-interactions';- }-- if (id.includes('/node_modules/@chakra-ui/') || id.includes('/node_modules/@emotion/')) {- return 'chakra';- }-- return 'vendor';+ codeSplitting: {+ groups: [+ {+ includeDependenciesRecursively: false,+ name: 'route-shared',+ priority: 30,+ test: (id) => matchesAnySuffix(id, ROUTE_SHARED_MODULES),+ },+ {+ includeDependenciesRecursively: false,+ name: 'workbench-topbar',+ priority: 30,+ test: (id) => matchesAnySuffix(id, WORKBENCH_TOPBAR_MODULES),+ },+ {+ name: getLegacyChunkName,+ },+ ],},},+ preserveEntrySignatures: 'allow-extension',},},plugins: [