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(ui): palette UX refinements — dedupe, syntax tip, scope header, pointer affordances

joshistoastc088f91b0322
diff --git a/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.browser.test.tsx
index 8c3d24445a..3f8914b400 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.browser.test.tsx
@@ -410,8 +410,105 @@ describe('CommandPaletteDialog interaction', () => {
await renderPalette({ entries: [], providers: [provider] });
expect(document.body.textContent).toContain('Recent');
- // Deliberately listed twice: once under Recent, once under Search in.
- expect(document.body.textContent?.match(/Search entities…/g)).toHaveLength(2);
+ // Listed once, under Recent — the launcher groups don't repeat recents.
+ expect(document.body.textContent?.match(/Search entities…/g)).toHaveLength(1);
+ });
+
+ it('advertises the query syntax in the empty launcher, scaled to host capabilities', async () => {
+ const capable: PaletteSearchProvider = {
+ contextKey: 'context',
+ label: 'Images',
+ providerKey: 'images',
+ search: vi.fn(() => []),
+ supportsCreatedAtRange: true,
+ };
+ await renderPalette({ entries: [entry('first', 'First command')], providers: [capable] });
+ expect(document.body.textContent).toContain('Type > for commands · from:/date: to filter by date');
+
+ await act(() => root?.unmount());
+ host?.remove();
+
+ // Launchpad shape: no providers → no date-token hint, `>` still advertised.
+ await renderPalette({ entries: [entry('first', 'First command')] });
+ expect(document.body.textContent).toContain('Type > for commands');
+ expect(document.body.textContent).not.toContain('filter by date');
+ });
+
+ it('closes a scope from the chip and returns to the root palette with focus', async () => {
+ const provider: PaletteSearchProvider = {
+ contextKey: 'context',
+ label: 'Entities',
+ providerKey: 'entities',
+ search: vi.fn(() => []),
+ };
+ const { input, onClose } = await renderPalette({
+ entries: [entry('first', 'First command')],
+ providers: [provider],
+ });
+
+ await act(() => userEvent.fill(input, 'search ent'));
+ await act(() => userEvent.keyboard('{Enter}'));
+ const chip = await vi.waitFor(() => {
+ const node = [...document.querySelectorAll('button')].find((button) => button.textContent?.includes('Entities'));
+ expect(node).toBeDefined();
+ return node!;
+ });
+
+ await act(() => userEvent.click(chip));
+ expect(onClose).not.toHaveBeenCalled();
+ expect(document.body.textContent).toContain('First command');
+ expect(input.value).toBe('');
+ await vi.waitFor(() => expect(document.activeElement).toBe(input));
+ });
+
+ it('runs the highlighted row secondary action from its pointer affordance', async () => {
+ const secondaryRun = vi.fn();
+ const withSecondary: PaletteEntry = {
+ ...entry('first', 'First command'),
+ secondary: { label: 'Open Elsewhere', run: secondaryRun },
+ };
+ const { onClose } = await renderPalette({ entries: [withSecondary] });
+
+ const secondaryButton = await vi.waitFor(() => {
+ const node = document.querySelector<HTMLButtonElement>('button[aria-label="Open Elsewhere"]');
+ expect(node).not.toBeNull();
+ return node!;
+ });
+
+ await act(() => userEvent.click(secondaryButton));
+ expect(secondaryRun).toHaveBeenCalledOnce();
+ expect(onClose).toHaveBeenCalledOnce();
+ });
+
+ it('hands a date-less scope the token-stripped text its scope row advertised', async () => {
+ const capableSearch = vi.fn(() => []);
+ const dateLessSearch = vi.fn(() => []);
+ const capable: PaletteSearchProvider = {
+ contextKey: 'context',
+ label: 'Images',
+ providerKey: 'images',
+ search: capableSearch,
+ supportsCreatedAtRange: true,
+ };
+ const dateLess: PaletteSearchProvider = {
+ contextKey: 'context',
+ label: 'Workflows',
+ providerKey: 'workflows',
+ search: dateLessSearch,
+ };
+ const { input } = await renderPalette({ entries: [], providers: [capable, dateLess] });
+
+ await act(() => userEvent.fill(input, 'from:7d sunset'));
+ expect(document.body.textContent).toContain('Search workflows for “sunset”');
+
+ // The workflows scope row is the last navigable row; ArrowUp wraps to it.
+ await act(() => userEvent.keyboard('{ArrowUp}'));
+ await act(() => userEvent.keyboard('{Tab}'));
+
+ expect(input.value).toBe('sunset');
+ await vi.waitFor(() => {
+ expect(dateLessSearch).toHaveBeenCalledWith({ range: undefined, text: 'sunset' });
+ });
});
it('drives stage preview from navigation and restores it on Escape and unmount', async () => {
diff --git a/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.tsx b/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.tsx
index bdc7e09042..9b22e67f89 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.tsx
+++ b/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteDialog.tsx
@@ -5,7 +5,7 @@ import { Dialog, HStack, Icon, Kbd, Portal, Spacer, Text, chakra } from '@chakra
import { useMountEffect } from '@platform/react/useMountEffect';
import { Button } from '@platform/ui/Button';
import { EmptyState } from '@platform/ui/EmptyState';
-import { SearchIcon } from 'lucide-react';
+import { SearchIcon, XIcon } from 'lucide-react';
import { useCallback, useMemo, useRef } from 'react';
import type { CommandPaletteRowsHandle } from './CommandPaletteRows';
@@ -152,18 +152,27 @@ const CommandPaletteContent = ({
>
<Icon as={SearchIcon} boxSize="4" color="fg.muted" flexShrink={0} />
{controller.chipLabel ? (
- <Text
+ <chakra.button
+ alignItems="center"
+ aria-label={`Close ${controller.chipLabel} — back to all results`}
bg="bg.emphasized"
borderRadius="sm"
color="fg"
+ cursor="pointer"
+ display="inline-flex"
flexShrink={0}
fontSize="xs"
fontWeight="600"
+ gap="1"
px="1.5"
py="0.5"
+ title="Back to all results"
+ type="button"
+ onClick={controller.onPopOverlay}
>
{controller.chipLabel}
- </Text>
+ <Icon as={XIcon} boxSize="3" color="fg.muted" />
+ </chakra.button>
) : null}
<chakra.input
ref={controller.setInputElement}
@@ -222,6 +231,7 @@ const CommandPaletteContent = ({
rows={controller.rows}
onActive={controller.onRowActive}
onRun={controller.onRowRun}
+ onRunSecondary={controller.onRowRunSecondary}
/>
)}
<HStack
diff --git a/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteRows.tsx b/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteRows.tsx
index af00671334..489d31373b 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteRows.tsx
+++ b/invokeai/frontend/webv2/src/workbench/palette/CommandPaletteRows.tsx
@@ -2,7 +2,7 @@ import type { ReactNode, Ref } from 'react';
import { Box, HStack, Icon, Kbd, ScrollArea, Spacer, Text, chakra } from '@chakra-ui/react';
import { dropdownGroupLabel } from '@theme/recipes';
-import { CheckIcon } from 'lucide-react';
+import { ArrowUpRightIcon, CheckIcon } from 'lucide-react';
import { useCallback, useImperativeHandle, useState } from 'react';
import { useVirtualizer } from 'react-hook-tanstack-virtual';
@@ -17,6 +17,8 @@ export const getCommandPaletteRowDomId = (rowId: string): string => `${RESULT_LI
const preventFocusSteal = (event: { preventDefault: () => void }) => event.preventDefault();
+const SECONDARY_BUTTON_HOVER_STYLE = { color: 'fg' };
+
const renderTitle = (title: string, matchIndexes?: readonly number[]): ReactNode => {
if (!matchIndexes || matchIndexes.length === 0) {
return title;
@@ -46,14 +48,14 @@ const renderTitle = (title: string, matchIndexes?: readonly number[]): ReactNode
return segments;
};
+// Rows are divs, not buttons: they stay out of the tab order (combobox
+// aria-activedescendant pattern) and may nest a real secondary-action button.
const rowButtonProps = {
- as: 'button',
cursor: 'pointer',
gap: '2.5',
h: `${ENTRY_ROW_HEIGHT_PX}px`,
px: '3',
rounded: 'sm',
- tabIndex: -1,
textAlign: 'start',
w: 'full',
} as const;
@@ -65,6 +67,7 @@ const EntryRow = ({
matchIndexes,
onActive,
onRun,
+ onRunSecondary,
}: {
domId: string;
entry: PaletteEntry;
@@ -72,42 +75,72 @@ const EntryRow = ({
matchIndexes?: readonly number[];
onActive: () => void;
onRun: () => void;
-}) => (
- <HStack
- {...rowButtonProps}
- id={domId}
- aria-selected={isActive}
- bg={isActive ? 'bg.emphasized' : undefined}
- role="option"
- onClick={onRun}
- onMouseDown={preventFocusSteal}
- onMouseMove={onActive}
- >
- {entry.thumbnailUrl ? (
- <chakra.img alt="" boxSize="7" flexShrink={0} objectFit="cover" rounded="sm" src={entry.thumbnailUrl} />
- ) : null}
- <Text fontSize="sm" truncate>
- {renderTitle(entry.title, matchIndexes)}
- </Text>
- {entry.subtitle === 'Current' ? (
- <Icon as={CheckIcon} boxSize="3.5" color="fg.muted" flexShrink={0} />
- ) : entry.subtitle ? (
- <Text color="fg.subtle" flexShrink={0} fontSize="xs" maxW="45%" truncate>
- {entry.subtitle}
+ onRunSecondary: () => void;
+}) => {
+ const onSecondaryClick = useCallback(
+ (event: React.MouseEvent) => {
+ event.stopPropagation();
+ onRunSecondary();
+ },
+ [onRunSecondary]
+ );
+
+ return (
+ <HStack
+ {...rowButtonProps}
+ id={domId}
+ aria-selected={isActive}
+ bg={isActive ? 'bg.emphasized' : undefined}
+ role="option"
+ onClick={onRun}
+ onMouseDown={preventFocusSteal}
+ onMouseMove={onActive}
+ >
+ {entry.thumbnailUrl ? (
+ <chakra.img alt="" boxSize="7" flexShrink={0} objectFit="cover" rounded="sm" src={entry.thumbnailUrl} />
+ ) : null}
+ <Text fontSize="sm" truncate>
+ {renderTitle(entry.title, matchIndexes)}
</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>
-);
+ {entry.subtitle === 'Current' ? (
+ <Icon as={CheckIcon} boxSize="3.5" color="fg.muted" flexShrink={0} />
+ ) : entry.subtitle ? (
+ <Text color="fg.subtle" flexShrink={0} fontSize="xs" maxW="45%" truncate>
+ {entry.subtitle}
+ </Text>
+ ) : null}
+ <Spacer />
+ {entry.secondary && isActive ? (
+ <chakra.button
+ aria-label={entry.secondary.label}
+ color="fg.muted"
+ cursor="pointer"
+ display="inline-flex"
+ flexShrink={0}
+ p="1"
+ rounded="sm"
+ tabIndex={-1}
+ title={entry.secondary.label}
+ type="button"
+ _hover={SECONDARY_BUTTON_HOVER_STYLE}
+ onClick={onSecondaryClick}
+ onMouseDown={preventFocusSteal}
+ >
+ <Icon as={ArrowUpRightIcon} boxSize="3.5" />
+ </chakra.button>
+ ) : null}
+ {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 ScopeRow = ({
domId,
@@ -150,6 +183,7 @@ const VirtualPaletteRow = ({
virtualStart,
onActive,
onRun,
+ onRunSecondary,
}: {
activeRowId: string | null;
measureElement: (node: Element | null) => void;
@@ -158,9 +192,11 @@ const VirtualPaletteRow = ({
virtualStart: number;
onActive: (rowId: string) => void;
onRun: (row: PaletteRow) => void;
+ onRunSecondary: (row: PaletteRow) => void;
}) => {
const handleActive = useCallback(() => onActive(row.id), [onActive, row.id]);
const handleRun = useCallback(() => onRun(row), [onRun, row]);
+ const handleRunSecondary = useCallback(() => onRunSecondary(row), [onRunSecondary, row]);
const isActive = row.id === activeRowId;
return (
@@ -193,6 +229,7 @@ const VirtualPaletteRow = ({
matchIndexes={row.matchIndexes}
onActive={handleActive}
onRun={handleRun}
+ onRunSecondary={handleRunSecondary}
/>
)}
</Box>
@@ -209,12 +246,14 @@ export const CommandPaletteRows = ({
rows,
onActive,
onRun,
+ onRunSecondary,
}: {
activeRowId: string | null;
ref?: Ref<CommandPaletteRowsHandle>;
rows: PaletteRow[];
onActive: (rowId: string) => void;
onRun: (row: PaletteRow) => void;
+ onRunSecondary: (row: PaletteRow) => void;
}) => {
const [scrollElement, setScrollElement] = useState<HTMLDivElement | null>(null);
const estimateRowSize = useCallback(
@@ -254,6 +293,7 @@ export const CommandPaletteRows = ({
virtualStart={virtualRow.start}
onActive={onActive}
onRun={onRun}
+ onRunSecondary={onRunSecondary}
/>
) : null;
})}
diff --git a/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts b/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts
index 55986ef905..760c8d436e 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts
@@ -220,16 +220,21 @@ describe('provider row assembly', () => {
expect(rows[0]).toMatchObject({ kind: 'label', label: 'workflows — Searching…' });
});
- it('builds one trailing scope row per provider', () => {
+ it('builds one trailing scope row per provider under a "Search in" header', () => {
const rows = buildScopeRows([{ label: 'Boards', providerKey: 'boards' }], 'sunset');
- expect(rows[0]).toMatchObject({ kind: 'scope', label: 'Search boards for “sunset”', providerKey: 'boards' });
+ expect(rows[0]).toMatchObject({ kind: 'label', label: SEARCH_SCOPE_GROUP });
+ expect(rows[1]).toMatchObject({ kind: 'scope', label: 'Search boards for “sunset”', providerKey: 'boards' });
+ });
+
+ it('builds no rows — not even the header — without providers', () => {
+ expect(buildScopeRows([], 'sunset')).toEqual([]);
});
it('labels scope rows as by-date searches when only a date filter is active', () => {
const rows = buildScopeRows([{ label: 'Images', providerKey: 'images' }], '');
- expect(rows[0]).toMatchObject({ kind: 'scope', label: 'Search images by date', providerKey: 'images' });
+ expect(rows[1]).toMatchObject({ kind: 'scope', label: 'Search images by date', providerKey: 'images' });
});
});
@@ -258,6 +263,12 @@ describe('searchPaletteRows', () => {
expect(rows.map((row) => row.id)).toEqual(['label:Navigation', 'app.selectCanvasTab']);
});
+ it('does not repeat a recent entry in its launcher group', () => {
+ const rows = searchPaletteRows(entries, '', ['app.selectCanvasTab']);
+
+ expect(rows.map((row) => row.id)).toEqual(['label:Recent', 'recent:app.selectCanvasTab']);
+ });
+
it('ranks fuzzy matches within their section and drops non-matches', () => {
const rows = searchPaletteRows(entries, 'invoke', []);
diff --git a/invokeai/frontend/webv2/src/workbench/palette/entries.ts b/invokeai/frontend/webv2/src/workbench/palette/entries.ts
index 5fed23240d..d9c955a40d 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/entries.ts
+++ b/invokeai/frontend/webv2/src/workbench/palette/entries.ts
@@ -175,6 +175,7 @@ const APP_COMMAND_GROUPS: Record<string, string> = {
'app.selectGenerateTab': 'Navigation',
'app.selectModelsTab': 'Navigation',
'app.selectQueueTab': 'Navigation',
+ 'app.selectUpscalingTab': 'Navigation',
'app.selectWorkflowsTab': 'Navigation',
'app.toggleLeftPanel': 'Layout',
'app.togglePanels': 'Layout',
@@ -189,6 +190,7 @@ const TITLE_OVERRIDES: Record<string, string> = {
'app.selectGenerateTab': 'Go to Generate',
'app.selectModelsTab': 'Go to Models',
'app.selectQueueTab': 'Go to Queue',
+ 'app.selectUpscalingTab': 'Go to Upscaling',
'app.selectWorkflowsTab': 'Go to Workflows',
};
@@ -451,10 +453,12 @@ const buildEmptyStateRows = (entries: readonly PaletteEntry[], recentIds: readon
}
}
+ // Entries already shown under Recent don't repeat in their launcher group.
+ const shownRecentIds = new Set(recent.map((entry) => entry.id));
const launcher = new Map<string, RankedEntry[]>();
for (const entry of entries) {
- if (!entry.showInEmptyState) {
+ if (!entry.showInEmptyState || shownRecentIds.has(entry.id)) {
continue;
}
@@ -596,19 +600,30 @@ export const buildProviderSectionRows = (
};
/**
- * Trailing escape hatches into scoped mode, one per provider. An empty query
- * means a pure date filter is active — the scope searches "by date".
+ * Trailing escape hatches into scoped mode, one per provider, under a shared
+ * "Search in" header. An empty query means a pure date filter is active — the
+ * scope searches "by date".
*/
export const buildScopeRows = (
providers: ReadonlyArray<Pick<PaletteSearchProvider, 'providerKey' | 'label'>>,
query: string
-): PaletteRow[] =>
- providers.map((provider) => ({
- id: getPaletteContributionKey('scope', provider.providerKey),
- kind: 'scope',
- label:
- query.length === 0
- ? `Search ${provider.label.toLowerCase()} by date`
- : `Search ${provider.label.toLowerCase()} for “${query}”`,
- providerKey: provider.providerKey,
- }));
+): PaletteRow[] => {
+ if (providers.length === 0) {
+ return [];
+ }
+
+ return [
+ // Distinct id: the scope-command *group* label ("label:Search in") can
+ // render in the same list when a query fuzzy-matches those commands.
+ { id: 'label:scope-rows', kind: 'label', label: SEARCH_SCOPE_GROUP },
+ ...providers.map<PaletteRow>((provider) => ({
+ id: getPaletteContributionKey('scope', provider.providerKey),
+ kind: 'scope',
+ label:
+ query.length === 0
+ ? `Search ${provider.label.toLowerCase()} by date`
+ : `Search ${provider.label.toLowerCase()} for “${query}”`,
+ providerKey: provider.providerKey,
+ })),
+ ];
+};
diff --git a/invokeai/frontend/webv2/src/workbench/palette/useCommandPaletteController.ts b/invokeai/frontend/webv2/src/workbench/palette/useCommandPaletteController.ts
index 18e388db84..43c07518cf 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/useCommandPaletteController.ts
+++ b/invokeai/frontend/webv2/src/workbench/palette/useCommandPaletteController.ts
@@ -70,9 +70,13 @@ export interface CommandPaletteController {
hasScopeRows: boolean;
isOverlayOpen: boolean;
onContentKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
+ /** Pop the active scope/stage back to the root palette (chip dismiss). */
+ onPopOverlay: () => void;
onRetry: () => void;
onRowActive: (rowId: string) => void;
onRowRun: (row: PaletteRow) => void;
+ /** Run a row's mod+Enter secondary action (row-level pointer affordance). */
+ onRowRunSecondary: (row: PaletteRow) => void;
onSearchChange: (event: ChangeEvent<HTMLInputElement>) => void;
onSearchKeyDown: (event: KeyboardEvent<HTMLInputElement>, scrollToIndex: ScrollToIndex) => void;
placeholder: string;
@@ -307,16 +311,19 @@ export const useCommandPaletteController = ({
const enterScope = useCallback(
(providerKey: string, { resetQuery = false }: { resetQuery?: boolean } = {}) => {
+ // A date-less scope cannot apply date tokens; hand it the token-stripped
+ // text its scope row advertised, not the raw token text.
+ const target = providers.find((provider) => provider.providerKey === providerKey);
+ const keptQuery = !target?.supportsCreatedAtRange && dateParse !== null ? dateParse.text.trim() : trimmedQuery;
+
clearDebounce();
setScopeProviderKey(providerKey);
- if (resetQuery) {
- setQuery('');
- }
- setDebouncedQuery(resetQuery ? '' : trimmedQuery);
+ setQuery(resetQuery ? '' : keptQuery);
+ setDebouncedQuery(resetQuery ? '' : keptQuery);
setActiveRowId(null);
focusInput();
},
- [clearDebounce, focusInput, trimmedQuery]
+ [clearDebounce, dateParse, focusInput, providers, trimmedQuery]
);
// One "Search images…"-style command per provider, merged into the local
@@ -361,10 +368,20 @@ export const useCommandPaletteController = ({
showAllOnEmpty: isCommandsScope && trimmedQuery.length === 0,
});
- if (trimmedQuery.length === 0 || isCommandsScope) {
+ if (isCommandsScope) {
return localRows;
}
+ if (trimmedQuery.length === 0) {
+ // Quiet trailing tip in the launcher — the only place the query syntax
+ // is advertised before it is typed.
+ const syntaxHint = providers.some((provider) => provider.supportsCreatedAtRange)
+ ? 'Type > for commands · from:/date: to filter by date'
+ : 'Type > for commands';
+
+ return [...localRows, { id: 'label:syntax-hint', kind: 'label', label: syntaxHint }];
+ }
+
const scopeProviders = isLivePureDate ? providers.filter((provider) => provider.supportsCreatedAtRange) : providers;
return [
@@ -453,6 +470,15 @@ export const useCommandPaletteController = ({
[onClose]
);
+ const onRowRunSecondary = useCallback(
+ (row: PaletteRow) => {
+ if (row.kind === 'entry' && row.entry.secondary) {
+ runSecondary(row.entry);
+ }
+ },
+ [runSecondary]
+ );
+
const moveActive = useCallback(
(offset: number, scrollToIndex: ScrollToIndex) => {
if (navigableRows.length === 0) {
@@ -589,9 +615,11 @@ export const useCommandPaletteController = ({
hasScopeRows: rows.some((row) => row.kind === 'scope'),
isOverlayOpen: Boolean(stage || scopeProviderKey),
onContentKeyDown,
+ onPopOverlay: popOverlay,
onRetry,
onRowActive,
onRowRun: runRow,
+ onRowRunSecondary,
onSearchChange,
onSearchKeyDown,
placeholder: stage