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(queue): palette queue items provider with reveal-in-widget

joshistoast232854462680
diff --git a/invokeai/frontend/webv2/src/architecture/dependencyPolicy.test.ts b/invokeai/frontend/webv2/src/architecture/dependencyPolicy.test.ts
index c95884cccf..845c80b09a 100644
--- a/invokeai/frontend/webv2/src/architecture/dependencyPolicy.test.ts
+++ b/invokeai/frontend/webv2/src/architecture/dependencyPolicy.test.ts
@@ -163,6 +163,7 @@ describe('feature public-interface registry', () => {
]);
expect(checkDependency('workbench/shell/View.tsx', '@features/identity')).toEqual([]);
expect(checkDependency('workbench/palette/paletteProviders.ts', '@features/workflow/queries')).toEqual([]);
+ expect(checkDependency('workbench/palette/paletteProviders.ts', '@features/queue/queries')).toEqual([]);
expect(checkDependency('features/gallery/ui/View.tsx', '@features/queue/publicApi')).toMatchObject([
{ rule: 'feature-public-interface' },
]);
diff --git a/invokeai/frontend/webv2/src/architecture/featureInterfaces.ts b/invokeai/frontend/webv2/src/architecture/featureInterfaces.ts
index 0beae8e8ba..90fe427f6c 100644
--- a/invokeai/frontend/webv2/src/architecture/featureInterfaces.ts
+++ b/invokeai/frontend/webv2/src/architecture/featureInterfaces.ts
@@ -10,7 +10,7 @@ export const FEATURE_PUBLIC_INTERFACES: Readonly<Record<string, readonly string[
identity: [],
models: ['react'],
nodes: [],
- queue: ['contracts', 'menu', 'react', 'utility', 'widget'],
+ queue: ['contracts', 'menu', 'queries', 'react', 'utility', 'widget'],
upscale: ['widget'],
workflow: ['contracts', 'graph', 'preview', 'queries', 'react', 'utility', 'widget'],
};
diff --git a/invokeai/frontend/webv2/src/features/queue/contracts.ts b/invokeai/frontend/webv2/src/features/queue/contracts.ts
index 10db8d69fe..1a73167c7e 100644
--- a/invokeai/frontend/webv2/src/features/queue/contracts.ts
+++ b/invokeai/frontend/webv2/src/features/queue/contracts.ts
@@ -48,7 +48,7 @@ export {
isBackendSubmittableSourceId,
shouldSubmitPendingQueueItem,
} from './core/submissionRules';
-export { extractGenerationMeta, type QueueGenerationMeta } from './core/generationMeta';
+export { extractGenerationMeta, getResultImageName, type QueueGenerationMeta } from './core/generationMeta';
export {
buildProjectQueueItemOriginPrefix,
buildQueueItemOrigin,
diff --git a/invokeai/frontend/webv2/src/features/queue/queries.ts b/invokeai/frontend/webv2/src/features/queue/queries.ts
new file mode 100644
index 0000000000..aae63e3497
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/queue/queries.ts
@@ -0,0 +1,6 @@
+/**
+ * Published Queue query surface for shell consumers (e.g. the command
+ * palette's queue search). Widget-internal data hooks stay private.
+ */
+export { getQueueReadModelOptions } from './publicApi';
+export { getQueueQueryScope, type QueueJobsScope } from './ui/queueScope';
diff --git a/invokeai/frontend/webv2/src/features/queue/react.ts b/invokeai/frontend/webv2/src/features/queue/react.ts
index 87b38fa0aa..5c5a5fcd3a 100644
--- a/invokeai/frontend/webv2/src/features/queue/react.ts
+++ b/invokeai/frontend/webv2/src/features/queue/react.ts
@@ -10,3 +10,4 @@ export {
export { type QueueItemProgressSink, useQueueItemProgress } from './data/progressStore';
export { QueueUiProvider, type QueueUiAdapter } from './ui/QueueUiContext';
export { getQueueItemAccess } from './ui/queueOwnership';
+export { clearPendingQueueItemReveal, requestQueueItemReveal } from './ui/queueUiStore';
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
index cab1dc7b56..d0e50b5034 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
@@ -6,7 +6,7 @@ import { extractGenerationMeta, getResultImageName } from '@features/queue/core/
import { useItemProgress } from '@features/queue/data/itemProgressStore';
import { Row } from '@platform/ui/Row';
import { ChevronRightIcon } from 'lucide-react';
-import { memo, useCallback, useState } from 'react';
+import { memo, useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { CancelQueueItemButton } from './CancelQueueItemButton';
@@ -16,6 +16,7 @@ import { QueueItemThumbnail } from './QueueItemThumbnail';
import { QueueStatusDot } from './QueueStatusDot';
import { QueueStepProgress } from './QueueStepProgress';
import { useQueueUi } from './QueueUiContext';
+import { clearPendingQueueItemReveal } from './queueUiStore';
import { getStatusMeta } from './statusMeta';
const CHEVRON_OPEN = { transform: 'rotate(90deg)' } as const;
@@ -34,76 +35,101 @@ const QUEUE_ITEM_BUTTON_SX: SystemStyleObject = {
transitionDuration: 'fastest',
} as const;
-export const QueueItemRow = memo(({ item }: { item: QueueItemReadModel }) => {
- const { t } = useTranslation();
- const { canManageItem, canViewItemDetails } = useQueueUi();
- const [expanded, setExpanded] = useState(false);
- const toggle = useCallback(() => setExpanded((open) => !open), []);
- const meta = extractGenerationMeta(item);
- const duration = formatDuration(item.startedAt, item.completedAt);
- const age = formatCompactAge(item.completedAt ?? item.createdAt);
- const ageLabel = [duration, age].filter(Boolean).join(' · ');
- const isFailed = item.status === 'failed';
- const isCancellable = (item.status === 'pending' || item.status === 'in_progress') && canManageItem(item);
- const canExpand = canViewItemDetails(item);
- const progress = useItemProgress(item.id);
- const liveImage = progress?.image ?? null;
- const resultImageName = getResultImageName(item);
- const statusLabel = t(getStatusMeta(item.status).labelKey);
+export const QueueItemRow = memo(
+ ({ item, revealRequested }: { item: QueueItemReadModel; revealRequested?: boolean }) => {
+ const { t } = useTranslation();
+ const { canManageItem, canViewItemDetails } = useQueueUi();
+ const [expanded, setExpanded] = useState(false);
+ const toggle = useCallback(() => setExpanded((open) => !open), []);
+ const rootRef = useRef<HTMLDivElement>(null);
+ const meta = extractGenerationMeta(item);
+ const duration = formatDuration(item.startedAt, item.completedAt);
+ const age = formatCompactAge(item.completedAt ?? item.createdAt);
+ const ageLabel = [duration, age].filter(Boolean).join(' · ');
+ const isFailed = item.status === 'failed';
+ const isCancellable = (item.status === 'pending' || item.status === 'in_progress') && canManageItem(item);
+ const canExpand = canViewItemDetails(item);
- const showBorder = expanded || isFailed;
- const borderColor = showBorder ? (isFailed ? 'fg.error' : 'border') : 'transparent';
+ // Consume a palette reveal request: expand (when permitted, via a
+ // render-phase adjustment), then bring the row into view and clear the
+ // pending id so the request fires once.
+ const [handledReveal, setHandledReveal] = useState(false);
+ if (revealRequested && !handledReveal) {
+ setHandledReveal(true);
+ if (canExpand) {
+ setExpanded(true);
+ }
+ }
+ if (!revealRequested && handledReveal) {
+ setHandledReveal(false);
+ }
+ useEffect(() => {
+ if (!revealRequested) {
+ return;
+ }
+ rootRef.current?.scrollIntoView({ block: 'nearest' });
+ clearPendingQueueItemReveal();
+ }, [revealRequested]);
- return (
- <Box overflow="hidden" rounded="md" borderWidth={1} borderColor={borderColor}>
- <HStack gap="0">
- <Row
- aria-expanded={canExpand ? expanded : undefined}
- as={canExpand ? 'button' : 'div'}
- css={QUEUE_ITEM_BUTTON_SX}
- onClick={canExpand ? toggle : undefined}
- >
- <QueueItemThumbnail boxSize="8" imageName={resultImageName} liveImage={liveImage} />
- <Stack flex="1" gap="0.5" minW="0">
- <Text fontSize="xs" truncate>
- {meta.positivePrompt?.trim() || t('widgets.queue.noPrompt')}
- </Text>
- <HStack gap="1.5" minW="0">
- <QueueStatusDot status={item.status} />
- <Text color="fg.subtle" fontSize="2xs" fontVariantNumeric="tabular-nums" truncate>
- {[statusLabel, ageLabel].filter(Boolean).join(' · ')}
+ const progress = useItemProgress(item.id);
+ const liveImage = progress?.image ?? null;
+ const resultImageName = getResultImageName(item);
+ const statusLabel = t(getStatusMeta(item.status).labelKey);
+
+ const showBorder = expanded || isFailed;
+ const borderColor = showBorder ? (isFailed ? 'fg.error' : 'border') : 'transparent';
+
+ return (
+ <Box ref={rootRef} overflow="hidden" rounded="md" borderWidth={1} borderColor={borderColor}>
+ <HStack gap="0">
+ <Row
+ aria-expanded={canExpand ? expanded : undefined}
+ as={canExpand ? 'button' : 'div'}
+ css={QUEUE_ITEM_BUTTON_SX}
+ onClick={canExpand ? toggle : undefined}
+ >
+ <QueueItemThumbnail boxSize="8" imageName={resultImageName} liveImage={liveImage} />
+ <Stack flex="1" gap="0.5" minW="0">
+ <Text fontSize="xs" truncate>
+ {meta.positivePrompt?.trim() || t('widgets.queue.noPrompt')}
</Text>
- </HStack>
- </Stack>
- {canExpand ? (
- <Icon
- as={ChevronRightIcon}
- boxSize="4"
- color="fg.muted"
- flexShrink={0}
- transition="transform var(--wb-motion-duration-fast) ease"
- css={expanded ? CHEVRON_OPEN : undefined}
- />
+ <HStack gap="1.5" minW="0">
+ <QueueStatusDot status={item.status} />
+ <Text color="fg.subtle" fontSize="2xs" fontVariantNumeric="tabular-nums" truncate>
+ {[statusLabel, ageLabel].filter(Boolean).join(' · ')}
+ </Text>
+ </HStack>
+ </Stack>
+ {canExpand ? (
+ <Icon
+ as={ChevronRightIcon}
+ boxSize="4"
+ color="fg.muted"
+ flexShrink={0}
+ transition="transform var(--wb-motion-duration-fast) ease"
+ css={expanded ? CHEVRON_OPEN : undefined}
+ />
+ ) : null}
+ </Row>
+ {isCancellable ? (
+ <Box flexShrink={0} pe="1">
+ <CancelQueueItemButton itemId={item.id} />
+ </Box>
) : null}
- </Row>
- {isCancellable ? (
- <Box flexShrink={0} pe="1">
- <CancelQueueItemButton itemId={item.id} />
+ </HStack>
+
+ {item.status === 'in_progress' ? (
+ <Box px="2.5" pb="2">
+ <QueueStepProgress message={progress?.message ?? ''} percentage={progress?.percentage ?? null} />
</Box>
) : null}
- </HStack>
- {item.status === 'in_progress' ? (
- <Box px="2.5" pb="2">
- <QueueStepProgress message={progress?.message ?? ''} percentage={progress?.percentage ?? null} />
- </Box>
- ) : null}
-
- {expanded ? (
- <Box pb="2.5" pt="1" px="2.5">
- <QueueItemDetails item={item} />
- </Box>
- ) : null}
- </Box>
- );
-});
+ {expanded ? (
+ <Box pb="2.5" pt="1" px="2.5">
+ <QueueItemDetails item={item} />
+ </Box>
+ ) : null}
+ </Box>
+ );
+ }
+);
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueWidgetView.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueWidgetView.tsx
index ab1b3e3267..f5dcecdd21 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueWidgetView.tsx
@@ -11,6 +11,7 @@ import { CurrentBatchSection } from './NowNextSection';
import { useQueueCounts } from './queueDataStore';
import { QueueFilterTabs } from './QueueFilterTabs';
import { QueueStats } from './QueueStats';
+import { usePendingQueueItemReveal } from './queueUiStore';
import { RecentSection } from './RecentSection';
/**
@@ -47,13 +48,22 @@ export const QueueWidgetView = ({
const QueueContent = () => {
const [filter, setFilter] = useState<QueueFilterId>('all');
+ const revealItemId = usePendingQueueItemReveal();
+ const [handledRevealId, setHandledRevealId] = useState<number | null>(null);
+
+ // Render-phase adjustment (not an effect): a reveal request must not be
+ // hidden by the active status tab.
+ if (revealItemId !== null && revealItemId !== handledRevealId) {
+ setHandledRevealId(revealItemId);
+ setFilter('all');
+ }
return (
<Stack gap="3" p="3">
<QueueStats />
<QueueFilterTabs value={filter} onChange={setFilter} />
<CurrentBatchSection />
- <RecentSection filter={filter} />
+ <RecentSection filter={filter} revealItemId={revealItemId} />
</Stack>
);
};
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/RecentSection.tsx b/invokeai/frontend/webv2/src/features/queue/ui/RecentSection.tsx
index c70120e0c4..5bb068f692 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/RecentSection.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/RecentSection.tsx
@@ -1,5 +1,5 @@
import { Stack, Text } from '@chakra-ui/react';
-import { useMemo } from 'react';
+import { useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import type { QueueFilterId } from './queueFilters';
@@ -7,13 +7,20 @@ import type { QueueFilterId } from './queueFilters';
import { useCurrentBatchItems, useQueueLoadState, useRecentItems } from './queueDataStore';
import { matchesFilter } from './queueFilters';
import { QueueItemRow } from './QueueItemRow';
+import { clearPendingQueueItemReveal } from './queueUiStore';
import { SectionHeader } from './SectionHeader';
/**
* RECENT — the windowed queue history, filtered by the active tab. The running
* and next items are excluded here since NOW & NEXT already shows them.
*/
-export const RecentSection = ({ filter }: { filter: QueueFilterId }) => {
+export const RecentSection = ({
+ filter,
+ revealItemId = null,
+}: {
+ filter: QueueFilterId;
+ revealItemId?: number | null;
+}) => {
const { t } = useTranslation();
const currentBatchItems = useCurrentBatchItems();
const items = useRecentItems();
@@ -25,6 +32,18 @@ export const RecentSection = ({ filter }: { filter: QueueFilterId }) => {
[excluded, filter, items]
);
+ // Reveal requests we can't fulfill must not go stale: an item in the current
+ // batch is already visible in NOW & NEXT, and one pruned past the recent
+ // window is gone. Rows we do render consume the request themselves.
+ useEffect(() => {
+ if (revealItemId === null || loadState !== 'loaded') {
+ return;
+ }
+ if (excluded.has(revealItemId) || !items.some((item) => item.id === revealItemId)) {
+ clearPendingQueueItemReveal();
+ }
+ }, [excluded, items, loadState, revealItemId]);
+
return (
<Stack gap="2">
<SectionHeader count={filtered.length} title={t('common.recent')} />
@@ -39,7 +58,7 @@ export const RecentSection = ({ filter }: { filter: QueueFilterId }) => {
) : (
<Stack gap="1">
{filtered.map((item) => (
- <QueueItemRow key={item.id} item={item} />
+ <QueueItemRow key={item.id} item={item} revealRequested={item.id === revealItemId} />
))}
</Stack>
)}
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/queueUiStore.ts b/invokeai/frontend/webv2/src/features/queue/ui/queueUiStore.ts
new file mode 100644
index 0000000000..f5ccb2ab34
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/queue/ui/queueUiStore.ts
@@ -0,0 +1,20 @@
+import { createExternalStore } from '@platform/state/externalStore';
+
+/**
+ * Cross-context requests into the queue widget. Shell surfaces (the command
+ * palette) can't reach the widget's local state, so they park a request here
+ * and the mounted widget consumes it — the same bridge workflowUiStore uses
+ * for pending library-workflow loads.
+ */
+const queueUiStore = createExternalStore<{ pendingRevealItemId: number | null }>({ pendingRevealItemId: null });
+
+export const requestQueueItemReveal = (itemId: number): void => {
+ queueUiStore.setSnapshot({ pendingRevealItemId: itemId });
+};
+
+export const clearPendingQueueItemReveal = (): void => {
+ queueUiStore.setSnapshot({ pendingRevealItemId: null });
+};
+
+export const usePendingQueueItemReveal = (): number | null =>
+ queueUiStore.useSelector((snapshot) => snapshot.pendingRevealItemId, Object.is);
diff --git a/invokeai/frontend/webv2/src/workbench/palette/paletteProviders.ts b/invokeai/frontend/webv2/src/workbench/palette/paletteProviders.ts
index ddf1a212db..c927ef5666 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/paletteProviders.ts
+++ b/invokeai/frontend/webv2/src/workbench/palette/paletteProviders.ts
@@ -1,13 +1,17 @@
import type { GalleryBoard, GalleryImage } from '@features/gallery/contracts';
import type { ModelConfig } from '@features/models';
+import type { QueueItemStatus, QueueQueryScope } from '@features/queue/contracts';
import type { PromptHistoryItem } from '@workbench/projectContracts';
import { galleryBoardsOptions, galleryImagesOptions } from '@features/gallery/queries';
import { focusPositivePrompt } from '@features/generation/react';
import { ensureModelsLoaded, getModelBaseLabel, getModelsSnapshot } from '@features/models';
+import { extractGenerationMeta, getResultImageName } from '@features/queue/contracts';
+import { getQueueReadModelOptions } from '@features/queue/queries';
import { listLibraryWorkflows } from '@features/workflow/queries';
import { requestLibraryWorkflowLoad } from '@features/workflow/react';
import { queryClient } from '@platform/query/client';
+import { absolutizeApiUrl } from '@platform/transport/http';
import type { PaletteEntry, PaletteSearchProvider } from './entries';
@@ -156,6 +160,59 @@ export const createModelsProvider = ({
},
});
+const QUEUE_STATUS_LABELS: Record<QueueItemStatus, string> = {
+ canceled: 'Canceled',
+ completed: 'Completed',
+ failed: 'Failed',
+ in_progress: 'In progress',
+ pending: 'Pending',
+ waiting: 'Waiting',
+};
+
+export const createQueueItemsProvider = ({
+ getScope,
+ openQueueWidget,
+ revealItem,
+}: {
+ getScope: () => QueueQueryScope;
+ openQueueWidget: () => void;
+ revealItem: (itemId: number) => void;
+}): PaletteSearchProvider => ({
+ id: 'queue-items',
+ label: 'Queue items',
+ search: async (query) => {
+ // The queue read model is a recent window with no server-side text search;
+ // filter the fetched window client-side.
+ const model = await queryClient.fetchQuery(getQueueReadModelOptions(getScope()));
+
+ return model.items
+ .map((item) => ({ item, meta: extractGenerationMeta(item) }))
+ .filter(({ item, meta }) =>
+ matchesTerms(
+ `${meta.positivePrompt ?? ''} ${meta.negativePrompt ?? ''} ${QUEUE_STATUS_LABELS[item.status]} ${item.userDisplayName ?? ''}`,
+ query
+ )
+ )
+ .map<PaletteEntry>(({ item, meta }) => {
+ const resultImageName = getResultImageName(item);
+
+ return {
+ group: 'Queue items',
+ id: `queue-item:${item.id}`,
+ run: () => {
+ openQueueWidget();
+ revealItem(item.id);
+ },
+ subtitle: QUEUE_STATUS_LABELS[item.status],
+ thumbnailUrl: resultImageName
+ ? absolutizeApiUrl(`/api/v1/images/i/${encodeURIComponent(resultImageName)}/thumbnail`)
+ : undefined,
+ title: meta.positivePrompt?.trim() || 'Untitled generation',
+ };
+ });
+ },
+});
+
export const createImagesProvider = ({
getSelectedBoardId,
openGalleryWidget,