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(launchpad): start a new project in a chosen layout
joshistoast55c791204055
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 0bbc5b4514..9171be67e4 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -464,6 +464,7 @@"libraryDescription": "Every project saved to your account.","listView": "List view","newProject": "New project",+ "newProjectWithLayout": "Start with a layout","noSavedProjects": "No saved projects yet.","noSavedProjectsDescription": "Create your first project to start generating.","noSearchMatches": "No projects match “{{search}}”.",diff --git a/invokeai/frontend/webv2/src/app/router.tsx b/invokeai/frontend/webv2/src/app/router.tsxindex 64879fefc4..4bc136255c 100644--- a/invokeai/frontend/webv2/src/app/router.tsx+++ b/invokeai/frontend/webv2/src/app/router.tsx@@ -23,7 +23,7 @@ import {useRouter,} from '@tanstack/react-router';import { WorkbenchSplashScreen } from '@workbench/components/WorkbenchSplashScreen';-import { isLaunchpadIntentId } from '@workbench/launchpad/intents';+import { isLaunchpadIntentId, isLaunchpadLayoutId } from '@workbench/launchpad/intents';import { Launchpad } from '@workbench/launchpad/Launchpad';import { peekOpenProjectIds, type WorkbenchSearch } from '@workbench/projects/session';import { loadWorkbenchSettings } from '@workbench/settings/store';@@ -191,6 +191,7 @@ const workbenchRoute = createRoute({validateSearch: (search: Record<string, unknown>): WorkbenchSearch => ({intent: isLaunchpadIntentId(search.intent) ? search.intent : undefined,new: search.new === true || search.new === 'true' || search.new === 1 ? true : undefined,+ preset: isLaunchpadLayoutId(search.preset) ? search.preset : undefined,project: typeof search.project === 'string' && search.project.length > 0 ? search.project : undefined,}),});diff --git a/invokeai/frontend/webv2/src/workbench/WorkbenchSessionController.tsx b/invokeai/frontend/webv2/src/workbench/WorkbenchSessionController.tsxindex 431695f2c8..c828335647 100644--- a/invokeai/frontend/webv2/src/workbench/WorkbenchSessionController.tsx+++ b/invokeai/frontend/webv2/src/workbench/WorkbenchSessionController.tsx@@ -25,8 +25,16 @@ const HydratedSessionController = ({ search }: { search: WorkbenchSearch }) => {// applies exactly once and never survives into a later navigation.const intent = resolveLaunchpadIntent(search.intent);- if (intent) {+ // A named preset wins: the user picked the arrangement itself, so it+ // outranks whatever arrangement an intent merely implies. The intent+ // still gets to name the invocation source, which a preset cannot.+ if (search.preset) {+ commands.layout.applyPreset(search.preset);+ } else if (intent) {commands.layout.applyPreset(intent.presetId);+ }++ if (intent) {commands.generation.setSource(intent.sourceId);}diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/intents.ts b/invokeai/frontend/webv2/src/workbench/launchpad/intents.tsindex 68c7e6ac04..b76a715176 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/intents.ts+++ b/invokeai/frontend/webv2/src/workbench/launchpad/intents.ts@@ -12,6 +12,12 @@ import type { BuiltInLayoutPresetId } from '@workbench/layoutContracts';* This is the whole contract behind `/app?new=true&intent=…`: the Launchpad* writes the id into the URL, and the editor's session controller applies it* once, on the fresh draft.+ *+ * `?preset=` is the same contract one level lower: it names an arrangement+ * directly, for when the user picked a layout rather than a kind of work. The+ * id list lives here rather than being derived from `layoutPresets` so that+ * validating the URL costs the editor route nothing — this module is already+ * shared between both routes, the preset table is not.*/export type LaunchpadIntentId = 'generate' | 'canvas' | 'upscale' | 'workflow';@@ -34,6 +40,16 @@ const INTENTS: Record<LaunchpadIntentId, LaunchpadIntent> = {export const isLaunchpadIntentId = (value: unknown): value is LaunchpadIntentId =>typeof value === 'string' && LAUNCHPAD_INTENT_IDS.includes(value as LaunchpadIntentId);+/**+ * The arrangements the Launchpad can start a draft in. Built-ins only: custom+ * presets live in the account state that only the mounted workbench holds, and+ * the Launchpad renders outside that provider.+ */+export const LAUNCHPAD_LAYOUT_IDS: readonly BuiltInLayoutPresetId[] = ['compose', 'edit', 'automate'];++export const isLaunchpadLayoutId = (value: unknown): value is BuiltInLayoutPresetId =>+ typeof value === 'string' && LAUNCHPAD_LAYOUT_IDS.includes(value as BuiltInLayoutPresetId);+/*** `null` for anything unrecognised — a hand-edited or stale URL should open a* plain draft rather than fail.diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/pages/HomePage.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/pages/HomePage.tsxindex 89d89cd42d..9d6998e36c 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/pages/HomePage.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/pages/HomePage.tsx@@ -8,18 +8,19 @@ import { useMountEffect } from '@platform/react/useMountEffect';import { captureAccountScope, isAccountScopeCurrent } from '@platform/state/accountLifecycle';import { Button } from '@platform/ui';import { PageShell } from '@platform/ui/PageShell';-import { Link, useNavigate } from '@tanstack/react-router';+import { useNavigate } from '@tanstack/react-router';import { IntentTiles } from '@workbench/launchpad/home/IntentTiles';import { LivePanel } from '@workbench/launchpad/home/LivePanel';import { RecentProjectsRow } from '@workbench/launchpad/home/RecentProjectsRow';import { ResumeCard } from '@workbench/launchpad/home/ResumeCard';import { KnownBrowserIssuesAlert } from '@workbench/launchpad/KnownBrowserIssuesAlert';+import { NewProjectButton } from '@workbench/launchpad/projects/NewProjectButton';import { prunePinnedProjects, toggleProjectPinPreference } from '@workbench/launchpad/projects/projectPins';import { getProjectLibrary, refreshProjectLibrary, useProjectLibrarySelector } from '@workbench/projects/library';import { refreshOpenProjects } from '@workbench/projects/openProjects';import { useImportProjectFile } from '@workbench/projects/useProjectFileActions';import { useWorkbenchPreferenceSelector } from '@workbench/settings/store';-import { FileUpIcon, PlusIcon } from 'lucide-react';+import { FileUpIcon } from 'lucide-react';import { useCallback } from 'react';import { useTranslation } from 'react-i18next';@@ -32,7 +33,6 @@ import { useTranslation } from 'react-i18next';* tiles that open a draft already arranged for the kind of work you named.*/-const NEW_PROJECT_SEARCH = { new: true } as const;const RECENT_PROJECT_COUNT = 4;const BROWSER_ISSUES_BANNER = <KnownBrowserIssuesAlert />;@@ -82,12 +82,7 @@ export const HomePage = () => {<FileUpIcon />{t('projects.importWithEllipsis')}</Button>- <Button asChild size="xs" variant="solid">- <Link search={NEW_PROJECT_SEARCH} to="/app">- <PlusIcon />- {t('projects.newProject')}- </Link>- </Button>+ <NewProjectButton /></>}banner={BROWSER_ISSUES_BANNER}diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/pages/ProjectsPage.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/pages/ProjectsPage.tsxindex 4af7e0b3c3..873ee74af9 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/pages/ProjectsPage.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/pages/ProjectsPage.tsx@@ -8,8 +8,9 @@ import { useMountEffect } from '@platform/react/useMountEffect';import { captureAccountScope, isAccountScopeCurrent } from '@platform/state/accountLifecycle';import { Button } from '@platform/ui';import { PageShell } from '@platform/ui/PageShell';-import { Link, useNavigate } from '@tanstack/react-router';+import { useNavigate } from '@tanstack/react-router';import { KnownBrowserIssuesAlert } from '@workbench/launchpad/KnownBrowserIssuesAlert';+import { NewProjectButton } from '@workbench/launchpad/projects/NewProjectButton';import { prunePinnedProjects, toggleProjectPinPreference } from '@workbench/launchpad/projects/projectPins';import { ProjectsBrowser } from '@workbench/launchpad/projects/ProjectsBrowser';import { ProjectsToolbar } from '@workbench/launchpad/projects/ProjectsToolbar';@@ -17,7 +18,7 @@ import { getProjectLibrary, refreshProjectLibrary } from '@workbench/projects/liimport { refreshOpenProjects } from '@workbench/projects/openProjects';import { useImportProjectFile } from '@workbench/projects/useProjectFileActions';import { patchWorkbenchPreferences, useWorkbenchPreferenceSelector } from '@workbench/settings/store';-import { FileUpIcon, PlusIcon } from 'lucide-react';+import { FileUpIcon } from 'lucide-react';import { useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -29,8 +30,6 @@ import { useTranslation } from 'react-i18next';* a filter you did not set is a filter you cannot find your way out of.*/-const NEW_PROJECT_SEARCH = { new: true } as const;-export const ProjectsPage = () => {const navigate = useNavigate();const { t } = useTranslation();@@ -79,12 +78,7 @@ export const ProjectsPage = () => {<FileUpIcon />{t('projects.importWithEllipsis')}</Button>- <Button asChild size="xs" variant="solid">- <Link search={NEW_PROJECT_SEARCH} to="/app">- <PlusIcon />- {t('projects.newProject')}- </Link>- </Button>+ <NewProjectButton /></>}banner={diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/projects/NewProjectButton.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/projects/NewProjectButton.tsxnew file mode 100644index 0000000000..24ac949c3b--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/launchpad/projects/NewProjectButton.tsx@@ -0,0 +1,100 @@+import type { BuiltInLayoutPresetId } from '@workbench/layoutContracts';+import type { LucideIcon } from 'lucide-react';++import { Icon, Menu, Portal } from '@chakra-ui/react';+import { Button, Group, IconButton, MenuContent } from '@platform/ui';+import { Link } from '@tanstack/react-router';+import { LAUNCHPAD_LAYOUT_IDS } from '@workbench/launchpad/intents';+import { layoutPresets } from '@workbench/layoutPresets';+import { ChevronDownIcon, LayersIcon, LayoutGridIcon, PlusIcon, TypeIcon, WorkflowIcon } from 'lucide-react';+import { useTranslation } from 'react-i18next';++/**+ * New project, plus the arrangement to open it in.+ *+ * The plain click keeps the old behaviour — a draft in whatever preset the+ * account last used — because most of the time the arrangement is not the+ * decision being made. The caret is for when it is: it names the three shipped+ * layouts so starting from "Edit" does not mean opening a draft and then+ * rearranging it.+ *+ * Labels come from the preset table itself rather than a parallel list, so the+ * menu and the editor's preset strip can never disagree about what a layout is+ * called. Icons are mapped locally: `resolveLayoutPresetIcon` exists for the+ * custom-preset picker and carries its whole curated catalogue, which is a+ * lot of Lucide to pull onto the Launchpad for three entries.+ */++const NEW_PROJECT_SEARCH = { new: true } as const;+const MENU_POSITIONING = { placement: 'bottom-end' } as const;++const LAYOUT_ICONS: Record<string, LucideIcon> = {+ layers: LayersIcon,+ type: TypeIcon,+ workflow: WorkflowIcon,+};++interface NewProjectLayoutItem {+ icon: LucideIcon;+ id: BuiltInLayoutPresetId;+ label: string;+ search: { new: true; preset: BuiltInLayoutPresetId };+}++const LAYOUT_ITEMS: NewProjectLayoutItem[] = LAUNCHPAD_LAYOUT_IDS.flatMap((id) => {+ const preset = layoutPresets.find((candidate) => candidate.id === id);++ return preset+ ? [+ {+ icon: LAYOUT_ICONS[preset.iconId ?? ''] ?? LayoutGridIcon,+ id,+ label: preset.label,+ search: { new: true, preset: id },+ },+ ]+ : [];+});++export const NewProjectButton = ({ variant = 'solid' }: { variant?: 'outline' | 'solid' }) => {+ const { t } = useTranslation();++ return (+ <Group attached>+ <Button asChild size="xs" variant={variant}>+ <Link search={NEW_PROJECT_SEARCH} to="/app">+ <Icon as={PlusIcon} boxSize="3.5" />+ {t('projects.newProject')}+ </Link>+ </Button>+ <Menu.Root positioning={MENU_POSITIONING}>+ <Menu.Trigger asChild>+ <IconButton aria-label={t('projects.newProjectWithLayout')} size="xs" variant={variant}>+ <Icon as={ChevronDownIcon} boxSize="3.5" />+ </IconButton>+ </Menu.Trigger>+ <Portal>+ <Menu.Positioner>+ <MenuContent minW="12rem">+ <Menu.ItemGroup>+ <Menu.ItemGroupLabel>{t('projects.newProjectWithLayout')}</Menu.ItemGroupLabel>+ {LAYOUT_ITEMS.map((item) => (+ <NewProjectLayoutMenuItem key={item.id} item={item} />+ ))}+ </Menu.ItemGroup>+ </MenuContent>+ </Menu.Positioner>+ </Portal>+ </Menu.Root>+ </Group>+ );+};++const NewProjectLayoutMenuItem = ({ item }: { item: NewProjectLayoutItem }) => (+ <Menu.Item asChild value={item.id}>+ <Link search={item.search} to="/app">+ <Icon as={item.icon} boxSize="3.5" color="fg.subtle" />+ <Menu.ItemText fontSize="xs">{item.label}</Menu.ItemText>+ </Link>+ </Menu.Item>+);diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsBrowser.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsBrowser.tsxindex 0c80195f57..b58a80475b 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsBrowser.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/projects/ProjectsBrowser.tsx@@ -4,16 +4,16 @@ import { Alert, Box, Flex, Icon, SimpleGrid, Skeleton, Text } from '@chakra-ui/rimport { Button } from '@platform/ui/Button';import { EmptyState } from '@platform/ui/EmptyState';import { Scrollable } from '@platform/ui/Scrollable';-import { Link } from '@tanstack/react-router';import { refreshProjectLibrary, useProjectLibrarySelector } from '@workbench/projects/library';import { useOpenProjectsSelector } from '@workbench/projects/openProjects';-import { FolderIcon, PlusIcon, SearchXIcon } from 'lucide-react';+import { FolderIcon, SearchXIcon } from 'lucide-react';import { useCallback, useEffectEvent, useLayoutEffect, useMemo, useRef } from 'react';import { useVirtualizer } from 'react-hook-tanstack-virtual';import { useTranslation } from 'react-i18next';import type { ProjectGroupId, ProjectRowModel, ProjectSortId, ProjectsViewId } from './projectLibraryView';+import { NewProjectButton } from './NewProjectButton';import { ProjectCard } from './ProjectCard';import { PROJECT_COVER_ASPECT_RATIO } from './ProjectCover';import { buildProjectGroups, flattenProjectGroupsToRows } from './projectLibraryView';@@ -57,7 +57,6 @@ const GROUP_LABEL_KEY: Record<ProjectGroupId, string> = {const SKELETON_GRID_COLUMNS = { base: 1, lg: 3, sm: 2 } as const;const NO_MATCHES_ICON = <Icon as={SearchXIcon} />;const NO_PROJECTS_ICON = <Icon as={FolderIcon} />;-const NEW_PROJECT_SEARCH = { new: true } as const;export interface ProjectsBrowserProps {/**@@ -319,12 +318,7 @@ const ProjectsEmptyState = ({page's one accent, and repeating that weight a few hundred pixelsaway doubles the loudest thing on an otherwise quiet screen withoutadding a choice. */}- <Button asChild size="xs" variant="outline">- <Link search={NEW_PROJECT_SEARCH} to="/app">- <Icon as={PlusIcon} boxSize="3.5" />- {t('projects.newProject')}- </Link>- </Button>+ <NewProjectButton variant="outline" /></EmptyState>);};diff --git a/invokeai/frontend/webv2/src/workbench/projects/session.ts b/invokeai/frontend/webv2/src/workbench/projects/session.tsindex 1409626cd8..a1aefc84df 100644--- a/invokeai/frontend/webv2/src/workbench/projects/session.ts+++ b/invokeai/frontend/webv2/src/workbench/projects/session.ts@@ -1,4 +1,5 @@import type { LaunchpadIntentId } from '@workbench/launchpad/intents';+import type { BuiltInLayoutPresetId } from '@workbench/layoutContracts';import type { AccountState, WorkbenchState } from '@workbench/projectContracts';import type { WorkbenchPreferences } from '@workbench/settings/contracts';@@ -18,12 +19,15 @@ export const SESSION_STATE_KEY = 'webv2:workbench-account';/*** Search params understood by the /app route: `project` deep-links a library* project into the session; `new` opens the editor with a fresh draft, and- * `intent` says how that draft should be arranged (see `launchpad/intents`).+ * `intent` or `preset` says how that draft should be arranged (see+ * `launchpad/intents`). `preset` names the arrangement outright and wins over+ * the one an intent implies.*/export interface WorkbenchSearch {new?: true;project?: string;intent?: LaunchpadIntentId;+ preset?: BuiltInLayoutPresetId;}export interface WorkbenchSessionBlob {