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(workbench): add mod+K command palette
joshistoasta0defed3372c
diff --git a/invokeai/frontend/webv2/package.json b/invokeai/frontend/webv2/package.jsonindex 4142d199aa..d22b5932e5 100644--- a/invokeai/frontend/webv2/package.json+++ b/invokeai/frontend/webv2/package.json@@ -40,6 +40,7 @@"@tanstack/react-virtual": "^3.14.6","@xyflow/react": "^12.11.2","ag-psd": "^31.0.2",+ "fuzzysort": "^3.1.0","i18next": "^26.3.6","i18next-http-backend": "^4.0.0","lucide-react": "^1.25.0",diff --git a/invokeai/frontend/webv2/pnpm-lock.yaml b/invokeai/frontend/webv2/pnpm-lock.yamlindex 3b28810373..15a719d98c 100644--- a/invokeai/frontend/webv2/pnpm-lock.yaml+++ b/invokeai/frontend/webv2/pnpm-lock.yaml@@ -44,6 +44,9 @@ importers:ag-psd:specifier: ^31.0.2version: 31.0.2+ fuzzysort:+ specifier: ^3.1.0+ version: 3.1.0i18next:specifier: ^26.3.6version: 26.3.6([email protected])@@ -1536,6 +1539,9 @@ packages:resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}+ resolution: {integrity: sha512-sR9BNCjBg6LNgwvxlBd0sBABvQitkLzoVY9MYYROQVX/FvfJ4Mai9LsGhDgd8qYdds0bY77VzYd5iuB+v5rwQQ==}+resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==}engines: {node: '>=6.9.0'}@@ -3694,6 +3700,8 @@ snapshots:+ [email protected]: {}+diff --git a/invokeai/frontend/webv2/src/app/WorkbenchApp.tsx b/invokeai/frontend/webv2/src/app/WorkbenchApp.tsxindex 04a08cda88..d4646c5aae 100644--- a/invokeai/frontend/webv2/src/app/WorkbenchApp.tsx+++ b/invokeai/frontend/webv2/src/app/WorkbenchApp.tsx@@ -3,6 +3,7 @@ import type { WorkbenchSearch } from '@workbench/projects/session';import { SessionExpiryGuard } from '@features/identity';import { useSearch } from '@tanstack/react-router';import { WorkbenchHotkeyRuntime } from '@workbench/hotkeys/WorkbenchHotkeyRuntime';+import { WorkbenchCommandPalette } from '@workbench/palette';import { WorkbenchShell } from '@workbench/shell';import { WidgetHosts } from '@workbench/widget-frame/WidgetHosts';import { getWidgetById, getWidgetsForRegion } from '@workbench/widgetRegistry';@@ -38,6 +39,7 @@ export const WorkbenchApp = () => {<WorkbenchUiPorts><SessionExpiryGuard /><WorkbenchHotkeyRuntime />+ <WorkbenchCommandPalette /><QueueRuntimeAdapter /><WorkbenchRuntime /><WorkbenchSessionController search={search} />diff --git a/invokeai/frontend/webv2/src/architecture/workbenchOwnershipManifest.json b/invokeai/frontend/webv2/src/architecture/workbenchOwnershipManifest.jsonindex bcb2751224..496af1915a 100644--- a/invokeai/frontend/webv2/src/architecture/workbenchOwnershipManifest.json+++ b/invokeai/frontend/webv2/src/architecture/workbenchOwnershipManifest.json@@ -3,21 +3,70 @@"currentOwner": "workbench","emptyDirectories": ["i18n"],"directoryRules": {- "canvas-engine": { "targetOwner": "workbench", "targetPath": "workbench/canvas-engine" },- "canvas-operations": { "targetOwner": "workbench", "targetPath": "workbench/canvas-operations" },- "components": { "targetOwner": "workbench", "targetPath": "workbench/components" },- "diagnostics": { "targetOwner": "workbench", "targetPath": "workbench/diagnostics" },- "extensions": { "targetOwner": "workbench", "targetPath": "workbench/extensions" },- "hotkeys": { "targetOwner": "workbench", "targetPath": "workbench/hotkeys" },- "i18n": { "targetOwner": "workbench", "targetPath": "workbench/i18n" },- "image-actions": { "targetOwner": "workbench", "targetPath": "workbench/image-actions" },- "launchpad": { "targetOwner": "workbench", "targetPath": "workbench/launchpad" },- "projects": { "targetOwner": "workbench", "targetPath": "workbench/projects" },- "queue-integration": { "targetOwner": "workbench", "targetPath": "workbench/queue-integration" },- "settings": { "targetOwner": "workbench", "targetPath": "workbench/settings" },- "shell": { "targetOwner": "workbench", "targetPath": "workbench/shell" },- "widget-frame": { "targetOwner": "workbench", "targetPath": "workbench/widget-frame" },- "widgets": { "targetOwner": "workbench", "targetPath": "workbench/widgets" }+ "canvas-engine": {+ "targetOwner": "workbench",+ "targetPath": "workbench/canvas-engine"+ },+ "canvas-operations": {+ "targetOwner": "workbench",+ "targetPath": "workbench/canvas-operations"+ },+ "components": {+ "targetOwner": "workbench",+ "targetPath": "workbench/components"+ },+ "diagnostics": {+ "targetOwner": "workbench",+ "targetPath": "workbench/diagnostics"+ },+ "extensions": {+ "targetOwner": "workbench",+ "targetPath": "workbench/extensions"+ },+ "hotkeys": {+ "targetOwner": "workbench",+ "targetPath": "workbench/hotkeys"+ },+ "i18n": {+ "targetOwner": "workbench",+ "targetPath": "workbench/i18n"+ },+ "image-actions": {+ "targetOwner": "workbench",+ "targetPath": "workbench/image-actions"+ },+ "launchpad": {+ "targetOwner": "workbench",+ "targetPath": "workbench/launchpad"+ },+ "palette": {+ "targetOwner": "workbench",+ "targetPath": "workbench/palette"+ },+ "projects": {+ "targetOwner": "workbench",+ "targetPath": "workbench/projects"+ },+ "queue-integration": {+ "targetOwner": "workbench",+ "targetPath": "workbench/queue-integration"+ },+ "settings": {+ "targetOwner": "workbench",+ "targetPath": "workbench/settings"+ },+ "shell": {+ "targetOwner": "workbench",+ "targetPath": "workbench/shell"+ },+ "widget-frame": {+ "targetOwner": "workbench",+ "targetPath": "workbench/widget-frame"+ },+ "widgets": {+ "targetOwner": "workbench",+ "targetPath": "workbench/widgets"+ }},"overrides": [{diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.test.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.test.tsindex c84eccc581..203648ee5d 100644--- a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.test.ts+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.test.ts@@ -5,9 +5,10 @@ import { firstPartyHotkeyCatalog } from './catalog';describe('firstPartyHotkeyCatalog', () => {it('keeps legacy default hotkey parity', () => {// 91 legacy-parity entries + `canvas.newSession` (webv2 new-canvas command,- // no default keys — Task 46).- expect(firstPartyHotkeyCatalog).toHaveLength(92);+ // no default keys — Task 46) + `app.openCommandPalette` (webv2-only, mod+k).+ expect(firstPartyHotkeyCatalog).toHaveLength(93);expect(firstPartyHotkeyCatalog.map((hotkey) => hotkey.id)).toContain('app.invoke');+ expect(firstPartyHotkeyCatalog.map((hotkey) => hotkey.id)).toContain('app.openCommandPalette');expect(firstPartyHotkeyCatalog.map((hotkey) => hotkey.id)).toContain('canvas.mergeDown');expect(firstPartyHotkeyCatalog.map((hotkey) => hotkey.id)).toContain('canvas.newSession');expect(firstPartyHotkeyCatalog.map((hotkey) => hotkey.id)).toContain('workflows.copySelection');diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.tsindex 8cce9b1878..46cb2051e1 100644--- a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts@@ -10,6 +10,7 @@ const categoryScopes = {const implemented = new Set(['app.cancelQueueItem',+ 'app.openCommandPalette','app.clearQueue','app.focusPrompt','app.invoke',@@ -103,6 +104,9 @@ const hotkey = (category: HotkeyCategory, id: string, defaultKeys: string[]): Ho};export const firstPartyHotkeyCatalog: HotkeyDefinition[] = [+ // The palette must open while typing and toggle closed above its own modal+ // layer, so it opts into both editable and modal contexts.+ { ...hotkey('app', 'openCommandPalette', ['mod+k']), allowInEditable: true, allowInModal: true },hotkey('app', 'invoke', ['mod+enter']),hotkey('app', 'invokeFront', ['mod+shift+enter']),hotkey('app', 'cancelQueueItem', ['shift+x']),diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.tsindex 18abe62111..3888dd3d3b 100644--- a/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts@@ -13,6 +13,7 @@ import { useMountEffect } from '@platform/react/useMountEffect';import { getConnectionStatus } from '@platform/transport/connectionStore';import { isInvocationRouteValid, resolveInvocationRoute } from '@workbench/invocation';import { submitResolvedInvocation } from '@workbench/invocationSubmit';+import { toggleCommandPalette } from '@workbench/palette/paletteStore';import { openWidgetPlacement } from '@workbench/widgetPlacementCommands';import { getWidgetsForRegion } from '@workbench/widgetRegistry';import { getProjectWidgetValues } from '@workbench/widgetState';@@ -31,6 +32,7 @@ const imageRecallCommands: Record<string, ImageRecallKind> = {export const FIRST_PARTY_APP_COMMAND_IDS = ['app.invoke','app.invokeFront',+ 'app.openCommandPalette','app.cancelQueueItem','app.clearQueue','app.selectGenerateTab',@@ -134,6 +136,11 @@ export const useRegisterFirstPartyCommands = () => {useEffect(() => {const disposers = [+ commandApi.register({+ handler: toggleCommandPalette,+ id: 'app.openCommandPalette',+ title: 'Open Command Palette',+ }),commandApi.register({ handler: submitInvocation, id: 'app.invoke', title: 'Invoke' }),commandApi.register({ handler: submitInvocation, id: 'app.invokeFront', title: 'Invoke front' }),commandApi.register({diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/Launchpad.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/Launchpad.tsxindex a5d9e08b2c..8aaf9905cd 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/Launchpad.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/Launchpad.tsx@@ -4,6 +4,7 @@ import { ModelsPage } from '@features/models';import { NodesPage } from '@features/nodes';import { Tabs } from '@platform/ui';import { useLocation, useNavigate } from '@tanstack/react-router';+import { LaunchpadCommandPalette } from '@workbench/palette';import { BoxIcon, BlocksIcon, FolderIcon, UsersIcon, type LucideIcon } from 'lucide-react';import { useCallback, useMemo, type ReactNode } from 'react';import { useTranslation } from 'react-i18next';@@ -111,6 +112,7 @@ export const Launchpad = () => {<Flex bg="bg" color="fg" direction="column" h="100dvh" overflow="hidden"><LaunchpadTopBar /><LaunchpadSections sections={filtered} />+ <LaunchpadCommandPalette /></Flex>);};diff --git a/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx b/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsxindex 562c02a9ca..9b45b74e4e 100644--- a/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx+++ b/invokeai/frontend/webv2/src/workbench/launchpad/LaunchpadTopBar.tsx@@ -6,6 +6,7 @@ import { useConnectionStatusSelector } from '@platform/transport/connectionStoreimport { Button } from '@platform/ui';import { InvokeMark } from '@platform/ui/InvokeMark';import { Link, useSearch } from '@tanstack/react-router';+import { PaletteButton } from '@workbench/palette';import { SettingsButton } from '@workbench/settings/SettingsDialog';import { ArrowLeftIcon } from 'lucide-react';import { useMemo } from 'react';@@ -75,6 +76,7 @@ export const LaunchpadTopBar = () => {<HStack gap="2"><ConnectionChip /><HStack gap="0.5">+ <PaletteButton /><SettingsButton /><AccountMenu /></HStack>diff --git a/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.tsx b/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.tsxnew file mode 100644index 0000000000..f7ccced885--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.tsx@@ -0,0 +1,387 @@+import type { ChangeEvent, KeyboardEvent, ReactNode } from 'react';++import { Box, Dialog, HStack, Icon, Kbd, Portal, ScrollArea, Spacer, Text, chakra } from '@chakra-ui/react';+import { useMountEffect } from '@platform/react/useMountEffect';+import { EmptyState } from '@platform/ui/EmptyState';+import { dropdownGroupLabel } from '@theme/recipes';+import { registerHotkeyModalLayer } from '@workbench/hotkeys/modalLayer';+import { SearchIcon } from 'lucide-react';+import { useCallback, useMemo, useState } from 'react';+import { useVirtualizer } from 'react-hook-tanstack-virtual';++import type { PaletteEntry, PaletteRow } from './entries';++import { searchPaletteRows } from './entries';+import { getRecentEntryIds, recordRecentEntry } from './recents';++/**+ * The palette surface: a top-anchored quiet overlay with one input, one mixed+ * virtualized list (fixed section order, fuzzy-ranked within sections), and a+ * footer hint bar. Follows the AddNodeDialog combobox pattern — focus stays on+ * the input, the highlighted row travels via aria-activedescendant, and hover+ * only claims the highlight on real mouse movement (not scroll-under-cursor).+ */++const RESULT_LIST_ID = 'command-palette-results';+const LABEL_ROW_HEIGHT_PX = 26;+const ENTRY_ROW_HEIGHT_PX = 40;+const PAGE_JUMP_ROWS = 8;+const VIRTUALIZER_INITIAL_RECT = { height: 384, width: 0 };++const INPUT_PLACEHOLDER_STYLE = { color: 'fg.subtle' };++const getRowDomId = (index: number): string => `${RESULT_LIST_ID}-${index}`;++/** Render the entry title with fuzzysort's matched characters subtly emphasized. */+const renderTitle = (title: string, matchIndexes?: readonly number[]): ReactNode => {+ if (!matchIndexes || matchIndexes.length === 0) {+ return title;+ }++ const matched = new Set(matchIndexes);+ const segments: ReactNode[] = [];+ let start = 0;++ for (let index = 1; index <= title.length; index += 1) {+ if (index === title.length || matched.has(index) !== matched.has(start)) {+ const text = title.slice(start, index);++ segments.push(+ matched.has(start) ? (+ <Text key={start} as="span" fontWeight="600">+ {text}+ </Text>+ ) : (+ text+ )+ );+ start = index;+ }+ }++ return segments;+};++const EntryRow = ({+ id,+ isActive,+ matchIndexes,+ entry,+ onActive,+ onRun,+}: {+ id: string;+ isActive: boolean;+ matchIndexes?: readonly number[];+ entry: PaletteEntry;+ onActive: () => void;+ onRun: () => void;+}) => (+ <HStack+ id={id}+ as="button"+ aria-selected={isActive}+ bg={isActive ? 'bg.emphasized' : undefined}+ role="option"+ tabIndex={-1}+ cursor="pointer"+ gap="2.5"+ h={`${ENTRY_ROW_HEIGHT_PX}px`}+ px="3"+ rounded="sm"+ textAlign="start"+ w="full"+ onClick={onRun}+ onMouseMove={onActive}+ >+ <Text fontSize="sm" truncate>+ {renderTitle(entry.title, matchIndexes)}+ </Text>+ {entry.subtitle ? (+ <Text color="fg.subtle" flexShrink={0} fontSize="xs">+ {entry.subtitle}+ </Text>+ ) : null}+ <Spacer />+ {entry.keys ? (+ <HStack flexShrink={0} gap="0.5">+ {entry.keys.map((part) => (+ <Kbd key={part} size="sm" textTransform="lowercase">+ {part}+ </Kbd>+ ))}+ </HStack>+ ) : null}+ </HStack>+);++const VirtualPaletteRow = ({+ activeIndex,+ measureElement,+ rows,+ virtualIndex,+ virtualStart,+ onActiveIndexChange,+ onRunRow,+}: {+ activeIndex: number;+ measureElement: (node: Element | null) => void;+ rows: PaletteRow[];+ virtualIndex: number;+ virtualStart: number;+ onActiveIndexChange: (index: number) => void;+ onRunRow: (row: PaletteRow) => void;+}) => {+ const row = rows[virtualIndex];+ const onActive = useCallback(() => onActiveIndexChange(virtualIndex), [onActiveIndexChange, virtualIndex]);+ const onRun = useCallback(() => row && onRunRow(row), [onRunRow, row]);++ if (!row) {+ return null;+ }++ return (+ <Box+ ref={measureElement}+ data-index={virtualIndex}+ left="0"+ position="absolute"+ top="0"+ transform={`translateY(${virtualStart}px)`}+ w="full"+ >+ {row.kind === 'label' ? (+ <Text css={dropdownGroupLabel} pb="1" pt="2" px="3" role="presentation">+ {row.label}+ </Text>+ ) : (+ <EntryRow+ id={getRowDomId(virtualIndex)}+ entry={row.entry}+ isActive={virtualIndex === activeIndex}+ matchIndexes={row.matchIndexes}+ onActive={onActive}+ onRun={onRun}+ />+ )}+ </Box>+ );+};++export const CommandPaletteDialog = ({+ entries,+ isOpen,+ onClose,+}: {+ entries: PaletteEntry[];+ isOpen: boolean;+ onClose: () => void;+}) => {+ const onDialogOpenChange = useCallback(+ (event: { open: boolean }) => {+ if (!event.open) {+ onClose();+ }+ },+ [onClose]+ );++ return (+ <Dialog.Root lazyMount open={isOpen} scrollBehavior="inside" unmountOnExit onOpenChange={onDialogOpenChange}>+ {isOpen ? <CommandPaletteContent entries={entries} onClose={onClose} /> : null}+ </Dialog.Root>+ );+};++const CommandPaletteContent = ({ entries, onClose }: { entries: PaletteEntry[]; onClose: () => void }) => {+ const [query, setQuery] = useState('');+ const [activeIndex, setActiveIndex] = useState(-1);+ // Snapshot at open: recents should not reshuffle while the palette is up.+ const [recentIds] = useState(getRecentEntryIds);+ const [scrollElement, setScrollElement] = useState<HTMLDivElement | null>(null);++ useMountEffect(() => registerHotkeyModalLayer('command-palette'));++ const rows = useMemo(() => searchPaletteRows(entries, query, recentIds), [entries, query, recentIds]);+ const entryRowIndexes = useMemo(() => rows.flatMap((row, index) => (row.kind === 'entry' ? [index] : [])), [rows]);+ // The highlight always lands on an entry row; -1 (or a stale index after a+ // query change) resolves to the first hit so Enter runs the top result.+ const effectiveActiveIndex = entryRowIndexes.includes(activeIndex) ? activeIndex : (entryRowIndexes[0] ?? -1);++ const estimateRowSize = useCallback(+ (index: number) => (rows[index]?.kind === 'label' ? LABEL_ROW_HEIGHT_PX : ENTRY_ROW_HEIGHT_PX),+ [rows]+ );+ const getRowKey = useCallback((index: number) => rows[index]?.id ?? index, [rows]);+ const getScrollElement = useCallback(() => scrollElement, [scrollElement]);++ const virtualizer = useVirtualizer({+ count: rows.length,+ estimateSize: estimateRowSize,+ getItemKey: getRowKey,+ getScrollElement,+ initialRect: VIRTUALIZER_INITIAL_RECT,+ overscan: 8,+ });++ const runRow = useCallback(+ (row: PaletteRow) => {+ if (row.kind !== 'entry') {+ return;+ }++ recordRecentEntry(row.entry.id);++ if (row.entry.keepOpen) {+ void row.entry.run();+ return;+ }++ // Close first so command side effects (focus, navigation, widget+ // placement) land in a palette-free world.+ onClose();+ void row.entry.run();+ },+ [onClose]+ );++ const moveActive = useCallback(+ (offset: number) => {+ if (entryRowIndexes.length === 0) {+ return;+ }++ const position = entryRowIndexes.indexOf(effectiveActiveIndex);+ const nextPosition =+ Math.abs(offset) === 1+ ? (position + offset + entryRowIndexes.length) % entryRowIndexes.length+ : Math.min(Math.max(position + offset, 0), entryRowIndexes.length - 1);+ const nextIndex = entryRowIndexes[nextPosition];++ if (nextIndex === undefined) {+ return;+ }++ setActiveIndex(nextIndex);+ virtualizer.scrollToIndex(nextIndex, { align: 'auto' });+ },+ [effectiveActiveIndex, entryRowIndexes, virtualizer]+ );++ const onSearchKeyDown = useCallback(+ (event: KeyboardEvent<HTMLInputElement>) => {+ if (event.key === 'ArrowDown') {+ event.preventDefault();+ moveActive(1);+ } else if (event.key === 'ArrowUp') {+ event.preventDefault();+ moveActive(-1);+ } else if (event.key === 'PageDown') {+ event.preventDefault();+ moveActive(PAGE_JUMP_ROWS);+ } else if (event.key === 'PageUp') {+ event.preventDefault();+ moveActive(-PAGE_JUMP_ROWS);+ } else if (event.key === 'Enter') {+ event.preventDefault();+ const row = effectiveActiveIndex === -1 ? undefined : rows[effectiveActiveIndex];++ if (row) {+ runRow(row);+ }+ }+ },+ [effectiveActiveIndex, moveActive, rows, runRow]+ );++ const onSearchChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {+ setQuery(event.currentTarget.value);+ setActiveIndex(-1);+ }, []);++ return (+ <Portal>+ <Dialog.Backdrop bg="blackAlpha.300" />+ <Dialog.Positioner alignItems="flex-start" pt="15vh">+ <Dialog.Content maxW="none" overflow="hidden" p="0" w="min(560px, calc(100vw - 32px))">+ <HStack borderBottomWidth="1px" borderColor="border.emphasized" flexShrink={0} gap="2.5" h="12" px="3">+ <Icon as={SearchIcon} boxSize="4" color="fg.muted" flexShrink={0} />+ <chakra.input+ autoFocus+ aria-activedescendant={effectiveActiveIndex === -1 ? undefined : getRowDomId(effectiveActiveIndex)}+ aria-controls={RESULT_LIST_ID}+ aria-expanded="true"+ aria-label="Search commands and settings"+ bg="transparent"+ color="fg"+ flex="1"+ fontSize="sm"+ outline="none"+ placeholder="Search commands, settings, and more…"+ role="combobox"+ value={query}+ w="full"+ _placeholder={INPUT_PLACEHOLDER_STYLE}+ onChange={onSearchChange}+ onKeyDown={onSearchKeyDown}+ />+ </HStack>+ {rows.length === 0 ? (+ <EmptyState py="6" title={`No results for “${query.trim()}”`} />+ ) : (+ <ScrollArea.Root maxH="min(400px, 55dvh)" size="xs" variant="hover" w="full">+ <ScrollArea.Viewport ref={setScrollElement} aria-label="Command palette results" maxH="inherit" w="full">+ <ScrollArea.Content id={RESULT_LIST_ID} pb="1.5" role="listbox" w="full">+ <Box h={`${virtualizer.totalSize}px`} position="relative" w="full">+ {virtualizer.virtualItems.map((virtualRow) => (+ <VirtualPaletteRow+ key={virtualRow.key}+ activeIndex={effectiveActiveIndex}+ measureElement={virtualizer.measureElement}+ rows={rows}+ virtualIndex={virtualRow.index}+ virtualStart={virtualRow.start}+ onActiveIndexChange={setActiveIndex}+ onRunRow={runRow}+ />+ ))}+ </Box>+ </ScrollArea.Content>+ </ScrollArea.Viewport>+ <ScrollArea.Scrollbar>+ <ScrollArea.Thumb />+ </ScrollArea.Scrollbar>+ </ScrollArea.Root>+ )}+ <HStack+ borderColor="border.emphasized"+ borderTopWidth="1px"+ color="fg.subtle"+ flexShrink={0}+ fontSize="xs"+ gap="4"+ h="8"+ hideBelow="sm"+ px="3"+ >+ <HStack gap="1">+ <Kbd size="sm">↑</Kbd>+ <Kbd size="sm">↓</Kbd>+ <Text>Navigate</Text>+ </HStack>+ <HStack gap="1">+ <Kbd size="sm">↵</Kbd>+ <Text>Run</Text>+ </HStack>+ <HStack gap="1">+ <Kbd size="sm" textTransform="lowercase">+ esc+ </Kbd>+ <Text>Close</Text>+ </HStack>+ </HStack>+ </Dialog.Content>+ </Dialog.Positioner>+ </Portal>+ );+};diff --git a/invokeai/frontend/webv2/src/workbench/palette/LaunchpadCommandPalette.tsx b/invokeai/frontend/webv2/src/workbench/palette/LaunchpadCommandPalette.tsxnew file mode 100644index 0000000000..08d4aeb75f--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/LaunchpadCommandPalette.tsx@@ -0,0 +1,110 @@+import { useCapabilities } from '@features/identity';+import { useNavigate, useSearch } from '@tanstack/react-router';+import { openWorkbenchSettings } from '@workbench/settings/settingsDialogStore';+import { patchWorkbenchPreferences, useWorkbenchPreferences } from '@workbench/settings/store';+import { useEffect, useMemo } from 'react';+import { tinykeys } from 'tinykeys';++import type { PaletteEntry } from './entries';++import { CommandPaletteDialog } from './CommandPaletteDialog';+import { buildSettingsEntries } from './entries';+import { closeCommandPalette, commandPaletteStore, toggleCommandPalette } from './paletteStore';++/**+ * Launchpad host: the editor's hotkey runtime is not mounted here, so this+ * host binds mod+K itself. The source set is deliberately reduced — section+ * navigation and settings only; editor commands need an editor mount. A mod+K+ * that works "sometimes" trains users not to trust it.+ */++const SETTINGS_ENTRY_DEPS = {+ openSettingsSection: openWorkbenchSettings,+ patchPreferences: patchWorkbenchPreferences,+};++export const LaunchpadCommandPalette = () => {+ const isOpen = commandPaletteStore.useSelector((snapshot) => snapshot.isOpen);+ const navigate = useNavigate();+ const search = useSearch({ strict: false }) as { project?: string };+ const preferences = useWorkbenchPreferences();+ const { canManageModels, canManageNodes, canManageUsers } = useCapabilities();++ useEffect(+ () =>+ tinykeys(window, {+ // preventDefault beats Firefox's Ctrl+K address-bar search; macOS has+ // no browser binding on Cmd+K.+ '$mod+KeyK': (event) => {+ event.preventDefault();+ toggleCommandPalette();+ },+ }),+ []+ );++ const entries = useMemo<PaletteEntry[]>(() => {+ const navigation: PaletteEntry[] = [+ {+ group: 'Navigation',+ id: 'launchpad.openEditor',+ keywords: 'workbench app project',+ run: () => void navigate({ search: search.project ? { project: search.project } : {}, to: '/app' }),+ showInEmptyState: true,+ title: 'Open Editor',+ },+ {+ group: 'Navigation',+ id: 'launchpad.goToProjects',+ run: () => void navigate({ to: '/projects' }),+ showInEmptyState: true,+ title: 'Go to Projects',+ },+ ...(canManageModels+ ? [+ {+ group: 'Navigation',+ id: 'launchpad.goToModels',+ run: () => void navigate({ to: '/models' }),+ showInEmptyState: true,+ title: 'Go to Models',+ },+ ]+ : []),+ ...(canManageNodes+ ? [+ {+ group: 'Navigation',+ id: 'launchpad.goToNodes',+ run: () => void navigate({ to: '/nodes' }),+ showInEmptyState: true,+ title: 'Go to Nodes',+ },+ ]+ : []),+ ...(canManageUsers+ ? [+ {+ group: 'Navigation',+ id: 'launchpad.goToUsers',+ run: () => void navigate({ to: '/users' }),+ showInEmptyState: true,+ title: 'Go to Users',+ },+ ]+ : []),+ {+ group: 'App',+ id: 'app.openSettings',+ keywords: 'preferences options',+ run: () => openWorkbenchSettings(),+ showInEmptyState: true,+ title: 'Open Settings',+ },+ ];++ return [...navigation, ...buildSettingsEntries(preferences, SETTINGS_ENTRY_DEPS)];+ }, [canManageModels, canManageNodes, canManageUsers, navigate, preferences, search.project]);++ return <CommandPaletteDialog entries={entries} isOpen={isOpen} onClose={closeCommandPalette} />;+};diff --git a/invokeai/frontend/webv2/src/workbench/palette/PaletteButton.tsx b/invokeai/frontend/webv2/src/workbench/palette/PaletteButton.tsxnew file mode 100644index 0000000000..67590382ea--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/PaletteButton.tsx@@ -0,0 +1,15 @@+import { Icon } from '@chakra-ui/react';+import { IconButton, Tooltip } from '@platform/ui';+import { formatHotkeyForPlatform } from '@workbench/hotkeys/keys';+import { SearchIcon } from 'lucide-react';++import { openCommandPalette } from './paletteStore';++/** Pointer affordance for the palette; the kbd hint keeps mod+K discoverable. */+export const PaletteButton = () => (+ <Tooltip content={`Command palette (${formatHotkeyForPlatform('mod+k').join('+')})`}>+ <IconButton aria-label="Command palette" size="sm" variant="ghost" onClick={openCommandPalette}>+ <Icon as={SearchIcon} />+ </IconButton>+ </Tooltip>+);diff --git a/invokeai/frontend/webv2/src/workbench/palette/WorkbenchCommandPalette.tsx b/invokeai/frontend/webv2/src/workbench/palette/WorkbenchCommandPalette.tsxnew file mode 100644index 0000000000..a32d2732eb--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/WorkbenchCommandPalette.tsx@@ -0,0 +1,87 @@+import { openWorkbenchSettings } from '@workbench/settings/settingsDialogStore';+import { patchWorkbenchPreferences, useWorkbenchPreferences } from '@workbench/settings/store';+import { useActiveProjectSelector, useWorkbenchExtensions } from '@workbench/WorkbenchContext';+import { useCallback, useMemo, useSyncExternalStore } from 'react';++import type { PaletteEntry } from './entries';++import { CommandPaletteDialog } from './CommandPaletteDialog';+import { buildCatalogCommandEntries, buildSettingsEntries } from './entries';+import { closeCommandPalette, commandPaletteStore } from './paletteStore';++/**+ * Editor host: aggregates the hotkey catalog, extension palette contributions,+ * and settings into the palette. Widget-scoped commands are filtered to widget+ * types present in the current layout, and execute through the contribution's+ * own source so widget handlers resolve exactly as they do for hotkeys.+ */++const SETTINGS_ENTRY_DEPS = {+ openSettingsSection: openWorkbenchSettings,+ patchPreferences: patchWorkbenchPreferences,+};++const STATIC_APP_ENTRIES: PaletteEntry[] = [+ {+ group: 'App',+ id: 'app.openSettings',+ keywords: 'preferences options',+ run: () => openWorkbenchSettings(),+ showInEmptyState: true,+ title: 'Open Settings',+ },+ {+ group: 'App',+ id: 'app.openHotkeySettings',+ keywords: 'hotkeys keybindings shortcuts',+ run: () => openWorkbenchSettings('hotkeys'),+ title: 'Keyboard Shortcuts',+ },+];++export const WorkbenchCommandPalette = () => {+ const isOpen = commandPaletteStore.useSelector((snapshot) => snapshot.isOpen);+ const extensions = useWorkbenchExtensions();+ const preferences = useWorkbenchPreferences();+ const projectId = useActiveProjectSelector((project) => project.id);+ const presentWidgetTypeIds = useActiveProjectSelector((project) =>+ [...new Set(Object.values(project.widgetInstances).map((instance) => instance.typeId))].sort()+ );+ const paletteStore = extensions.stores.palette;+ const paletteContributions = useSyncExternalStore(paletteStore.subscribe, paletteStore.list, paletteStore.list);++ const executeCommand = useCallback(+ (commandId: string) => {+ // Widget handlers register with a source; reuse it so scoped commands+ // resolve, falling back to the sourceless (global) registration.+ const contribution = extensions.stores.commands.findLatest(+ (candidate) => candidate.id === commandId && (!candidate.source || candidate.source.projectId === projectId)+ );++ return extensions.commands.executeForSource(commandId, contribution?.source ?? null);+ },+ [extensions, projectId]+ );++ const entries = useMemo<PaletteEntry[]>(+ () => [+ ...buildCatalogCommandEntries({+ customHotkeys: preferences.customHotkeys,+ execute: executeCommand,+ presentWidgetTypeIds: new Set(presentWidgetTypeIds),+ }),+ ...paletteContributions.map<PaletteEntry>((contribution) => ({+ group: 'Commands',+ id: `palette:${contribution.commandId}`,+ keywords: contribution.keywords?.join(' '),+ run: () => extensions.commands.executeForSource(contribution.commandId, contribution.source ?? null),+ title: contribution.title,+ })),+ ...STATIC_APP_ENTRIES,+ ...buildSettingsEntries(preferences, SETTINGS_ENTRY_DEPS),+ ],+ [executeCommand, extensions, paletteContributions, preferences, presentWidgetTypeIds]+ );++ return <CommandPaletteDialog entries={entries} isOpen={isOpen} onClose={closeCommandPalette} />;+};diff --git a/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts b/invokeai/frontend/webv2/src/workbench/palette/entries.test.tsnew file mode 100644index 0000000000..942ae45ede--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts@@ -0,0 +1,150 @@+import { DEFAULT_PREFERENCES } from '@workbench/settings/store';+import { describe, expect, it, vi } from 'vitest';++import type { PaletteEntry } from './entries';++import { buildCatalogCommandEntries, buildSettingsEntries, searchPaletteRows } from './entries';++/**+ * The palette's source aggregation and ranking contract: unimplemented and+ * hotkey-only commands never surface, widget commands follow layout presence,+ * settings rows read/write preferences, and the row list keeps its fixed+ * section order with fuzzy ranking inside each section.+ */++const noop = () => undefined;++const makeEntry = (overrides: Partial<PaletteEntry> & Pick<PaletteEntry, 'id' | 'title' | 'group'>): PaletteEntry => ({+ run: noop,+ ...overrides,+});++describe('buildCatalogCommandEntries', () => {+ const build = (presentWidgetTypeIds: ReadonlySet<string>, execute: (commandId: string) => unknown = noop) =>+ buildCatalogCommandEntries({ customHotkeys: {}, execute, presentWidgetTypeIds });++ it('surfaces implemented app commands with palette-facing titles and groups', () => {+ const entries = build(new Set());+ const invoke = entries.find((entry) => entry.id === 'app.invoke');+ const generateTab = entries.find((entry) => entry.id === 'app.selectGenerateTab');++ expect(invoke).toMatchObject({ group: 'Generation', title: 'Invoke' });+ expect(generateTab).toMatchObject({ group: 'Navigation', showInEmptyState: true, title: 'Go to Generate' });+ });++ it('hides unimplemented and hotkey-only commands', () => {+ const ids = build(new Set(['canvas', 'gallery', 'preview', 'workflow'])).map((entry) => entry.id);++ expect(ids).not.toContain('app.selectUpscalingTab');+ expect(ids).not.toContain('gallery.galleryNavLeft');+ expect(ids).not.toContain('app.promptWeightUp');+ expect(ids).not.toContain('app.openCommandPalette');+ });++ it('shows widget-scoped commands only while the widget type is in the layout', () => {+ const withoutCanvas = build(new Set(['gallery'])).map((entry) => entry.id);+ const withCanvas = build(new Set(['canvas'])).map((entry) => entry.id);++ expect(withoutCanvas).not.toContain('canvas.undo');+ expect(withoutCanvas).toContain('gallery.remix');+ expect(withCanvas).toContain('canvas.undo');+ });++ it('formats the bound hotkey (custom overrides win) and executes by command id', () => {+ const execute = vi.fn();+ const entries = buildCatalogCommandEntries({+ customHotkeys: { 'app.clearQueue': ['mod+shift+q'] },+ execute,+ presentWidgetTypeIds: new Set(),+ });+ const invoke = entries.find((entry) => entry.id === 'app.invoke');+ const clearQueue = entries.find((entry) => entry.id === 'app.clearQueue');++ expect(invoke?.keys).toEqual(['ctrl', 'enter']);+ expect(clearQueue?.keys).toEqual(['ctrl', 'shift', 'q']);++ invoke?.run();+ expect(execute).toHaveBeenCalledWith('app.invoke');+ });+});++describe('buildSettingsEntries', () => {+ it('renders toggle state and flips the preference in place', () => {+ const patchPreferences = vi.fn();+ const entries = buildSettingsEntries(+ { ...DEFAULT_PREFERENCES, reduceMotion: false },+ { openSettingsSection: vi.fn(), patchPreferences }+ );+ const reduceMotion = entries.find((entry) => entry.id === 'setting.reduceMotion');++ expect(reduceMotion).toMatchObject({ keepOpen: true, subtitle: 'Off' });++ reduceMotion?.run();+ expect(patchPreferences).toHaveBeenCalledWith({ reduceMotion: true });+ });++ it('deep-links enum preferences and sections to the settings dialog', () => {+ const openSettingsSection = vi.fn();+ const entries = buildSettingsEntries(DEFAULT_PREFERENCES, { openSettingsSection, patchPreferences: vi.fn() });+ const theme = entries.find((entry) => entry.id === 'setting.themeId');+ const workflowSection = entries.find((entry) => entry.id === 'settings.section.workflow');++ expect(theme?.subtitle).toBe('Classic');++ theme?.run();+ expect(openSettingsSection).toHaveBeenCalledWith('appearance');++ workflowSection?.run();+ expect(openSettingsSection).toHaveBeenCalledWith('workflow');+ });+});++describe('searchPaletteRows', () => {+ const entries: PaletteEntry[] = [+ makeEntry({ group: 'Generation', id: 'app.invoke', title: 'Invoke' }),+ makeEntry({ group: 'Generation', id: 'app.invokeFront', title: 'Invoke (Front of Queue)' }),+ makeEntry({ group: 'Navigation', id: 'app.selectCanvasTab', showInEmptyState: true, title: 'Go to Canvas' }),+ makeEntry({ group: 'Settings', id: 'setting.reduceMotion', subtitle: 'Off', title: 'Reduce Motion' }),+ ];++ it('renders the launcher state for an empty query: recents, then navigation only', () => {+ const rows = searchPaletteRows(entries, '', ['setting.reduceMotion']);++ expect(rows.map((row) => row.id)).toEqual([+ 'label:Recent',+ 'recent:setting.reduceMotion',+ 'label:Navigation',+ 'app.selectCanvasTab',+ ]);+ });++ it('filters stale recent ids against the live entry list', () => {+ const rows = searchPaletteRows(entries, '', ['no.longer.exists']);++ expect(rows.map((row) => row.id)).toEqual(['label:Navigation', 'app.selectCanvasTab']);+ });++ it('ranks fuzzy matches within their section and drops non-matches', () => {+ const rows = searchPaletteRows(entries, 'invoke', []);++ expect(rows.map((row) => row.id)).toEqual(['label:Generation', 'app.invoke', 'app.invokeFront']);+ });++ it('keeps the fixed section order regardless of match strength', () => {+ const rows = searchPaletteRows(+ [+ makeEntry({ group: 'Settings', id: 'setting.a', title: 'Motion' }),+ makeEntry({ group: 'Generation', id: 'command.a', title: 'Prompt Motion Nudge' }),+ ],+ 'motion',+ []+ );+ const labels = rows.filter((row) => row.kind === 'label').map((row) => row.id);++ expect(labels).toEqual(['label:Generation', 'label:Settings']);+ });++ it('returns no rows for a junk query', () => {+ expect(searchPaletteRows(entries, 'zzzzqqq', [])).toEqual([]);+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/palette/entries.ts b/invokeai/frontend/webv2/src/workbench/palette/entries.tsnew file mode 100644index 0000000000..5baf5ca167--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/entries.ts@@ -0,0 +1,378 @@+import type { CustomHotkeys, HotkeyDefinition } from '@workbench/hotkeys/types';+import type { WorkbenchPreferences } from '@workbench/settings/contracts';+import type { SettingsSectionId } from '@workbench/widgetContracts';++import { THEMES_BY_ID } from '@theme/themes';+import { firstPartyHotkeyCatalog } from '@workbench/hotkeys/catalog';+import { formatHotkeyForPlatform } from '@workbench/hotkeys/keys';+import fuzzysort from 'fuzzysort';++/**+ * Palette content model: every source (catalog commands, extension palette+ * contributions, settings, navigation) normalizes into `PaletteEntry`, and+ * `searchPaletteRows` turns the aggregate into the rendered row list. Ranking+ * is fuzzy (fuzzysort) *within* a section; section order itself is fixed so+ * the list reads spatially — commands above settings, always.+ */++export interface PaletteEntry {+ id: string;+ title: string;+ /** Section header the entry renders under; ordered via PALETTE_GROUP_ORDER. */+ group: string;+ /** Trailing muted text: a setting's current value, an entity's metadata. */+ subtitle?: string;+ /** Extra match terms, never rendered. */+ keywords?: string;+ /** Platform-formatted key chips for the bound hotkey, e.g. ['cmd', 'k']. */+ keys?: string[];+ /** Keep the palette open after running (settings toggles). */+ keepOpen?: boolean;+ /** Show in the empty-query launcher state (navigation entries). */+ showInEmptyState?: boolean;+ run: () => unknown;+}++export type PaletteRow =+ | { kind: 'label'; id: string; label: string }+ | { kind: 'entry'; id: string; entry: PaletteEntry; matchIndexes?: readonly number[] };++const PALETTE_GROUP_ORDER = [+ 'Recent',+ 'Generation',+ 'Queue',+ 'Navigation',+ 'Layout',+ 'App',+ 'Canvas',+ 'Gallery',+ 'Viewer',+ 'Workflows',+ 'Commands',+ 'Settings',+];++const RECENT_GROUP = 'Recent';+const EMPTY_STATE_RECENT_LIMIT = 6;++/** Matches below this fuzzysort score (0–1) are noise, not results. */+const MATCH_THRESHOLD = 0.2;++const groupRank = (group: string): number => {+ const index = PALETTE_GROUP_ORDER.indexOf(group);++ return index === -1 ? PALETTE_GROUP_ORDER.length : index;+};++// ---------------------------------------------------------------------------+// Commands source (hotkey catalog)+// ---------------------------------------------------------------------------++/**+ * Hotkey-only interactions that would be pure noise as palette rows: arrow+ * navigation, caret-relative nudges, and the palette's own toggle.+ */+const PALETTE_HIDDEN_COMMANDS = new Set([+ 'app.openCommandPalette',+ 'app.promptWeightDown',+ 'app.promptWeightUp',+ 'canvas.nextEntity',+ 'canvas.prevEntity',+ 'gallery.clearSelection',+ 'gallery.galleryNavDown',+ 'gallery.galleryNavDownAlt',+ 'gallery.galleryNavLeft',+ 'gallery.galleryNavLeftAlt',+ 'gallery.galleryNavRight',+ 'gallery.galleryNavRightAlt',+ 'gallery.galleryNavUp',+ 'gallery.galleryNavUpAlt',+]);++/** App-category commands regrouped into palette-facing sections. */+const APP_COMMAND_GROUPS: Record<string, string> = {+ 'app.cancelQueueItem': 'Queue',+ 'app.clearQueue': 'Queue',+ 'app.focusPrompt': 'Generation',+ 'app.invoke': 'Generation',+ 'app.invokeFront': 'Generation',+ 'app.promptHistoryNext': 'Generation',+ 'app.promptHistoryPrev': 'Generation',+ 'app.resetPanelLayout': 'Layout',+ 'app.selectCanvasTab': 'Navigation',+ 'app.selectGenerateTab': 'Navigation',+ 'app.selectModelsTab': 'Navigation',+ 'app.selectQueueTab': 'Navigation',+ 'app.selectWorkflowsTab': 'Navigation',+ 'app.toggleLeftPanel': 'Layout',+ 'app.togglePanels': 'Layout',+ 'app.toggleRightPanel': 'Layout',+};++const TITLE_OVERRIDES: Record<string, string> = {+ 'app.invokeFront': 'Invoke (Front of Queue)',+ 'app.promptHistoryNext': 'Next Prompt from History',+ 'app.promptHistoryPrev': 'Previous Prompt from History',+ 'app.selectCanvasTab': 'Go to Canvas',+ 'app.selectGenerateTab': 'Go to Generate',+ 'app.selectModelsTab': 'Go to Models',+ 'app.selectQueueTab': 'Go to Queue',+ 'app.selectWorkflowsTab': 'Go to Workflows',+};++/** Widget-scoped catalog categories: shown only while the widget type is in the layout. */+const WIDGET_CATEGORY_GROUPS: Record<string, { group: string; typeId: string }> = {+ canvas: { group: 'Canvas', typeId: 'canvas' },+ gallery: { group: 'Gallery', typeId: 'gallery' },+ viewer: { group: 'Viewer', typeId: 'preview' },+ workflows: { group: 'Workflows', typeId: 'workflow' },+};++const getEntryKeys = (definition: HotkeyDefinition, customHotkeys: CustomHotkeys): string[] | undefined => {+ const keys = customHotkeys[definition.id] ?? definition.defaultKeys;++ return keys[0] ? formatHotkeyForPlatform(keys[0]) : undefined;+};++export const buildCatalogCommandEntries = ({+ catalog = firstPartyHotkeyCatalog,+ customHotkeys,+ execute,+ presentWidgetTypeIds,+}: {+ catalog?: HotkeyDefinition[];+ customHotkeys: CustomHotkeys;+ execute: (commandId: string) => unknown;+ presentWidgetTypeIds: ReadonlySet<string>;+}): PaletteEntry[] =>+ catalog+ .filter((definition) => definition.implemented !== false && !PALETTE_HIDDEN_COMMANDS.has(definition.commandId))+ .filter((definition) => {+ const widgetGroup = WIDGET_CATEGORY_GROUPS[definition.category];++ return !widgetGroup || presentWidgetTypeIds.has(widgetGroup.typeId);+ })+ .map((definition) => {+ const widgetGroup = WIDGET_CATEGORY_GROUPS[definition.category];+ const group = widgetGroup?.group ?? APP_COMMAND_GROUPS[definition.commandId] ?? 'App';++ return {+ group,+ id: definition.commandId,+ keys: getEntryKeys(definition, customHotkeys),+ keywords: widgetGroup?.group,+ run: () => execute(definition.commandId),+ showInEmptyState: group === 'Navigation',+ title: TITLE_OVERRIDES[definition.commandId] ?? definition.title,+ };+ });++// ---------------------------------------------------------------------------+// Settings source+// ---------------------------------------------------------------------------++type BooleanPreferenceKey = {+ [Key in keyof WorkbenchPreferences]: WorkbenchPreferences[Key] extends boolean ? Key : never;+}[keyof WorkbenchPreferences];++const SETTING_TOGGLES: ReadonlyArray<{ key: BooleanPreferenceKey; keywords?: string; title: string }> = [+ { key: 'reduceMotion', keywords: 'animation appearance', title: 'Reduce Motion' },+ { key: 'confirmImageDeletion', keywords: 'delete safety', title: 'Confirm Image Deletion' },+ { key: 'showFocusRegionHighlight', keywords: 'panel outline', title: 'Show Focus Region Highlight' },+ { key: 'enableInformationalPopovers', keywords: 'help tooltips', title: 'Informational Popovers' },+ { key: 'enableModelDescriptions', keywords: 'model manager', title: 'Model Descriptions' },+ { key: 'developerLogEnabled', keywords: 'debug console', title: 'Developer Logging' },+ { key: 'workflowSnapToGrid', keywords: 'workflow editor nodes', title: 'Snap Workflow Nodes to Grid' },+ { key: 'workflowShowMinimap', keywords: 'workflow editor', title: 'Show Workflow Minimap' },+ { key: 'workflowValidateConnections', keywords: 'workflow editor edges', title: 'Validate Workflow Connections' },+];++const SETTINGS_SECTIONS: ReadonlyArray<{ id: SettingsSectionId; title: string }> = [+ { id: 'appearance', title: 'Appearance' },+ { id: 'behavior', title: 'Behavior' },+ { id: 'hotkeys', title: 'Hotkeys' },+ { id: 'project', title: 'Project' },+ { id: 'queue', title: 'Queue' },+ { id: 'workflow', title: 'Workflow' },+ { id: 'developer', title: 'Developer' },+ { id: 'workspace', title: 'Workspace' },+];++export interface SettingsEntryDeps {+ openSettingsSection: (sectionId: SettingsSectionId) => void;+ patchPreferences: (patch: Partial<WorkbenchPreferences>) => unknown;+}++export const buildSettingsEntries = (preferences: WorkbenchPreferences, deps: SettingsEntryDeps): PaletteEntry[] => {+ const toggles = SETTING_TOGGLES.map<PaletteEntry>(({ key, keywords, title }) => ({+ group: 'Settings',+ id: `setting.${key}`,+ keepOpen: true,+ keywords: keywords ? `${keywords} toggle` : 'toggle',+ run: () => deps.patchPreferences({ [key]: !preferences[key] }),+ subtitle: preferences[key] ? 'On' : 'Off',+ title,+ }));++ // Multi-value preferences deep-link to their settings section; the palette+ // links to complex pickers rather than replicating them.+ const enums: PaletteEntry[] = [+ {+ group: 'Settings',+ id: 'setting.themeId',+ keywords: 'appearance color dark light',+ run: () => deps.openSettingsSection('appearance'),+ subtitle: THEMES_BY_ID[preferences.themeId]?.label ?? preferences.themeId,+ title: 'Theme',+ },+ {+ group: 'Settings',+ id: 'setting.language',+ keywords: 'locale translation',+ run: () => deps.openSettingsSection('appearance'),+ subtitle: preferences.language,+ title: 'Language',+ },+ {+ group: 'Settings',+ id: 'setting.workflowEdgeStyle',+ keywords: 'workflow editor connections',+ run: () => deps.openSettingsSection('workflow'),+ subtitle: preferences.workflowEdgeStyle === 'square' ? 'Square' : 'Curved',+ title: 'Workflow Edge Style',+ },+ {+ group: 'Settings',+ id: 'setting.queueJobsScope',+ keywords: 'queue filter',+ run: () => deps.openSettingsSection('queue'),+ subtitle: preferences.queueJobsScope === 'all' ? 'All Projects' : 'Active Project',+ title: 'Queue Jobs Scope',+ },+ ];++ const sections = SETTINGS_SECTIONS.map<PaletteEntry>(({ id, title }) => ({+ group: 'Settings',+ id: `settings.section.${id}`,+ keywords: 'settings preferences open',+ run: () => deps.openSettingsSection(id),+ title: `Settings: ${title}`,+ }));++ return [...toggles, ...enums, ...sections];+};++// ---------------------------------------------------------------------------+// Search / row assembly+// ---------------------------------------------------------------------------++interface RankedEntry {+ entry: PaletteEntry;+ matchIndexes?: readonly number[];+ score: number;+}++const toGroupedRows = (groups: Map<string, RankedEntry[]>): PaletteRow[] => {+ const rows: PaletteRow[] = [];+ const orderedGroups = [...groups.keys()].sort(+ (left, right) => groupRank(left) - groupRank(right) || left.localeCompare(right)+ );++ for (const group of orderedGroups) {+ const ranked = groups.get(group) ?? [];++ if (ranked.length === 0) {+ continue;+ }++ rows.push({ id: `label:${group}`, kind: 'label', label: group });++ for (const { entry, matchIndexes } of ranked) {+ rows.push({ entry, id: entry.id, kind: 'entry', matchIndexes });+ }+ }++ return rows;+};++const buildEmptyStateRows = (entries: readonly PaletteEntry[], recentIds: readonly string[]): PaletteRow[] => {+ const byId = new Map(entries.map((entry) => [entry.id, entry]));+ const recent = recentIds+ .map((id) => byId.get(id))+ .filter((entry): entry is PaletteEntry => entry !== undefined)+ .slice(0, EMPTY_STATE_RECENT_LIMIT);+ const rows: PaletteRow[] = [];++ if (recent.length > 0) {+ rows.push({ id: `label:${RECENT_GROUP}`, kind: 'label', label: RECENT_GROUP });++ for (const entry of recent) {+ rows.push({ entry, id: `recent:${entry.id}`, kind: 'entry' });+ }+ }++ const launcher = new Map<string, RankedEntry[]>();++ for (const entry of entries) {+ if (!entry.showInEmptyState) {+ continue;+ }++ launcher.set(entry.group, [...(launcher.get(entry.group) ?? []), { entry, score: 0 }]);+ }++ return [...rows, ...toGroupedRows(launcher)];+};++/**+ * The full query pipeline: empty query renders the launcher state (recents ++ * navigation); otherwise fuzzysort ranks every entry over title/keywords/+ * subtitle (subtitle down-weighted so value text like "On" cannot dominate),+ * grouped into the fixed section order, ranked within each section by score,+ * then recency, then title.+ */+export const searchPaletteRows = (+ entries: readonly PaletteEntry[],+ query: string,+ recentIds: readonly string[]+): PaletteRow[] => {+ const trimmed = query.trim();++ if (trimmed.length === 0) {+ return buildEmptyStateRows(entries, recentIds);+ }++ const results = fuzzysort.go(trimmed, entries, {+ keys: [(entry) => entry.title, (entry) => entry.keywords ?? '', (entry) => entry.subtitle ?? ''],+ scoreFn: (result) => Math.max(result[0]?.score ?? 0, (result[1]?.score ?? 0) * 0.9, (result[2]?.score ?? 0) * 0.5),+ threshold: MATCH_THRESHOLD,+ });+ const recencyRank = new Map(recentIds.map((id, index) => [id, index]));+ const groups = new Map<string, RankedEntry[]>();++ for (const result of results) {+ const entry = result.obj;+ const titleResult = result[0];++ groups.set(entry.group, [+ ...(groups.get(entry.group) ?? []),+ {+ entry,+ matchIndexes: titleResult && titleResult.score > 0 ? titleResult.indexes : undefined,+ score: result.score,+ },+ ]);+ }++ for (const ranked of groups.values()) {+ ranked.sort(+ (left, right) =>+ right.score - left.score ||+ (recencyRank.get(left.entry.id) ?? Number.POSITIVE_INFINITY) -+ (recencyRank.get(right.entry.id) ?? Number.POSITIVE_INFINITY) ||+ left.entry.title.localeCompare(right.entry.title)+ );+ }++ return toGroupedRows(groups);+};diff --git a/invokeai/frontend/webv2/src/workbench/palette/index.ts b/invokeai/frontend/webv2/src/workbench/palette/index.tsnew file mode 100644index 0000000000..885a8f6a0a--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/index.ts@@ -0,0 +1,5 @@+export type { PaletteEntry, PaletteRow } from './entries';+export { LaunchpadCommandPalette } from './LaunchpadCommandPalette';+export { PaletteButton } from './PaletteButton';+export { closeCommandPalette, openCommandPalette, toggleCommandPalette } from './paletteStore';+export { WorkbenchCommandPalette } from './WorkbenchCommandPalette';diff --git a/invokeai/frontend/webv2/src/workbench/palette/paletteStore.ts b/invokeai/frontend/webv2/src/workbench/palette/paletteStore.tsnew file mode 100644index 0000000000..c65ed3130b--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/paletteStore.ts@@ -0,0 +1,23 @@+import { createExternalStore } from '@platform/state/externalStore';++/**+ * Open/close state for the command palette, addressable from anywhere: the+ * top-bar buttons, the `app.openCommandPalette` command, and the Launchpad's+ * own mod+K binding all funnel through here. The dialog is hosted per surface+ * (WorkbenchCommandPalette in the editor, LaunchpadCommandPalette on the+ * launchpad) and subscribes to this store.+ */++export const commandPaletteStore = createExternalStore<{ isOpen: boolean }>({ isOpen: false });++export const openCommandPalette = (): void => {+ commandPaletteStore.setSnapshot({ isOpen: true });+};++export const closeCommandPalette = (): void => {+ commandPaletteStore.setSnapshot({ isOpen: false });+};++export const toggleCommandPalette = (): void => {+ commandPaletteStore.setSnapshot({ isOpen: !commandPaletteStore.getSnapshot().isOpen });+};diff --git a/invokeai/frontend/webv2/src/workbench/palette/recents.ts b/invokeai/frontend/webv2/src/workbench/palette/recents.tsnew file mode 100644index 0000000000..d055ba8f32--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/palette/recents.ts@@ -0,0 +1,39 @@+/**+ * Ring buffer of recently executed palette entry ids, persisted per browser+ * (not per project — muscle memory should not reset when switching projects).+ * Stored ids can go stale (commands renamed, widgets closed); readers filter+ * them against the live entry list at render time.+ */++const STORAGE_KEY = 'invokeai:v7:webv2:palette-recents';+const MAX_RECENTS = 20;++const isBrowser = (): boolean => typeof window !== 'undefined' && typeof window.localStorage !== 'undefined';++export const getRecentEntryIds = (): string[] => {+ if (!isBrowser()) {+ return [];+ }++ try {+ const parsed = JSON.parse(window.localStorage.getItem(STORAGE_KEY) ?? '[]') as unknown;++ return Array.isArray(parsed) ? parsed.filter((id): id is string => typeof id === 'string') : [];+ } catch {+ return [];+ }+};++export const recordRecentEntry = (id: string): void => {+ if (!isBrowser()) {+ return;+ }++ const next = [id, ...getRecentEntryIds().filter((existing) => existing !== id)].slice(0, MAX_RECENTS);++ try {+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify(next));+ } catch {+ // Quota or private-mode failures are non-fatal; recents are a convenience.+ }+};diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/TopBar.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/TopBar.tsxindex 6825a95c1e..97c9fd7dba 100644--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/TopBar.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/TopBar.tsx@@ -2,6 +2,7 @@ import { Flex, HStack, Separator } from '@chakra-ui/react';import { AccountMenu, useCapabilities } from '@features/identity';import { InvokeMark } from '@platform/ui/InvokeMark';import { Link } from '@tanstack/react-router';+import { PaletteButton } from '@workbench/palette';import { ProjectTabs } from '@workbench/projects/components';import { SettingsButton } from '@/workbench/settings';@@ -55,6 +56,7 @@ export const TopBar = () => {<HStack gap="0.5">{canManageNodes ? <NodesManagerButton /> : null}{canManageModels ? <ModelManagerButton /> : null}+ <PaletteButton /><SettingsButton /></HStack><AccountMenu />