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(models): preserve project navigation context

joshistoast39fbc723375d
diff --git a/invokeai/frontend/webv2/src/router.tsx b/invokeai/frontend/webv2/src/router.tsx
index 141bb865a3..b9573a9ee0 100644
--- a/invokeai/frontend/webv2/src/router.tsx
+++ b/invokeai/frontend/webv2/src/router.tsx
@@ -99,6 +99,9 @@ const modelsHomeRoute = createRoute({
component: Launchpad,
getParentRoute: () => authenticatedRoute,
path: 'models',
+ validateSearch: (search: Record<string, unknown>): { project?: string } => ({
+ project: typeof search.project === 'string' && search.project.length > 0 ? search.project : undefined,
+ }),
});
const nodesHomeRoute = createRoute({
diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts
index ec5f3494d9..7a2f524f4a 100644
--- a/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts
+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts
@@ -179,7 +179,7 @@ export const useRegisterFirstPartyCommands = () => {
title: 'Select Workflows tab',
}),
commandApi.register({
- handler: () => (window.location.hash = '#/models'),
+ handler: () => (window.location.hash = `#/models?project=${encodeURIComponent(projectRef.current.id)}`),
id: 'app.selectModelsTab',
title: 'Select Models tab',
}),
diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx
index 5d35c8f4ce..2b23ea64a9 100644
--- a/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx
+++ b/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx
@@ -1,10 +1,15 @@
import type { BackendConnectionStatus } from '@workbench/types';
import { Box, Flex, HStack, Text } from '@chakra-ui/react';
+import { Link, useSearch } from '@tanstack/react-router';
import { AccountMenu } from '@workbench/auth/components/AccountMenu';
import { useConnectionStatusSelector } from '@workbench/backend/connectionStore';
import { InvokeMark } from '@workbench/components/InvokeMark';
+import { Button } from '@workbench/components/ui';
import { SettingsButton } from '@workbench/settings/SettingsDialog';
+import { ArrowLeftIcon } from 'lucide-react';
+import { useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
const CONNECTION_LABEL: Record<Exclude<BackendConnectionStatus, 'connected'>, string> = {
connecting: 'Connecting…',
@@ -39,29 +44,43 @@ const ConnectionChip = () => {
);
};
-export const LaunchpadTopBar = () => (
- <Flex
- align="center"
- borderBottomWidth="1px"
- bg="bg.subtle"
- flexShrink={0}
- justify="space-between"
- pe="1.5"
- ps="4"
- h="12"
- >
- <HStack gap="3">
- <InvokeMark size={20} />
- <Text fontSize="sm" fontWeight="700">
- Invoke
- </Text>
- </HStack>
- <HStack gap="2">
- <ConnectionChip />
- <HStack gap="0.5">
- <SettingsButton />
- <AccountMenu />
+export const LaunchpadTopBar = () => {
+ const { t } = useTranslation();
+ const search = useSearch({ strict: false }) as { project?: string };
+ const projectSearch = useMemo(() => (search.project ? { project: search.project } : {}), [search.project]);
+
+ return (
+ <Flex
+ align="center"
+ borderBottomWidth="1px"
+ bg="bg.subtle"
+ flexShrink={0}
+ justify="space-between"
+ pe="1.5"
+ ps="4"
+ h="12"
+ >
+ <HStack gap="3">
+ <InvokeMark size={20} />
+ <Text fontSize="sm" fontWeight="700">
+ Invoke
+ </Text>
+ {search.project ? (
+ <Button asChild colorPalette="accent" size="sm" variant="solid">
+ <Link search={projectSearch} to="/app">
+ <ArrowLeftIcon />
+ {t('launchpad.backToProject')}
+ </Link>
+ </Button>
+ ) : null}
</HStack>
- </HStack>
- </Flex>
-);
+ <HStack gap="2">
+ <ConnectionChip />
+ <HStack gap="0.5">
+ <SettingsButton />
+ <AccountMenu />
+ </HStack>
+ </HStack>
+ </Flex>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/models/manager/layoutConstants.ts b/invokeai/frontend/webv2/src/workbench/launchpad/models/manager/layoutConstants.ts
index d749adfda4..efba7857af 100644
--- a/invokeai/frontend/webv2/src/workbench/launchpad/models/manager/layoutConstants.ts
+++ b/invokeai/frontend/webv2/src/workbench/launchpad/models/manager/layoutConstants.ts
@@ -1,4 +1,4 @@
-export const LIBRARY_WIDTH = '22rem';
+export const LIBRARY_WIDTH = 'clamp(22rem, 32vw, 28rem)';
// Both column headers share a min height so the library title bar lines up with
// the detail tab bar.
diff --git a/invokeai/frontend/webv2/src/workbench/models/components/ModelSelect.tsx b/invokeai/frontend/webv2/src/workbench/models/components/ModelSelect.tsx
index 2fe22b3742..32d9669c4e 100644
--- a/invokeai/frontend/webv2/src/workbench/models/components/ModelSelect.tsx
+++ b/invokeai/frontend/webv2/src/workbench/models/components/ModelSelect.tsx
@@ -22,6 +22,7 @@ import { getModelPickerGroups } from '@workbench/models/library';
import { ensureModelsLoaded, useModelsSelector } from '@workbench/models/modelsStore';
import { formatBytes, getModelTypePluralLabel } from '@workbench/models/taxonomy';
import { useWorkbenchPreferenceSelector } from '@workbench/settings/store';
+import { useActiveProjectId } from '@workbench/WorkbenchContext';
import { BoxIcon, CheckIcon, ChevronDownIcon, RotateCcwIcon, SearchIcon, XIcon } from 'lucide-react';
import { useDeferredValue, useEffect, useMemo, useRef, useState } from 'react';
@@ -397,15 +398,20 @@ export const ModelSelect = ({
);
};
-const ModelManagerLinkButton = () => (
- <Tooltip content="Manage models" showArrow>
- <IconButton aria-label="Manage models" asChild flexShrink={0} size="xs" variant="ghost">
- <Link to="/models">
- <BoxIcon />
- </Link>
- </IconButton>
- </Tooltip>
-);
+const ModelManagerLinkButton = () => {
+ const projectId = useActiveProjectId();
+ const search = useMemo(() => ({ project: projectId }), [projectId]);
+
+ return (
+ <Tooltip content="Manage models" showArrow>
+ <IconButton aria-label="Manage models" asChild flexShrink={0} size="xs" variant="ghost">
+ <Link search={search} to="/models">
+ <BoxIcon />
+ </Link>
+ </IconButton>
+ </Tooltip>
+ );
+};
const BaseChip = ({
base,
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/ModelManagerButton.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/ModelManagerButton.tsx
index 3cab1806be..4578489b42 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/ModelManagerButton.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/ModelManagerButton.tsx
@@ -1,15 +1,19 @@
import { Link } from '@tanstack/react-router';
import { IconButton, Tooltip } from '@workbench/components/ui';
+import { useActiveProjectId } from '@workbench/WorkbenchContext';
import { BoxIcon } from 'lucide-react';
+import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
export const ModelManagerButton = () => {
const { t } = useTranslation();
+ const projectId = useActiveProjectId();
+ const search = useMemo(() => ({ project: projectId }), [projectId]);
return (
<Tooltip content={t('models.manager')} showArrow>
<IconButton aria-label={t('models.manager')} asChild size="sm" variant="ghost">
- <Link to="/models">
+ <Link search={search} to="/models">
<BoxIcon />
</Link>
</IconButton>