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(webv2): list open projects in the Launchpad sidebar
Josh Corbett313dcbcef0b9
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 35b0a40a17..314f907502 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1687,7 +1687,7 @@"viewAllProjects": "View all projects"},"openProjects": {- "activeLabel": "Open projects. Current project: {{name}}",+ "current": "Current","label": "Open projects","openEditor": "Open editor"},diff --git a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjsindex aa3bb47e76..e1061f33bd 100644--- a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs+++ b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs@@ -311,21 +311,32 @@ const runKeyboardJourney = async (browser) => {try {await waitForHome(page);- const projectsTab = page.getByRole('tab', { exact: true, name: 'Projects' });- const fontsTab = page.getByRole('tab', { exact: true, name: 'Fonts' });- const modelsTab = page.getByRole('tab', { exact: true, name: 'Models' });-- // Arrow navigation must cross rail groups while skipping headings.- await projectsTab.focus();- await projectsTab.press('ArrowDown');- await expectFocused(fontsTab, 'ArrowDown should move focus from Projects to Fonts.');- assert.match(page.url(), /#\/fonts$/);- assert.equal(await fontsTab.getAttribute('aria-selected'), 'true');- await fontsTab.press('ArrowDown');- await expectFocused(modelsTab, 'ArrowDown should move focus from Fonts to Models.');+ const rail = page.getByRole('navigation', { exact: true, name: 'Launchpad sections' });+ const projectsLink = rail.getByRole('link', { exact: true, name: 'Projects' });+ const fontsLink = rail.getByRole('link', { exact: true, name: 'Fonts' });+ const modelsLink = rail.getByRole('link', { exact: true, name: 'Models' });++ // The rail's links are in visual order, so Tab and reading order follow what it shows.+ const railLinkTops = await rail+ .getByRole('link')+ .evaluateAll((links) => links.map((link) => link.getBoundingClientRect().top));+ assert.deepEqual(+ railLinkTops,+ [...railLinkTops].sort((a, b) => a - b),+ 'Launchpad rail links must follow their visual order.'+ );++ await fontsLink.focus();+ await fontsLink.press('Enter');+ await page.waitForURL(/#\/fonts$/);+ assert.equal(await fontsLink.getAttribute('aria-current'), 'page');+ await fontsLink.press('Tab');+ await expectFocused(modelsLink, 'Tab should move focus from Fonts to Models.');+ await modelsLink.press('Enter');await waitForModels(page);assert.match(page.url(), /#\/models$/);- assert.equal(await modelsTab.getAttribute('aria-selected'), 'true');+ assert.equal(await modelsLink.getAttribute('aria-current'), 'page');+ assert.equal(await fontsLink.getAttribute('aria-current'), null);const paletteTrigger = page.getByRole('button', { exact: true, name: 'Command palette' });@@ -339,8 +350,8 @@ const runKeyboardJourney = async (browser) => {await paletteDialog.waitFor({ state: 'hidden' });await expectFocused(paletteTrigger, 'Closing the command palette should restore focus to its trigger.');- await projectsTab.focus();- await projectsTab.press('Enter');+ await projectsLink.focus();+ await projectsLink.press('Enter');await waitForProjects(page);const projectLink = page.getByRole('link', { exact: true, name: 'Open Fixture Project 001' });diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/Launchpad.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/Launchpad.tsxindex 45bd7f520c..1ee433701d 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/Launchpad.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/Launchpad.tsx@@ -4,12 +4,11 @@ import { useCapabilities, UsersPage } from '@features/identity';import { requestIntermediatesFocus } from '@features/intermediates';import { ModelsPage } from '@features/models';import { NodesPage } from '@features/nodes';-import { Tabs } from '@platform/ui';-import { useLocation, useNavigate } from '@tanstack/react-router';+import { useLocation } from '@tanstack/react-router';import { LaunchpadCommandPalette } from '@workbench/palette/LaunchpadCommandPalette';import { openWorkbenchSettings } from '@workbench/settings/settingsDialogStore';import { BlocksIcon, BoxIcon, FolderIcon, HouseIcon, TypeIcon, UsersIcon, type LucideIcon } from 'lucide-react';-import { useCallback, useMemo, type ReactNode } from 'react';+import { useMemo, useState, type ReactNode } from 'react';import { useTranslation } from 'react-i18next';import { LaunchpadNav, type LaunchpadNavGroupId } from './LaunchpadNav';@@ -59,7 +58,7 @@ const SECTION_PATHS: Record<LaunchpadSectionId, '/' | '/projects' | '/models' |users: '/users',};-const TABS_CSS: SystemStyleObject = {+const SECTIONS_CSS: SystemStyleObject = {display: 'flex',flex: 1,flexDirection: { base: 'column', md: 'row' },@@ -152,40 +151,35 @@ export const Launchpad = () => {const LaunchpadSections = ({ sections }: { sections: LaunchpadSection[] }) => {const location = useLocation();- const navigate = useNavigate();const requestedSectionId = getRequestedSectionId(location.pathname);const activeSectionId = getActiveSectionId(sections, requestedSectionId);const activeSectionLabel = sections.find((section) => section.id === activeSectionId)?.label ?? activeSectionId;- const handleValueChange = useCallback(- (details: { value: string }) => {- if (isSectionId(details.value)) {- void navigate({ to: SECTION_PATHS[details.value] });- }- },- [navigate]+ const navItems = useMemo(+ () => sections.map((section) => ({ ...section, to: SECTION_PATHS[section.id] })),+ [sections]);+ // Visited pages stay mounted (hidden) so returning to one keeps its state, as the former lazily mounted tabs did.+ const [visitedIds, setVisitedIds] = useState<ReadonlySet<LaunchpadSectionId>>(() => new Set([activeSectionId]));++ if (!visitedIds.has(activeSectionId)) {+ setVisitedIds(new Set(visitedIds).add(activeSectionId));+ }return (- <Tabs.Root- css={TABS_CSS}- lazyMount- size="sm"- orientation="vertical"- value={activeSectionId}- variant="subtle"- onValueChange={handleValueChange}- >- <LaunchpadNav items={sections} />+ <Flex css={SECTIONS_CSS}>+ <LaunchpadNav activeId={activeSectionId} items={navItems} /><Box aria-labelledby="launchpad-page-heading" as="main" flex="1" minH="0" minW="0" position="relative"><VisuallyHidden as="h1" id="launchpad-page-heading">{activeSectionLabel}</VisuallyHidden>- {sections.map((section) => (- <Tabs.Content key={section.id} h="full" m="0" minH="0" p="0" value={section.id}>- {section.render()}- </Tabs.Content>- ))}+ {sections+ .filter((section) => visitedIds.has(section.id))+ .map((section) => (+ <Box key={section.id} h="full" hidden={section.id !== activeSectionId} minH="0">+ {section.render()}+ </Box>+ ))}</Box>- </Tabs.Root>+ </Flex>);};diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadNav.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadNav.tsxindex 5d16b7e0fa..ba287d4ace 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadNav.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadNav.tsx@@ -2,11 +2,13 @@ import type { SystemStyleObject } from '@chakra-ui/react';import type { LucideIcon } from 'lucide-react';import { Box, Icon, Stack, Text } from '@chakra-ui/react';-import { Tabs } from '@platform/ui';-import { Fragment, useMemo } from 'react';+import { Button } from '@platform/ui/Button';+import { Link } from '@tanstack/react-router';+import { useId, useMemo } from 'react';import { useTranslation } from 'react-i18next';import { HelpMenu } from './HelpMenu';+import { OpenProjectsNavSection } from './OpenProjectsControl';const NAV_BORDER_END_WIDTH = { md: '1px' } as const;const NAV_BORDER_BOTTOM_WIDTH = { base: '1px', md: '0' } as const;@@ -16,8 +18,8 @@ const NAV_HEIGHT = { base: 'auto', md: 'full' } as const;const FOOTER_MARGIN_TOP = { md: 'auto' } as const;/**- * Keep decorative group headings inside one Tabs.List so arrow navigation crosses groups while separating work- * from administration.+ * Sections are routes, so the rail is route links in visual order: Workspace, the open projects, then Manage.+ * Tab and reading order follow what the rail shows.*/export type LaunchpadNavGroupId = 'workspace' | 'manage';@@ -27,10 +29,9 @@ export interface LaunchpadNavItem {label: string;icon: LucideIcon;group: LaunchpadNavGroupId;+ to: string;}-const GROUP_ORDER: readonly LaunchpadNavGroupId[] = ['workspace', 'manage'];-const GROUP_LABEL_KEY: Record<LaunchpadNavGroupId, string> = {manage: 'launchpad.groups.manage',workspace: 'launchpad.groups.workspace',@@ -42,20 +43,62 @@ const GROUP_LABEL_SX: SystemStyleObject = {fontSize: '2xs',fontWeight: '600',letterSpacing: '0.02em',+ pb: '1',+ pt: '1',+ px: '2',textTransform: 'uppercase',};+/** Space between rail groups; headings carry no top padding of their own. */+const NAV_SX: SystemStyleObject = { '& > section ~ section': { pt: '2' } };++/** Rail entries match the settings dialog's navigation items: ghost buttons, subtle for the current page. */+const NAV_ITEM_PROPS = { justifyContent: 'start', size: 'sm', w: 'full' } as const;-export const LaunchpadNav = ({ items }: { items: LaunchpadNavItem[] }) => {+const NavGroup = ({+ activeId,+ group,+ items,+ showLabel,+}: {+ activeId: string;+ group: LaunchpadNavGroupId;+ items: LaunchpadNavItem[];+ showLabel: boolean;+}) => {const { t } = useTranslation();- const groups = useMemo(- () =>- GROUP_ORDER.map((group) => ({ group, items: items.filter((item) => item.group === group) })).filter(- (entry) => entry.items.length > 0- ),- [items]+ const headingId = useId();++ return (+ <Stack aria-labelledby={showLabel ? headingId : undefined} as="section" gap="0.5">+ {showLabel ? (+ <Text css={GROUP_LABEL_SX} id={headingId}>+ {t(GROUP_LABEL_KEY[group])}+ </Text>+ ) : null}+ {items.map((item) => (+ <Button+ key={item.id}+ asChild+ {...NAV_ITEM_PROPS}+ aria-current={item.id === activeId ? 'page' : undefined}+ variant={item.id === activeId ? 'subtle' : 'ghost'}+ >+ <Link to={item.to}>+ <Icon as={item.icon} boxSize="3.5" flexShrink={0} />+ <Text truncate>{item.label}</Text>+ </Link>+ </Button>+ ))}+ </Stack>);+};++export const LaunchpadNav = ({ activeId, items }: { activeId: string; items: LaunchpadNavItem[] }) => {+ const { t } = useTranslation();+ const workspaceItems = useMemo(() => items.filter((item) => item.group === 'workspace'), [items]);+ const manageItems = useMemo(() => items.filter((item) => item.group === 'manage'), [items]);// Show headings only when multiple groups need distinguishing.- const showGroupLabels = groups.length > 1;+ const showGroupLabels = workspaceItems.length > 0 && manageItems.length > 0;return (<Stack@@ -64,36 +107,23 @@ export const LaunchpadNav = ({ items }: { items: LaunchpadNavItem[] }) => {borderColor="border.subtle"borderBottomWidth={NAV_BORDER_BOTTOM_WIDTH}borderEndWidth={NAV_BORDER_END_WIDTH}+ css={NAV_SX}flexShrink={0}- gap="2"+ gap="0"h={NAV_HEIGHT}minH="0"p="2"w={NAV_WIDTH}>{items.length > 1 ? (- <Tabs.List flexShrink={0} gap="0.5">- {groups.map((entry, index) => (- <Fragment key={entry.group}>- {showGroupLabels ? (- // A `role="separator"` element is an invalid tablist child, so- // the spacing above each heading does the dividing instead.- <Text css={GROUP_LABEL_SX} pb="1" pt={index > 0 ? '3' : '1'} px="2" role="presentation">- {t(GROUP_LABEL_KEY[entry.group])}- </Text>- ) : null}- {entry.items.map((item) => (- <Tabs.Trigger key={item.id} value={item.id}>- <Icon as={item.icon} boxSize="3.5" flexShrink={0} />- <Text truncate>{item.label}</Text>- </Tabs.Trigger>- ))}- </Fragment>- ))}- </Tabs.List>+ <NavGroup activeId={activeId} group="workspace" items={workspaceItems} showLabel={showGroupLabels} />+ ) : null}+ <OpenProjectsNavSection headingCss={GROUP_LABEL_SX} itemProps={NAV_ITEM_PROPS} />+ {items.length > 1 && manageItems.length > 0 ? (+ <NavGroup activeId={activeId} group="manage" items={manageItems} showLabel={showGroupLabels} />) : null}- <Box mt={FOOTER_MARGIN_TOP}>+ <Box mt={FOOTER_MARGIN_TOP} pt="2"><HelpMenu /></Box></Stack>diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsxindex e664ecf817..ad989a85e5 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx@@ -8,8 +8,6 @@ import { PaletteButton } from '@workbench/palette/PaletteButton';import { SettingsButton } from '@workbench/settings/SettingsButton';import { useTranslation } from 'react-i18next';-import { OpenProjectsControl } from './OpenProjectsControl';-const CONNECTION_LABEL_KEY: Record<Exclude<BackendConnectionStatus, 'connected'>, string> = {connecting: 'launchpad.connection.connecting',disconnected: 'launchpad.connection.disconnected',@@ -61,7 +59,6 @@ export const LaunchpadTopBar = () => (<Text fontSize="sm" fontWeight="700">Invoke</Text>- <OpenProjectsControl /></HStack><HStack gap="2"><ConnectionChip />diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/OpenProjectsControl.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/OpenProjectsControl.tsxindex 5236dd6b3f..68e7356d2e 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/OpenProjectsControl.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/OpenProjectsControl.tsx@@ -1,13 +1,14 @@-import { Icon, Menu, Portal } from '@chakra-ui/react';+import type { SystemStyleObject } from '@chakra-ui/react';++import { Badge, Icon, Stack, Text } from '@chakra-ui/react';import { useMountEffect } from '@platform/react/useMountEffect';import { Button } from '@platform/ui/Button';-import { MenuContent } from '@platform/ui/Menu';import { MiddleTruncate } from '@platform/ui/MiddleTruncate';import { Link } from '@tanstack/react-router';import { useProjectLibrarySelector } from '@workbench/projects/library';import { refreshOpenProjects, useOpenProjectsSelector } from '@workbench/projects/openProjects';-import { ArrowLeftIcon, CheckIcon } from 'lucide-react';-import { useMemo } from 'react';+import { ArrowUpRightIcon, FolderOpenIcon } from 'lucide-react';+import { useId, useMemo, type ComponentProps } from 'react';import { useTranslation } from 'react-i18next';/**@@ -15,10 +16,30 @@ import { useTranslation } from 'react-i18next';* resolve them.*/-const MENU_POSITIONING = { placement: 'bottom-start' } as const;+/** Many open projects scroll inside the section instead of pushing Manage out of the rail. */+const LIST_MAX_H = '48';++/** These entries leave the Launchpad for the editor; a corner arrow says so on hover and keyboard focus. */+const LEAVE_ENTRY_CSS: SystemStyleObject = {+ '& [data-leave-icon]': {+ opacity: 0,+ transitionDuration: 'var(--wb-motion-duration-fast)',+ transitionProperty: 'opacity',+ },+ '&:hover [data-leave-icon], &:focus-visible [data-leave-icon]': { opacity: 1 },+};++type NavItemProps = Pick<ComponentProps<typeof Button>, 'justifyContent' | 'size' | 'w'>;-export const OpenProjectsControl = () => {+export const OpenProjectsNavSection = ({+ headingCss,+ itemProps,+}: {+ headingCss: SystemStyleObject;+ itemProps: NavItemProps;+}) => {const { t } = useTranslation();+ const headingId = useId();const status = useOpenProjectsSelector((snapshot) => snapshot.status);const openProjectIds = useOpenProjectsSelector((snapshot) => snapshot.ids);const activeProjectId = useOpenProjectsSelector((snapshot) => snapshot.activeId);@@ -38,73 +59,69 @@ export const OpenProjectsControl = () => {return openProjectIds.map((id) => ({ id, name: nameById.get(id) ?? null }));}, [openProjectIds, summaries]);- if (status !== 'ready') {+ if (status !== 'ready' || (openProjectIds !== null && openProjects.length === 0)) {return null;}- if (openProjectIds === null) {- return <OpenEditorButton />;- }-- if (openProjects.length === 0) {- return null;- }-- const activeName = openProjects.find((project) => project.id === activeProjectId)?.name;- const triggerLabel = activeName ?? t('launchpad.openProjects.label');-return (- <Menu.Root positioning={MENU_POSITIONING}>- <Menu.Trigger asChild>- <Button- aria-label={activeName ? t('launchpad.openProjects.activeLabel', { name: activeName }) : triggerLabel}- maxW="56"- size="xs"- variant="subtle"- >- <ArrowLeftIcon />- <MiddleTruncate text={triggerLabel} />- </Button>- </Menu.Trigger>- <Portal>- <Menu.Positioner>- <MenuContent minW="15rem">- {openProjects.map((project) => (- <OpenProjectItem- id={project.id}- isActive={project.id === activeProjectId}- key={project.id}- name={project.name}- />- ))}- </MenuContent>- </Menu.Positioner>- </Portal>- </Menu.Root>+ <Stack aria-labelledby={headingId} as="section" flexShrink={1} gap="0.5" minH="0">+ <Text css={headingCss} id={headingId}>+ {t('launchpad.openProjects.label')}+ </Text>+ <Stack gap="0.5" maxH={LIST_MAX_H} minH="0" overflowY="auto">+ {openProjectIds === null ? (+ <Button asChild {...itemProps} css={LEAVE_ENTRY_CSS} variant="ghost">+ <Link to="/app">+ <Icon as={FolderOpenIcon} boxSize="3.5" flexShrink={0} />+ <Text flex="1" minW="0" textAlign="start" truncate>+ {t('launchpad.openProjects.openEditor')}+ </Text>+ <LeaveIcon />+ </Link>+ </Button>+ ) : (+ openProjects.map((project) => (+ <OpenProjectEntry+ key={project.id}+ id={project.id}+ isActive={project.id === activeProjectId}+ itemProps={itemProps}+ name={project.name}+ />+ ))+ )}+ </Stack>+ </Stack>);};-const OpenProjectItem = ({ id, isActive, name }: { id: string; isActive: boolean; name: string | null }) => {+const LeaveIcon = () => <Icon as={ArrowUpRightIcon} aria-hidden boxSize="3.5" data-leave-icon flexShrink={0} />;++const OpenProjectEntry = ({+ id,+ isActive,+ itemProps,+ name,+}: {+ id: string;+ isActive: boolean;+ itemProps: NavItemProps;+ name: string | null;+}) => {+ const { t } = useTranslation();const search = useMemo(() => ({ project: id }), [id]);return (- <Menu.Item asChild value={id}>+ <Button asChild {...itemProps} css={LEAVE_ENTRY_CSS} variant="ghost"><Link search={search} to="/app">- <Icon as={CheckIcon} boxSize="3.5" opacity={isActive ? 1 : 0} />- <Menu.ItemText>{name ?? id}</Menu.ItemText>- </Link>- </Menu.Item>- );-};--const OpenEditorButton = () => {- const { t } = useTranslation();-- return (- <Button asChild size="xs" variant="subtle">- <Link to="/app">- <ArrowLeftIcon />- {t('launchpad.openProjects.openEditor')}+ <Icon as={FolderOpenIcon} boxSize="3.5" flexShrink={0} />+ <MiddleTruncate flex="1" minW="0" text={name ?? id} textAlign="start" />+ {isActive ? (+ <Badge flexShrink={0} size="xs" variant="subtle">+ {t('launchpad.openProjects.current')}+ </Badge>+ ) : null}+ <LeaveIcon /></Link></Button>);