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.

refactor(webv2): build queue rows from the shared list item

Josh Corbettb51a4f594b15
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/CancelQueueItemButton.tsx b/invokeai/frontend/webv2/src/features/queue/ui/CancelQueueItemButton.tsx
index 693a7301da..386599aaa7 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/CancelQueueItemButton.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/CancelQueueItemButton.tsx
@@ -12,10 +12,7 @@ import { useTranslation } from 'react-i18next';
import { refreshQueue } from './queueDataStore';
import { useQueueUi } from './QueueUiContext';
-/**
- * Cancel by backend ID across clients; local coordination follows status events. Stop propagation to preserve row
- * state.
- */
+/** Cancel by backend ID across clients; local coordination follows status events. */
export const CancelQueueItemButton = ({ itemId }: { itemId: number }) => {
const { t } = useTranslation();
const { notify } = useQueueUi();
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/NowNextSection.tsx b/invokeai/frontend/webv2/src/features/queue/ui/NowNextSection.tsx
index 72dee75bba..3776d24920 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/NowNextSection.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/NowNextSection.tsx
@@ -1,11 +1,12 @@
import { Stack } from '@chakra-ui/react';
+import { ListSectionHeader } from '@platform/ui/list/ListSectionHeader';
+import { ListStack } from '@platform/ui/list/ListStack';
import { useTranslation } from 'react-i18next';
import type { QueueItemRevealRequest } from './queueUiStore';
import { useCurrentBatchItems } from './queueDataStore';
import { QueueItemRow } from './QueueItemRow';
-import { SectionHeader } from './SectionHeader';
/** CURRENT BATCH — the running item plus every pending item in the same backend batch. */
export const CurrentBatchSection = ({ revealRequest = null }: { revealRequest?: QueueItemRevealRequest | null }) => {
@@ -18,9 +19,9 @@ export const CurrentBatchSection = ({ revealRequest = null }: { revealRequest?:
}
return (
- <Stack gap="2">
- <SectionHeader count={count} title={t('widgets.queue.currentBatch')} />
- <Stack gap="1">
+ <Stack gap="1">
+ <ListSectionHeader count={count} label={t('widgets.queue.currentBatch')} />
+ <ListStack label={t('widgets.queue.currentBatch')}>
{items.map((item) => (
<QueueItemRow
key={item.id}
@@ -28,7 +29,7 @@ export const CurrentBatchSection = ({ revealRequest = null }: { revealRequest?:
revealRequest={item.id === revealRequest?.itemId ? revealRequest : null}
/>
))}
- </Stack>
+ </ListStack>
</Stack>
);
};
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.browser.test.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.browser.test.tsx
new file mode 100644
index 0000000000..e883edc773
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.browser.test.tsx
@@ -0,0 +1,139 @@
+/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */
+import type { QueueItemReadModel } from '@features/queue/core/types';
+
+import { ChakraProvider } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import type * as QueueDataStore from './queueDataStore';
+
+import { QueueItemRow } from './QueueItemRow';
+import { QueueUiProvider, type QueueUiAdapter } from './QueueUiContext';
+
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+vi.mock('@features/queue/publicApi', () => ({
+ getQueueReadModelOptions: () => ({ queryFn: () => Promise.resolve(null), queryKey: ['queue'] }),
+ queueCommands: { cancelItem: () => Promise.resolve() },
+}));
+vi.mock('./queueDataStore', async (importOriginal) => ({
+ ...(await importOriginal<typeof QueueDataStore>()),
+ refreshQueue: () => Promise.resolve(),
+}));
+
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const item = (overrides: Partial<QueueItemReadModel> = {}): QueueItemReadModel => ({
+ batchId: 'batch-1',
+ createdAt: '2026-06-27T00:00:00Z',
+ fieldValues: [{ fieldName: 'prompt', nodePath: 'positive_prompt', value: 'A castle at dusk' }],
+ id: 7,
+ resultImageNames: [],
+ sessionId: 'session-1',
+ status: 'pending',
+ updatedAt: '2026-06-27T00:00:00Z',
+ userId: 'user-1',
+ ...overrides,
+});
+
+const adapter = (overrides: Partial<QueueUiAdapter> = {}): QueueUiAdapter => ({
+ ItemActions: () => null,
+ activeProjectId: null,
+ canManageItem: () => true,
+ canManageProcessor: true,
+ canViewItemDetails: () => true,
+ isConnected: true,
+ notify: { error: () => undefined, info: () => undefined, success: () => undefined },
+ openQueue: () => undefined,
+ preloadItemActions: () => undefined,
+ queueJobsScope: 'all',
+ ...overrides,
+});
+
+let host: HTMLDivElement;
+let root: Root;
+
+beforeEach(() => {
+ host = document.createElement('div');
+ host.style.cssText = 'width:420px;';
+ document.body.append(host);
+ root = createRoot(host);
+});
+
+afterEach(async () => {
+ await act(() => root.unmount());
+ host.remove();
+});
+
+const render = async (ui: QueueUiAdapter, queueItem: QueueItemReadModel) => {
+ await act(() =>
+ root.render(
+ <ChakraProvider value={system}>
+ <QueueUiProvider adapter={ui}>
+ <div role="list">
+ <QueueItemRow item={queueItem} />
+ </div>
+ </QueueUiProvider>
+ </ChakraProvider>
+ )
+ );
+};
+
+const primary = () => host.querySelector<HTMLElement>('[data-list-primary]')!;
+
+describe('QueueItemRow', () => {
+ it('is a list item whose row button discloses details while the cancel control stays beside it', async () => {
+ await render(adapter(), item());
+
+ const card = host.querySelector<HTMLElement>('[role="list"] > [role="listitem"]')!;
+
+ expect(card).not.toBeNull();
+ expect(card.querySelector('[role="presentation"] [data-list-primary]')).toBe(primary());
+ expect(primary().tagName).toBe('BUTTON');
+ expect(primary().getAttribute('aria-expanded')).toBe('false');
+ expect(primary().textContent).toContain('A castle at dusk');
+
+ const cancel = host.querySelector<HTMLButtonElement>('button[aria-label="widgets.queue.cancelItem"]')!;
+
+ expect(cancel).not.toBeNull();
+ expect(primary().contains(cancel)).toBe(false);
+ expect(card.contains(cancel)).toBe(true);
+
+ await act(() => cancel.click());
+ expect(primary().getAttribute('aria-expanded')).toBe('false');
+
+ await act(() => primary().click());
+ expect(primary().getAttribute('aria-expanded')).toBe('true');
+ // The details stay inside the list item, so they read as part of the row.
+ expect(card.textContent).toContain('common.prompt');
+
+ await act(() => primary().click());
+ expect(primary().getAttribute('aria-expanded')).toBe('false');
+ expect(card.textContent).not.toContain('common.prompt');
+ });
+
+ it('renders a row without viewable details as static content, not a button', async () => {
+ await render(
+ adapter({ canManageItem: () => false, canViewItemDetails: () => false }),
+ item({ userId: 'redacted' })
+ );
+
+ expect(primary().tagName).toBe('DIV');
+ expect(primary().hasAttribute('aria-expanded')).toBe(false);
+ expect(host.querySelector('button')).toBeNull();
+ expect(host.querySelector('[role="list"] > [role="listitem"]')).not.toBeNull();
+ });
+
+ it('warms the item actions on focus, before the first expand', async () => {
+ const preloadItemActions = vi.fn();
+
+ await render(adapter({ preloadItemActions }), item());
+ // Dispatch focusin directly: element.focus() is a no-op for focus events while the test window is unfocused.
+ await act(() => {
+ primary().dispatchEvent(new FocusEvent('focusin', { bubbles: true }));
+ });
+
+ expect(preloadItemActions).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
index 46da6fa3ca..abb677a1a8 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
@@ -1,10 +1,10 @@
-import type { SystemStyleObject } from '@chakra-ui/react';
+/* eslint-disable react-perf/jsx-no-jsx-as-prop */
import type { QueueItemReadModel } from '@features/queue/core/types';
-import { Box, HStack, Icon, Stack, Text } from '@chakra-ui/react';
+import { Box, HStack, Icon, Text } from '@chakra-ui/react';
import { extractGenerationMeta, getResultImageName } from '@features/queue/core/generationMeta';
import { useItemProgress } from '@features/queue/data/itemProgressStore';
-import { Row } from '@platform/ui/Row';
+import { ListItem } from '@platform/ui/list/ListItem';
import { ChevronRightIcon } from 'lucide-react';
import { memo, useCallback, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -22,20 +22,6 @@ import { useDeviceLabel } from './useDeviceLabel';
const CHEVRON_OPEN = { transform: 'rotate(90deg)' } as const;
-const QUEUE_ITEM_BUTTON_SX: SystemStyleObject = {
- display: 'flex',
- alignItems: 'center',
- flex: 1,
- gap: 2.5,
- minH: 11,
- minW: 0,
- px: 2,
- py: 1.5,
- textAlign: 'start',
- rounded: 'none',
- transitionDuration: 'fastest',
-} as const;
-
export const QueueItemRow = memo(
({ item, revealRequest }: { item: QueueItemReadModel; revealRequest?: QueueItemRevealRequest | null }) => {
const { t } = useTranslation();
@@ -80,58 +66,47 @@ export const QueueItemRow = memo(
const showBorder = expanded || isFailed;
const borderColor = showBorder ? (isFailed ? 'fg.error' : 'border') : 'transparent';
+ // The card is the list item: progress and details belong to the row, not to the list.
return (
- <Box ref={consumeReveal} 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}
- onFocus={canExpand ? preload : undefined}
- onPointerEnter={canExpand ? preload : 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')}
+ <Box ref={consumeReveal} borderColor={borderColor} borderWidth={1} overflow="hidden" role="listitem" rounded="md">
+ <ListItem
+ actions={isCancellable ? <CancelQueueItemButton itemId={item.id} /> : undefined}
+ description={
+ <HStack gap="1.5" minW="0">
+ <QueueStatusDot status={item.status} />
+ <Text
+ fontVariantNumeric="tabular-nums"
+ title={deviceLabel ? t('widgets.queue.device.tooltip', { name: deviceLabel.name }) : undefined}
+ truncate
+ >
+ {[
+ statusLabel,
+ ageLabel,
+ deviceLabel ? t('widgets.queue.device.shortLabel', { index: deviceLabel.index }) : null,
+ ]
+ .filter(Boolean)
+ .join(' · ')}
</Text>
- <HStack gap="1.5" minW="0">
- <QueueStatusDot status={item.status} />
- <Text
- color="fg.muted"
- fontSize="2xs"
- fontVariantNumeric="tabular-nums"
- title={deviceLabel ? t('widgets.queue.device.tooltip', { name: deviceLabel.name }) : undefined}
- truncate
- >
- {[
- statusLabel,
- ageLabel,
- deviceLabel ? t('widgets.queue.device.shortLabel', { index: deviceLabel.index }) : null,
- ]
- .filter(Boolean)
- .join(' · ')}
- </Text>
- </HStack>
- </Stack>
- {canExpand ? (
+ </HStack>
+ }
+ isExpanded={canExpand ? expanded : undefined}
+ leading={<QueueItemThumbnail boxSize="8" imageName={resultImageName} liveImage={liveImage} />}
+ role="presentation"
+ title={meta.positivePrompt?.trim() || t('widgets.queue.noPrompt')}
+ titleTruncate="end"
+ trailing={
+ 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}
- </HStack>
+ ) : undefined
+ }
+ onIntent={canExpand ? preload : undefined}
+ onPress={canExpand ? toggle : undefined}
+ />
{item.status === 'in_progress' ? (
<Box px="2.5" pb="2">
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/RecentSection.tsx b/invokeai/frontend/webv2/src/features/queue/ui/RecentSection.tsx
index df32cb0399..4b62dc7e18 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/RecentSection.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/RecentSection.tsx
@@ -1,6 +1,8 @@
import { Stack, Text } from '@chakra-ui/react';
import { useMountEffect } from '@platform/react/useMountEffect';
import { segmentTabsPanelId, segmentTabsTabId } from '@platform/ui';
+import { ListSectionHeader } from '@platform/ui/list/ListSectionHeader';
+import { ListStack } from '@platform/ui/list/ListStack';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -11,7 +13,6 @@ import { matchesFilter } from './queueFilters';
import { QUEUE_FILTER_TABS_ID } from './QueueFilterTabs';
import { QueueItemRow } from './QueueItemRow';
import { clearPendingQueueItemReveal, type QueueItemRevealRequest } from './queueUiStore';
-import { SectionHeader } from './SectionHeader';
/** Exclude running and next items from recent history because NOW & NEXT already shows them. */
export const RecentSection = ({
@@ -41,16 +42,16 @@ export const RecentSection = ({
return (
<Stack
aria-labelledby={segmentTabsTabId(QUEUE_FILTER_TABS_ID, filter)}
- gap="2"
+ gap="1"
id={segmentTabsPanelId(QUEUE_FILTER_TABS_ID)}
role="tabpanel"
>
{cannotReveal && revealRequest ? (
<UnavailableRevealConsumer key={revealRequest.requestId} request={revealRequest} />
) : null}
- <SectionHeader count={filtered.length} title={t('common.recent')} />
+ <ListSectionHeader count={filtered.length} label={t('common.recent')} />
{filtered.length === 0 ? (
- <Text color={loadState === 'error' ? 'fg.error' : 'fg.subtle'} fontSize="2xs" px="1">
+ <Text color={loadState === 'error' ? 'fg.error' : 'fg.subtle'} fontSize="2xs" px="2">
{loadState === 'loading'
? t('widgets.queue.loading')
: loadState === 'error'
@@ -58,7 +59,7 @@ export const RecentSection = ({
: t('common.nothingHereYet')}
</Text>
) : (
- <Stack gap="1">
+ <ListStack label={t('common.recent')}>
{filtered.map((item) => (
<QueueItemRow
key={item.id}
@@ -66,7 +67,7 @@ export const RecentSection = ({
revealRequest={item.id === revealRequest?.itemId ? revealRequest : null}
/>
))}
- </Stack>
+ </ListStack>
)}
</Stack>
);
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/SectionHeader.tsx b/invokeai/frontend/webv2/src/features/queue/ui/SectionHeader.tsx
deleted file mode 100644
index c22ce55d2c..0000000000
--- a/invokeai/frontend/webv2/src/features/queue/ui/SectionHeader.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import { HStack, Text } from '@chakra-ui/react';
-
-/** Small uppercase section label with an optional count, e.g. "RECENT 13". */
-export const SectionHeader = ({ title, count }: { title: string; count?: number }) => (
- <HStack gap="2" px="1">
- <Text color="fg.muted" fontSize="2xs" fontWeight="700" letterSpacing="0.06em" textTransform="uppercase">
- {title}
- </Text>
- {count !== undefined ? (
- <Text color="fg.muted" fontSize="2xs" fontVariantNumeric="tabular-nums">
- {count}
- </Text>
- ) : null}
- </HStack>
-);