Skip to content

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.

feat: add project home and management UI

joshistoast8df601038b40
diff --git a/invokeai/frontend/webv2/src/WorkbenchApp.tsx b/invokeai/frontend/webv2/src/WorkbenchApp.tsx
index c018866671..c7541774c0 100644
--- a/invokeai/frontend/webv2/src/WorkbenchApp.tsx
+++ b/invokeai/frontend/webv2/src/WorkbenchApp.tsx
@@ -1,21 +1,35 @@
+import { useSearch } from '@tanstack/react-router';
+
import { SessionExpiryGuard } from './workbench/auth/components/SessionExpiryGuard';
import { ThemeController } from './workbench/ThemeController';
import { ModelsRuntime } from './workbench/widgets/models/ModelsRuntime';
import { WorkbenchProvider } from './workbench/WorkbenchContext';
import { WorkbenchRuntime } from './workbench/WorkbenchRuntime';
+import { WorkbenchSessionController } from './workbench/WorkbenchSessionController';
import { WorkbenchShell } from './workbench/WorkbenchShell';
+import type { WorkbenchSearch } from './workbench/projects/session';
/**
- * The authenticated application: providers, runtimes, and the shell. Mounted
- * by the index route once the auth guard has resolved, so the backend socket
+ * The authenticated editor: providers, runtimes, and the shell. Mounted by
+ * the /app route once the auth guard has resolved, so the backend socket
* always connects with a valid token (or none, in single-user mode).
+ *
+ * The route's search params shape the boot: ?project deep-links a library
+ * project into the session, ?new starts a fresh draft. Both are consumed by
+ * the persistence load; the session controller handles params that change
+ * while the editor is already mounted.
*/
-export const WorkbenchApp = () => (
- <WorkbenchProvider>
- <ThemeController />
- <SessionExpiryGuard />
- <WorkbenchRuntime />
- <ModelsRuntime />
- <WorkbenchShell />
- </WorkbenchProvider>
-);
+export const WorkbenchApp = () => {
+ const search = useSearch({ strict: false }) as WorkbenchSearch;
+
+ return (
+ <WorkbenchProvider loadOptions={{ createNew: search.new, openProjectId: search.project }}>
+ <ThemeController />
+ <SessionExpiryGuard />
+ <WorkbenchRuntime />
+ <ModelsRuntime />
+ <WorkbenchSessionController search={search} />
+ <WorkbenchShell />
+ </WorkbenchProvider>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/router.tsx b/invokeai/frontend/webv2/src/router.tsx
index 1f38d04f0a..aa28b80c48 100644
--- a/invokeai/frontend/webv2/src/router.tsx
+++ b/invokeai/frontend/webv2/src/router.tsx
@@ -4,6 +4,7 @@ import {
createRootRoute,
createRoute,
createRouter,
+ lazyRouteComponent,
Navigate,
Outlet,
redirect,
@@ -12,15 +13,21 @@ import {
import { ensureAuthSession } from './workbench/auth/session';
import { LoginScreen } from './workbench/auth/components/LoginScreen';
import { SetupScreen } from './workbench/auth/components/SetupScreen';
-import { WorkbenchApp } from './WorkbenchApp';
+import { HomeScreen } from './workbench/home/HomeScreen';
+import { peekOpenProjectIds, type WorkbenchSearch } from './workbench/projects/session';
/**
- * Code-based route tree. Every guard starts from `ensureAuthSession()`, which
- * resolves the backend's multi-user status once per app load:
+ * Code-based route tree. The authenticated layout route owns the auth guard,
+ * which resolves the backend's multi-user status once per app load:
*
- * - multi-user off → the workbench renders directly and /login + /setup bounce home
+ * - multi-user off → authenticated routes render directly; /login + /setup bounce home
* - setup required → everything funnels to /setup
- * - signed out → the workbench redirects to /login
+ * - signed out → authenticated routes redirect to /login
+ *
+ * Under it, `/` is the Home surface (project library, profile, resources) and
+ * `/app` is the editor. The editor bundle — canvas, workflow, widgets — is
+ * code-split behind `lazyRouteComponent`, so Home stays light; `defaultPreload:
+ * 'intent'` starts fetching that chunk the moment a project card is hovered.
*
* Hash history is used because the bundle is served with a relative base
* (`./`), so the app cannot rely on server-side fallback for deep paths.
@@ -28,7 +35,7 @@ import { WorkbenchApp } from './WorkbenchApp';
const rootRoute = createRootRoute({ component: Outlet });
-const workbenchRoute = createRoute({
+const authenticatedRoute = createRoute({
beforeLoad: async () => {
const session = await ensureAuthSession();
@@ -44,11 +51,47 @@ const workbenchRoute = createRoute({
throw redirect({ to: '/login' });
}
},
- component: WorkbenchApp,
+ component: Outlet,
getParentRoute: () => rootRoute,
+ id: 'authenticated',
+});
+
+const homeRoute = createRoute({
+ component: HomeScreen,
+ getParentRoute: () => authenticatedRoute,
path: '/',
});
+const workbenchRoute = createRoute({
+ beforeLoad: async ({ cause, search }) => {
+ // Photoshop semantics: the editor without documents is Home. A definite
+ // empty session redirects unless the URL explicitly asks for a project or
+ // a fresh draft; an unknowable session (first run, legacy blob, backend
+ // unreachable) falls through and the editor boots from what it can find.
+ //
+ // Only actual entries are checked: search-only changes ('stay', e.g. the
+ // session controller stripping ?new before the draft has autosaved) must
+ // not re-evaluate a blob that is still catching up, and hover preloads
+ // should not hit the session endpoint at all.
+ if (cause !== 'enter' || search.project || search.new) {
+ return;
+ }
+
+ const openProjectIds = await peekOpenProjectIds();
+
+ if (openProjectIds !== null && openProjectIds.length === 0) {
+ throw redirect({ to: '/' });
+ }
+ },
+ component: lazyRouteComponent(() => import('./WorkbenchApp'), 'WorkbenchApp'),
+ getParentRoute: () => authenticatedRoute,
+ path: '/app',
+ validateSearch: (search: Record<string, unknown>): WorkbenchSearch => ({
+ new: search.new === true || search.new === 'true' || search.new === 1 ? true : undefined,
+ project: typeof search.project === 'string' && search.project.length > 0 ? search.project : undefined,
+ }),
+});
+
const loginRoute = createRoute({
beforeLoad: async () => {
const session = await ensureAuthSession();
@@ -88,8 +131,13 @@ const RouterPending = () => (
export const router = createRouter({
defaultNotFoundComponent: () => <Navigate to="/" />,
defaultPendingComponent: RouterPending,
+ defaultPreload: 'intent',
history: createHashHistory(),
- routeTree: rootRoute.addChildren([workbenchRoute, loginRoute, setupRoute]),
+ routeTree: rootRoute.addChildren([
+ authenticatedRoute.addChildren([homeRoute, workbenchRoute]),
+ loginRoute,
+ setupRoute,
+ ]),
});
declare module '@tanstack/react-router' {
diff --git a/invokeai/frontend/webv2/src/workbench/WorkbenchSessionController.tsx b/invokeai/frontend/webv2/src/workbench/WorkbenchSessionController.tsx
new file mode 100644
index 0000000000..9eeecf3b09
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/WorkbenchSessionController.tsx
@@ -0,0 +1,79 @@
+import { useNavigate } from '@tanstack/react-router';
+import { useEffect, useRef } from 'react';
+
+import { hydrateProjectFromServer } from './projects/syncedPersistence';
+import { useWorkbench } from './WorkbenchContext';
+import type { WorkbenchSearch } from './projects/session';
+
+/**
+ * Keeps a mounted editor in line with the /app search params. Renders nothing.
+ *
+ * Boot is not its job — `WorkbenchProvider` consumes the params present at
+ * mount as load options. This covers what happens afterwards:
+ *
+ * - `?new` is stripped once hydration has consumed it, so a reload (or a
+ * bookmark) does not mint another draft project.
+ * - `?project` changing while the editor is open (a deep link clicked from
+ * elsewhere) focuses the tab if it is open, or hydrates it from the
+ * library and opens it if not.
+ */
+export const WorkbenchSessionController = ({ search }: { search: WorkbenchSearch }) => {
+ const { state, dispatch, hasHydrated } = useWorkbench();
+ const navigate = useNavigate();
+ const latestStateRef = useRef(state);
+ // The mount-time param was already handled by the boot load options.
+ const handledProjectIdRef = useRef<string | null>(search.project ?? null);
+
+ latestStateRef.current = state;
+
+ const isNewRequested = search.new === true;
+
+ useEffect(() => {
+ if (!hasHydrated || !isNewRequested) {
+ return;
+ }
+
+ void navigate({ replace: true, search: {}, to: '/app' });
+ }, [hasHydrated, isNewRequested, navigate]);
+
+ const requestedProjectId = search.project;
+
+ useEffect(() => {
+ if (!hasHydrated || !requestedProjectId || handledProjectIdRef.current === requestedProjectId) {
+ return undefined;
+ }
+
+ handledProjectIdRef.current = requestedProjectId;
+
+ if (latestStateRef.current.projects.some((project) => project.id === requestedProjectId)) {
+ dispatch({ projectId: requestedProjectId, type: 'switchProject' });
+
+ return undefined;
+ }
+
+ let isCancelled = false;
+
+ void hydrateProjectFromServer(requestedProjectId).then((project) => {
+ if (isCancelled) {
+ return;
+ }
+
+ if (project) {
+ dispatch({ project, type: 'openProject' });
+ } else {
+ dispatch({
+ kind: 'info',
+ message: 'The linked project does not exist on this account — it may have been deleted.',
+ title: 'Project not found',
+ type: 'recordNotice',
+ });
+ }
+ });
+
+ return () => {
+ isCancelled = true;
+ };
+ }, [dispatch, hasHydrated, requestedProjectId]);
+
+ return null;
+};
diff --git a/invokeai/frontend/webv2/src/workbench/auth/components/AuthScreen.tsx b/invokeai/frontend/webv2/src/workbench/auth/components/AuthScreen.tsx
index 126bf2fff3..056a777049 100644
--- a/invokeai/frontend/webv2/src/workbench/auth/components/AuthScreen.tsx
+++ b/invokeai/frontend/webv2/src/workbench/auth/components/AuthScreen.tsx
@@ -50,9 +50,10 @@ export const AuthFormAlert = ({ message, tone }: { message: string; tone: 'error
</Alert.Root>
);
-const InvokeMark = () => (
+/** The Invoke logomark, drawn in the theme accent. Shared with the Home shell. */
+export const InvokeMark = ({ size = 36 }: { size?: number }) => (
<Box color="accent.invoke">
- <svg aria-hidden="true" fill="none" height="36" viewBox="0 0 44 44" width="36">
+ <svg aria-hidden="true" fill="none" height={size} viewBox="0 0 44 44" width={size}>
<path
d="M29.1951 10.6667H42V2H2V10.6667H14.8049L29.1951 33.3333H42V42H2V33.3333H14.8049"
stroke="currentColor"
diff --git a/invokeai/frontend/webv2/src/workbench/auth/components/SetupScreen.tsx b/invokeai/frontend/webv2/src/workbench/auth/components/SetupScreen.tsx
index 28ee85e752..277024ac67 100644
--- a/invokeai/frontend/webv2/src/workbench/auth/components/SetupScreen.tsx
+++ b/invokeai/frontend/webv2/src/workbench/auth/components/SetupScreen.tsx
@@ -37,7 +37,7 @@ export const SetupScreen = () => {
return (
<AuthScreen
footer="You can add more users later from the user menu."
- subtitle="Multi-user mode is on. Create the administrator account to get started."
+ subtitle="Create the administrator account to get started."
title="Set up Invoke"
>
<chakra.form
diff --git a/invokeai/frontend/webv2/src/workbench/components/OpenProjectDialog.tsx b/invokeai/frontend/webv2/src/workbench/components/OpenProjectDialog.tsx
new file mode 100644
index 0000000000..593855e018
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/components/OpenProjectDialog.tsx
@@ -0,0 +1,156 @@
+import { chakra, Dialog, Icon, Portal, Spinner, Stack, Text } from '@chakra-ui/react';
+import { useEffect, useState } from 'react';
+import { ArrowRightIcon, FileUpIcon } from 'lucide-react';
+
+import { Button, CloseButton } from './ui/Button';
+import { Scrollable } from './ui/Scrollable';
+import { formatRelativeTime } from '../home/formatRelativeTime';
+import { useNotify } from '../useNotify';
+import { useWorkbench } from '../WorkbenchContext';
+import { refreshProjectLibrary, useProjectLibrary, type ProjectSummary } from '../projects/library';
+import { importProjectFile, pickProjectFile } from '../projects/projectFile';
+import { adoptProjectRecord, hydrateProjectFromServer } from '../projects/syncedPersistence';
+
+/**
+ * "Open project…" from the tab bar: the saved projects that are not already
+ * open as tabs, plus import. Selecting one hydrates its document from the
+ * library and opens it in place — no navigation, the editor stays mounted.
+ */
+export const OpenProjectDialog = ({ isOpen, onClose }: { isOpen: boolean; onClose: () => void }) => {
+ const { state, dispatch } = useWorkbench();
+ const notify = useNotify();
+ const library = useProjectLibrary();
+ const [busyProjectId, setBusyProjectId] = useState<string | null>(null);
+
+ useEffect(() => {
+ if (isOpen) {
+ void refreshProjectLibrary();
+ }
+ }, [isOpen]);
+
+ const openProjectIds = new Set(state.projects.map((project) => project.id));
+ const available = library.summaries.filter((summary) => !openProjectIds.has(summary.id));
+
+ const openProject = async (summary: ProjectSummary) => {
+ setBusyProjectId(summary.id);
+
+ const project = await hydrateProjectFromServer(summary.id);
+
+ setBusyProjectId(null);
+
+ if (!project) {
+ notify.error('Could not open project', `"${summary.name}" could not be loaded from the server.`);
+ void refreshProjectLibrary();
+
+ return;
+ }
+
+ dispatch({ project, type: 'openProject' });
+ onClose();
+ };
+
+ const handleImport = async () => {
+ const file = await pickProjectFile();
+
+ if (!file) {
+ return;
+ }
+
+ try {
+ const record = await importProjectFile(file);
+ const project = adoptProjectRecord(record);
+
+ if (project) {
+ dispatch({ project, type: 'openProject' });
+ onClose();
+ }
+ } catch (error) {
+ notify.error('Import failed', error instanceof Error ? error.message : undefined);
+ }
+ };
+
+ return (
+ <Dialog.Root
+ lazyMount
+ open={isOpen}
+ placement="center"
+ size="sm"
+ unmountOnExit
+ onOpenChange={(event) => {
+ if (!event.open) {
+ onClose();
+ }
+ }}
+ >
+ <Portal>
+ <Dialog.Backdrop />
+ <Dialog.Positioner>
+ <Dialog.Content bg="bg.surface" borderColor="border.subtle" borderWidth="1px" color="fg.default">
+ <Dialog.Header>
+ <Dialog.Title fontSize="sm" fontWeight="700">
+ Open project
+ </Dialog.Title>
+ </Dialog.Header>
+ <Dialog.Body>
+ <Scrollable maxH="72">
+ <Stack gap="1">
+ {available.map((summary) => (
+ <chakra.button
+ key={summary.id}
+ alignItems="center"
+ disabled={busyProjectId !== null}
+ display="flex"
+ gap="2.5"
+ px="2.5"
+ py="2"
+ rounded="md"
+ textAlign="start"
+ type="button"
+ w="full"
+ _disabled={{ opacity: 0.6 }}
+ _hover={{ bg: 'bg.surfaceRaised' }}
+ onClick={() => void openProject(summary)}
+ >
+ <Stack flex="1" gap="0" minW="0">
+ <Text fontSize="xs" fontWeight="600" truncate>
+ {summary.name}
+ </Text>
+ <Text color="fg.muted" fontSize="2xs">
+ Edited {formatRelativeTime(summary.updatedAt)}
+ </Text>
+ </Stack>
+ {busyProjectId === summary.id ? (
+ <Spinner color="fg.muted" size="xs" />
+ ) : (
+ <Icon as={ArrowRightIcon} boxSize="3.5" color="fg.muted" />
+ )}
+ </chakra.button>
+ ))}
+ {available.length === 0 ? (
+ <Text color="fg.muted" fontSize="xs" px="2.5" py="4" textAlign="center">
+ {library.summaries.length === 0
+ ? 'No saved projects yet.'
+ : 'All saved projects are already open.'}
+ </Text>
+ ) : null}
+ </Stack>
+ </Scrollable>
+ </Dialog.Body>
+ <Dialog.Footer gap="2" justifyContent="space-between">
+ <Button size="xs" variant="outline" onClick={() => void handleImport()}>
+ <FileUpIcon />
+ Import…
+ </Button>
+ <Button size="xs" variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ </Dialog.Footer>
+ <Dialog.CloseTrigger asChild>
+ <CloseButton color="fg.muted" size="sm" />
+ </Dialog.CloseTrigger>
+ </Dialog.Content>
+ </Dialog.Positioner>
+ </Portal>
+ </Dialog.Root>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/components/ProjectTabs.tsx b/invokeai/frontend/webv2/src/workbench/components/ProjectTabs.tsx
index bd3d03c1b1..1d86fe6186 100644
--- a/invokeai/frontend/webv2/src/workbench/components/ProjectTabs.tsx
+++ b/invokeai/frontend/webv2/src/workbench/components/ProjectTabs.tsx
@@ -1,69 +1,228 @@
+import { Icon, Menu, Portal } from '@chakra-ui/react';
+import { useRef, useState, type MouseEvent } from 'react';
+import { FileDownIcon, FolderCogIcon, FolderOpenIcon, PencilIcon, PlusIcon, Trash2Icon, XIcon } from 'lucide-react';
+
import { CloseButton, IconButton } from './ui/Button';
+import { ConfirmDialog } from './ui/ConfirmDialog';
+import { MenuContent } from './ui/Menu';
+import { OpenProjectDialog } from './OpenProjectDialog';
+import { RenameDialog } from './ui/RenameDialog';
import { Tabs } from './ui/Tabs';
-import { PlusIcon } from 'lucide-react';
-
import { Tooltip } from './ui/Tooltip';
+import type { Project } from '../types';
+import { exportOpenProject } from '../projects/projectFile';
+import { useProjectActions } from '../projects/useProjectActions';
import { useWorkbench } from '../WorkbenchContext';
/**
- * Document-style project tabs, immediately right of the Invoke control.
+ * Document-style tabs for the open projects (the session), immediately right
+ * of the Invoke control. Tabs are not the library: closing one only removes
+ * it from the session — the project stays saved and reopens through the
+ * folder button's Open Project dialog. Closing the last tab lands on Home.
*
- * Each tab is a container with two real buttons (select + close) rather than the
- * prototype's invalid button-nested-in-button, so keyboard focus and click
- * targets behave correctly.
+ * Each tab is a container with two real buttons (select + close) rather than
+ * the prototype's invalid button-nested-in-button, so keyboard focus and
+ * click targets behave correctly. Right-clicking a tab opens a context menu
+ * with rename, details, export, close, and delete.
*/
export const ProjectTabs = () => {
const { state, activeProject, dispatch } = useWorkbench();
+ const { closeProject, deleteProject } = useProjectActions();
+ const [menuTarget, setMenuTarget] = useState<{ project: Project; x: number; y: number } | null>(null);
+ const [renameTarget, setRenameTarget] = useState<Project | null>(null);
+ const [deleteTarget, setDeleteTarget] = useState<Project | null>(null);
+ const [isOpenDialogVisible, setIsOpenDialogVisible] = useState(false);
const onSwitchProject = (projectId: string) => {
dispatch({ projectId, type: 'switchProject' });
};
+ const openContextMenu = (project: Project, event: MouseEvent) => {
+ event.preventDefault();
+ setMenuTarget({ project, x: event.clientX, y: event.clientY });
+ };
+
return (
- <Tabs.Root minW="max-content" variant="subtle" value={activeProject.id} h="full" w="full">
- <Tabs.List flex="1 1 auto" h="full" py="1">
- {state.projects.map((project) => (
- <Tabs.Trigger
- key={project.id}
- value={project.id}
- onClick={() => onSwitchProject(project.id)}
- fontSize="xs"
- h="full"
- >
- {project.name}
- {/*{project.id !== activeProject.id && project.queue.items.some((item) => item.resultImages?.length) ? (
- <Badge colorPalette="blue" size="xs">
- Results
- </Badge>
- ) : null}*/}
- {state.projects.length > 1 && (
+ <>
+ <Tabs.Root minW="max-content" variant="subtle" value={activeProject.id} h="full" w="full">
+ <Tabs.List flex="1 1 auto" h="full" py="1">
+ {state.projects.map((project) => (
+ <Tabs.Trigger
+ key={project.id}
+ value={project.id}
+ onClick={() => onSwitchProject(project.id)}
+ onContextMenu={(event) => openContextMenu(project, event)}
+ fontSize="xs"
+ h="full"
+ >
+ {project.name}
<CloseButton
size="2xs"
me="-2"
as="span"
role="button"
+ aria-label={`Close ${project.name}`}
onClick={(event) => {
event.stopPropagation();
- dispatch({ projectId: project.id, type: 'closeProject' });
+ closeProject(project);
}}
/>
- )}
- </Tabs.Trigger>
- ))}
- <Tooltip content="Create new project" showArrow>
- <IconButton
- aria-label="Create new project"
- flexShrink={0}
- size="xs"
- variant="ghost"
- alignSelf="center"
- ms="2"
- onClick={() => dispatch({ type: 'createProject' })}
- >
- <PlusIcon />
- </IconButton>
- </Tooltip>
- </Tabs.List>
- </Tabs.Root>
+ </Tabs.Trigger>
+ ))}
+ <Tooltip content="Create new project" showArrow>
+ <IconButton
+ aria-label="Create new project"
+ flexShrink={0}
+ size="xs"
+ variant="ghost"
+ alignSelf="center"
+ ms="2"
+ onClick={() => dispatch({ type: 'createProject' })}
+ >
+ <PlusIcon />
+ </IconButton>
+ </Tooltip>
+ <Tooltip content="Open project" showArrow>
+ <IconButton
+ aria-label="Open project"
+ flexShrink={0}
+ size="xs"
+ variant="ghost"
+ alignSelf="center"
+ onClick={() => setIsOpenDialogVisible(true)}
+ >
+ <FolderOpenIcon />
+ </IconButton>
+ </Tooltip>
+ </Tabs.List>
+ </Tabs.Root>
+ <ProjectTabContextMenu
+ target={menuTarget}
+ onClose={() => setMenuTarget(null)}
+ onCloseProject={closeProject}
+ onDelete={(project) => setDeleteTarget(project)}
+ onRename={(project) => setRenameTarget(project)}
+ />
+ <RenameDialog
+ initialName={renameTarget?.name ?? ''}
+ isOpen={renameTarget !== null}
+ onClose={() => setRenameTarget(null)}
+ onSubmit={(name) => {
+ if (renameTarget) {
+ dispatch({ name, projectId: renameTarget.id, type: 'renameProject' });
+ }
+ }}
+ />
+ <ConfirmDialog
+ body={`Delete "${deleteTarget?.name ?? ''}"? The project and its saved copy on the server are removed permanently. To keep it in your library, close the tab instead.`}
+ confirmLabel="Delete project"
+ isOpen={deleteTarget !== null}
+ title="Delete project?"
+ onClose={() => setDeleteTarget(null)}
+ onConfirm={async () => {
+ if (deleteTarget) {
+ await deleteProject(deleteTarget);
+ }
+ }}
+ />
+ <OpenProjectDialog isOpen={isOpenDialogVisible} onClose={() => setIsOpenDialogVisible(false)} />
+ </>
+ );
+};
+
+const ProjectTabContextMenu = ({
+ onClose,
+ onCloseProject,
+ onDelete,
+ onRename,
+ target,
+}: {
+ onClose: () => void;
+ onCloseProject: (project: Project) => void;
+ onDelete: (project: Project) => void;
+ onRename: (project: Project) => void;
+ target: { project: Project; x: number; y: number } | null;
+}) => {
+ const { dispatch } = useWorkbench();
+ const targetRef = useRef(target);
+
+ targetRef.current = target;
+
+ const openProjectDetails = (project: Project) => {
+ dispatch({ projectId: project.id, type: 'switchProject' });
+
+ // Reveal the Project panel wherever the project already shows it; default
+ // to enabling it in the right rail. Both actions operate on the active
+ // project, which the switch above just made this one.
+ const { left, right } = project.widgetRegions;
+ const region = right.enabledWidgetIds.includes('project')
+ ? 'right'
+ : left.enabledWidgetIds.includes('project')
+ ? 'left'
+ : null;
+
+ if (region) {
+ dispatch({ region, type: 'selectRegionWidget', widgetId: 'project' });
+ } else {
+ dispatch({ region: 'right', type: 'toggleRegionWidget', widgetId: 'project' });
+ }
+ };
+
+ return (
+ <Menu.Root
+ key={target?.project.id ?? 'closed'}
+ lazyMount
+ open={target !== null}
+ positioning={{
+ getAnchorRect: () => {
+ const currentTarget = targetRef.current;
+
+ return currentTarget ? { height: 1, width: 1, x: currentTarget.x, y: currentTarget.y } : null;
+ },
+ placement: 'bottom-start',
+ }}
+ unmountOnExit
+ onOpenChange={(event) => {
+ if (!event.open) {
+ onClose();
+ }
+ }}
+ >
+ <Portal>
+ <Menu.Positioner>
+ {target ? (
+ <MenuContent minW="44">
+ <Menu.Item value="rename" onClick={() => onRename(target.project)}>
+ <Icon as={PencilIcon} boxSize="3.5" />
+ Rename…
+ </Menu.Item>
+ <Menu.Item value="details" onClick={() => openProjectDetails(target.project)}>
+ <Icon as={FolderCogIcon} boxSize="3.5" />
+ Project details
+ </Menu.Item>
+ <Menu.Item value="export" onClick={() => exportOpenProject(target.project)}>
+ <Icon as={FileDownIcon} boxSize="3.5" />
+ Export
+ </Menu.Item>
+ <Menu.Separator />
+ <Menu.Item value="close" onClick={() => onCloseProject(target.project)}>
+ <Icon as={XIcon} boxSize="3.5" />
+ Close
+ </Menu.Item>
+ <Menu.Separator />
+ <Menu.Item
+ color="fg.error"
+ value="delete"
+ _hover={{ bg: 'bg.error', color: 'fg.error' }}
+ onClick={() => onDelete(target.project)}
+ >
+ <Icon as={Trash2Icon} boxSize="3.5" />
+ Delete project…
+ </Menu.Item>
+ </MenuContent>
+ ) : null}
+ </Menu.Positioner>
+ </Portal>
+ </Menu.Root>
);
};
diff --git a/invokeai/frontend/webv2/src/workbench/components/TopBar.tsx b/invokeai/frontend/webv2/src/workbench/components/TopBar.tsx
index 50708d356b..08d9d4a14c 100644
--- a/invokeai/frontend/webv2/src/workbench/components/TopBar.tsx
+++ b/invokeai/frontend/webv2/src/workbench/components/TopBar.tsx
@@ -10,6 +10,7 @@ import { UserMenu } from '../auth/components/UserMenu';
import { useWorkbench } from '../WorkbenchContext';
import { DEFAULT_THEME_ID, THEMES_BY_ID } from '../../theme/themes';
import { Tooltip } from './ui/Tooltip';
+import { Link } from '@tanstack/react-router';
/** Workbench top bar: brand, global Invoke command cluster, project tabs, layout + account controls. */
export const TopBar = () => (
@@ -44,16 +45,16 @@ const BrandMark = () => {
const theme = THEMES_BY_ID[state.account.preferences.themeId] ?? THEMES_BY_ID[DEFAULT_THEME_ID];
return (
- <Flex
- align="center"
- aria-label="Invoke"
- as="button"
- flexShrink={0}
- h="full"
- justify="center"
- rounded="md"
- aspectRatio="1/1"
- me="-1"
+ <Link
+ to="/"
+ style={{
+ flexShrink: 0,
+ height: '100%',
+ aspectRatio: '1/1',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ }}
>
<svg aria-hidden="true" fill="none" height="20" viewBox="0 0 44 44" width="20">
<path
@@ -62,7 +63,7 @@ const BrandMark = () => {
strokeWidth="2.8"
/>
</svg>
- </Flex>
+ </Link>
);
};
diff --git a/invokeai/frontend/webv2/src/workbench/components/ui/RenameDialog.tsx b/invokeai/frontend/webv2/src/workbench/components/ui/RenameDialog.tsx
new file mode 100644
index 0000000000..f1566ff3b4
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/components/ui/RenameDialog.tsx
@@ -0,0 +1,104 @@
+import { chakra, Dialog, Input, Portal, Stack } from '@chakra-ui/react';
+import { useState } from 'react';
+
+import { Button, CloseButton } from './Button';
+import { Field } from './Field';
+
+/**
+ * Controlled single-field rename dialog. `onSubmit` only fires for a
+ * non-empty name that actually changed; it may be async, in which case the
+ * submit button shows a pending state and errors keep the dialog open so the
+ * caller's message (usually a toast) can be acted on.
+ */
+export const RenameDialog = ({
+ initialName,
+ isOpen,
+ label = 'Project name',
+ onClose,
+ onSubmit,
+ title = 'Rename project',
+}: {
+ initialName: string;
+ isOpen: boolean;
+ label?: string;
+ onClose: () => void;
+ onSubmit: (name: string) => Promise<void> | void;
+ title?: string;
+}) => {
+ const [isPending, setIsPending] = useState(false);
+
+ const commit = async (value: string) => {
+ const name = value.trim();
+
+ if (!name || name === initialName.trim()) {
+ onClose();
+
+ return;
+ }
+
+ setIsPending(true);
+
+ try {
+ await onSubmit(name);
+ onClose();
+ } catch {
+ // The caller surfaced the failure (toast/notification); stay open so
+ // the name is not lost.
+ } finally {
+ setIsPending(false);
+ }
+ };
+
+ return (
+ <Dialog.Root
+ lazyMount
+ open={isOpen}
+ placement="center"
+ size="xs"
+ unmountOnExit
+ onOpenChange={(event) => {
+ if (!event.open) {
+ onClose();
+ }
+ }}
+ >
+ <Portal>
+ <Dialog.Backdrop />
+ <Dialog.Positioner>
+ <Dialog.Content bg="bg.surface" borderColor="border.subtle" borderWidth="1px" color="fg.default">
+ <chakra.form
+ onSubmit={(event) => {
+ event.preventDefault();
+ void commit(new FormData(event.currentTarget).get('renameValue')?.toString() ?? '');
+ }}
+ >
+ <Dialog.Header>
+ <Dialog.Title fontSize="sm" fontWeight="700">
+ {title}
+ </Dialog.Title>
+ </Dialog.Header>
+ <Dialog.Body>
+ <Stack gap="2">
+ <Field label={label}>
+ <Input autoFocus defaultValue={initialName} name="renameValue" size="sm" />
+ </Field>
+ </Stack>
+ </Dialog.Body>
+ <Dialog.Footer gap="2">
+ <Button disabled={isPending} size="xs" type="button" variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ <Button loading={isPending} size="xs" type="submit" variant="solid">
+ Rename
+ </Button>
+ </Dialog.Footer>
+ </chakra.form>
+ <Dialog.CloseTrigger asChild>
+ <CloseButton color="fg.muted" size="sm" />
+ </Dialog.CloseTrigger>
+ </Dialog.Content>
+ </Dialog.Positioner>
+ </Portal>
+ </Dialog.Root>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/home/HomeScreen.tsx b/invokeai/frontend/webv2/src/workbench/home/HomeScreen.tsx
new file mode 100644
index 0000000000..7528fc6adc
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/home/HomeScreen.tsx
@@ -0,0 +1,99 @@
+import type { SystemStyleObject } from '@chakra-ui/react';
+import { Box, Flex, Heading, HStack, Stack, Text } from '@chakra-ui/react';
+import { Link, useNavigate } from '@tanstack/react-router';
+import { useEffect } from 'react';
+import { FileUpIcon, PlusIcon } from 'lucide-react';
+
+import { Button } from '../components/ui/Button';
+import { HomeTopBar } from './HomeTopBar';
+import { ProjectsGrid } from './ProjectsGrid';
+import { ResourceLinks } from './ResourceLinks';
+import { toaster } from '../components/ui/toaster';
+import { refreshProjectLibrary } from '../projects/library';
+import { useAuthSession } from '../auth/session';
+import { importProjectFile, pickProjectFile } from '../projects/projectFile';
+
+const HOME_SCREEN_CONTENT_WRAPPER_SX: SystemStyleObject = {
+ flex: 1,
+ maxW: '6xl',
+ mx: 'auto',
+ p: { base: 4, md: 8 },
+ w: 'full',
+};
+
+/**
+ * The landing surface at `/`: your project library, profile, and pointers to
+ * docs and community — the editor equivalent of Photoshop's home screen. It
+ * deliberately mounts none of the workbench providers or runtimes, so it
+ * stays on the light side of the route-level code split; everything here
+ * works against the library store and the auth session alone.
+ */
+export const HomeScreen = () => {
+ const session = useAuthSession();
+ const navigate = useNavigate();
+
+ useEffect(() => {
+ void refreshProjectLibrary();
+ }, []);
+
+ const displayName = session.user?.display_name?.trim();
+ const greeting = displayName ? `Welcome back, ${displayName}` : 'Welcome to Invoke';
+
+ const handleImport = async () => {
+ const file = await pickProjectFile();
+
+ if (!file) {
+ return;
+ }
+
+ try {
+ const record = await importProjectFile(file);
+
+ await navigate({ search: { project: record.project_id }, to: '/app' });
+ } catch (error) {
+ toaster.create({
+ description: error instanceof Error ? error.message : undefined,
+ title: 'Import failed',
+ type: 'error',
+ });
+ }
+ };
+
+ return (
+ <Flex bg="bg.shell" color="fg.default" direction="column" minH="100dvh">
+ <HomeTopBar />
+ <Box css={HOME_SCREEN_CONTENT_WRAPPER_SX}>
+ <Flex direction={{ base: 'column', md: 'row' }} gap={{ base: '8', md: '10' }}>
+ <Stack flex="1" gap="5" minW="0">
+ <Flex align="center" gap="3" justify="space-between" wrap="wrap">
+ <Stack gap="0.5">
+ <Heading fontSize="xl" fontWeight="700">
+ {greeting}
+ </Heading>
+ <Text color="fg.muted" fontSize="xs">
+ Pick up where you left off, or start something new.
+ </Text>
+ </Stack>
+ <HStack gap="2">
+ <Button size="xs" variant="outline" onClick={() => void handleImport()}>
+ <FileUpIcon />
+ Import…
+ </Button>
+ <Button asChild size="xs" variant="solid">
+ <Link search={{ new: true }} to="/app">
+ <PlusIcon />
+ New project
+ </Link>
+ </Button>
+ </HStack>
+ </Flex>
+ <ProjectsGrid />
+ </Stack>
+ <Box flexShrink={0} w={{ base: 'full', md: '60' }}>
+ <ResourceLinks />
+ </Box>
+ </Flex>
+ </Box>
+ </Flex>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/home/HomeTopBar.tsx b/invokeai/frontend/webv2/src/workbench/home/HomeTopBar.tsx
new file mode 100644
index 0000000000..11ba3e363d
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/home/HomeTopBar.tsx
@@ -0,0 +1,91 @@
+import { Avatar, chakra, Flex, HStack, Icon, Menu, Portal, Text } from '@chakra-ui/react';
+import { useNavigate } from '@tanstack/react-router';
+import { ChevronDownIcon, LogOutIcon } from 'lucide-react';
+
+import { InvokeMark } from '../auth/components/AuthScreen';
+import { MenuContent } from '../components/ui/Menu';
+import { logoutSession, useAuthSession } from '../auth/session';
+
+/**
+ * Home's slim header: brand on the left, the signed-in account on the right.
+ * Account settings and user management live in the editor shell; here the
+ * menu only carries identity and sign-out, and single-user mode shows no
+ * account cluster at all.
+ */
+export const HomeTopBar = () => (
+ <Flex
+ align="center"
+ borderBottomWidth="1px"
+ borderColor="border.subtle"
+ flexShrink={0}
+ justify="space-between"
+ px={{ base: '5', md: '8' }}
+ py="3"
+ >
+ <HStack gap="2.5">
+ <InvokeMark size={22} />
+ <Text fontSize="sm" fontWeight="700">
+ Invoke
+ </Text>
+ </HStack>
+ <HomeUserMenu />
+ </Flex>
+);
+
+const HomeUserMenu = () => {
+ const session = useAuthSession();
+ const navigate = useNavigate();
+
+ if (!session.multiuserEnabled || session.user === null) {
+ return null;
+ }
+
+ const user = session.user;
+ const label = user.display_name?.trim() || user.email;
+
+ const signOut = async () => {
+ await logoutSession();
+ await navigate({ to: '/login' });
+ };
+
+ return (
+ <Menu.Root positioning={{ placement: 'bottom-end' }}>
+ <Menu.Trigger asChild>
+ <chakra.button
+ alignItems="center"
+ color="fg.default"
+ display="flex"
+ flexShrink={0}
+ gap="1.5"
+ px="1.5"
+ py="1"
+ rounded="md"
+ type="button"
+ _hover={{ bg: 'bg.surface' }}
+ >
+ <Avatar.Root bg="accent.widget" color="fg.default" size="2xs">
+ <Avatar.Fallback fontSize="2xs" name={label} />
+ </Avatar.Root>
+ <Text fontSize="xs" fontWeight="600">
+ {label}
+ </Text>
+ <Icon as={ChevronDownIcon} boxSize="3" color="fg.muted" />
+ </chakra.button>
+ </Menu.Trigger>
+ <Portal>
+ <Menu.Positioner>
+ <MenuContent minW="48">
+ <Text color="fg.muted" fontSize="2xs" px="3" py="2">
+ {user.email}
+ </Text>
+ <Menu.Separator />
+ <Menu.Item value="sign-out" onClick={() => void signOut()}>
+ <Icon as={LogOutIcon} boxSize="3.5" />
+ Sign out
+ </Menu.Item>
+ </MenuContent>
+ </Menu.Positioner>
+ </Portal>
+ </Menu.Root>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/home/NewProjectCard.tsx b/invokeai/frontend/webv2/src/workbench/home/NewProjectCard.tsx
new file mode 100644
index 0000000000..c463ee8a3c
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/home/NewProjectCard.tsx
@@ -0,0 +1,27 @@
+import { Flex, Icon, Text } from '@chakra-ui/react';
+import { Link } from '@tanstack/react-router';
+import { PlusIcon } from 'lucide-react';
+
+/** The grid's leading cell: start a fresh draft in the editor. */
+export const NewProjectCard = () => (
+ <Flex
+ align="center"
+ borderColor="border.subtle"
+ borderStyle="dashed"
+ borderWidth="1.5px"
+ direction="column"
+ gap="2"
+ justify="center"
+ minH="40"
+ position="relative"
+ rounded="lg"
+ transition="border-color 0.15s ease, background 0.15s ease"
+ _hover={{ bg: 'bg.surface', borderColor: 'border.emphasized' }}
+ >
+ <Link aria-label="Create new project" search={{ new: true }} style={{ inset: 0, position: 'absolute' }} to="/app" />
+ <Icon as={PlusIcon} boxSize="6" color="fg.muted" />
+ <Text color="fg.muted" fontSize="xs" fontWeight="600">
+ New project
+ </Text>
+ </Flex>
+);
diff --git a/invokeai/frontend/webv2/src/workbench/home/ProjectCard.tsx b/invokeai/frontend/webv2/src/workbench/home/ProjectCard.tsx
new file mode 100644
index 0000000000..088e70b1b7
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/home/ProjectCard.tsx
@@ -0,0 +1,178 @@
+import { Box, Flex, Icon, Menu, Portal, Stack, Text } from '@chakra-ui/react';
+import { Link } from '@tanstack/react-router';
+import { useState } from 'react';
+import {
+ ArrowRightIcon,
+ CopyIcon,
+ EllipsisVerticalIcon,
+ FileDownIcon,
+ FolderIcon,
+ PencilIcon,
+ Trash2Icon,
+} from 'lucide-react';
+
+import { ConfirmDialog } from '../components/ui/ConfirmDialog';
+import { IconButton } from '../components/ui/Button';
+import { MenuContent } from '../components/ui/Menu';
+import { RenameDialog } from '../components/ui/RenameDialog';
+import { formatRelativeTime } from './formatRelativeTime';
+import { toaster } from '../components/ui/toaster';
+import { exportLibraryProject } from '../projects/projectFile';
+import {
+ deleteLibraryProject,
+ duplicateLibraryProject,
+ renameLibraryProject,
+ type ProjectSummary,
+} from '../projects/library';
+
+/**
+ * One saved project in the Home grid. The whole card is a deep link into the
+ * editor (`/app?project=…` — hovering preloads the editor chunk); the corner
+ * menu carries the library actions, which all run against the server without
+ * mounting the editor.
+ */
+export const ProjectCard = ({ summary }: { summary: ProjectSummary }) => {
+ const [isRenameOpen, setIsRenameOpen] = useState(false);
+ const [isDeleteOpen, setIsDeleteOpen] = useState(false);
+
+ const handleRename = async (name: string) => {
+ try {
+ await renameLibraryProject(summary.id, name);
+ } catch (error) {
+ toaster.create({
+ description: error instanceof Error ? error.message : undefined,
+ title: 'Rename failed',
+ type: 'error',
+ });
+ throw error;
+ }
+ };
+
+ const handleDuplicate = async () => {
+ try {
+ const copy = await duplicateLibraryProject(summary.id);
+
+ toaster.create({ description: `"${copy.name}" was created.`, title: 'Project duplicated', type: 'success' });
+ } catch (error) {
+ toaster.create({
+ description: error instanceof Error ? error.message : undefined,
+ title: 'Duplicate failed',
+ type: 'error',
+ });
+ }
+ };
+
+ const handleExport = async () => {
+ try {
+ await exportLibraryProject(summary.id);
+ } catch (error) {
+ toaster.create({
+ description: error instanceof Error ? error.message : undefined,
+ title: 'Export failed',
+ type: 'error',
+ });
+ }
+ };
+
+ const handleDelete = async () => {
+ try {
+ await deleteLibraryProject(summary.id);
+ } catch (error) {
+ toaster.create({
+ description: error instanceof Error ? error.message : undefined,
+ title: 'Delete failed',
+ type: 'error',
+ });
+ }
+ };
+
+ return (
+ <Box
+ bg="bg.surface"
+ borderColor="border.subtle"
+ borderWidth="1px"
+ overflow="hidden"
+ position="relative"
+ rounded="lg"
+ transition="border-color 0.15s ease, background 0.15s ease"
+ _hover={{ bg: 'bg.surfaceRaised', borderColor: 'border.emphasized' }}
+ >
+ <Link
+ aria-label={`Open ${summary.name}`}
+ search={{ project: summary.id }}
+ style={{ inset: 0, position: 'absolute' }}
+ to="/app"
+ />
+ <Flex align="center" bg="bg.subtle" h="24" justify="center" pointerEvents="none">
+ <Icon as={FolderIcon} boxSize="8" color="fg.subtle" opacity={0.6} />
+ </Flex>
+ <Flex align="center" gap="2" p="3" pointerEvents="none">
+ <Stack flex="1" gap="0" minW="0">
+ <Text fontSize="xs" fontWeight="600" truncate>
+ {summary.name}
+ </Text>
+ <Text color="fg.muted" fontSize="2xs">
+ Edited {formatRelativeTime(summary.updatedAt)}
+ </Text>
+ </Stack>
+ </Flex>
+ <Box bottom="2" pointerEvents="auto" position="absolute" right="2" zIndex="1">
+ <Menu.Root positioning={{ placement: 'bottom-end' }}>
+ <Menu.Trigger asChild>
+ <IconButton aria-label={`Actions for ${summary.name}`} color="fg.muted" size="2xs" variant="ghost">
+ <EllipsisVerticalIcon />
+ </IconButton>
+ </Menu.Trigger>
+ <Portal>
+ <Menu.Positioner>
+ <MenuContent minW="44">
+ <Menu.Item asChild value="open">
+ <Link search={{ project: summary.id }} to="/app">
+ <Icon as={ArrowRightIcon} boxSize="3.5" />
+ Open
+ </Link>
+ </Menu.Item>
+ <Menu.Item value="rename" onClick={() => setIsRenameOpen(true)}>
+ <Icon as={PencilIcon} boxSize="3.5" />
+ Rename…
+ </Menu.Item>
+ <Menu.Item value="duplicate" onClick={() => void handleDuplicate()}>
+ <Icon as={CopyIcon} boxSize="3.5" />
+ Duplicate
+ </Menu.Item>
+ <Menu.Item value="export" onClick={() => void handleExport()}>
+ <Icon as={FileDownIcon} boxSize="3.5" />
+ Export
+ </Menu.Item>
+ <Menu.Separator />
+ <Menu.Item
+ color="fg.error"
+ value="delete"
+ _hover={{ bg: 'bg.error', color: 'fg.error' }}
+ onClick={() => setIsDeleteOpen(true)}
+ >
+ <Icon as={Trash2Icon} boxSize="3.5" />
+ Delete…
+ </Menu.Item>
+ </MenuContent>
+ </Menu.Positioner>
+ </Portal>
+ </Menu.Root>
+ </Box>
+ <RenameDialog
+ initialName={summary.name}
+ isOpen={isRenameOpen}
+ onClose={() => setIsRenameOpen(false)}
+ onSubmit={handleRename}
+ />
+ <ConfirmDialog
+ body={`Delete "${summary.name}"? The project is removed from the server permanently.`}
+ confirmLabel="Delete project"
+ isOpen={isDeleteOpen}
+ title="Delete project?"
+ onClose={() => setIsDeleteOpen(false)}
+ onConfirm={handleDelete}
+ />
+ </Box>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/home/ProjectsGrid.tsx b/invokeai/frontend/webv2/src/workbench/home/ProjectsGrid.tsx
new file mode 100644
index 0000000000..efb666eb9b
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/home/ProjectsGrid.tsx
@@ -0,0 +1,38 @@
+import { Alert, SimpleGrid, Skeleton, Stack } from '@chakra-ui/react';
+
+import { Button } from '../components/ui/Button';
+import { NewProjectCard } from './NewProjectCard';
+import { ProjectCard } from './ProjectCard';
+import { refreshProjectLibrary, useProjectLibrary } from '../projects/library';
+
+/**
+ * The saved-projects grid, fed by the project library store (summaries are
+ * already sorted most-recently-edited first). The "new project" cell always
+ * leads, so an empty library still presents the next step.
+ */
+export const ProjectsGrid = () => {
+ const library = useProjectLibrary();
+ const isFirstLoad = library.summaries.length === 0 && (library.status === 'idle' || library.status === 'loading');
+
+ return (
+ <Stack gap="3">
+ {library.status === 'error' ? (
+ <Alert.Root borderRadius="md" size="sm" status="error">
+ <Alert.Indicator />
+ <Alert.Title flex="1" fontSize="xs">
+ {library.error ?? 'Failed to load your projects.'}
+ </Alert.Title>
+ <Button size="2xs" variant="outline" onClick={() => void refreshProjectLibrary()}>
+ Retry
+ </Button>
+ </Alert.Root>
+ ) : null}
+ <SimpleGrid columns={{ base: 1, lg: 3, sm: 2 }} gap="4">
+ <NewProjectCard />
+ {isFirstLoad
+ ? Array.from({ length: 3 }, (_value, index) => <Skeleton key={index} minH="40" rounded="lg" />)
+ : library.summaries.map((summary) => <ProjectCard key={summary.id} summary={summary} />)}
+ </SimpleGrid>
+ </Stack>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/home/ResourceLinks.tsx b/invokeai/frontend/webv2/src/workbench/home/ResourceLinks.tsx
new file mode 100644
index 0000000000..93af399ddd
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/home/ResourceLinks.tsx
@@ -0,0 +1,36 @@
+import { Card, Flex, Icon, Link, Stack, Text } from '@chakra-ui/react';
+import { BookOpenTextIcon, ClapperboardIcon, CodeIcon, ExternalLinkIcon, MessagesSquareIcon } from 'lucide-react';
+import type { ComponentType } from 'react';
+
+/**
+ * Home's side rail: pointers out to the docs and community, plus the
+ * placeholder slot where in-app tutorials will land.
+ */
+
+const RESOURCES: { href: string; icon: ComponentType; label: string }[] = [
+ { href: 'https://invoke-ai.github.io/InvokeAI/', icon: BookOpenTextIcon, label: 'Documentation' },
+ { href: 'https://www.youtube.com/@invokeai', icon: ClapperboardIcon, label: 'YouTube' },
+ { href: 'https://discord.gg/ZmtBAhwWhy', icon: MessagesSquareIcon, label: 'Discord' },
+ { href: 'https://github.com/invoke-ai/InvokeAI', icon: CodeIcon, label: 'GitHub' },
+];
+
+export const ResourceLinks = () => (
+ <Stack>
+ <Card.Root variant="outline">
+ <Card.Header>Resources</Card.Header>
+ <Card.Body>
+ {RESOURCES.map((resource) => (
+ <Link href={resource.href} target="_blank" rel="noreferrer" asChild key={resource.href}>
+ <Flex align="center" gap={2} py={1}>
+ <Icon as={resource.icon} boxSize="3.5" />
+ <Text fontSize="sm">{resource.label}</Text>
+ <Icon as={ExternalLinkIcon} boxSize="3" color="fg.subtle" ms="auto" />
+ </Flex>
+ </Link>
+ ))}
+ </Card.Body>
+ </Card.Root>
+
+ {/* TODO: Tutorials */}
+ </Stack>
+);
diff --git a/invokeai/frontend/webv2/src/workbench/home/formatRelativeTime.ts b/invokeai/frontend/webv2/src/workbench/home/formatRelativeTime.ts
new file mode 100644
index 0000000000..7182fc5232
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/home/formatRelativeTime.ts
@@ -0,0 +1,37 @@
+/**
+ * Compact "Edited 5 minutes ago" timestamps for the Home grid and the Open
+ * Project dialog. Expects ISO timestamps (the project library normalizes the
+ * backend's SQLite format at its boundary).
+ */
+
+const DIVISIONS: { amount: number; unit: Intl.RelativeTimeFormatUnit }[] = [
+ { amount: 60, unit: 'second' },
+ { amount: 60, unit: 'minute' },
+ { amount: 24, unit: 'hour' },
+ { amount: 7, unit: 'day' },
+ { amount: 4.345, unit: 'week' },
+ { amount: 12, unit: 'month' },
+ { amount: Number.POSITIVE_INFINITY, unit: 'year' },
+];
+
+const formatter = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
+
+export const formatRelativeTime = (timestamp: string): string => {
+ const date = new Date(timestamp);
+
+ if (Number.isNaN(date.getTime())) {
+ return '';
+ }
+
+ let duration = (date.getTime() - Date.now()) / 1000;
+
+ for (const division of DIVISIONS) {
+ if (Math.abs(duration) < division.amount) {
+ return formatter.format(Math.round(duration), division.unit);
+ }
+
+ duration /= division.amount;
+ }
+
+ return '';
+};
diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectFile.test.ts b/invokeai/frontend/webv2/src/workbench/projects/projectFile.test.ts
new file mode 100644
index 0000000000..57b615f287
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/projects/projectFile.test.ts
@@ -0,0 +1,92 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { createDraftProject } from '../workbenchState';
+import type * as projectFileModule from './projectFile';
+import type * as persistenceModule from './syncedPersistence';
+
+/**
+ * The portable project file format: versioned envelope, defensive parsing,
+ * and the import rule that a file can never overwrite an existing project
+ * because it always lands under a fresh id.
+ */
+
+const api = vi.hoisted(() => ({
+ createProject: vi.fn(),
+ getProject: vi.fn(),
+}));
+
+vi.mock('./api', () => api);
+
+let projectFile: typeof projectFileModule;
+let persistence: typeof persistenceModule;
+
+beforeEach(async () => {
+ vi.resetModules();
+ api.createProject.mockReset();
+ api.getProject.mockReset();
+
+ projectFile = await import('./projectFile');
+ persistence = await import('./syncedPersistence');
+});
+
+describe('project file envelope', () => {
+ it('round-trips a serialized project document', () => {
+ const project = createDraftProject([]);
+ const document = persistence.serializeProjectDocument(project);
+ const file = projectFile.buildProjectFile(document);
+ const parsed = projectFile.parseProjectFile(JSON.stringify(file));
+
+ expect(parsed).toEqual(document);
+ });
+
+ it('rejects files that are not project exports', () => {
+ expect(projectFile.parseProjectFile('not json')).toBeNull();
+ expect(projectFile.parseProjectFile('{}')).toBeNull();
+ expect(projectFile.parseProjectFile(JSON.stringify({ document: {}, kind: 'other', version: 1 }))).toBeNull();
+ expect(
+ projectFile.parseProjectFile(JSON.stringify({ document: {}, kind: 'invokeai-project', version: 99 }))
+ ).toBeNull();
+ expect(projectFile.parseProjectFile(JSON.stringify({ kind: 'invokeai-project', version: 1 }))).toBeNull();
+ });
+});
+
+describe('importProjectFile', () => {
+ const fileFor = (contents: unknown): File => new File([JSON.stringify(contents)], 'export.invokeproject.json');
+
+ it('creates the project under a fresh id, never the id in the file', async () => {
+ const project = { ...createDraftProject([]), name: 'Exported project' };
+ const document = persistence.serializeProjectDocument(project);
+
+ api.createProject.mockImplementation((request: { project_id?: string; name: string }) =>
+ Promise.resolve({
+ created_at: '2026-06-10 10:00:00.000',
+ data: {},
+ name: request.name,
+ project_id: request.project_id ?? '',
+ revision: 1,
+ updated_at: '2026-06-10 10:00:00.000',
+ })
+ );
+
+ const record = await projectFile.importProjectFile(fileFor(projectFile.buildProjectFile(document)));
+
+ expect(record.project_id).not.toBe(project.id);
+ expect(record.name).toBe('Exported project');
+
+ const createRequest = api.createProject.mock.calls[0][0] as { data: Record<string, unknown>; project_id: string };
+
+ expect(createRequest.data.id).toBe(createRequest.project_id);
+ });
+
+ it('rejects files whose document is not a usable project', async () => {
+ const file = fileFor(projectFile.buildProjectFile({ name: 'No layout' }));
+
+ await expect(projectFile.importProjectFile(file)).rejects.toThrow('damaged');
+ expect(api.createProject).not.toHaveBeenCalled();
+ });
+
+ it('rejects non-project files before touching the server', async () => {
+ await expect(projectFile.importProjectFile(fileFor({ some: 'json' }))).rejects.toThrow('not an Invoke project');
+ expect(api.createProject).not.toHaveBeenCalled();
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/projects/projectFile.ts b/invokeai/frontend/webv2/src/workbench/projects/projectFile.ts
new file mode 100644
index 0000000000..35f2cfd9e3
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/projects/projectFile.ts
@@ -0,0 +1,119 @@
+import { createProjectId } from './ids';
+import { upsertProjectSummary } from './library';
+import { deserializeProjectDocument, serializeProjectDocument } from './syncedPersistence';
+import { createProject as apiCreateProject, getProject as apiGetProject, type ProjectRecordDTO } from './api';
+import type { Project } from '../types';
+
+/**
+ * The portable project file: a versioned envelope around the same document
+ * shape the server stores. Export and import both reuse the sync layer's
+ * serialize/deserialize pair, so the file format inherits its healing of
+ * partial documents and there is exactly one definition of "a project
+ * document" in the app.
+ */
+
+export const PROJECT_FILE_KIND = 'invokeai-project';
+export const PROJECT_FILE_VERSION = 1;
+
+export interface ProjectFile {
+ kind: typeof PROJECT_FILE_KIND;
+ version: typeof PROJECT_FILE_VERSION;
+ exportedAt: string;
+ document: Record<string, unknown>;
+}
+
+export const buildProjectFile = (projectDocument: Record<string, unknown>): ProjectFile => ({
+ document: projectDocument,
+ exportedAt: new Date().toISOString(),
+ kind: PROJECT_FILE_KIND,
+ version: PROJECT_FILE_VERSION,
+});
+
+/** Returns the embedded document, or null when the text is not a project file. */
+export const parseProjectFile = (text: string): Record<string, unknown> | null => {
+ try {
+ const parsed = JSON.parse(text) as Partial<ProjectFile> | null;
+
+ if (
+ !parsed ||
+ parsed.kind !== PROJECT_FILE_KIND ||
+ parsed.version !== PROJECT_FILE_VERSION ||
+ !parsed.document ||
+ typeof parsed.document !== 'object' ||
+ Array.isArray(parsed.document)
+ ) {
+ return null;
+ }
+
+ return parsed.document as Record<string, unknown>;
+ } catch {
+ return null;
+ }
+};
+
+const sanitizeFileName = (name: string): string => name.replace(/[^\w\- ]+/gu, '').trim() || 'project';
+
+const downloadProjectFile = (name: string, projectDocument: Record<string, unknown>): void => {
+ const blob = new Blob([JSON.stringify(buildProjectFile(projectDocument), null, 2)], { type: 'application/json' });
+ const url = URL.createObjectURL(blob);
+ const anchor = document.createElement('a');
+
+ anchor.href = url;
+ anchor.download = `${sanitizeFileName(name)}.invokeproject.json`;
+ anchor.click();
+ URL.revokeObjectURL(url);
+};
+
+/** Export a closed project straight from its server record. */
+export const exportLibraryProject = async (projectId: string): Promise<void> => {
+ const record = await apiGetProject(projectId);
+
+ downloadProjectFile(record.name, record.data);
+};
+
+/** Export an open project from its live in-memory document. */
+export const exportOpenProject = (project: Project): void => {
+ downloadProjectFile(project.name, serializeProjectDocument(project));
+};
+
+/**
+ * Import a project file as a new server project. The document gets a fresh
+ * id — never the one in the file — so an import can never collide with (and
+ * overwrite) an existing project. Throws with a user-readable message.
+ */
+export const importProjectFile = async (file: File): Promise<ProjectRecordDTO> => {
+ const projectDocument = parseProjectFile(await file.text());
+
+ if (!projectDocument) {
+ throw new Error('This file is not an Invoke project export.');
+ }
+
+ const id = createProjectId();
+ const name =
+ typeof projectDocument.name === 'string' && projectDocument.name.trim()
+ ? projectDocument.name.trim()
+ : 'Imported project';
+ const document = { ...projectDocument, id, name };
+
+ if (!deserializeProjectDocument(document)) {
+ throw new Error('The project file is damaged and cannot be opened.');
+ }
+
+ const record = await apiCreateProject({ data: document, name, project_id: id });
+
+ upsertProjectSummary({ id: record.project_id, name: record.name, revision: record.revision });
+
+ return record;
+};
+
+/** Open the browser's file picker for a project file; null when dismissed. */
+export const pickProjectFile = (): Promise<File | null> =>
+ new Promise((resolve) => {
+ const input = document.createElement('input');
+
+ input.type = 'file';
+ input.accept = 'application/json,.json';
+ input.onchange = () => resolve(input.files?.[0] ?? null);
+ input.oncancel = () => resolve(null);
+ input.click();
+ });